瀏覽代碼

订单详情申请退款

kk.shi 3 年之前
父節點
當前提交
95c798aa02
共有 3 個文件被更改,包括 95 次插入1 次删除
  1. 14 0
      api/welfareMall.js
  2. 77 0
      pages/welfareMall/order/orderCompletion.js
  3. 4 1
      pages/welfareMall/order/orderCompletion.wxml

+ 14 - 0
api/welfareMall.js

@@ -37,6 +37,20 @@ class WelfareMall extends request {
     return this.postRequest(`${this.BASE_URL}open/welfare-mall/activity/get-pay-params`, params);
   }
 
+   /**
+   * 获取订单的退款单信息
+   */
+  static getRefundOrderList(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/get-refund-order-list`, params);
+  }
+
+  /**
+   * 获取订单的退款单状态
+   */
+  static getRefundOrderStatus(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/get-refund-order-status`, params);
+  }
+
 }
 
 export default WelfareMall

+ 77 - 0
pages/welfareMall/order/orderCompletion.js

@@ -16,6 +16,9 @@ Page({
     isLogin: false,
     orderDetail: null,
     orderSn: '',
+    hidden: true,
+    reason: '',
+    inputValue: null,
   },
 
   /**
@@ -144,6 +147,80 @@ Page({
   },
 
   /**
+   * 取消
+   */
+  getMode: function(){
+    this.setData({
+         hidden: false,
+         inputValue: '',
+    });
+},
+
+  /**
+   * 取消
+   */
+  cancel: function(){
+        this.setData({
+             hidden: true,
+        });
+    },
+    /**
+     * 提交
+     */
+    confirm: function(){
+      this.setData({
+        hidden: false
+      });
+      var res = this.data.reason;
+      console.log(res);
+      if(res == null || res =='' || res == undefined){
+        wx.showToast({
+          title: '退款原因必填',
+          icon: 'none',
+          duration: 1500
+        })
+      } else {
+        this.goRefund(res);
+      }
+    },
+
+    /**
+     * 退款原因
+     */
+    getReason: function(e){
+      this.setData({
+        reason: e.detail.value
+      })
+    },
+
+  /**
+   * 
+   * 申请退款
+   */ 
+  goRefund: function(reason) {
+    WelfareMall.orderRefund({
+      mobile: getMobileCache(),
+      orderSn: this.data.orderSn,
+      reason: reason,
+    }).then(res => {
+        if (res.code == 200) {
+          this.cancel();
+          this.onLoad(this.options);
+          const url = "../refund/refund?orderSn=" + this.data.orderSn
+          wx.navigateTo({
+              url
+          })
+        }
+        this.data.lock = false
+    }).catch(_ => {
+        console.log(_)
+        this.cancel();
+        this.data.lock = false
+    })
+    
+  },
+
+  /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {

+ 4 - 1
pages/welfareMall/order/orderCompletion.wxml

@@ -56,9 +56,12 @@
       <view class="order-refund flex-row" wx:if="{{orderDetail.status.value == 1}}" catchtap="goPay">
         <view class="lower-order-text">去支付</view>
       </view>
-      <view class="order-refund flex-row" wx:if="{{orderDetail.status.value == 2 || orderDetail.status.value == 5}}">
+      <view class="order-refund flex-row" wx:if="{{orderDetail.status.value == 2 || orderDetail.status.value == 5}}" catchtap="getMode">
         <view class="lower-order-text">申请退款</view>
       </view>
     </view>
+    <modal hidden="{{hidden}}" title="退款原因" confirm-text="提交" cancel-text="取消" bindcancel="cancel" bindconfirm="confirm" >
+      <input bindinput="getReason" type="text" placeholder="请输入退款原因" value="{{inputValue}}"/>
+    </modal>
   </view>
 </view>