Browse Source

feat(pages) feat 退款

clp 3 years ago
parent
commit
fb5e218da4

BIN
images/groupmeallist/goodDetailbackgroundImg.png


BIN
images/groupmeallist/order_good.png


BIN
images/groupmeallist/store_none.png


+ 3 - 5
pages/groupmeallist/goodDetails/goodDetails.js

@@ -807,13 +807,11 @@ Page({
                 comboSkuList: comboSkuList,
             }).then(res => {
                 if (res.code == 200) {
-
                     wx.switchTab({
                         url: '/pages/groupmeallist/storeGoods/storeGoods'
                     });
                 }
-            }).catch(_ => {})
-
+            }).catch(_ => { })
         } else {
             wx.showToast({
                 title: '请选择您喜欢的商品哟,亲!',
@@ -833,9 +831,9 @@ Page({
         //列表显示清空
         this.data.comBoObject.productComboSetsList.forEach(item => {
             item.comboSku.productList.forEach(v => {
-                    v.num = 0
+                v.num = 0
 
-                }),
+            }),
                 item.shopCarList = []
         })
 

+ 139 - 1
pages/groupmeallist/myOrder/myOrder.js

@@ -1,20 +1,158 @@
 // pages/groupmeallist/myOrder/myOrder.js
+import order from '../../../api/order'
+const cache = require('../../../utils/cache.js');
+import Activity from '../../../api/activity';
+const app = getApp()
+import storeGoods from '../../../api/storeGoods'
+import base from "../../../utils/base";
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-
+        showAllSku: false,
+        orderInfo: {},
+        orderSn: '',
+        orderGoodList: [], //spu-sku商品信息
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        if (options.sn) {
+            this.reloadPage(options.sn)
+        }
+    },
 
+    // // 时间戳转化
+    // getLocalTime(nS) {
+    //     return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
+    // },
+
+    dateFormat(timestamp, format) {
+        if (String(timestamp).length === 10) {
+            timestamp = timestamp * 1000
+        }
+        var date = new Date(timestamp)
+        var Y = date.getFullYear()
+        var M = date.getMonth() + 1
+        var D = date.getDate()
+        var hour = date.getHours()
+        var min = date.getMinutes()
+        var sec = date.getSeconds()
+        if (format === 'YYYY') {
+            return Y // 2021
+        } else if (format === 'YYYY-MM') { // 2021-07
+            return Y + '-' + (M < 10 ? '0' + M : M)
+        } else if (format === 'YYYY-MM-DD') { // 2021-07-12
+            return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D)
+        } else if (format === 'HH:mm:ss') { // 10:20:35
+            return (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
+        } else if (format === 'YYYY-MM-DD HH:mm') { // 2021-07-12 10:20
+            return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D) + ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min)
+        } else if (format === 'YYYY-MM-DD HH:mm:ss') { // 2021-07-12 10:20:35
+            return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D) + ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
+        } else {
+            return '--'
+        }
     },
 
