Browse Source

订单详情处理

kk.shi 3 years ago
parent
commit
513fdc1ec6

+ 5 - 5
pages/welfareMall/historical/historical.js

@@ -38,7 +38,7 @@ Page({
       mobile: getMobileCache(),
     }).then(res => {
         if (res.code == 200) {
-            this.userOrderistView(res.data)
+            this.userOrderListView(res.data)
         }
         this.data.lock = false
     }).catch(_ => {
@@ -47,7 +47,7 @@ Page({
     })
 },
 
-  userOrderistView: function(data) {
+  userOrderListView: function(data) {
     if (!Array.isArray(data) || data.length == 0) {
         console.log("订单列表数据为空");
         if (this.data.page == 1) {
@@ -73,7 +73,7 @@ Page({
         mobileTop:getMobileCache(),
         orderList: this.data.orderList
     })
-}, 
+  }, 
 
   /**
    * 生命周期函数--监听页面初次渲染完成
@@ -124,8 +124,8 @@ Page({
   },
 
   getCompletion(e) {
-    const url = "../order/orderCompletion?id=" + e.currentTarget.dataset.id
-    wx.redirectTo({
+    const url = "../order/orderCompletion?ordersn=" + e.currentTarget.dataset.ordersn
+    wx.navigateTo({
         url
     })
   },

+ 2 - 2
pages/welfareMall/historical/historical.wxml

@@ -3,7 +3,7 @@
 <view class="historical flex-column">
   <view class="historical-style flex-column">
     <!-- 内容 -->
-    <view class="historical-content flex-column" wx:for="{{orderList}}" wx:key="index" data-id="{{item.id}}">
+    <view class="historical-content flex-column" wx:for="{{orderList}}" wx:key="index" data-ordersn="{{item.orderSn}}">
       <view class="content-hm flex-column">
         <view class="content-head flex-row">
           <view class="content-head-date">{{item.payedAt}}</view>
@@ -21,7 +21,7 @@
         </view>
       </view>
       <view class="content-line"></view>
-      <view class="content-lower flex-row" catchtap="getCompletion">
+      <view class="content-lower flex-row" data-ordersn="{{item.orderSn}}" catchtap="getCompletion">
         <view class="lower-total">共{{item.goodsList.length}}件商品 合计¥{{item.payPriceFormatter}}</view>
         <view class="lower-order-style flex-row">
           <view class="lower-order-text">订单详情</view>

+ 47 - 1
pages/welfareMall/order/orderCompletion.js

@@ -1,20 +1,66 @@
 // pages/welfareMall/order/orderCompletion.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,
+    isLogin: false,
+    orderDetail: null,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    var that = this;
+    that.orderSn = options.ordersn
+    this.setData({
+      isLogin: getMobileCache() != '',
+  })
+  if(this.data.isLogin){
+      this.getOrder(that.orderSn);
+  }
+  },
 
+  // 订单数据
+  getOrder: function(data) {
+    WelfareMall.getOrder({
+      mobile: getMobileCache(),
+      orderSn: data,
+    }).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 (!data) {
+        console.log("订单详情数据为空");
+        return
+    }
+
+    this.data.orderDetail = this.data.orderDetail.concat(...data)
+    this.setData({
+        mobileTop:getMobileCache(),
+        orderDetail: this.data.orderDetail
+    })
+    console.log(orderDetail);
+  }, 
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */