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.
73 lines
2.1 KiB
73 lines
2.1 KiB
// pages/client/bank-list/index.js
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { getBankCardList, deleteBankcard } from "../../../api/payment"
|
|
const util = require('../../../utils/util')
|
|
const event = require('../../../utils/event')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
show: false,
|
|
actions: [
|
|
{ id: 1, name: '设为默认' },
|
|
{ id: 2, name: '解除绑定' }
|
|
],
|
|
nowIndex: -1,
|
|
bankList: []
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
getBankCardList().then(result => {
|
|
this.setData({ bankList: result.data, height: app.globalData.fragmentHeight })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
this.setData({ height: app.globalData.fragmentHeight })
|
|
util.showToast(err)
|
|
console.log(err)
|
|
})
|
|
},
|
|
showActionSheet(e) {
|
|
this.data.nowIndex = e.currentTarget.dataset.index
|
|
if (this.data.nowIndex < 0) {
|
|
// if(!app.userInfo.isAuth){
|
|
// Dialog.alert({ title: '温馨提示', message: '您还没有进行个人信息认证,无法绑定银行卡,现在去进行个人信息认证?' }).then(() => {
|
|
// wx.navigateTo({ url: '/pages/home/authory/index' })
|
|
// })
|
|
// return
|
|
// }
|
|
wx.navigateTo({url: '/pages/client/bank-add/index'})
|
|
return
|
|
}
|
|
this.setData({ show: true })
|
|
},
|
|
onClose: function() {
|
|
this.setData({ show: false })
|
|
},
|
|
onSelect: function({detail}) {
|
|
if(detail.id == 2){
|
|
Dialog.alert({ title: '温馨提示', message: '确定解除绑定该银行卡?' }).then(() => {
|
|
this.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)
|
|
})
|
|
}
|
|
})
|