+
+    reloadPage(orderSn) {
+        this.setData({
+            orderSn
+        })
+
+        this.getOrderdetail();
+    },
+    async getOrderdetail() {
+        let _self = this;
+        try {
+            let orderRes = await order.getOrderDetail({
+                orderSn: _self.data.orderSn,
+                mobile: cache.getMobile()
+            });
+            if (orderRes.code == 200 && orderRes.msg == "success") {
+                let orderInfo = orderRes.data;
+                orderInfo.originPrice = (parseFloat(orderInfo.payPrice) / 100).toFixed(2)
+                orderInfo.orderRefund.createTime = _self.dateFormat(orderInfo.orderRefund.createTime, 'YYYY-MM-DD HH:mm:ss')
+                _self.setData({
+                    orderInfo: orderInfo,
+                })
+                //组建spu sku
+                _self.createOrderGoodList(orderInfo.orderGoodsList)
+            }
+        } catch (error) {
+            console.log(error);
+        }
+    },
+
+    /**
+* 组建spu sku
+* @param {*} list 
+*/
+    createOrderGoodList(list) {
+
+        console.log("进入详情")
+        console.log(list)
+        let _self = this;
+        if (list.length == 0) {
+            return;
+        }
+        let orderGoodList = [];
+        for (let a = 0; a < list.length; a++) { //最外层
+            //某一个商品种类
+            let goodList = list[a];
+            //sku-list
+            let orderGoodsSkuList = goodList.orderGoodsSkuList;
+            for (let b = 0; b < orderGoodsSkuList.length; b++) {
+                let orderGood = {};
+                orderGood.productName = goodList.productName;
+                let orderGoodsSku = orderGoodsSkuList[b];
+                let text = '';
+                if (orderGoodsSku.comboSkuList != null && orderGoodsSku.comboSkuList.length > 0) {
+                    console.log("进入套餐拼接")
+                    text = "套餐:"
+                    let productName = ''
+                    let specValue = []
+                    let num = ''
+                    orderGoodsSku.comboSkuList.forEach(function (comboSkuList, index) {
+                        comboSkuList.skuList.forEach(function (skuList, skuindex) {
+                            productName = skuList.productName
+                            num = skuList.num
+                            if (skuList.specList != null) {
+                                let specList = JSON.parse(skuList.specList);
+                                if (base.isArray(specList)) {
+                                    specList.forEach(function (specList, skuindex) {
+
+                                        specValue.push(specList.specValue + " X" + num)
+
+                                    })
+                                }
+                            } else {
+                                specValue.push(productName + " X" + num)
+                            }
+                        })
+                    }
+                    )
+                    specValue = specValue.join('、') || ""
+                    text = text + "(" + specValue + ")"
+
+                }
+                orderGood.num = orderGoodsSkuList[b].num;
+                orderGood.allFee = base.fenToYuan(orderGoodsSkuList[b].price * orderGoodsSkuList[b].num)
+                orderGood.skuText = text
+                orderGoodList.push(orderGood)
+            }
+        }
+        _self.setData({
+            orderGoodList: orderGoodList
+        })
+
+        console.log(this.data.orderGoodList)
+    },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 19 - 17
pages/groupmeallist/myOrder/myOrder.wxml

@@ -1,18 +1,18 @@
 <view class="page">
     <view class="myOrder flex-column">
         <view class="myOrder_state flex-column_start_center">
-            <view style=" font-size: 49rpx;font-weight: 700;text-align: left;color: #000000;">待退款</view>
+            <view style=" font-size: 49rpx;font-weight: 700;text-align: left;color: #000000;">{{orderInfo.stateText}}</view>
             <view style="font-size: 32rpx;font-weight: 700;text-align: center;color: #313131;">
-                <span class="fontSize-28">退款金额:</span>¥20.0
+                <span class="fontSize-28">退款金额:</span>¥{{orderInfo.totalOriPriceY}}
             </view>
         </view>
-        <view style="width: 93%; border-bottom: 1px #e2e2e2 solid; margin:0px auto;margin-top: 18rpx;"></view>
-        <view class="myOrder_refund flex-row">
+        <!-- <view style="width: 93%; border-bottom: 1px #e2e2e2 solid; margin:0px auto;margin-top: 18rpx;"></view> -->
+        <!-- <view class="myOrder_refund flex-row">
             <view class="fontSize-3" style="margin-left: 28rpx;">退款进度</view>
             <view class="refund_revoke">撤销退款</view>
-        </view>
+        </view> -->
 
-        <view class="myOrder_center flex-column">
+        <!-- <view class="myOrder_center flex-column">
 
             <view class="flex-row" style="margin-top: 26rpx;margin-left: 17rpx;">
                 <view style="width: 14rpx;height: 14rpx;background: #ffffff;border: 1rpx solid #e2e2e2;border-radius: 50%;"></view>
