From a81a1a31ce7ee003e0006168e4d4e57da97c2bb6 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 05 三月 2024 18:46:46 +0800 Subject: [PATCH] 个人中心 --- pages/personalCenter/myOrder/index.js | 186 +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 167 insertions(+), 19 deletions(-) diff --git a/pages/personalCenter/myOrder/index.js b/pages/personalCenter/myOrder/index.js index 358d636..4537c2f 100644 --- a/pages/personalCenter/myOrder/index.js +++ b/pages/personalCenter/myOrder/index.js @@ -1,10 +1,49 @@ +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, + activeName: "FavoriteBookCity", + tabList: [ + { + label: '鍏ㄩ儴', + key: 0, + value: 'all', + }, + { + label: '寰呮敮浠�', + key: 1, + value: 'WaitPay', + }, + { + label: '宸插畬鎴�', + key: 1, + value: 'Success', + }, + { + label: '宸插彇娑�', + key: 1, + value: 'Cancel', + } + ], + list: [], + //鍒嗛〉 + page: 1, + limit: 12, + pageTotalCount: 0, + bottomLoading: false, + isMoreData: false, + // 杩斿洖椤堕儴 + isBackTop: false, + setScrollValue: 0, + skeletonLoding: true, + queryFilter: [] }, /** @@ -12,6 +51,7 @@ */ onLoad(options) { console.log(options); + this.getDataList(false) }, /** @@ -20,40 +60,148 @@ 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, + activeName: info.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.total, + 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: 18, + 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); }, /** -- Gitblit v1.9.1