瀏覽代碼

解决横屏问题

kk.shi 3 年之前
父節點
當前提交
54d49c4533
共有 4 個文件被更改,包括 138 次插入3 次删除
  1. 35 0
      api/welfareMall.js
  2. 63 1
      pages/welfareMall/historical/historical.js
  3. 2 2
      pages/welfareMall/personal/personal.wxss
  4. 38 0
      utils/util.js

+ 35 - 0
api/welfareMall.js

@@ -0,0 +1,35 @@
+import request from '../utils/request.js'
+
+class WelfareMall extends request {
+
+  /**
+   * 获取订单
+   */
+  static getOrder(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/get`, params);
+  }
+
+  /**
+   * 取消订单
+   */
+  static cancelOrder(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/cancel`, params);
+  }
+
+  /**
+   * 订单列表
+   */
+  static getOrderList(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/list`, params);
+  }
+
+    /**
+   * 订单退款
+   */
+  static orderRefund(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/refund`, params, true)
+  }
+
+}
+
+export default WelfareMall

+ 63 - 1
pages/welfareMall/historical/historical.js

@@ -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
+    })
+}, 
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 2 - 2
pages/welfareMall/personal/personal.wxss

@@ -30,7 +30,7 @@
 }
 
 .head-personal{
-  width: 100%;
+  width: 666rpx;
   height: 136rpx;
   justify-content: flex-start;
   margin-left: 35rpx;
@@ -84,7 +84,7 @@
 }
 
 .content{
-  width: 100%;
+  width: 750rpx;
   height: auto;
 }
 

+ 38 - 0
utils/util.js

@@ -100,6 +100,44 @@ function getQueryVariable(variable,query)
        return(false);
 }
 
+function parseTime(time, cFormat) {
+  if (arguments.length === 0 || !time) {
+    return null
+  }
+  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
+  let date
+  if (typeof time === 'object') {
+    date = time
+  } else {
+    if ((typeof time === 'string')) {
+      if ((/^[0-9]+$/.test(time))) {
+        time = parseInt(time)
+      } else {
+        time = time.replace(new RegExp(/-/gm), '/')
+      }
+    }
+    if ((typeof time === 'number') && (time.toString().length === 10)) {
+      time = time * 1000
+    }
+    date = new Date(time)
+  }
+  const formatObj = {
+    y: date.getFullYear(),
+    m: date.getMonth() + 1,
+    d: date.getDate(),
+    h: date.getHours(),
+    i: date.getMinutes(),
+    s: date.getSeconds(),
+    a: date.getDay()
+  }
+  const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
+    const value = formatObj[key]
+    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
+    return value.toString().padStart(2, '0')
+  })
+  return time_str
+}
+
 module.exports = {
   formatTime,
   sha1,