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.
82 lines
2.4 KiB
82 lines
2.4 KiB
// pages/message/detail/index.js
|
|
import Scene from '../../index/scene'
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { getBankCardList, deleteBankcard } from "../../../api/saas"
|
|
const util = require('../../../utils/util')
|
|
const event = require('../../../utils/event')
|
|
const app = getApp()
|
|
|
|
Scene({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
height: app.globalData.fragmentHeight,
|
|
nowIndex: -1,
|
|
bankList: [],
|
|
show: false,
|
|
actions: [
|
|
// { id: 1, name: '设置为默认银行卡' },
|
|
{ id: 2, name: '删除银行卡' }
|
|
]
|
|
},
|
|
onLoad: function () {
|
|
event.on('EventMessage', this, this.onEvent)
|
|
this.fetchCardList()
|
|
},
|
|
onEvent: function(message){
|
|
if (message.what == 201) {
|
|
this.fetchCardList()
|
|
}
|
|
},
|
|
fetchCardList: function(){
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
getBankCardList().then(result => {
|
|
this.setData({ height: app.globalData.fragmentHeight, bankList: result.data })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
this.setData({ height: app.globalData.fragmentHeight })
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
showActionSheet: function(e){
|
|
this.data.nowIndex = e.currentTarget.dataset.index
|
|
if (this.data.nowIndex < 0) {
|
|
wx.navigateTo({ url: '/pages/settlement/bank-add/index' })
|
|
return
|
|
}
|
|
var item = this.data.bankList[this.data.nowIndex]
|
|
if(item.isDefault == 1){
|
|
this.setData({ show: true, ['actions[0].disabled']: false })
|
|
} else {
|
|
this.setData({ show: true, ['actions[0].disabled']: false })
|
|
}
|
|
},
|
|
onSelect: function({detail}) {
|
|
// this.setData({ show: false})
|
|
if(detail.id == 1){
|
|
|
|
} else if(detail.id == 2){
|
|
Dialog.confirm({ title: '温馨提示', message: '确定删除该银行卡?' }).then(() => {
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
var item = this.data.bankList[this.data.nowIndex]
|
|
deleteBankcard({id: 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)
|
|
})
|
|
})
|
|
}
|
|
},
|
|
onClose: function(){
|
|
this.setData({ show: false})
|
|
},
|
|
onUnload: function(){
|
|
event.remove('EventMessage', this)
|
|
}
|
|
})
|