Selaa lähdekoodia

fix: prevent duplicate withdraw transfer confirmation

danyshen 1 päivä sitten
vanhempi
commit
53351f05c6

+ 1 - 1
packageUser/pages/user/cash/cash.wxml

@@ -19,7 +19,7 @@
         <view class="radish-main__time"><format-time type="formatTime" value="{{item.ctime}}" ></format-time></view>
         <view class="clean"></view>
       </view>
-      <view class="radish-main__count">{{item.count / 100}}余额</view>
+      <view class="radish-main__count">{{item.count / 100}}</view>
     </view>
   </view>
   

+ 22 - 1
packageUser/pages/user/cashDetail/cashDetail.js

@@ -2,7 +2,9 @@ var _request = require('../../../../utils/request.js')
 var rid
 Page({
   data: {
-    detail: {}
+    detail: {},
+    confirmingTransfer: false,
+    confirmedTransfer: false
   },
   onLoad: function (options) {
     rid = options.id
@@ -15,6 +17,9 @@ Page({
     }
     var success = function (res) {
       var data = res.data
+      if (that.data.confirmedTransfer) {
+        data.can_confirm_transfer = false
+      }
       that.setData({
         detail: data
       })
@@ -24,6 +29,9 @@ Page({
   confirmMerchantTransfer () {
     var that = this
     var detail = that.data.detail || {}
+    if (that.data.confirmingTransfer) {
+      return
+    }
     if (!detail.can_confirm_transfer || !detail.package_info) {
       wx.showToast({
         title: '当前提现无需确认收款',
@@ -40,6 +48,11 @@ Page({
       })
       return
     }
+    detail.can_confirm_transfer = false
+    that.setData({
+      detail: detail,
+      confirmingTransfer: true
+    })
     wx.requestMerchantTransfer({
       mchId: String(detail.mch_id || ''),
       appId: String(detail.app_id || ''),
@@ -50,9 +63,17 @@ Page({
           icon: 'none',
           duration: 2000
         })
+        that.setData({
+          confirmedTransfer: true
+        })
         that.getRadish()
       },
       fail: function (res) {
+        detail.can_confirm_transfer = true
+        that.setData({
+          detail: detail,
+          confirmingTransfer: false
+        })
         wx.showToast({
           title: (res && res.errMsg) ? res.errMsg : '确认收款失败',
           icon: 'none',

+ 31 - 3
packageUser/pages/user/withdraw/withdraw.js

@@ -11,7 +11,8 @@ Page({
     cashList: [],
     cashList_more: true,
     cashList_change: false,
-    cashTotal: 0
+    cashTotal: 0,
+    confirmedTransferIds: {}
   },
   /**
    * 生命周期函数--监听页面加载
@@ -67,7 +68,14 @@ Page({
           cashList_change: false
         })
       }
-      var result = that.data.cashList.concat(res.data.list || [])
+      var confirmedTransferIds = that.data.confirmedTransferIds || {}
+      var list = res.data.list || []
+      list.forEach(function (item) {
+        if (confirmedTransferIds[item.id]) {
+          item.can_confirm_transfer = false
+        }
+      })
+      var result = that.data.cashList.concat(list)
       var listMore = res.data.list_count > result.length
       that.setData({
         cashList: result,
@@ -80,6 +88,9 @@ Page({
     var that = this
     var index = e.currentTarget.dataset.index
     var item = that.data.cashList[index] || {}
+    if (item.confirming_transfer) {
+      return
+    }
     if (!item.can_confirm_transfer || !item.package_info) {
       wx.showToast({
         title: '当前提现无需确认收款',
@@ -96,6 +107,12 @@ Page({
       })
       return
     }
+    var cashList = that.data.cashList
+    cashList[index].can_confirm_transfer = false
+    cashList[index].confirming_transfer = true
+    that.setData({
+      cashList: cashList
+    })
     wx.requestMerchantTransfer({
       mchId: String(item.mch_id || ''),
       appId: String(item.app_id || ''),
@@ -106,14 +123,25 @@ Page({
           icon: 'none',
           duration: 2000
         })
+        var confirmedTransferIds = that.data.confirmedTransferIds || {}
+        confirmedTransferIds[item.id] = true
         that.setData({
           page: 1,
           cashList_more: true,
-          cashList_change: true
+          cashList_change: true,
+          confirmedTransferIds: confirmedTransferIds
         })
         that.getCashList()
       },
       fail: function (res) {
+        var cashList = that.data.cashList
+        if (cashList[index]) {
+          cashList[index].can_confirm_transfer = true
+          cashList[index].confirming_transfer = false
+          that.setData({
+            cashList: cashList
+          })
+        }
         wx.showToast({
           title: (res && res.errMsg) ? res.errMsg : '确认收款失败',
           icon: 'none',