|
@@ -1,7 +1,6 @@
|
|
|
var _request = require('../../../../utils/request.js')
|
|
var _request = require('../../../../utils/request.js')
|
|
|
var util = require('../../../../utils/util.js')
|
|
var util = require('../../../../utils/util.js')
|
|
|
var MAX_MERCHANT_TRANSFER_CASH = 20000
|
|
var MAX_MERCHANT_TRANSFER_CASH = 20000
|
|
|
-var TAKE_CASH_SUBSCRIBE_TEMPLATE_ID = "L073dR84XibBZNxfvTkvTIemd7JAbj5o2Og7-VBAiX8"
|
|
|
|
|
var PENDING_VIRTUAL_RECHARGE_ORDER_KEY = 'pendingVirtualRechargeOrderId'
|
|
var PENDING_VIRTUAL_RECHARGE_ORDER_KEY = 'pendingVirtualRechargeOrderId'
|
|
|
Page({
|
|
Page({
|
|
|
data: {
|
|
data: {
|
|
@@ -17,7 +16,12 @@ Page({
|
|
|
withdraw_num:0,
|
|
withdraw_num:0,
|
|
|
view_withdraw:0,
|
|
view_withdraw:0,
|
|
|
view_fee:0,
|
|
view_fee:0,
|
|
|
- syncingPendingRecharge:false
|
|
|
|
|
|
|
+ syncingPendingRecharge:false,
|
|
|
|
|
+ submittingTakeCash:false,
|
|
|
|
|
+ transferConfirmDialog:false,
|
|
|
|
|
+ pendingTakeCash:null,
|
|
|
|
|
+ transferConfirming:false,
|
|
|
|
|
+ transferCanceling:false
|
|
|
},
|
|
},
|
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
|
this.getBalanceInfo()
|
|
this.getBalanceInfo()
|
|
@@ -165,9 +169,7 @@ Page({
|
|
|
},
|
|
},
|
|
|
getBankInfoAndTip(){
|
|
getBankInfoAndTip(){
|
|
|
var that = this
|
|
var that = this
|
|
|
- that.requestTakeCashSubscribe(function () {
|
|
|
|
|
- that.showWithdrawConfirm()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ that.showWithdrawConfirm()
|
|
|
},
|
|
},
|
|
|
showWithdrawConfirm () {
|
|
showWithdrawConfirm () {
|
|
|
var that = this
|
|
var that = this
|
|
@@ -199,9 +201,7 @@ Page({
|
|
|
var that = this
|
|
var that = this
|
|
|
console.log('that.data.has_bank',that.data.has_bank)
|
|
console.log('that.data.has_bank',that.data.has_bank)
|
|
|
// if (that.data.has_bank) {
|
|
// if (that.data.has_bank) {
|
|
|
- that.requestTakeCashSubscribe(function () {
|
|
|
|
|
- that.withdrawClick()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ that.withdrawClick()
|
|
|
// } else {
|
|
// } else {
|
|
|
// that.setData({
|
|
// that.setData({
|
|
|
// confirmDialog: false,
|
|
// confirmDialog: false,
|
|
@@ -209,24 +209,6 @@ Page({
|
|
|
// })
|
|
// })
|
|
|
// }
|
|
// }
|
|
|
},
|
|
},
|
|
|
- requestTakeCashSubscribe (done) {
|
|
|
|
|
- if (!wx.requestSubscribeMessage) {
|
|
|
|
|
- done && done()
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- wx.requestSubscribeMessage({
|
|
|
|
|
- tmplIds: [TAKE_CASH_SUBSCRIBE_TEMPLATE_ID],
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- console.log("take cash subscribe message", res)
|
|
|
|
|
- },
|
|
|
|
|
- fail: function (res) {
|
|
|
|
|
- console.log("take cash subscribe message fail", res)
|
|
|
|
|
- },
|
|
|
|
|
- complete: function () {
|
|
|
|
|
- done && done()
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
closedDialog () {
|
|
closedDialog () {
|
|
|
var that = this
|
|
var that = this
|
|
|
that.setData({
|
|
that.setData({
|
|
@@ -235,29 +217,149 @@ Page({
|
|
|
},
|
|
},
|
|
|
withdrawClick () {
|
|
withdrawClick () {
|
|
|
var that = this
|
|
var that = this
|
|
|
|
|
+ if (that.data.submittingTakeCash) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
var url = 'v1/user/takecash'
|
|
var url = 'v1/user/takecash'
|
|
|
var params = {
|
|
var params = {
|
|
|
amount: that.data.withdraw_num
|
|
amount: that.data.withdraw_num
|
|
|
}
|
|
}
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ submittingTakeCash: true
|
|
|
|
|
+ })
|
|
|
var success = function (res) {
|
|
var success = function (res) {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ submittingTakeCash: false
|
|
|
|
|
+ })
|
|
|
if (res.data) {
|
|
if (res.data) {
|
|
|
that.setData({
|
|
that.setData({
|
|
|
confirmDialog: false
|
|
confirmDialog: false
|
|
|
})
|
|
})
|
|
|
- // that.data.lockWithdraw = false
|
|
|
|
|
|
|
+ if (res.data.can_confirm_transfer && res.data.package_info) {
|
|
|
|
|
+ that.showTakeCashTransferConfirm(res.data)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ that.finishTakeCashTransfer('提现成功~')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ var fail = function () {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ submittingTakeCash: false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ _request.$post(url, params, success, fail)
|
|
|
|
|
+ },
|
|
|
|
|
+ showTakeCashTransferConfirm (order) {
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ pendingTakeCash: order,
|
|
|
|
|
+ transferConfirmDialog: true,
|
|
|
|
|
+ transferConfirming: false,
|
|
|
|
|
+ transferCanceling: false
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ confirmTakeCashTransfer () {
|
|
|
|
|
+ var that = this
|
|
|
|
|
+ var order = that.data.pendingTakeCash || {}
|
|
|
|
|
+ if (that.data.transferConfirming) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!order.package_info) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '提现确认信息缺失,请稍后重试',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!wx.canIUse || !wx.canIUse('requestMerchantTransfer')) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '当前微信版本不支持确认收款,请升级微信',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ transferConfirming: true
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.requestMerchantTransfer({
|
|
|
|
|
+ mchId: String(order.mch_id || ''),
|
|
|
|
|
+ appId: String(order.app_id || ''),
|
|
|
|
|
+ package: order.package_info,
|
|
|
|
|
+ success: function () {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ transferConfirmDialog: false,
|
|
|
|
|
+ pendingTakeCash: null,
|
|
|
|
|
+ transferConfirming: false
|
|
|
|
|
+ })
|
|
|
|
|
+ that.finishTakeCashTransfer('确认收款已提交')
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: function (res) {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ transferConfirming: false
|
|
|
|
|
+ })
|
|
|
|
|
+ var errMsg = (res && res.errMsg) ? res.errMsg : ''
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: '提现成功~',
|
|
|
|
|
|
|
+ title: errMsg.indexOf('cancel') >= 0 ? '用户取消确认,可继续确认或取消提现' : '确认收款失败,请稍后重试',
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
|
- duration: 2000
|
|
|
|
|
- })
|
|
|
|
|
- getApp().globalData.withdrawChanged = true
|
|
|
|
|
- that.refreshBalancePage()
|
|
|
|
|
- that.getCashTotal()
|
|
|
|
|
- wx.navigateTo({
|
|
|
|
|
- url: '/packageUser/pages/user/withdraw/withdraw'
|
|
|
|
|
|
|
+ duration: 3000
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ cancelTakeCashTransfer () {
|
|
|
|
|
+ var that = this
|
|
|
|
|
+ var order = that.data.pendingTakeCash || {}
|
|
|
|
|
+ if (that.data.transferCanceling) {
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
- _request.$post(url, params, success)
|
|
|
|
|
|
|
+ if (!order.order_id && !order.id) {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ transferConfirmDialog: false,
|
|
|
|
|
+ pendingTakeCash: null
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ transferCanceling: true
|
|
|
|
|
+ })
|
|
|
|
|
+ var params = {
|
|
|
|
|
+ order_id: order.order_id || '',
|
|
|
|
|
+ id: order.id || ''
|
|
|
|
|
+ }
|
|
|
|
|
+ var success = function () {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ transferConfirmDialog: false,
|
|
|
|
|
+ pendingTakeCash: null,
|
|
|
|
|
+ transferCanceling: false
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '已取消提现',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ getApp().globalData.withdrawChanged = true
|
|
|
|
|
+ that.refreshBalancePage()
|
|
|
|
|
+ that.getCashTotal()
|
|
|
|
|
+ }
|
|
|
|
|
+ var fail = function () {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ transferCanceling: false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ _request.$post('v1/user/takecash/cancel', params, success, fail)
|
|
|
|
|
+ },
|
|
|
|
|
+ finishTakeCashTransfer (title) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: title || '提现成功~',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ getApp().globalData.withdrawChanged = true
|
|
|
|
|
+ this.refreshBalancePage()
|
|
|
|
|
+ this.getCashTotal()
|
|
|
|
|
+ wx.navigateTo({
|
|
|
|
|
+ url: '/packageUser/pages/user/withdraw/withdraw'
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|