From b7ed8541113f8fa116b19d13e34a70a929310077 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 12 三月 2024 14:38:22 +0800 Subject: [PATCH] 样书申请 --- pages/personalCenter/myOrder/index.js | 310 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 292 insertions(+), 18 deletions(-) diff --git a/pages/personalCenter/myOrder/index.js b/pages/personalCenter/myOrder/index.js index 358d636..8b502b1 100644 --- a/pages/personalCenter/myOrder/index.js +++ b/pages/personalCenter/myOrder/index.js @@ -1,10 +1,44 @@ +const app = getApp(); +import moment from 'moment' +import tool2 from "../../../assets/js/toolClass.js" +import { getPublicImage } from "../../../assets/js/middleGround/tool.js"; Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - + active: 0, + tabList: [ + { + label: '鍏ㄩ儴', + value: 'all', + }, + { + label: '寰呮敮浠�', + value: 'WaitPay', + }, + { + label: '宸插畬鎴�', + value: 'Success', + }, + { + label: '宸插彇娑�', + value: 'Cancel', + } + ], + list: [], + //鍒嗛〉 + page: 1, + limit: 12, + pageTotalCount: 0, + bottomLoading: false, + isMoreData: false, + // 杩斿洖椤堕儴 + isBackTop: false, + setScrollValue: 0, + skeletonLoding: true, + queryFilter: [] }, /** @@ -12,6 +46,7 @@ */ onLoad(options) { console.log(options); + this.getDataList(false) }, /** @@ -20,39 +55,278 @@ onReady() { }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず - */ - onShow() { - + tabBookClick(item) { + console.log(item, 1) + let that = this; + let info = this.data.tabList[item.detail.value] + that.setData({ + skeletonLoding: true, + active: item.detail.value, + queryFilter: info.value == 'all' ? [] : [{ field: 'State', value: info.value }], + list: [], + page: 1, + bottomLoading: false, + isMoreData: false, + }) + that.getDataList(false); }, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 - */ - onHide() { + getDataList(isReachBottom) { + const data = { + start: this.data.page * this.data.limit - this.data.limit, + size: this.data.limit, + filterList: this.data.queryFilter, + sort: { + type: 'Desc', + field: 'CreateDate' + } + } + app.MG.store.getUserOrderList(data).then((res) => { + try { + if (res.datas.length > 0) { + res.datas.forEach((item, index) => { + item.payPrice = tool2.toDecimal2(item.payPrice) + item.createDate = moment(item.createDate).format("YYYY-MM-DD HH:mm:ss"); + item.finishedDate = moment(item.finishedDate).format("YYYY-MM-DD HH:mm:ss"); + if (item.state == "Success") { + item.colorName = 'success'; + item.CustomState = "宸插畬鎴�"; + } + if (item.state == "Cancel") { + item.colorName = 'cancal'; + item.CustomState = "宸插彇娑�"; + } + if (item.state == "WaitPay") { + item.colorName = 'waitPay'; + item.CustomState = "寰呮敮浠�"; + } + if (item.state == "WaitDeliver") { + item.colorName = 'waitDeliver'; + item.CustomState = "姝e湪鏀粯"; + } + if (item.state == "GroupPaySuccess") { + item.colorName = 'success'; + item.CustomState = "绛夊緟鎷煎洟" + } + if (item.state == "ReFounding") { + item.colorName = 'ReFounding'; + item.CustomState = "閫�娆句腑" + } + if (item.state == "ReFoundFinished") { + item.colorName = 'ReFoundFinished'; + item.CustomState = "閫�娆惧畬鎴�" + } + let oldlist = []; + oldlist = item.saleMethodLinks + oldlist.forEach(istrue => { + istrue.name = istrue.orderSaleMethod.product.name + istrue.payPrice = tool2.toDecimal2(istrue.payPrice) + istrue.icon = getPublicImage(istrue.orderSaleMethod.product.icon, "", 400) + }) + }) + let dataList = res.datas; + //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹� + if (isReachBottom) { + dataList = [...this.data.list, ...dataList] //灏嗘柊鏁版嵁鍔犲叆鑰佹暟鎹腑 + } + this.setData({ + list: dataList, + pageTotalCount: res.totalSize, + bottomLoading: false, + isMoreData: dataList.length > 0 ? false : true, + skeletonLoding: false, + loading: false + }) + } else { + this.setData({ + skeletonLoding: false, + loading: false + }) + } + } catch (error) { + console.log(error) + } + }) }, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 - */ - onUnload() { - - }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ onPullDownRefresh() { - + if (this._freshing) return + this.setData({ + // list: [], + page: 1, + limit: 12, + pageTotalCount: 0, + bottomLoading: false, + isMoreData: false + }) + this._freshing = true; + this.setData({ + triggered: false, + }) + this.getDataList(false); + this._freshing = false }, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ onReachBottom() { + this.setData({ + bottomLoading: true, + isMoreData: false + }) + let bool = false; + if (this.data.pageTotalCount > this.data.list.length) { + bool = true; + this.setData({ + page: this.data.page + 1, + }) + } else { + setTimeout(() => { + this.setData({ + bottomLoading: false, + isMoreData: true + }) + }, 100) + return false; + } + this.getDataList(bool); + }, + + onCancel(e) { + let { orderNum } = e.currentTarget.dataset + console.log(orderNum, 12) + wx.showModal({ + title: '鎻愮ず', //鎻愮ず鐨勬爣棰� + content: '纭畾瑕佸彇娑堣鍗曪紵', //鎻愮ず鐨勫唴瀹� + success: function (res) { + if (res.confirm) { + app.MG.store.cancelOrder({ orderNum: orderNum }).then(() => { + wx.showToast({ + title: "璁㈠崟宸插彇娑�", + icon: 'success', + duration: 1000 + }) + this.getDataList(false) + }) + } else if (res.cancel) { + console.log('鐢ㄦ埛鐐瑰嚮浜嗗彇娑�') + } + } + }) + + }, + //绔嬪嵆鏀粯銆佸啀娆¤喘涔� + onPayment(e) { + var that = this; + const { + orderNum + } = e.currentTarget.dataset + const data = { + orderNum: orderNum, + }; + app.MG.store.getOrderByOrderNum(data).then(res => { + if (res && res.state != "WaitPay") { + app.MG.store.confirmOrder(data).then(conRes => { + if (conRes.orderNumber) { + const resOrderNum = { + orderNum: conRes.orderNumber, + }; + if (conRes.payPrice != 0) { + app.MG.store.makeWeChatPay(resOrderNum).then(payRes => { + const payVal = JSON.parse(payRes); + wx.requestPayment({ + "appId": payVal.appId, + "timeStamp": payVal.timeStamp, + "nonceStr": payVal.nonceStr, + "package": payVal.package, + "signType": payVal.signType, + "paySign": payVal.paySign, + "success": function (res) { + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPaySuccess: true + }) + } + console.log(res, "鎴愬姛") + }, + "fail": function (res) { + console.log(res, "澶辫触") + }, + "complete": function (res) { + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPayComplete: true + }) + } + if (that.data.isPaySuccess && that.data.isPayComplete) { + that.navToBack() + } + } + }) + }); + } else { + wx.showToast({ + title: '棰嗗彇鎴愬姛', + }) + // 鍙坊鍔犺繑鍥炰笂绾� + setTimeout(() => { + that.navToBack() + }, 2000); + } + } + }); + } else { + app.MG.store + .makeWeChatPay({ + orderNum: orderNum + }) + .then(payRes => { + const payVal = JSON.parse(payRes); + wx.requestPayment({ + "appId": payVal.appId, + "timeStamp": payVal.timeStamp, + "nonceStr": payVal.nonceStr, + "package": payVal.package, + "signType": payVal.signType, + "paySign": payVal.paySign, + "success": function (res) { + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPaySuccess: true + }) + } + }, + "fail": function (res) { + console.log(res, "澶辫触") + }, + "complete": function (res) { + if (res.errMsg == 'requestPayment:ok') { + that.setData({ + isPayComplete: true + }) + } + if (that.data.isPaySuccess && that.data.isPayComplete) { + that.navToBack() + } + } + }) + }); + } + }); + + }, + + //鍒犻櫎璁㈠崟 + onDel(e) { + const { + orderNum + } = e.currentTarget.dataset }, -- Gitblit v1.9.1