|
@@ -1,20 +1,82 @@
|
|
|
// pages/welfareMall/historical/historical.js
|
|
|
+import WelfareMall from '../../../api/welfareMall'
|
|
|
+import { parseTime } from '../../../utils/util'
|
|
|
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
-
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ lock: false,
|
|
|
+ noResult: false,
|
|
|
+ noMore: false,
|
|
|
+ mobileTop: 'TONY WU',
|
|
|
+ orderList: []
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
+ this.setData({
|
|
|
+ isLogin: getMobileCache() != ''
|
|
|
+ })
|
|
|
+ if(this.data.isLogin){
|
|
|
+ this.getOrderList();
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
|
|
|
+ // 订单数据
|
|
|
+ getOrderList: function() {
|
|
|
+ WelfareMall.getOrderList({
|
|
|
+ page: this.data.page,
|
|
|
+ pageSize: this.data.pageSize,
|
|
|
+ mobile: getMobileCache(),
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.userOrderistView(res.data)
|
|
|
+ }
|
|
|
+ this.data.lock = false
|
|
|
+ }).catch(_ => {
|
|
|
+ console.log(_)
|
|
|
+ this.data.lock = false
|
|
|
+ })
|
|
|
+},
|
|
|
+
|
|
|
+ userOrderistView: function(data) {
|
|
|
+ if (!Array.isArray(data) || data.length == 0) {
|
|
|
+ console.log("订单列表数据为空");
|
|
|
+ if (this.data.page == 1) {
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ noResult: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ noMore: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ data.forEach(v => {
|
|
|
+ let beginTime = v.coupon.couponBeginTimestamp
|
|
|
+ let endTime = v.coupon.couponEndTimestamp
|
|
|
+ v.coupon.couponBeginTimestamp = parseTime(beginTime, "{y}.{m}.{d}")
|
|
|
+ v.coupon.couponEndTimestamp = parseTime(endTime, "{y}.{m}.{d}")
|
|
|
+ })
|
|
|
+
|
|
|
+ this.data.couponList = this.data.couponList.concat(...data)
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ couponList: this.data.couponList
|
|
|
+ })
|
|
|
+},
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|