You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
68 lines
1.7 KiB
// pages/bank/index/index.js
|
|
import { getBankCardList, deleteBankcard } from "../../../api/payment"
|
|
import { $wuxDialog } from '../../../components/index'
|
|
const util = require('../../../utils/util')
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
isSetPwd: 0,
|
|
nowIndex: -1,
|
|
bankList: []
|
|
},
|
|
onShow: function () {
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
getBankCardList().then(result => {
|
|
this.setData({ bankList: result.data })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
showActionSheet(e) {
|
|
this.data.nowIndex = e.currentTarget.dataset.index
|
|
if (this.data.nowIndex < 0) {
|
|
wx.navigateTo({ url: '/pages/withdrawal/bank-create/index' })
|
|
return
|
|
}
|
|
var that = this
|
|
wx.showActionSheet({
|
|
itemList: ['解除绑定'],
|
|
success(res){
|
|
if (res.tapIndex === 0){
|
|
$wuxDialog().open({
|
|
resetOnClose: true,
|
|
title: '温馨提示',
|
|
content: '确定解除绑定该银行卡?',
|
|
buttons: [{
|
|
text: '取消'
|
|
}, {
|
|
text: '确定',
|
|
type: 'primary',
|
|
onTap(e) {
|
|
that.unbindCard()
|
|
}
|
|
}]
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
unbindCard: function () {
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
var item = this.data.bankList[this.data.nowIndex]
|
|
deleteBankcard(item.id).then(res => {
|
|
wx.hideLoading()
|
|
util.showToast('解除成功')
|
|
this.data.bankList.splice(this.data.nowIndex, 1);
|
|
this.setData({ bankList: this.data.bankList })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
|
|
})
|