@@ -24,40 +24,42 @@
             <view class="fontSize-28" style="color:#AFD250;margin-left: 49rpx;margin-top: 34rpx;">商家审核中</view>
 
             <view style="line-height:35rpx;  width: 576rpx;height: 64rpx;font-size: 24rpx;font-weight: 400;text-align: left;color: #989898;margin-left:49rpx;margin-top: 9rpx;">商家审核中,待商家确认审核通过,按支付方式原路返 还,如有疑问请联系我们</view>
-        </view>
+        </view> -->
 
 
     </view>
 
     <view class="myOrder_refund_order flex-column">
-        <view class="fontSize-3" style="margin-left: 28rpx;margin-top: 26rpx;">退款进度</view>
+        <view class="fontSize-3" style="margin-left: 28rpx;margin-top: 26rpx;">退款明细</view>
         <view style="width: 93%; border-bottom: 1px #e2e2e2 solid; margin:0px auto;margin-top: 18rpx;"></view>
-
+        <view wx:for="{{orderGoodList}}" wx:for-index="idx" wx:key="idx" wx:for-item="item">
         <view class="list_order_good flex-row">
             <view class="flex-row" style="align-items: flex-start;">
                 <image style="width: 109rpx;height:109rpx" src="/images/groupmeallist/order_good.png"></image>
                 <view style="margin-left: 13rpx;">
-                    <view class="fontSize24">清爽夏日套餐</view>
-                    <view class="fontSize24">x1</view>
+                    <view class="fontSize24">{{item.productName}}</view>
+                    <view class="fontSize24">x{{item.num}}</view>
                 </view>
             </view>
             <view style="margin-right: 45rpx;">
-                <view style="font-size: 32rpx;font-weight: 700;text-align: right;color: #313131;">¥20.0</view>
-                <view style="font-size: 24rpx;font-weight: 400;text-align: right;color: #989898;">共1件</view>
+                <view style="font-size: 32rpx;font-weight: 700;text-align: right;color: #313131;">¥{{item.allFee}}</view>
+                <!-- <view style="font-size: 24rpx;font-weight: 400;text-align: right;color: #989898;">共{{item.num}}件</view> -->
             </view>
         </view>
+
+    </view>
     </view>
 
     <view class="list_order_bottom flex-column">
         <view class="fontSize24" style="color: #989898;    margin-left: 26rpx;margin-top: 33rpx;">退款原因:
-            <span style="font-size: 24rpx;font-weight: 300;text-align: left;color: #000000;">点错了/点多了/点少了</span>
+            <span style="font-size: 24rpx;font-weight: 300;text-align: left;color: #000000;">{{orderInfo.orderRefund.reason}}</span>
         </view>
         <view class="fontSize24" style="color: #989898;    margin-left: 26rpx;">退款编号:
-            <span style="font-size: 24rpx;font-weight: 300;text-align: left;color: #000000;">D4816460408184929451</span>
+            <span style="font-size: 24rpx;font-weight: 300;text-align: left;color: #000000;">{{orderInfo.orderRefund.orderSn}}</span>
         </view>
         <view class="fontSize24" style="color: #989898;    margin-left: 26rpx;margin-bottom: 38rpx;">退款时间:
-            <span style="font-size: 24rpx;font-weight: 300;text-align: left;color: #000000;">2022-05-09 16:40:43</span>
+            <span style="font-size: 24rpx;font-weight: 300;text-align: left;color: #000000;">{{orderInfo.orderRefund.createTime}}</span>
         </view>
     </view>
 
-</view>
+</view>

+ 2 - 2
pages/groupmeallist/myOrder/myOrder.wxss

