完成商城
This commit is contained in:
parent
077446af4d
commit
501004ec60
3
app.json
3
app.json
@ -37,7 +37,8 @@
|
||||
"pages/shop/yetGoodsOrderDetail/yetGoodsOrderDetail",
|
||||
"pages/shop/betrayGoodsDetail/betrayGoodsDetail",
|
||||
"pages/shop/saveAssigneeInfo/saveAssigneeInfo",
|
||||
"pages/shop/reportReplenish/reportReplenish"
|
||||
"pages/shop/reportReplenish/reportReplenish",
|
||||
"pages/shop/replenishDetail/replenishDetail"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTextStyle": "black",
|
||||
|
3
app.wxss
3
app.wxss
@ -372,8 +372,7 @@ swiper-item {
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
height: 0;
|
||||
padding: 0rpx 0rpx 50rpx;
|
||||
padding: 0rpx 0rpx 10px 0rpx;
|
||||
}
|
||||
|
||||
.tip-margin {
|
||||
|
@ -29,6 +29,7 @@ const apiPath = {
|
||||
mineSellGoods: '/api/goods/listpage', //我售卖的软著
|
||||
replenishList: '/api/correction/{kind}', //补充资料列表
|
||||
replenishDetail: '/api/correction/get/{correctionId}', //补充资料详情
|
||||
replenishSave: '/api/correction/save', //保存补充材料
|
||||
saveBuyPersonInfo: '/api/order/save-input/{orderId}', //保存购买人信息
|
||||
}
|
||||
class Shop {
|
||||
@ -183,6 +184,10 @@ class Shop {
|
||||
correctionId: id
|
||||
})
|
||||
}
|
||||
//保存补充材料
|
||||
static doSaveReplenish(data) {
|
||||
return this.requestHandler(apiPath.replenishSave, "POST", data)
|
||||
}
|
||||
//保存受让人信息
|
||||
static doSaveBuyPersonInfo(orderId, data) {
|
||||
return this.requestHandler(apiPath.saveBuyPersonInfo, "POST", data, {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 定义api服务地址
|
||||
// const appUrl = 'https://www.aimzhu.com'
|
||||
const appUrl = 'http://121.36.71.250:58038'
|
||||
const appUrl = 'https://www.aimzhu.com'
|
||||
// const appUrl = 'http://121.36.71.250:58038'
|
||||
const prewBaseUrl = ''
|
||||
const operatorUrl = appUrl + '/operator'
|
||||
const operatorPlug = appUrl + '/operator-plugin'
|
||||
@ -11,6 +11,7 @@ const previewUrl = copyrightUrl + '/route/file/v2/download/true/'
|
||||
const imgAssets = appUrl + '/miniapp-assets'
|
||||
const sImgPrefix = aiShopUrl + '/route/file/download/true/'
|
||||
const upShopImgUrl = aiShopUrl + '/api/file/v2/upload-image'
|
||||
const upShopFileUrl = aiShopUrl + '/api/file/v2/upload-file'
|
||||
|
||||
|
||||
export {
|
||||
@ -23,5 +24,6 @@ export {
|
||||
imgAssets,
|
||||
appUrl,
|
||||
sImgPrefix,
|
||||
upShopImgUrl
|
||||
upShopImgUrl,
|
||||
upShopFileUrl
|
||||
}
|
@ -232,9 +232,7 @@
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 20rpx;
|
||||
}
|
||||
|
||||
|
||||
.weui-half-screen-dialog__hd__side+.weui-half-screen-dialog__hd__main {
|
||||
padding: 0 46rpx;
|
||||
|
@ -231,9 +231,7 @@
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 20rpx;
|
||||
}
|
||||
|
||||
|
||||
.weui-half-screen-dialog__hd__side+.weui-half-screen-dialog__hd__main {
|
||||
padding: 0 46rpx;
|
||||
|
@ -181,9 +181,7 @@
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx 0rpx;
|
||||
}
|
||||
|
||||
|
||||
.bottom-box {
|
||||
position: fixed;
|
||||
|
@ -610,9 +610,6 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__bd {
|
||||
padding-bottom: 40rpx;
|
||||
|
@ -615,9 +615,6 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__bd {
|
||||
padding-bottom: 40rpx;
|
||||
|
@ -562,8 +562,3 @@
|
||||
color: var(--primary-color);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
height: 0;
|
||||
padding: 0rpx 0rpx 40rpx;
|
||||
}
|
@ -122,10 +122,7 @@
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.custom-tips {
|
||||
margin-top: 80px;
|
||||
|
@ -231,9 +231,6 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__bd {
|
||||
padding-bottom: 40rpx;
|
||||
|
@ -176,9 +176,7 @@
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx;
|
||||
}
|
||||
|
||||
|
||||
.weui-half-screen-dialog__bd {
|
||||
padding-bottom: 40rpx;
|
||||
|
@ -217,9 +217,7 @@
|
||||
background-color: var(--btn-green-color-active);
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx 0rpx;
|
||||
}
|
||||
|
||||
|
||||
.weui-half-screen-dialog__bd {
|
||||
padding-bottom: 40rpx;
|
||||
|
@ -343,10 +343,6 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__ft {
|
||||
padding: 0rpx 0rpx 40rpx;
|
||||
}
|
||||
|
||||
.weui-half-screen-dialog__bd {
|
||||
padding-bottom: 40rpx;
|
||||
}
|
@ -79,19 +79,19 @@ Page({
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
_self.setData({
|
||||
'tabList[2].hasMsg': true,
|
||||
'menuList[2].hasMsg': true
|
||||
'menuList[1].hasMsg': true
|
||||
})
|
||||
} else {
|
||||
_self.setData({
|
||||
'tabList[2].hasMsg': false,
|
||||
'menuList[2].hasMsg': false
|
||||
'menuList[1].hasMsg': false
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
_self.setData({
|
||||
'tabList[2].hasMsg': false,
|
||||
'menuList[2].hasMsg': false
|
||||
'menuList[1].hasMsg': false
|
||||
})
|
||||
})
|
||||
},
|
||||
|
@ -25,7 +25,8 @@ Page({
|
||||
listRefreshTrig: false,
|
||||
isLoadMore: false,
|
||||
hasMore: true,
|
||||
goodsList: []
|
||||
goodsList: [],
|
||||
needRefresh: false
|
||||
},
|
||||
|
||||
/**
|
||||
@ -45,6 +46,14 @@ Page({
|
||||
})
|
||||
this.doRefreshList()
|
||||
},
|
||||
onShow() {
|
||||
if (this.data.needRefresh) {
|
||||
this.setData({
|
||||
needRefresh: false
|
||||
})
|
||||
this.doRefreshList()
|
||||
}
|
||||
},
|
||||
inputKeywords(e) {
|
||||
this.setData({
|
||||
'pageData.keywords': e.detail.value
|
||||
|
@ -3,6 +3,24 @@ import Shop from '../../../net/api/shop'
|
||||
import {
|
||||
sImgPrefix
|
||||
} from '../../../net/mainUrl'
|
||||
const Cache = require('../../../utils/storage')
|
||||
var docFix = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf'];
|
||||
var imgFix = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'ico', 'tiff', 'tif'];
|
||||
|
||||
// 工具函数:检查文件类型
|
||||
function getFileExtension(filename) {
|
||||
if (!filename || typeof filename !== 'string') return '';
|
||||
var lastDot = filename.lastIndexOf('.');
|
||||
return lastDot === -1 ? '' : filename.substring(lastDot + 1).toLowerCase();
|
||||
}
|
||||
|
||||
function isImageFile(filename) {
|
||||
return imgFix.indexOf(getFileExtension(filename)) !== -1;
|
||||
}
|
||||
|
||||
function isDocumentFile(filename) {
|
||||
return docFix.indexOf(getFileExtension(filename)) !== -1;
|
||||
}
|
||||
Page({
|
||||
|
||||
/**
|
||||
@ -34,6 +52,9 @@ Page({
|
||||
listRefreshTrig: false,
|
||||
replenlishList: [], //补充资料
|
||||
kind: 'buy', //用来标识 buy买家 sell卖家
|
||||
files: [],
|
||||
downloadProgress: 0,
|
||||
downloading: false
|
||||
},
|
||||
|
||||
/**
|
||||
@ -78,8 +99,33 @@ Page({
|
||||
})
|
||||
this.upPageNeedRefresh()
|
||||
this.doGetOrderDetail()
|
||||
this.doRefreshList()
|
||||
}
|
||||
},
|
||||
//显示补充详情
|
||||
doShowReplishDetail(e) {
|
||||
const item = e.currentTarget.dataset.item
|
||||
console.log(item)
|
||||
if (this.data.kind == 'buy' && item.buyId == '') {
|
||||
this.setData({
|
||||
msgHint: '请补充内容',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.data.kind == 'sell' && item.sellId == '') {
|
||||
this.setData({
|
||||
msgHint: '请补充内容',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: '/pages/shop/replenishDetail/replenishDetail?id=' + item.correctionId + '&kind=' + this.data.kind,
|
||||
})
|
||||
},
|
||||
bindChangeTab(e) {
|
||||
const tabIndex = e.currentTarget.dataset.value
|
||||
this.setData({
|
||||
@ -155,6 +201,9 @@ Page({
|
||||
_self.setData({
|
||||
order: res
|
||||
})
|
||||
if (res.orderStatus == '过户已完成' && res.producePhoto != '') {
|
||||
_self.doGetFileInfo(res.producePhoto)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading()
|
||||
@ -168,8 +217,45 @@ Page({
|
||||
}, 1800);
|
||||
})
|
||||
},
|
||||
//获取商品详情
|
||||
// 添加baseUrl
|
||||
addPrefix: function (list) {
|
||||
return list.map(function (item) {
|
||||
item.netUrl = sImgPrefix + item.fileId;
|
||||
return item;
|
||||
});
|
||||
},
|
||||
//获取文件详情
|
||||
doGetFileInfo(ids) {
|
||||
var that = this;
|
||||
var data = {
|
||||
ids: ids
|
||||
};
|
||||
|
||||
wx.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
Shop.doGetFileInfos(data)
|
||||
.then(function (res) {
|
||||
wx.hideLoading();
|
||||
if (res && res !== null) {
|
||||
const list = that.addPrefix(res)
|
||||
that.setData({
|
||||
files: list
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
wx.hideLoading();
|
||||
that.showMessage(err.msg || '获取证书详情失败,请稍后重试', 'error');
|
||||
});
|
||||
},
|
||||
showMessage: function (msg, type) {
|
||||
this.setData({
|
||||
msgHint: msg,
|
||||
msgType: type || 'info',
|
||||
msgShow: true
|
||||
});
|
||||
},
|
||||
doPreImg(e) {
|
||||
wx.previewImage({
|
||||
urls: [e.currentTarget.dataset.value],
|
||||
@ -267,5 +353,86 @@ Page({
|
||||
wx.navigateTo({
|
||||
url: '/pages/shop/reportReplenish/reportReplenish?id=' + item.correctionId,
|
||||
})
|
||||
}
|
||||
},
|
||||
doPreImg: function (e) {
|
||||
var url = e.currentTarget.dataset.value;
|
||||
wx.previewImage({
|
||||
urls: [url]
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 下载文件
|
||||
doDownloadFile: function (e) {
|
||||
var item = e.currentTarget.dataset.item;
|
||||
// 判断是否是图片
|
||||
if (isImageFile(item.fileName)) {
|
||||
wx.previewImage({
|
||||
urls: [item.netUrl]
|
||||
});
|
||||
} else {
|
||||
// 判断是否支持打开
|
||||
if (isDocumentFile(item.fileName)) {
|
||||
// 去下载文件
|
||||
this.goDownloadFile(item);
|
||||
} else {
|
||||
this.showMessage('该文件无法在小程序中打开,请前往电脑端查看', 'info');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
goDownloadFile: function (item) {
|
||||
var that = this;
|
||||
that.setData({
|
||||
downloadProgress: 0,
|
||||
downloading: true
|
||||
});
|
||||
|
||||
var token = Cache.get('token');
|
||||
var header = {};
|
||||
if (token) {
|
||||
header.Auth = 'Bearer ' + token;
|
||||
}
|
||||
|
||||
var downloadTask = wx.downloadFile({
|
||||
url: item.netUrl,
|
||||
header: header,
|
||||
success: function (res) {
|
||||
that.setData({
|
||||
downloadProgress: 0,
|
||||
downloading: false
|
||||
});
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
wx.getFileSystemManager().saveFile({
|
||||
tempFilePath: res.tempFilePath,
|
||||
filePath: wx.env.USER_DATA_PATH + '/' + item.fileName,
|
||||
success: function (res) {
|
||||
wx.openDocument({
|
||||
filePath: res.savedFilePath,
|
||||
showMenu: true
|
||||
});
|
||||
},
|
||||
fail: function (err) {
|
||||
console.error('文件保存失败', err);
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('下载失败', err);
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
downloadTask.onProgressUpdate(function (res) {
|
||||
that.setData({
|
||||
downloadProgress: res.progress
|
||||
});
|
||||
});
|
||||
},
|
||||
})
|
@ -2,6 +2,7 @@
|
||||
"usingComponents": {
|
||||
"mp-toptips": "weui-miniprogram/toptips/toptips",
|
||||
"container-loading": "/components/container-loading/container-loading",
|
||||
"mp-loading": "weui-miniprogram/loading/loading"
|
||||
"mp-loading": "weui-miniprogram/loading/loading",
|
||||
"down-progress": "/components/down-progress/down-progress"
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
<view wx:if="{{order.waitCorrectionCount>0}}" class="info-tag">{{order.waitCorrectionCount}}</view>
|
||||
</view>
|
||||
<view wx:if="{{order.buyUserDTO != null && kind=='buy'}}" bind:tap="bindChangeTab" data-value="3" class="select-tab {{curTab==3? 'line':''}}">受让人信息</view>
|
||||
<view wx:if="{{kind=='buy' && order.orderStatus=='过户已完成'}}" bind:tap="bindChangeTab" data-value="4" class="select-tab {{curTab==4? 'line':''}}">证书详情</view>
|
||||
</view>
|
||||
<view class="box" wx:if="{{curTab==0}}">
|
||||
<view class="section">
|
||||
@ -112,31 +113,31 @@
|
||||
<view class="list-box">
|
||||
<block wx:for="{{replenlishList}}" wx:key="index">
|
||||
<view class="list-item">
|
||||
<view style="display: flex;flex-direction: row;">
|
||||
<view class="item-content">
|
||||
<view style="display: flex;flex-direction: column;">
|
||||
<view class="item-content" bind:tap="doShowReplishDetail" data-item="{{item}}">
|
||||
<view class="item-title">
|
||||
{{item.correctionTitle}}
|
||||
</view>
|
||||
<view class="item-desc">{{item.correctionRemark}}</view>
|
||||
<!-- 卖家 -->
|
||||
<block wx:if="{{kind=='sell'}}">
|
||||
<view class="status-tag {{item.sellId==''? 'col-primary':'col-green'}}">{{item.sellId==''?'待补充':'已补充'}}</view>
|
||||
</block>
|
||||
<!-- 买家 -->
|
||||
<block wx:if="{{kind=='buy'}}">
|
||||
<view class="status-tag {{item.buyId=='' ? 'col-primary' :'col-green'}}">
|
||||
{{item.buyId==''?'待补充':'已补充'}}
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="item-desc">{{item.correctionRemark}}</view>
|
||||
</view>
|
||||
<view class="item-bottom">
|
||||
<view class="item-time">{{item.createTime}}</view>
|
||||
<view class="item-btns">
|
||||
<view data-value="{{item}}" bind:tap="goReplenish" class="btn-blue" wx:if="{{kind=='buy' && item.buyId==''}}">去补充</view>
|
||||
<view data-value="{{item}}" bind:tap="goReplenish" class="btn-blue" wx:if="{{kind=='sell' && item.sellId==''}}">去补充</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-bottom">
|
||||
<!-- 卖家 -->
|
||||
<block wx:if="{{kind=='sell'}}">
|
||||
<view class="status-tag {{item.sellId==''? 'col-primary':'col-green'}}">{{item.sellId==''?'待补充':'已补充'}}</view>
|
||||
</block>
|
||||
<!-- 买家 -->
|
||||
<block wx:if="{{kind=='buy'}}">
|
||||
<view class="status-tag {{item.buyId=='' ? 'col-primary' :'col-green'}}">
|
||||
{{item.buyId==''?'待补充':'已补充'}}
|
||||
</view>
|
||||
</block>
|
||||
<view class="item-time">{{item.createTime}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<mp-loading show="{{isLoadMore}}" type="circle"></mp-loading>
|
||||
@ -152,37 +153,66 @@
|
||||
<view class="item">
|
||||
<text class="label">类别</text>
|
||||
<view class="select-content-item">
|
||||
<view class="select-time v-select">{{order.buyUserDTO.type}}</view>
|
||||
<view class="select-time v-select">{{order.buyUserDTO.type != ''? order.buyUserDTO.type:'暂无'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="label">姓名或机构名称</text>
|
||||
<view class="select-content-item">
|
||||
<view class="value v-select">{{order.buyUserDTO.name}}</view>
|
||||
<view class="value v-select">{{order.buyUserDTO.name != ''?order.buyUserDTO.name:'暂无'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="label">所在省市</text>
|
||||
<view class="select-content-item">
|
||||
<view class="select-time v-select">{{order.buyUserDTO.city}}</view>
|
||||
<view class="select-time v-select">{{order.buyUserDTO.city != '' ?order.buyUserDTO.city:'暂无'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="label">联系电话</text>
|
||||
<view class="select-content-item">
|
||||
<view class="value v-select">{{order.buyUserDTO.phone}}</view>
|
||||
<view class="value v-select">{{order.buyUserDTO.phone !='' ?order.buyUserDTO.phone:'暂无'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="label">证件类型</text>
|
||||
<view class="select-content-item" style="border-bottom: none;">
|
||||
<view class="value v-select">{{order.buyUserDTO.idcardType}}</view>
|
||||
<view class="value v-select">{{order.buyUserDTO.idcardType != '' ?order.buyUserDTO.idcardType:'暂无'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="label">证件号码</text>
|
||||
<view class="select-content-item" style="border-bottom: none;">
|
||||
<view class="value v-select">{{order.buyUserDTO.idcard}}</view>
|
||||
<view class="value v-select">{{order.buyUserDTO.idcard != ''? order.buyUserDTO.idcardType:'暂无'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{curTab==4 && kind=='buy' && order.orderStatus=='过户已完成'}}" class="box">
|
||||
<view class="item">
|
||||
<text class="label">下证时间</text>
|
||||
<view class="select-content-item" style="border-bottom: none;">
|
||||
<view class="value v-select">{{order.produceTime}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="label">证书</text>
|
||||
<view class="select-content-no-h">
|
||||
<view class="select-item-box">
|
||||
<view class="value v-select">
|
||||
<view class="accessory-box">
|
||||
<view class="accessory-item" wx:for="{{files}}" bind:tap="doDownloadFile" data-item="{{item}}" wx:key="index">
|
||||
<block wx:if="{{tools.isImg(item.fileType)}}">
|
||||
<image class="accessory-img" mode="scaleToFill" src="{{item.netUrl}}"></image>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="icon-source accessory-img"></view>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -198,5 +228,6 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<down-progress isShow="{{downloading}}" progress="{{downloadProgress}}"></down-progress>
|
||||
<mp-toptips delay="2000" msg="{{msgHint}}" type="{{msgType}}" show="{{msgShow}}"></mp-toptips>
|
||||
<wxs src="../../../utils/comm.wxs" module="tools"></wxs>
|
@ -249,7 +249,7 @@
|
||||
|
||||
.item-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-direction: row;
|
||||
font-size: 28rpx;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
@ -266,6 +266,7 @@
|
||||
text-overflow: ellipsis;
|
||||
box-sizing: border-box;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-desc {
|
||||
@ -318,4 +319,42 @@
|
||||
|
||||
.col-green {
|
||||
background-color: var(--bg-green-status-light-color);
|
||||
}
|
||||
|
||||
.accessory-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.accessory-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 40%;
|
||||
padding: 15rpx;
|
||||
margin: 10rpx;
|
||||
border: 1rpx solid var(--divider-color);
|
||||
box-sizing: border-box;
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.accessory-img {
|
||||
width: 100%;
|
||||
height: 200rpx;
|
||||
}
|
||||
|
||||
.file-name {
|
||||
width: 100%;
|
||||
font-size: 20rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.icon-source {
|
||||
background-image: url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSI2NCA2NCA4OTYgODk2IiB3aWR0aD0iNTIiIGhlaWdodD0iNTIiIHN0eWxlPSIiIGZpbHRlcj0ibm9uZSI+CiAgICAKICAgIDxnPgogICAgPHBhdGggZD0iTTkyOCAxNjFINjk5LjJjLTQ5LjEgMC05Ny4xIDE0LjEtMTM4LjQgNDAuN0w1MTIgMjMzbC00OC44LTMxLjNBMjU1LjIgMjU1LjIgMCAwIDAgMzI0LjggMTYxSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY1NjhjMCAxNy43IDE0LjMgMzIgMzIgMzJoMjI4LjhjNDkuMSAwIDk3LjEgMTQuMSAxMzguNCA0MC43bDQ0LjQgMjguNmMxLjMuOCAyLjggMS4zIDQuMyAxLjNzMy0uNCA0LjMtMS4zbDQ0LjQtMjguNkM2MDIgODA3LjEgNjUwLjEgNzkzIDY5OS4yIDc5M0g5MjhjMTcuNyAwIDMyLTE0LjMgMzItMzJWMTkzYzAtMTcuNy0xNC4zLTMyLTMyLTMyek00MDQgNTUzLjVjMCA0LjEtMy4yIDcuNS03LjEgNy41SDIxMS4xYy0zLjkgMC03LjEtMy40LTcuMS03LjV2LTQ1YzAtNC4xIDMuMi03LjUgNy4xLTcuNWgxODUuN2MzLjkgMCA3LjEgMy40IDcuMSA3LjV2NDV6bTAtMTQwYzAgNC4xLTMuMiA3LjUtNy4xIDcuNUgyMTEuMWMtMy45IDAtNy4xLTMuNC03LjEtNy41di00NWMwLTQuMSAzLjItNy41IDcuMS03LjVoMTg1LjdjMy45IDAgNy4xIDMuNCA3LjEgNy41djQ1em00MTYgMTQwYzAgNC4xLTMuMiA3LjUtNy4xIDcuNUg2MjcuMWMtMy45IDAtNy4xLTMuNC03LjEtNy41di00NWMwLTQuMSAzLjItNy41IDcuMS03LjVoMTg1LjdjMy45IDAgNy4xIDMuNCA3LjEgNy41djQ1em0wLTE0MGMwIDQuMS0zLjIgNy41LTcuMSA3LjVINjI3LjFjLTMuOSAwLTcuMS0zLjQtNy4xLTcuNXYtNDVjMC00LjEgMy4yLTcuNSA3LjEtNy41aDE4NS43YzMuOSAwIDcuMSAzLjQgNy4xIDcuNXY0NXoiIGZpbGw9InJnYmEoMTI5LDE3OSw1NSwxKSI+PC9wYXRoPgogICAgPC9nPgogIDwvc3ZnPg==');
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
}
|
@ -139,7 +139,7 @@ Page({
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
this.backPageRefresh()
|
||||
}, 1500);
|
||||
} catch (err) {
|
||||
wx.hideLoading();
|
||||
@ -186,5 +186,13 @@ Page({
|
||||
wx.navigateBack()
|
||||
}, 1200);
|
||||
})
|
||||
},
|
||||
backPageRefresh: function () {
|
||||
var pages = getCurrentPages();
|
||||
var beforePage = pages[pages.length - 2];
|
||||
beforePage.setData({
|
||||
needRefresh: true
|
||||
});
|
||||
wx.navigateBack();
|
||||
}
|
||||
})
|
@ -1,11 +1,11 @@
|
||||
<view class="page-container {{animationClass}}" style="height: 100vh;background-color: var(--tabbar-normal-color);padding: 0rpx 30rpx;">
|
||||
<view class="page-container {{animationClass}}" style="height: 100vh;background-color: var(--black-tr-color);padding: 0rpx 30rpx;">
|
||||
<view class="temp-custom-navbar" style="height: {{totalHeight}}px; padding-top: {{statusBarHeight}}px;">
|
||||
<view bind:tap="doBack" class="icon-arrow-white-left-line size-64"></view>
|
||||
<view class="temp-navbar-title" style="color:var(--white-color);">我要买</view>
|
||||
</view>
|
||||
<view wx:if="{{goods != null}}" class="detail-box">
|
||||
<image bind:tap="doPreImg" data-url="{{goods.goodsPhoto}}" src="{{goods.goodsPhoto}}" mode="scaleToFill" class="detail-img"></image>
|
||||
<view class="bottom-fixed-footer" style="background-color: var(--tabbar-normal-color);color:var(--white-color);">
|
||||
<view class="bottom-fixed-footer" style="background-color: var(--black-tr-color);color:var(--white-color);">
|
||||
<view class="goods-name">{{goods.goodsName}}</view>
|
||||
<scroll-view scroll-y style="height: 140rpx;margin-top: 8rpx;">
|
||||
<view>
|
||||
|
@ -48,7 +48,8 @@ Page({
|
||||
isSticky: false,
|
||||
msgType: 'info',
|
||||
msgHint: '',
|
||||
msgShow: false
|
||||
msgShow: false,
|
||||
needRefresh: false
|
||||
},
|
||||
|
||||
/**
|
||||
@ -85,6 +86,12 @@ Page({
|
||||
this.setData({
|
||||
tabList
|
||||
});
|
||||
if (this.data.needRefresh) {
|
||||
this.setData({
|
||||
needRefresh: false
|
||||
})
|
||||
this.doRefreshList()
|
||||
}
|
||||
},
|
||||
onPageScroll(e) {
|
||||
this.setData({
|
||||
|
448
pages/shop/replenishDetail/replenishDetail.js
Normal file
448
pages/shop/replenishDetail/replenishDetail.js
Normal file
@ -0,0 +1,448 @@
|
||||
// pages/shop/publishCopyright/publishCopyright.js
|
||||
import Shop from '../../../net/api/shop'
|
||||
var {
|
||||
upShopImgUrl,
|
||||
sImgPrefix,
|
||||
upShopFileUrl
|
||||
} = require('../../../net/mainUrl');
|
||||
var Cache = require('../../../utils/storage');
|
||||
|
||||
var docFix = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf'];
|
||||
var imgFix = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'ico', 'tiff', 'tif'];
|
||||
|
||||
// 工具函数:检查文件类型
|
||||
function getFileExtension(filename) {
|
||||
if (!filename || typeof filename !== 'string') return '';
|
||||
var lastDot = filename.lastIndexOf('.');
|
||||
return lastDot === -1 ? '' : filename.substring(lastDot + 1).toLowerCase();
|
||||
}
|
||||
|
||||
function isImageFile(filename) {
|
||||
return imgFix.indexOf(getFileExtension(filename)) !== -1;
|
||||
}
|
||||
|
||||
function isDocumentFile(filename) {
|
||||
return docFix.indexOf(getFileExtension(filename)) !== -1;
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
msgHint: '',
|
||||
msgType: 'info',
|
||||
msgShow: false,
|
||||
files: [],
|
||||
maxCount: 4,
|
||||
replenishId: '',
|
||||
replenish: null,
|
||||
replenishFiles: [],
|
||||
downloading: false,
|
||||
downloadProgress: 0,
|
||||
showActionsheet: false,
|
||||
kind: 'buy',
|
||||
restore: null,
|
||||
restoreFiles: []
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
var that = this;
|
||||
wx.setNavigationBarTitle({
|
||||
title: '资料补充'
|
||||
});
|
||||
wx.setNavigationBarColor({
|
||||
frontColor: '#000000',
|
||||
backgroundColor: '#FFFFFF',
|
||||
animation: {
|
||||
duration: 500,
|
||||
timingFunc: 'easeIn'
|
||||
}
|
||||
});
|
||||
|
||||
var id = options.id;
|
||||
var kind = options.kind
|
||||
if (id && id !== '') {
|
||||
this.setData({
|
||||
replenishId: id,
|
||||
kind: kind
|
||||
});
|
||||
this.doGetReplenishDetail();
|
||||
} else {
|
||||
this.showMessage('数据有误,请稍后重试', 'error');
|
||||
setTimeout(function () {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
|
||||
// 获取补充详情
|
||||
doGetReplenishDetail: function () {
|
||||
var that = this;
|
||||
wx.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
|
||||
Shop.doGetReplenishDetail(this.data.replenishId)
|
||||
.then(function (res) {
|
||||
wx.hideLoading();
|
||||
that.setData({
|
||||
replenish: res
|
||||
});
|
||||
// 获取附件信息
|
||||
if (that.data.replenish.correctionFiles && that.data.replenish.correctionFiles !== '') {
|
||||
that.doGetFileInfo(1, that.data.replenish.correctionFiles);
|
||||
}
|
||||
//判断是购买还是售卖
|
||||
that.doGetReplenishRestoreDetail()
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.log(err)
|
||||
wx.hideLoading();
|
||||
that.showMessage(err.msg || '网络错误,请稍后重试', 'error');
|
||||
setTimeout(function () {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
});
|
||||
},
|
||||
//获取回复详情
|
||||
doGetReplenishRestoreDetail() {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
})
|
||||
const _self = this
|
||||
const id = _self.data.kind == 'buy' ? _self.data.replenish.buyId : _self.data.replenish.sellId
|
||||
Shop.doGetReplenishDetail(id)
|
||||
.then(res => {
|
||||
wx.hideLoading()
|
||||
console.log('回复详情', res)
|
||||
if (res) {
|
||||
_self.setData({
|
||||
restore: res
|
||||
})
|
||||
if (_self.data.restore.correctionFiles && _self.data.restore.correctionFiles !== '') {
|
||||
_self.doGetFileInfo(2, _self.data.restore.correctionFiles);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
wx.hideLoading()
|
||||
_self.setData({
|
||||
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取文件信息
|
||||
doGetFileInfo(type, ids) {
|
||||
var that = this;
|
||||
var data = {
|
||||
ids: ids
|
||||
};
|
||||
|
||||
wx.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
Shop.doGetFileInfos(data)
|
||||
.then(function (res) {
|
||||
wx.hideLoading();
|
||||
|
||||
if (res && res !== null) {
|
||||
var list = that.addPrefix(res);
|
||||
if (type == 1) {
|
||||
that.setData({
|
||||
replenishFiles: list
|
||||
});
|
||||
} else {
|
||||
that.setData({
|
||||
restoreFiles: list
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
wx.hideLoading();
|
||||
that.showMessage(err.msg || '获取附件失败,请稍后重试', 'error');
|
||||
});
|
||||
},
|
||||
|
||||
inputRemark: function (e) {
|
||||
this.setData({
|
||||
remark: e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 添加baseUrl
|
||||
addPrefix: function (list) {
|
||||
return list.map(function (item) {
|
||||
item.netUrl = sImgPrefix + item.fileId;
|
||||
return item;
|
||||
});
|
||||
},
|
||||
|
||||
doPreImg: function (e) {
|
||||
var url = e.currentTarget.dataset.value;
|
||||
wx.previewImage({
|
||||
urls: [url]
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 下载文件
|
||||
doDownloadFile: function (e) {
|
||||
var item = e.currentTarget.dataset.item;
|
||||
console.log(isImageFile(item.fileName))
|
||||
// 判断是否是图片
|
||||
if (isImageFile(item.fileName)) {
|
||||
wx.previewImage({
|
||||
urls: [item.netUrl]
|
||||
});
|
||||
} else {
|
||||
// 判断是否支持打开
|
||||
if (isDocumentFile(item.fileName)) {
|
||||
// 去下载文件
|
||||
this.goDownloadFile(item);
|
||||
} else {
|
||||
this.showMessage('该文件无法在小程序中打开,请前往电脑端查看', 'info');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
goDownloadFile: function (item) {
|
||||
var that = this;
|
||||
that.setData({
|
||||
downloadProgress: 0,
|
||||
downloading: true
|
||||
});
|
||||
|
||||
var token = Cache.get('token');
|
||||
var header = {};
|
||||
if (token) {
|
||||
header.Auth = 'Bearer ' + token;
|
||||
}
|
||||
|
||||
var downloadTask = wx.downloadFile({
|
||||
url: item.netUrl,
|
||||
header: header,
|
||||
success: function (res) {
|
||||
that.setData({
|
||||
downloadProgress: 0,
|
||||
downloading: false
|
||||
});
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
wx.getFileSystemManager().saveFile({
|
||||
tempFilePath: res.tempFilePath,
|
||||
filePath: wx.env.USER_DATA_PATH + '/' + item.fileName,
|
||||
success: function (res) {
|
||||
wx.openDocument({
|
||||
filePath: res.savedFilePath,
|
||||
showMenu: true
|
||||
});
|
||||
},
|
||||
fail: function (err) {
|
||||
console.error('文件保存失败', err);
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('下载失败', err);
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
downloadTask.onProgressUpdate(function (res) {
|
||||
that.setData({
|
||||
downloadProgress: res.progress
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
backPageRefresh: function () {
|
||||
var pages = getCurrentPages();
|
||||
var beforePage = pages[pages.length - 2];
|
||||
beforePage.setData({
|
||||
needRefresh: true
|
||||
});
|
||||
wx.navigateBack();
|
||||
},
|
||||
|
||||
showMessage: function (msg, type) {
|
||||
this.setData({
|
||||
msgHint: msg,
|
||||
msgType: type || 'info',
|
||||
msgShow: true
|
||||
});
|
||||
},
|
||||
|
||||
bindChooseWay: function (e) {
|
||||
this.setData({
|
||||
showActionsheet: false
|
||||
});
|
||||
var that = this;
|
||||
var value = e.detail.value;
|
||||
|
||||
if (value === 'img') {
|
||||
wx.chooseMedia({
|
||||
count: 4,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album'],
|
||||
success: function (res) {
|
||||
if (res && res.tempFiles.length > 0) {
|
||||
that.doUploadFile(1, res.tempFiles);
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
that.showMessage(err.errMsg || '选择文件失败,请稍后重试', 'error');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
wx.chooseMessageFile({
|
||||
count: 1,
|
||||
type: 'file',
|
||||
extension: docFix,
|
||||
success: function (res) {
|
||||
if (res && res.tempFiles.length > 0) {
|
||||
that.doUploadFile(2, res.tempFiles);
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
that.showMessage(err.errMsg || '选择文件失败,请稍后重试', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
bindChooseFile: function () {
|
||||
this.setData({
|
||||
showActionsheet: true
|
||||
});
|
||||
},
|
||||
|
||||
// 上传文件 type=1 图片 =2文件
|
||||
doUploadFile: function (type, files) {
|
||||
var that = this;
|
||||
wx.showLoading({
|
||||
title: '上传中...'
|
||||
});
|
||||
|
||||
var upUrl = type === 1 ? upShopImgUrl : upShopFileUrl;
|
||||
var upType = type === 1 ? 'image' : 'file';
|
||||
var token = Cache.get('token');
|
||||
var header = {};
|
||||
|
||||
if (token) {
|
||||
header.Auth = 'Bearer ' + token;
|
||||
}
|
||||
|
||||
var uploadPromises = files.map(function (file, index) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var filePath = type === 1 ? file.tempFilePath : file.path;
|
||||
|
||||
wx.uploadFile({
|
||||
url: upUrl,
|
||||
header: header,
|
||||
filePath: filePath,
|
||||
name: upType,
|
||||
success: function (res) {
|
||||
try {
|
||||
var result = JSON.parse(res.data);
|
||||
result.data.netUrl = sImgPrefix + result.data.fileId;
|
||||
resolve(result.data);
|
||||
} catch (err) {
|
||||
reject(new Error('解析上传结果失败'));
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all(uploadPromises)
|
||||
.then(function (results) {
|
||||
var newFiles = that.data.files.concat(results);
|
||||
that.setData({
|
||||
files: newFiles
|
||||
});
|
||||
wx.hideLoading();
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error('上传失败', err);
|
||||
wx.hideLoading();
|
||||
that.showMessage('上传文件失败,请稍后重试', 'error');
|
||||
});
|
||||
},
|
||||
doDelFile(e) {
|
||||
const index = e.currentTarget.dataset.index
|
||||
var tempFiles = this.data.files
|
||||
if (index >= 0 && index < tempFiles.length) {
|
||||
tempFiles.splice(index, 1);
|
||||
}
|
||||
this.setData({
|
||||
files: tempFiles
|
||||
});
|
||||
|
||||
},
|
||||
//校验参数
|
||||
checkParams() {
|
||||
const isRemarkValid = this.data.remark.trim() !== '';
|
||||
const isFileValid = this.data.files.length > 0;
|
||||
if (!isRemarkValid && !isFileValid) {
|
||||
this.setData({
|
||||
msgHint: '请输入补充内容或上传附件(至少完成一项)',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
//提交
|
||||
doSubmit() {
|
||||
var isLegal = this.checkParams()
|
||||
if (isLegal) {
|
||||
wx.showLoading({
|
||||
title: '提交中...',
|
||||
})
|
||||
var fileIds = ''
|
||||
if (this.data.files.length > 0) {
|
||||
fileIds = this.data.files.map(item => item.fileId)
|
||||
.join(',')
|
||||
}
|
||||
const data = {
|
||||
correctionFiles: fileIds,
|
||||
correctionParentId: this.data.replenish.correctionId,
|
||||
correctionRemark: this.data.remark,
|
||||
orderId: this.data.replenish.orderId
|
||||
}
|
||||
const _self = this
|
||||
Shop.doSaveReplenish(data)
|
||||
.then(res => {
|
||||
wx.hideLoading()
|
||||
_self.setData({
|
||||
msgHint: '提交成功',
|
||||
msgType: 'success',
|
||||
msgShow: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
_self.backPageRefresh()
|
||||
}, 1500);
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading()
|
||||
_self.setData({
|
||||
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
8
pages/shop/replenishDetail/replenishDetail.json
Normal file
8
pages/shop/replenishDetail/replenishDetail.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"mp-toptips": "weui-miniprogram/toptips/toptips",
|
||||
"mp-uploader": "weui-miniprogram/uploader/uploader",
|
||||
"down-progress": "/components/down-progress/down-progress",
|
||||
"mp-actionSheet": "weui-miniprogram/actionsheet/actionsheet"
|
||||
}
|
||||
}
|
81
pages/shop/replenishDetail/replenishDetail.wxml
Normal file
81
pages/shop/replenishDetail/replenishDetail.wxml
Normal file
@ -0,0 +1,81 @@
|
||||
<view class="page-container" style="background-color: var(--divider-color);">
|
||||
<view class="content-box">
|
||||
<view class="content-container" style="min-height: 100vh;">
|
||||
<view class="info-title">平台需要您补充的内容说明</view>
|
||||
<!-- 第一部分 -->
|
||||
<view class="section">
|
||||
<view class="item">
|
||||
<text class="label">主题</text>
|
||||
<view class="select-content-item">
|
||||
<view class="value v-select">{{replenish.correctionTitle}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="label">内容</text>
|
||||
<view class="select-content-no-h">
|
||||
<view class="select-item-box">
|
||||
<view class="value v-select">{{replenish.correctionRemark}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" wx:if="{{replenish.correctionFiles !=''}}">
|
||||
<text class="label">附件</text>
|
||||
<view class="select-content-no-h">
|
||||
<view class="select-item-box">
|
||||
<view class="value v-select">
|
||||
<view class="accessory-box">
|
||||
<view class="accessory-item" wx:for="{{replenishFiles}}" bind:tap="doDownloadFile" data-item="{{item}}" wx:key="index">
|
||||
<block wx:if="{{tools.isImg(item.fileType)}}">
|
||||
<image class="accessory-img" mode="scaleToFill" src="{{item.netUrl}}"></image>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="icon-source"></view>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="info-title">您补充的内容</view>
|
||||
<!-- 第一部分 -->
|
||||
<view class="section">
|
||||
<view class="item">
|
||||
<text class="label">内容</text>
|
||||
<view class="select-content-no-h">
|
||||
<view class="select-item-box">
|
||||
<view class="value v-select">{{restore.correctionRemark}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" wx:if="{{restore.correctionFiles !=''}}">
|
||||
<text class="label">附件</text>
|
||||
<view class="select-content-no-h">
|
||||
<view class="select-item-box">
|
||||
<view class="value v-select">
|
||||
<view class="accessory-box">
|
||||
<view class="accessory-item" wx:for="{{restoreFiles}}" bind:tap="doDownloadFile" data-item="{{item}}" wx:key="index">
|
||||
<block wx:if="{{tools.isImg(item.fileType)}}">
|
||||
<image class="accessory-img" mode="scaleToFill" src="{{item.netUrl}}"></image>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="icon-source"></view>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<down-progress isShow="{{downloading}}" progress="{{downloadProgress}}"></down-progress>
|
||||
<mp-toptips delay="2000" msg="{{msgHint}}" type="{{msgType}}" show="{{msgShow}}"></mp-toptips>
|
||||
<wxs src="../../../utils/comm.wxs" module="tools"></wxs>
|
248
pages/shop/replenishDetail/replenishDetail.wxss
Normal file
248
pages/shop/replenishDetail/replenishDetail.wxss
Normal file
@ -0,0 +1,248 @@
|
||||
/* pages/shop/publishCopyright/publishCopyright.wxss */
|
||||
|
||||
.content-box {
|
||||
border-radius: 20rpx;
|
||||
margin-top: -10rpx;
|
||||
}
|
||||
|
||||
.upload-img-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.content-container {
|
||||
margin: 0rpx -30rpx 0rpx -30rpx;
|
||||
background-color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.info-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
.info-title::before {
|
||||
content: "";
|
||||
width: 10rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 5rpx;
|
||||
border-left: 15rpx solid var(--blue-color);
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 15rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-bottom: 10rpx;
|
||||
padding: 20rpx 10rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
color: var(--text-color);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.textarea-content {
|
||||
margin-top: 10rpx;
|
||||
padding: 10rpx 0rpx;
|
||||
font-size: 28rpx;
|
||||
border-bottom: 1rpx solid var(--divider-color);
|
||||
}
|
||||
|
||||
.select-content {
|
||||
margin-top: 15rpx;
|
||||
display: flex;
|
||||
height: 70rpx;
|
||||
flex-direction: row;
|
||||
border-radius: 5rpx;
|
||||
background-color: var(--bg-gray-input-color);
|
||||
padding: 0rpx 10rpx;
|
||||
}
|
||||
|
||||
.select-content-no-h {
|
||||
margin-top: 15rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
min-height: 70rpx;
|
||||
flex-direction: row;
|
||||
border-radius: 5rpx;
|
||||
padding: 0rpx 15rpx 10rpx 0rpx;
|
||||
border-bottom: 1rpx solid var(--divider-color);
|
||||
}
|
||||
|
||||
.select-content-item {
|
||||
margin-top: 15rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: 70rpx;
|
||||
flex-direction: row;
|
||||
border-radius: 5rpx;
|
||||
padding: 0rpx 15rpx 10rpx 0rpx;
|
||||
border-bottom: 1rpx solid var(--divider-color);
|
||||
}
|
||||
|
||||
.select-item-box {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
padding: 5rpx;
|
||||
}
|
||||
|
||||
.select-item-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
background-color: var(--divider-color);
|
||||
padding: 5rpx 15rpx;
|
||||
border-radius: 5rpx;
|
||||
font-size: 24rpx;
|
||||
margin-right: 15rpx;
|
||||
margin-top: 5rpx;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.desc {
|
||||
flex: 1;
|
||||
color: #999;
|
||||
text-align: left;
|
||||
padding-left: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
padding-right: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.select-time {
|
||||
color: var(--text-color);
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.clear-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.value {
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
|
||||
.value-hint {
|
||||
color: var(--text-gray-hint-color);
|
||||
}
|
||||
|
||||
.v-select {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.v-normal {
|
||||
color: var(--text-gray-hint-color)
|
||||
}
|
||||
|
||||
.custom-dialog {
|
||||
background-color: var(--white-color);
|
||||
}
|
||||
|
||||
.custom-tips {
|
||||
margin-top: 80px;
|
||||
}
|
||||
|
||||
.upload-file-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
padding: 20rpx 0rpx;
|
||||
}
|
||||
|
||||
.upload-file-item {
|
||||
width: 20%;
|
||||
height: 150rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border: 1rpx solid var(--divider-color);
|
||||
border-radius: 10rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.upload-file-del {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
position: absolute;
|
||||
top: -15rpx;
|
||||
right: -15rpx;
|
||||
}
|
||||
|
||||
.upload-file-item:nth-of-type(n+2) {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.icon-add-line {
|
||||
background-image: url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB0PSIxNzQ5ODEwMTM0NTA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQzMDkiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTUxMS45MTQ2NjcgOTYwYTIxLjMzMzMzMyAyMS4zMzMzMzMgMCAwIDEtMjEuMzMzMzM0LTIxLjMzMzMzM2wwLjEyOC04NTMuMzMzMzM0YTIxLjMzMzMzMyAyMS4zMzMzMzMgMCAxIDEgNDIuNjY2NjY3IDBsLTAuMTI4IDg1My4zMzMzMzRhMjEuMzMzMzMzIDIxLjMzMzMzMyAwIDAgMS0yMS4zMzMzMzMgMjEuMzMzMzMzeiIgZmlsbD0iI2NkY2RjZCIgcC1pZD0iNDMxMCI+PC9wYXRoPjxwYXRoIGQ9Ik05MzguNjY2NjY3IDUzMy4zMTJIODUuMzMzMzMzYTIxLjMzMzMzMyAyMS4zMzMzMzMgMCAxIDEgMC00Mi42NjY2NjdoODUzLjMzMzMzNGEyMS4zMzMzMzMgMjEuMzMzMzMzIDAgMSAxIDAgNDIuNjY2NjY3eiIgZmlsbD0iI2NkY2RjZCIgcC1pZD0iNDMxMSI+PC9wYXRoPjwvc3ZnPg==');
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.accessory-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.accessory-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 21%;
|
||||
padding: 15rpx;
|
||||
margin: 10rpx;
|
||||
border: 1rpx solid var(--divider-color);
|
||||
box-sizing: border-box;
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.accessory-img {
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
}
|
||||
|
||||
.file-name {
|
||||
width: 100%;
|
||||
font-size: 20rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.icon-source {
|
||||
background-image: url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSI2NCA2NCA4OTYgODk2IiB3aWR0aD0iNTIiIGhlaWdodD0iNTIiIHN0eWxlPSIiIGZpbHRlcj0ibm9uZSI+CiAgICAKICAgIDxnPgogICAgPHBhdGggZD0iTTkyOCAxNjFINjk5LjJjLTQ5LjEgMC05Ny4xIDE0LjEtMTM4LjQgNDAuN0w1MTIgMjMzbC00OC44LTMxLjNBMjU1LjIgMjU1LjIgMCAwIDAgMzI0LjggMTYxSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY1NjhjMCAxNy43IDE0LjMgMzIgMzIgMzJoMjI4LjhjNDkuMSAwIDk3LjEgMTQuMSAxMzguNCA0MC43bDQ0LjQgMjguNmMxLjMuOCAyLjggMS4zIDQuMyAxLjNzMy0uNCA0LjMtMS4zbDQ0LjQtMjguNkM2MDIgODA3LjEgNjUwLjEgNzkzIDY5OS4yIDc5M0g5MjhjMTcuNyAwIDMyLTE0LjMgMzItMzJWMTkzYzAtMTcuNy0xNC4zLTMyLTMyLTMyek00MDQgNTUzLjVjMCA0LjEtMy4yIDcuNS03LjEgNy41SDIxMS4xYy0zLjkgMC03LjEtMy40LTcuMS03LjV2LTQ1YzAtNC4xIDMuMi03LjUgNy4xLTcuNWgxODUuN2MzLjkgMCA3LjEgMy40IDcuMSA3LjV2NDV6bTAtMTQwYzAgNC4xLTMuMiA3LjUtNy4xIDcuNUgyMTEuMWMtMy45IDAtNy4xLTMuNC03LjEtNy41di00NWMwLTQuMSAzLjItNy41IDcuMS03LjVoMTg1LjdjMy45IDAgNy4xIDMuNCA3LjEgNy41djQ1em00MTYgMTQwYzAgNC4xLTMuMiA3LjUtNy4xIDcuNUg2MjcuMWMtMy45IDAtNy4xLTMuNC03LjEtNy41di00NWMwLTQuMSAzLjItNy41IDcuMS03LjVoMTg1LjdjMy45IDAgNy4xIDMuNCA3LjEgNy41djQ1em0wLTE0MGMwIDQuMS0zLjIgNy41LTcuMSA3LjVINjI3LjFjLTMuOSAwLTcuMS0zLjQtNy4xLTcuNXYtNDVjMC00LjEgMy4yLTcuNSA3LjEtNy41aDE4NS43YzMuOSAwIDcuMSAzLjQgNy4xIDcuNXY0NXoiIGZpbGw9InJnYmEoMTI5LDE3OSw1NSwxKSI+PC9wYXRoPgogICAgPC9nPgogIDwvc3ZnPg==');
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
}
|
@ -1,17 +1,31 @@
|
||||
// pages/shop/publishCopyright/publishCopyright.js
|
||||
import Shop from '../../../net/api/shop'
|
||||
import {
|
||||
var {
|
||||
upShopImgUrl,
|
||||
sImgPrefix
|
||||
} from '../../../net/mainUrl'
|
||||
const Cache = require('../../../utils/storage')
|
||||
const docFix = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf']
|
||||
const imgFix = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'ico', 'tiff', 'tif']
|
||||
Page({
|
||||
sImgPrefix,
|
||||
upShopFileUrl
|
||||
} = require('../../../net/mainUrl');
|
||||
var Cache = require('../../../utils/storage');
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
var docFix = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf'];
|
||||
var imgFix = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'ico', 'tiff', 'tif'];
|
||||
|
||||
// 工具函数:检查文件类型
|
||||
function getFileExtension(filename) {
|
||||
if (!filename || typeof filename !== 'string') return '';
|
||||
var lastDot = filename.lastIndexOf('.');
|
||||
return lastDot === -1 ? '' : filename.substring(lastDot + 1).toLowerCase();
|
||||
}
|
||||
|
||||
function isImageFile(filename) {
|
||||
return imgFix.indexOf(getFileExtension(filename)) !== -1;
|
||||
}
|
||||
|
||||
function isDocumentFile(filename) {
|
||||
return docFix.indexOf(getFileExtension(filename)) !== -1;
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
msgHint: '',
|
||||
msgType: 'info',
|
||||
@ -20,9 +34,9 @@ Page({
|
||||
maxCount: 4,
|
||||
replenishId: '',
|
||||
replenish: null,
|
||||
replenishFiles: [], //附件
|
||||
downloading: false, //是否下载
|
||||
downloadProgress: 0, //下载进度
|
||||
replenishFiles: [],
|
||||
downloading: false,
|
||||
downloadProgress: 0,
|
||||
remark: '',
|
||||
showActionsheet: false,
|
||||
groups: [{
|
||||
@ -30,204 +44,160 @@ Page({
|
||||
value: 'img'
|
||||
},
|
||||
{
|
||||
text: '文件',
|
||||
text: '文件(Word、PDF)',
|
||||
value: 'file'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
var that = this;
|
||||
wx.setNavigationBarTitle({
|
||||
title: '资料补充',
|
||||
})
|
||||
title: '资料补充'
|
||||
});
|
||||
wx.setNavigationBarColor({
|
||||
frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000
|
||||
backgroundColor: '#FFFFFF', // 传递的颜色值,仅支持十六进制颜色
|
||||
animation: { // 可选项
|
||||
frontColor: '#000000',
|
||||
backgroundColor: '#FFFFFF',
|
||||
animation: {
|
||||
duration: 500,
|
||||
timingFunc: 'easeIn'
|
||||
}
|
||||
})
|
||||
this.setData({
|
||||
selectFile: this.selectFile.bind(this),
|
||||
uploadFile: this.uploadFile.bind(this)
|
||||
})
|
||||
const id = options.id
|
||||
if (id && id != '') {
|
||||
});
|
||||
|
||||
var id = options.id;
|
||||
if (id && id !== '') {
|
||||
this.setData({
|
||||
replenishId: id
|
||||
})
|
||||
this.doGetReplenishDetail()
|
||||
});
|
||||
this.doGetReplenishDetail();
|
||||
} else {
|
||||
this.setData({
|
||||
msgHint: '数据有误,请稍后重试',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack()
|
||||
this.showMessage('数据有误,请稍后重试', 'error');
|
||||
setTimeout(function () {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
//获取补充详情
|
||||
async doGetReplenishDetail() {
|
||||
try {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
})
|
||||
const res = await Shop.doGetReplenishDetail(this.data.replenishId)
|
||||
this.setData({
|
||||
replenish: res
|
||||
})
|
||||
wx.hideLoading()
|
||||
//去获取附件信息
|
||||
if (this.data.replenish.correctionFiles && this.data.replenish.correctionFiles != '') {
|
||||
this.doGetFileInfo(this.data.replenish.correctionFiles)
|
||||
}
|
||||
} catch (err) {
|
||||
wx.hideLoading()
|
||||
this.setData({
|
||||
msgType: 'error',
|
||||
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
||||
msgShow: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack()
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
//获取文件信息
|
||||
doGetFileInfo(ids) {
|
||||
const data = {
|
||||
ids: ids
|
||||
}
|
||||
|
||||
// 获取补充详情
|
||||
doGetReplenishDetail: function () {
|
||||
var that = this;
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
})
|
||||
Shop.doGetFileInfos(data)
|
||||
.then(res => {
|
||||
wx.hideLoading()
|
||||
if (res && res != null) {
|
||||
const list = this.addPrefix(res)
|
||||
this.setData({
|
||||
replenishFiles: list
|
||||
})
|
||||
title: '加载中...'
|
||||
});
|
||||
|
||||
Shop.doGetReplenishDetail(this.data.replenishId)
|
||||
.then(function (res) {
|
||||
wx.hideLoading();
|
||||
that.setData({
|
||||
replenish: res
|
||||
});
|
||||
console.log('详情', res)
|
||||
// 获取附件信息
|
||||
if (that.data.replenish.correctionFiles && that.data.replenish.correctionFiles !== '') {
|
||||
that.doGetFileInfo(that.data.replenish.correctionFiles);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading()
|
||||
this.setData({
|
||||
msgHint: err.msg ? err.msg : '获取附件失败,请稍后重试',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
})
|
||||
})
|
||||
.catch(function (err) {
|
||||
wx.hideLoading();
|
||||
that.showMessage(err.msg || '网络错误,请稍后重试', 'error');
|
||||
setTimeout(function () {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
});
|
||||
},
|
||||
inputRemark(e) {
|
||||
|
||||
// 获取文件信息
|
||||
doGetFileInfo: function (ids) {
|
||||
var that = this;
|
||||
var data = {
|
||||
ids: ids
|
||||
};
|
||||
|
||||
wx.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
Shop.doGetFileInfos(data)
|
||||
.then(function (res) {
|
||||
wx.hideLoading();
|
||||
if (res && res !== null) {
|
||||
var list = that.addPrefix(res);
|
||||
that.setData({
|
||||
replenishFiles: list
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
wx.hideLoading();
|
||||
that.showMessage(err.msg || '获取附件失败,请稍后重试', 'error');
|
||||
});
|
||||
},
|
||||
|
||||
inputRemark: function (e) {
|
||||
this.setData({
|
||||
remark: e.detail.value
|
||||
})
|
||||
});
|
||||
},
|
||||
//添加baseUrl
|
||||
addPrefix(list) {
|
||||
list.map(item => {
|
||||
item.netUrl = sImgPrefix + item.fileId
|
||||
})
|
||||
return list
|
||||
|
||||
// 添加baseUrl
|
||||
addPrefix: function (list) {
|
||||
return list.map(function (item) {
|
||||
item.netUrl = sImgPrefix + item.fileId;
|
||||
return item;
|
||||
});
|
||||
},
|
||||
doPreImg(e) {
|
||||
|
||||
doPreImg: function (e) {
|
||||
var url = e.currentTarget.dataset.value;
|
||||
wx.previewImage({
|
||||
urls: [e],
|
||||
})
|
||||
urls: [url]
|
||||
});
|
||||
},
|
||||
deleteImage(e) {
|
||||
var index = e.detail.index;
|
||||
this.data.files.splice(index, 1);
|
||||
|
||||
|
||||
|
||||
// 下载文件
|
||||
doDownloadFile: function (e) {
|
||||
var item = e.currentTarget.dataset.item;
|
||||
|
||||
// 判断是否是图片
|
||||
if (isImageFile(item.fileName)) {
|
||||
wx.previewImage({
|
||||
urls: [item.netUrl]
|
||||
});
|
||||
} else {
|
||||
// 判断是否支持打开
|
||||
if (isDocumentFile(item.fileName)) {
|
||||
// 去下载文件
|
||||
this.goDownloadFile(item);
|
||||
} else {
|
||||
this.showMessage('该文件无法在小程序中打开,请前往电脑端查看', 'info');
|
||||
}
|
||||
}
|
||||
},
|
||||
selectFile(files) {
|
||||
console.log('files', files)
|
||||
},
|
||||
uploadFile(files) {
|
||||
var tempFilePaths = files.tempFilePaths;
|
||||
var token = Cache.get('token')
|
||||
var header = {}
|
||||
|
||||
goDownloadFile: function (item) {
|
||||
var that = this;
|
||||
that.setData({
|
||||
downloadProgress: 0,
|
||||
downloading: true
|
||||
});
|
||||
|
||||
var token = Cache.get('token');
|
||||
var header = {};
|
||||
if (token) {
|
||||
header.Auth = 'Bearer ' + token;
|
||||
}
|
||||
var that = this
|
||||
for (var i = 0; i < tempFilePaths.length; i++) {
|
||||
wx.uploadFile({
|
||||
url: upShopImgUrl,
|
||||
header: header,
|
||||
filePath: tempFilePaths[i],
|
||||
name: 'image',
|
||||
success: function (res) {
|
||||
console.log(res)
|
||||
var result = JSON.parse(res.data)
|
||||
that.data.files.push(result.data)
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 文件上传的函数,返回一个promise
|
||||
return new Promise(function (resolve, reject) {
|
||||
var result = {};
|
||||
result['urls'] = tempFilePaths;
|
||||
resolve(result);
|
||||
})
|
||||
},
|
||||
//下载文件
|
||||
doDownloadFile(e) {
|
||||
const item = e.currentTarget.dataset.item
|
||||
//判断是否是图片
|
||||
if (imgFix.indexOf(item.fileType) != -1) {
|
||||
this.doPreImg(item.netUrl)
|
||||
} else {
|
||||
//判断是否支持打开
|
||||
if (docFix.indexOf(item.fileType) != -1) {
|
||||
//去下载文件
|
||||
this.goDownloadFile(item)
|
||||
} else {
|
||||
this.setData({
|
||||
msgHint: '该文件无法在小程序中打开,请前往电脑端查看',
|
||||
msgType: 'info',
|
||||
msgShow: true
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
goDownloadFile(item) {
|
||||
const _self = this
|
||||
_self.setData({
|
||||
downloadProgress: 0,
|
||||
downloading: true, //显示下载进度
|
||||
})
|
||||
|
||||
const token = Cache.get('token')
|
||||
const header = {}
|
||||
if (token) {
|
||||
header.Auth = `Bearer ${token}`;
|
||||
}
|
||||
const downloadTask = wx.downloadFile({
|
||||
var downloadTask = wx.downloadFile({
|
||||
url: item.netUrl,
|
||||
header: header,
|
||||
success(res) {
|
||||
console.log('下载成功', res)
|
||||
_self.setData({
|
||||
success: function (res) {
|
||||
that.setData({
|
||||
downloadProgress: 0,
|
||||
downloading: false
|
||||
})
|
||||
});
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
_self.setData({
|
||||
successHint: '下载成功',
|
||||
showSuccess: true
|
||||
})
|
||||
wx.getFileSystemManager().saveFile({
|
||||
tempFilePath: res.tempFilePath,
|
||||
filePath: wx.env.USER_DATA_PATH + '/' + item.fileName,
|
||||
@ -235,76 +205,211 @@ Page({
|
||||
wx.openDocument({
|
||||
filePath: res.savedFilePath,
|
||||
showMenu: true
|
||||
})
|
||||
});
|
||||
},
|
||||
fail: function (err) {
|
||||
console.error('文件保存失败', err);
|
||||
_self.showErr('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。')
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
_self.showErr('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。')
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
_self.showErr('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。')
|
||||
console.log(`下载失败${err}`)
|
||||
fail: function (err) {
|
||||
console.log('下载失败', err);
|
||||
that.showMessage('很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。', 'error');
|
||||
}
|
||||
})
|
||||
downloadTask.onProgressUpdate(res => {
|
||||
console.log(res.progress)
|
||||
_self.setData({
|
||||
});
|
||||
|
||||
downloadTask.onProgressUpdate(function (res) {
|
||||
that.setData({
|
||||
downloadProgress: res.progress
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
backPageRefresh: function () {
|
||||
var pages = getCurrentPages();
|
||||
var beforePage = pages[pages.length - 2];
|
||||
beforePage.setData({
|
||||
needRefresh: true
|
||||
})
|
||||
wx.navigateBack()
|
||||
});
|
||||
wx.navigateBack();
|
||||
},
|
||||
showErr(msg) {
|
||||
|
||||
showMessage: function (msg, type) {
|
||||
this.setData({
|
||||
msgHint: msg,
|
||||
msgType: 'error',
|
||||
msgShow: true,
|
||||
downloading: false,
|
||||
downloadProgress: 0
|
||||
})
|
||||
msgType: type || 'info',
|
||||
msgShow: true
|
||||
});
|
||||
},
|
||||
bindChooseWay(e) {
|
||||
if (e.detail.value == 'img') {
|
||||
|
||||
bindChooseWay: function (e) {
|
||||
this.setData({
|
||||
showActionsheet: false
|
||||
});
|
||||
var that = this;
|
||||
var value = e.detail.value;
|
||||
|
||||
if (value === 'img') {
|
||||
wx.chooseMedia({
|
||||
count: 4,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album'],
|
||||
success(res) {
|
||||
console.log(res)
|
||||
success: function (res) {
|
||||
if (res && res.tempFiles.length > 0) {
|
||||
that.doUploadFile(1, res.tempFiles);
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
|
||||
fail: function (err) {
|
||||
that.showMessage(err.errMsg || '选择文件失败,请稍后重试', 'error');
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
wx.chooseMessageFile({
|
||||
count: 1,
|
||||
type: 'file',
|
||||
extension:docFix,
|
||||
success(res) {
|
||||
console.log(res)
|
||||
extension: docFix,
|
||||
success: function (res) {
|
||||
if (res && res.tempFiles.length > 0) {
|
||||
that.doUploadFile(2, res.tempFiles);
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
|
||||
fail: function (err) {
|
||||
that.showMessage(err.errMsg || '选择文件失败,请稍后重试', 'error');
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
bindChooseFile() {
|
||||
|
||||
bindChooseFile: function () {
|
||||
this.setData({
|
||||
showActionsheet: true
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
// 上传文件 type=1 图片 =2文件
|
||||
doUploadFile: function (type, files) {
|
||||
var that = this;
|
||||
wx.showLoading({
|
||||
title: '上传中...'
|
||||
});
|
||||
|
||||
var upUrl = type === 1 ? upShopImgUrl : upShopFileUrl;
|
||||
var upType = type === 1 ? 'image' : 'file';
|
||||
var token = Cache.get('token');
|
||||
var header = {};
|
||||
|
||||
if (token) {
|
||||
header.Auth = 'Bearer ' + token;
|
||||
}
|
||||
|
||||
var uploadPromises = files.map(function (file, index) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var filePath = type === 1 ? file.tempFilePath : file.path;
|
||||
|
||||
wx.uploadFile({
|
||||
url: upUrl,
|
||||
header: header,
|
||||
filePath: filePath,
|
||||
name: upType,
|
||||
success: function (res) {
|
||||
try {
|
||||
var result = JSON.parse(res.data);
|
||||
result.data.netUrl = sImgPrefix + result.data.fileId;
|
||||
resolve(result.data);
|
||||
} catch (err) {
|
||||
reject(new Error('解析上传结果失败'));
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all(uploadPromises)
|
||||
.then(function (results) {
|
||||
var newFiles = that.data.files.concat(results);
|
||||
that.setData({
|
||||
files: newFiles
|
||||
});
|
||||
wx.hideLoading();
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error('上传失败', err);
|
||||
wx.hideLoading();
|
||||
that.showMessage('上传文件失败,请稍后重试', 'error');
|
||||
});
|
||||
},
|
||||
doDelFile(e) {
|
||||
const index = e.currentTarget.dataset.index
|
||||
var tempFiles = this.data.files
|
||||
if (index >= 0 && index < tempFiles.length) {
|
||||
tempFiles.splice(index, 1);
|
||||
}
|
||||
this.setData({
|
||||
files: tempFiles
|
||||
});
|
||||
|
||||
},
|
||||
//校验参数
|
||||
checkParams() {
|
||||
const isRemarkValid = this.data.remark.trim() !== '';
|
||||
const isFileValid = this.data.files.length > 0;
|
||||
if (!isRemarkValid && !isFileValid) {
|
||||
this.setData({
|
||||
msgHint: '请输入补充内容或上传附件(至少完成一项)',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
//提交
|
||||
doSubmit() {
|
||||
var isLegal = this.checkParams()
|
||||
if (isLegal) {
|
||||
wx.showLoading({
|
||||
title: '提交中...',
|
||||
})
|
||||
var fileIds = ''
|
||||
if (this.data.files.length > 0) {
|
||||
fileIds = this.data.files.map(item => item.fileId)
|
||||
.join(',')
|
||||
}
|
||||
const data = {
|
||||
correctionFiles: fileIds,
|
||||
correctionParentId: this.data.replenish.correctionId,
|
||||
correctionRemark: this.data.remark,
|
||||
orderId: this.data.replenish.orderId
|
||||
}
|
||||
const _self = this
|
||||
Shop.doSaveReplenish(data)
|
||||
.then(res => {
|
||||
wx.hideLoading()
|
||||
_self.setData({
|
||||
msgHint: '提交成功',
|
||||
msgType: 'success',
|
||||
msgShow: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
_self.backPageRefresh()
|
||||
}, 1500);
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading()
|
||||
_self.setData({
|
||||
msgHint: err.msg ? err.msg : '网络错误,请稍后重试',
|
||||
msgType: 'error',
|
||||
msgShow: true
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
@ -54,8 +54,15 @@
|
||||
<view class="upload-file-box">
|
||||
<block wx:for="{{files}}" wx:key="index">
|
||||
<view class="upload-file-item">
|
||||
<view></view>
|
||||
<view>{{item.fileName}}</view>
|
||||
<block wx:if="{{tools.isImg(item.fileName)}}">
|
||||
<image bind:tap="doPreImg" data-value="{{item.netUrl}}" class="accessory-img" mode="scaleToFill" src="{{item.netUrl}}"></image>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="icon-source"></view>
|
||||
<view class="file-name">{{item.fileName}}</view>
|
||||
</block>
|
||||
<view bind:tap="doDelFile" data-item="{{item}}" data-index="{{index}}" class="upload-file-del icon-clear"></view>
|
||||
</view>
|
||||
</block>
|
||||
<view bind:tap="bindChooseFile" class="upload-file-item" wx:if="{{files.length<maxCount}}">
|
||||
@ -68,7 +75,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom-fixed-footer">
|
||||
<view class="bottom-btn-blue" bind:tap="doSave">提交</view>
|
||||
<view class="bottom-btn-blue" bind:tap="doSubmit">提交</view>
|
||||
</view>
|
||||
<down-progress isShow="{{downloading}}" progress="{{downloadProgress}}"></down-progress>
|
||||
<mp-toptips delay="2000" msg="{{msgHint}}" type="{{msgType}}" show="{{msgShow}}"></mp-toptips>
|
||||
|
@ -179,13 +179,22 @@
|
||||
|
||||
.upload-file-item {
|
||||
width: 20%;
|
||||
height: 120rpx;
|
||||
height: 150rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border: 1rpx solid var(--divider-color);
|
||||
border-radius: 10rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.upload-file-del {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
position: absolute;
|
||||
top: -15rpx;
|
||||
right: -15rpx;
|
||||
}
|
||||
|
||||
.upload-file-item:nth-of-type(n+2) {
|
||||
|
BIN
static/images/ic_shop_normal.png
Executable file
BIN
static/images/ic_shop_normal.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 586 B |
BIN
static/images/ic_shop_select.png
Executable file
BIN
static/images/ic_shop_select.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 577 B |
@ -51,6 +51,7 @@ page {
|
||||
--red-color-light: #FF000079;
|
||||
--white-color: #FFFFFF;
|
||||
--black-color: #000000;
|
||||
--black-tr-color: #000000dc;
|
||||
--blue-color: #3270FF;
|
||||
--gray-color: #9c9c9c;
|
||||
--gray-bg-color: #efefef79;
|
||||
|
@ -441,13 +441,18 @@ var phoneNum = function (str, startLength, endLength, replaceStr) {
|
||||
return str.slice(0, startLength) + replaceStr + str.slice(str.length - endLength);
|
||||
}
|
||||
//判断是否是图片
|
||||
var isImg = function (fix) {
|
||||
var isImg = function (filename) {
|
||||
var input = filename.trim();
|
||||
var hasDot = input.indexOf('.') !== -1;
|
||||
var extension = hasDot
|
||||
? input.substring(input.lastIndexOf('.') + 1).toLowerCase()
|
||||
: input.toLowerCase();
|
||||
var imageExtensions = [
|
||||
'jpg', 'jpeg', 'png', 'gif', 'bmp',
|
||||
'webp', 'svg', 'ico', 'tiff', 'tif'
|
||||
]
|
||||
return imageExtensions.indexOf(fix) != -1;
|
||||
}
|
||||
];
|
||||
return imageExtensions.indexOf(extension) !== -1;
|
||||
};
|
||||
module.exports = {
|
||||
isEmpty: isEmpty,
|
||||
status: status,
|
||||
|
@ -39,8 +39,8 @@ const tabList = [{
|
||||
{
|
||||
"pagePath": "pages/shop/market/market",
|
||||
"text": "商城",
|
||||
"iconPath": "/static/images/ic_home_normal.png",
|
||||
"selectedIconPath": "/static/images/ic_home_select.png",
|
||||
"iconPath": "/static/images/ic_shop_normal.png",
|
||||
"selectedIconPath": "/static/images/ic_shop_select.png",
|
||||
"selected": false,
|
||||
"hasMsg": false,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user