| | |
| | | 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: [] |
| | | }, |
| | | |
| | | /** |
| | |
| | | */ |
| | | onLoad(options) { |
| | | console.log(options); |
| | | this.getDataList(false) |
| | | }, |
| | | |
| | | /** |
| | |
| | | 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 = "正在支付"; |
| | | } |
| | | 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); |
| | | }, |
| | | |
| | | /** |