@@ -1,6 +1,6 @@
 .myOrder {
     width: 709rpx;
-    height: 622rpx;
+    height: 187rpx;
     background: #ffffff;
     border-radius: 25rpx;
     margin: auto;
@@ -45,7 +45,7 @@
 }
 .myOrder_refund_order{
     width: 709rpx;
-    height: 253rpx;
+    /* height: 253rpx; */
     background: #ffffff;
     border-radius: 25rpx;
     margin: auto;

+ 6 - 3
pages/groupmeallist/storeGoods/storeGoods.js

@@ -207,12 +207,15 @@ CustomPage({
   },
 
 
-  loadData() {
-    storeGoods.getExhibit(cache.getStoreId()).then(res => {
+  async loadData() {
+     await storeGoods.getExhibit(cache.getStoreId()).then(res => {
       if (res.code == 200) {
         this.dataMapView(res.data)
       }
-    }).catch(_ => {})
+    }).catch(_ => {
+      
+    })
+
   },
 
 

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

@@ -62,7 +62,7 @@ Page({
             if (res.code == 200) {
               that.getTOrderList()
             }
-          }).catch(_ => {})
+          }).catch(_ => { })
 
         } else if (sm.cancel) {
 
@@ -117,7 +117,7 @@ Page({
   // 申请退款
   goTorefund(e) {
     let sn = e.currentTarget.dataset.sn;
-    
+
 
     wx.navigateTo({
       url: '/pages/groupmeallist/refund/refund?sn=' + sn,
@@ -236,6 +236,14 @@ Page({
    */
   onShow: async function () {
     this.getOrderList();
+
+    // 重置页码
+    this.setData({
+      tpage: 1,
+      tpageSize: 10,
+
+    })
+
     this.getTOrderList();
     let info = await getColor();
     this.setData({
@@ -257,9 +265,21 @@ Page({
     })
 
     let ordersn = e.currentTarget.dataset.sn;
-    wx.navigateTo({
-      url: '/pages/groupmeallist/orderDetail/orderDetail?sn=' + ordersn,
-    })
+    let refund = e.currentTarget.dataset.refund;
+
+    if (refund != null) {
+      wx.navigateTo({
+        url: '/pages/groupmeallist/myOrder/myOrder?sn=' + ordersn,
+      })
+
+
+    } else {
+      wx.navigateTo({
+        url: '/pages/groupmeallist/orderDetail/orderDetail?sn=' + ordersn,
+      })
+
+    }
+
   },
 
   /**

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

@@ -14,7 +14,7 @@
       <swiper-item>
         <scroll-view style="height: 95%;" scroll-y="true" bindscrolltolower="bottomefficientListbyOrder">
           <view>
-            <view class="orderDiv flex-column"  wx:for="{{torderList}}" wx:key="index" data-sn="{{item.orderSn}}" catchtap="orderDetail">
+            <view class="orderDiv flex-column"  wx:for="{{torderList}}" wx:key="index" data-refund="{{item.refundStatus}}" data-sn="{{item.orderSn}}" catchtap="orderDetail">
               <view class="orderDiv_title flex-row">
                 <view class="order_store_name">{{item.store.storeName}}</view>
                 <view class="order_state">{{item.stateText}}</view>

+ 1 - 1
project.config.json

@@ -48,7 +48,7 @@
         "ignoreUploadUnusedFiles": false
     },
     "compileType": "miniprogram",
-    "libVersion": "2.19.2",
+    "libVersion": "2.24.3",
     "appid": "wxcc1cdb8babd3f62c",
     "projectname": "%E9%A3%9E%E7%A0%81",
     "debugOptions": {

+ 42 - 0
project.private.config.json

@@ -702,6 +702,48 @@
                     "name": "",
                     "pathName": "pages/groupmeallist/storeGoods/storeGoods",
                     "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/welfareMall/historical/historical",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/groupmeallist/storeGoods/storeGoods",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/groupmeallist/myOrder/myOrder",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/welfareMall/historical/historical",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/groupmeallist/myOrder/myOrder",
+                    "query": "sn=654499421493156",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/groupmeallist/myOrder/myOrder",
+                    "query": "sn=654499421493156",
                     "scene": null,
                     "launchMode": "default"
                 }