diff --git a/app.json b/app.json index b2d95a0..fabb3de 100644 --- a/app.json +++ b/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", diff --git a/app.wxss b/app.wxss index 1bf5eae..67df8d7 100644 --- a/app.wxss +++ b/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 { diff --git a/net/api/shop.js b/net/api/shop.js index 77f1883..ba7f506 100644 --- a/net/api/shop.js +++ b/net/api/shop.js @@ -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, { diff --git a/net/mainUrl.js b/net/mainUrl.js index 7747ce7..645d3bd 100644 --- a/net/mainUrl.js +++ b/net/mainUrl.js @@ -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 } \ No newline at end of file diff --git a/pages/copyright/applyRefund/applyRefund.wxss b/pages/copyright/applyRefund/applyRefund.wxss index 2355d96..cd0644f 100644 --- a/pages/copyright/applyRefund/applyRefund.wxss +++ b/pages/copyright/applyRefund/applyRefund.wxss @@ -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; diff --git a/pages/copyright/applyRepair/applyRepair.wxss b/pages/copyright/applyRepair/applyRepair.wxss index 465f81f..1ed54f0 100644 --- a/pages/copyright/applyRepair/applyRepair.wxss +++ b/pages/copyright/applyRepair/applyRepair.wxss @@ -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; diff --git a/pages/copyright/createProjectInfo/createProjectInfo.wxss b/pages/copyright/createProjectInfo/createProjectInfo.wxss index 64d23cc..795df29 100644 --- a/pages/copyright/createProjectInfo/createProjectInfo.wxss +++ b/pages/copyright/createProjectInfo/createProjectInfo.wxss @@ -181,9 +181,7 @@ background-color: #f0f0f0; } -.weui-half-screen-dialog__ft { - padding: 0rpx 0rpx 40rpx 0rpx; -} + .bottom-box { position: fixed; diff --git a/pages/copyright/refund/refund.wxss b/pages/copyright/refund/refund.wxss index ea0e41c..a22c33a 100644 --- a/pages/copyright/refund/refund.wxss +++ b/pages/copyright/refund/refund.wxss @@ -610,9 +610,6 @@ color: white; } -.weui-half-screen-dialog__ft { - padding: 0rpx 0rpx 40rpx; -} .weui-half-screen-dialog__bd { padding-bottom: 40rpx; diff --git a/pages/copyright/repair/repair.wxss b/pages/copyright/repair/repair.wxss index d64f835..fa4b978 100644 --- a/pages/copyright/repair/repair.wxss +++ b/pages/copyright/repair/repair.wxss @@ -615,9 +615,6 @@ color: white; } -.weui-half-screen-dialog__ft { - padding: 0rpx 0rpx 40rpx; -} .weui-half-screen-dialog__bd { padding-bottom: 40rpx; diff --git a/pages/index/index.wxss b/pages/index/index.wxss index 2769ac1..156df51 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -562,8 +562,3 @@ color: var(--primary-color); font-weight: bold; } - -.weui-half-screen-dialog__ft { - height: 0; - padding: 0rpx 0rpx 40rpx; -} \ No newline at end of file diff --git a/pages/login/login.wxss b/pages/login/login.wxss index 241bf07..e4d56a8 100644 --- a/pages/login/login.wxss +++ b/pages/login/login.wxss @@ -122,10 +122,7 @@ margin-bottom: 10px; } -.weui-half-screen-dialog__ft { - padding: 0rpx 0rpx 40rpx; - text-align: center; -} + .custom-tips { margin-top: 80px; diff --git a/pages/mine/mineAccount/invoiceInfo/invoiceInfo.wxss b/pages/mine/mineAccount/invoiceInfo/invoiceInfo.wxss index f1a4d0f..2f1b6b2 100644 --- a/pages/mine/mineAccount/invoiceInfo/invoiceInfo.wxss +++ b/pages/mine/mineAccount/invoiceInfo/invoiceInfo.wxss @@ -231,9 +231,6 @@ color: white; } -.weui-half-screen-dialog__ft { - padding: 0rpx 0rpx 40rpx; -} .weui-half-screen-dialog__bd { padding-bottom: 40rpx; diff --git a/pages/mine/mineAccount/makeInvoice/makeInvoice.wxss b/pages/mine/mineAccount/makeInvoice/makeInvoice.wxss index 4333006..638f4a8 100644 --- a/pages/mine/mineAccount/makeInvoice/makeInvoice.wxss +++ b/pages/mine/mineAccount/makeInvoice/makeInvoice.wxss @@ -176,9 +176,7 @@ margin-left: 20rpx; } -.weui-half-screen-dialog__ft { - padding: 0rpx 0rpx 40rpx; -} + .weui-half-screen-dialog__bd { padding-bottom: 40rpx; diff --git a/pages/mine/mineAccount/mineContact/mineContact.wxss b/pages/mine/mineAccount/mineContact/mineContact.wxss index 10ea012..498850a 100644 --- a/pages/mine/mineAccount/mineContact/mineContact.wxss +++ b/pages/mine/mineAccount/mineContact/mineContact.wxss @@ -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; diff --git a/pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.wxss b/pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.wxss index 2783fdd..fac451b 100644 --- a/pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.wxss +++ b/pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage.wxss @@ -343,10 +343,6 @@ color: white; } -.weui-half-screen-dialog__ft { - padding: 0rpx 0rpx 40rpx; -} - .weui-half-screen-dialog__bd { padding-bottom: 40rpx; } \ No newline at end of file diff --git a/pages/mine/mineIndex/mine.js b/pages/mine/mineIndex/mine.js index 5e7ecfb..0f91971 100644 --- a/pages/mine/mineIndex/mine.js +++ b/pages/mine/mineIndex/mine.js @@ -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 }) }) }, diff --git a/pages/shop/betrayGoods/betrayGoods.js b/pages/shop/betrayGoods/betrayGoods.js index a009d37..fc34042 100644 --- a/pages/shop/betrayGoods/betrayGoods.js +++ b/pages/shop/betrayGoods/betrayGoods.js @@ -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 diff --git a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.js b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.js index bba0f1a..6495a2d 100644 --- a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.js +++ b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.js @@ -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 + }); + }); + }, }) \ No newline at end of file diff --git a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.json b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.json index 0fbec82..32d558c 100644 --- a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.json +++ b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.json @@ -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" } } \ No newline at end of file diff --git a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxml b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxml index 4a0441f..b7e620b 100644 --- a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxml +++ b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxml @@ -12,6 +12,7 @@ {{order.waitCorrectionCount}} 受让人信息 + 证书详情 @@ -112,31 +113,31 @@ - - + + {{item.correctionTitle}} - {{item.correctionRemark}} + + + {{item.sellId==''?'待补充':'已补充'}} + + + + + {{item.buyId==''?'待补充':'已补充'}} + + + {{item.correctionRemark}} + + + {{item.createTime}} 去补充 去补充 - - - - {{item.sellId==''?'待补充':'已补充'}} - - - - - {{item.buyId==''?'待补充':'已补充'}} - - - {{item.createTime}} - @@ -152,37 +153,66 @@ 类别 - {{order.buyUserDTO.type}} + {{order.buyUserDTO.type != ''? order.buyUserDTO.type:'暂无'}} 姓名或机构名称 - {{order.buyUserDTO.name}} + {{order.buyUserDTO.name != ''?order.buyUserDTO.name:'暂无'}} 所在省市 - {{order.buyUserDTO.city}} + {{order.buyUserDTO.city != '' ?order.buyUserDTO.city:'暂无'}} 联系电话 - {{order.buyUserDTO.phone}} + {{order.buyUserDTO.phone !='' ?order.buyUserDTO.phone:'暂无'}} 证件类型 - {{order.buyUserDTO.idcardType}} + {{order.buyUserDTO.idcardType != '' ?order.buyUserDTO.idcardType:'暂无'}} 证件号码 - {{order.buyUserDTO.idcard}} + {{order.buyUserDTO.idcard != ''? order.buyUserDTO.idcardType:'暂无'}} + + + + + + + 下证时间 + + {{order.produceTime}} + + + + 证书 + + + + + + + + {{item.fileName}} + + + + {{item.fileName}} + + + + @@ -198,5 +228,6 @@ + \ No newline at end of file diff --git a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxss b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxss index 3b743d3..1154969 100644 --- a/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxss +++ b/pages/shop/betrayGoodsDetail/betrayGoodsDetail.wxss @@ -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; } \ No newline at end of file diff --git a/pages/shop/goodsDetail/goodsDetail.js b/pages/shop/goodsDetail/goodsDetail.js index 6f1ea77..6221a24 100644 --- a/pages/shop/goodsDetail/goodsDetail.js +++ b/pages/shop/goodsDetail/goodsDetail.js @@ -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(); } }) \ No newline at end of file diff --git a/pages/shop/goodsDetail/goodsDetail.wxml b/pages/shop/goodsDetail/goodsDetail.wxml index 8f9868a..78afdd6 100644 --- a/pages/shop/goodsDetail/goodsDetail.wxml +++ b/pages/shop/goodsDetail/goodsDetail.wxml @@ -1,11 +1,11 @@ - + 我要买 - + {{goods.goodsName}} diff --git a/pages/shop/market/market.js b/pages/shop/market/market.js index 30df075..eb02740 100644 --- a/pages/shop/market/market.js +++ b/pages/shop/market/market.js @@ -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({ diff --git a/pages/shop/replenishDetail/replenishDetail.js b/pages/shop/replenishDetail/replenishDetail.js new file mode 100644 index 0000000..f01cb25 --- /dev/null +++ b/pages/shop/replenishDetail/replenishDetail.js @@ -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 + }) + }) + } + } +}); \ No newline at end of file diff --git a/pages/shop/replenishDetail/replenishDetail.json b/pages/shop/replenishDetail/replenishDetail.json new file mode 100644 index 0000000..54eb14f --- /dev/null +++ b/pages/shop/replenishDetail/replenishDetail.json @@ -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" + } +} \ No newline at end of file diff --git a/pages/shop/replenishDetail/replenishDetail.wxml b/pages/shop/replenishDetail/replenishDetail.wxml new file mode 100644 index 0000000..18beba0 --- /dev/null +++ b/pages/shop/replenishDetail/replenishDetail.wxml @@ -0,0 +1,81 @@ + + + + 平台需要您补充的内容说明 + + + + 主题 + + {{replenish.correctionTitle}} + + + + 内容 + + + {{replenish.correctionRemark}} + + + + + 附件 + + + + + + + + {{item.fileName}} + + + + {{item.fileName}} + + + + + + + + + 您补充的内容 + + + + 内容 + + + {{restore.correctionRemark}} + + + + + 附件 + + + + + + + + {{item.fileName}} + + + + {{item.fileName}} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/shop/replenishDetail/replenishDetail.wxss b/pages/shop/replenishDetail/replenishDetail.wxss new file mode 100644 index 0000000..80d9d4a --- /dev/null +++ b/pages/shop/replenishDetail/replenishDetail.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/shop/reportReplenish/reportReplenish.js b/pages/shop/reportReplenish/reportReplenish.js index 2bb87a7..4aeb196 100644 --- a/pages/shop/reportReplenish/reportReplenish.js +++ b/pages/shop/reportReplenish/reportReplenish.js @@ -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 + }) + }) + } } -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/pages/shop/reportReplenish/reportReplenish.wxml b/pages/shop/reportReplenish/reportReplenish.wxml index 70e5b22..fb586d5 100644 --- a/pages/shop/reportReplenish/reportReplenish.wxml +++ b/pages/shop/reportReplenish/reportReplenish.wxml @@ -54,8 +54,15 @@ - - {{item.fileName}} + + + {{item.fileName}} + + + + {{item.fileName}} + + @@ -68,7 +75,7 @@ - 提交 + 提交 diff --git a/pages/shop/reportReplenish/reportReplenish.wxss b/pages/shop/reportReplenish/reportReplenish.wxss index 0488468..3edc1fd 100644 --- a/pages/shop/reportReplenish/reportReplenish.wxss +++ b/pages/shop/reportReplenish/reportReplenish.wxss @@ -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) { diff --git a/static/images/ic_shop_normal.png b/static/images/ic_shop_normal.png new file mode 100755 index 0000000..1347e4b Binary files /dev/null and b/static/images/ic_shop_normal.png differ diff --git a/static/images/ic_shop_select.png b/static/images/ic_shop_select.png new file mode 100755 index 0000000..628cc91 Binary files /dev/null and b/static/images/ic_shop_select.png differ diff --git a/static/style/common.wxss b/static/style/common.wxss index ef06be6..2e2c81c 100644 --- a/static/style/common.wxss +++ b/static/style/common.wxss @@ -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; diff --git a/utils/comm.wxs b/utils/comm.wxs index 62692b3..2cf3d21 100644 --- a/utils/comm.wxs +++ b/utils/comm.wxs @@ -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, diff --git a/utils/data.js b/utils/data.js index ec63b30..971eb7d 100644 --- a/utils/data.js +++ b/utils/data.js @@ -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, },