Kaynağa Gözat

fix: refresh balance records after recharge

root 1 gün önce
ebeveyn
işleme
87cd3f28a9

+ 4 - 0
packageUser/pages/user/cash/cash.js

@@ -23,6 +23,10 @@ Page({
 	// this.getCashTotal()
   },
   onShow () {
+    if (getApp().globalData.rechargeChanged) {
+      getApp().globalData.rechargeChanged = false
+      this.refreshBalancePage()
+    }
   },
   onReachBottom: function () {
     if (this.data.more) {

+ 17 - 0
packageUser/pages/user/fund/fund.js

@@ -48,10 +48,27 @@ Page({
     }
   },
   onShow () {
+    if (getApp().globalData.rechargeChanged) {
+      getApp().globalData.rechargeChanged = false
+      this.refreshCashPage()
+      this.checkCertified()
+      this.getWithDrawlimit()
+      return
+    }
     this.getCashTotal()
     this.checkCertified()
     this.getWithDrawlimit()
   },
+  refreshCashPage () {
+    this.setData({
+      page: 1,
+      cashList: [],
+      cashList_more: true,
+      cashList_change: false
+    })
+    this.getCashTotal()
+    this.getCashList()
+  },
   getCashTotal () {
     var that = this
     var url = 'v1/user/cash/balance/info'

+ 18 - 0
packageUser/pages/user/recharge/recharge.js

@@ -134,6 +134,7 @@ Page({
     var url = 'v1/virtual_pay/recharge/status'
     var success = function (res) {
       if (res.data && res.data.state === 1) {
+        getApp().globalData.rechargeChanged = true
         that.getCashTotal()
         wx.showToast({
           title: '充值成功',
@@ -171,6 +172,7 @@ Page({
     that.setData({
       lock: false
     })
+    that.refreshPreviousPage()
     console.log('that.data.source', that.data.source)
     if (that.data.source) {
       wx.navigateBack()
@@ -179,6 +181,22 @@ Page({
       wx.navigateBack()
     }
   },
+  refreshPreviousPage () {
+    var pages = getCurrentPages()
+    var delta = this.data.source ? 2 : 1
+    var prevPage = pages[pages.length - 1 - delta]
+    if (!prevPage) {
+      return
+    }
+    if (prevPage.refreshBalancePage) {
+      prevPage.refreshBalancePage()
+    } else if (prevPage.refreshCashPage) {
+      prevPage.refreshCashPage()
+    } else if (prevPage.getCashTotal && prevPage.getCashList) {
+      prevPage.getCashTotal()
+      prevPage.getCashList()
+    }
+  },
   onShareAppMessage: function (val) {
     return _request.share({
       sc: 'xcx_user_recharge'

+ 15 - 1
packageUser/pages/user/transfer/transferList/transferList.js

@@ -21,6 +21,10 @@ Page({
     this.getCashList()
   },
   onShow () {
+    if (getApp().globalData.rechargeChanged) {
+      getApp().globalData.rechargeChanged = false
+      this.refreshCashPage()
+    }
   },
   onPullDownRefresh: function () {
     this.setData({
@@ -52,6 +56,16 @@ Page({
     }
     _request.$get(url, params, success)
   },
+  refreshCashPage () {
+    this.setData({
+      page: 1,
+      cashList: [],
+      cashList_more: true,
+      cashList_change: false
+    })
+    this.getCashTotal()
+    this.getCashList()
+  },
   getCashList () {
     console.log(this.data.page)
     var that = this
@@ -81,4 +95,4 @@ Page({
       sc: 'xcx_user_withdraw'
     })
   }
-})
+})