| | |
| | | // pages/rechargeCard/rechargeCard.js |
| | | //虚拟卡列表 |
| | | const { |
| | | get, |
| | | post |
| | |
| | | content: '确认' |
| | | }, |
| | | currentTab: 0, // 当前显示的表格,默认为第一个表格 |
| | | allCardPoints: [{ |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 0, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }], |
| | | allCardPoints: [], |
| | | allWaterPoints: [{ |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | },{ |
| | | }, { |
| | | "id": "string", |
| | | "inUse": 1, |
| | | "inUseName": "string", |
| | | "money": 110, |
| | | "vcNum": "200030000000" |
| | | }], |
| | | showDialog: false |
| | | showDialog: false, |
| | | isWXRefreshing: false |
| | | }, |
| | | // 切换 Tabs |
| | | switchTab: function (e) { |
| | |
| | | */ |
| | | onLoad(options) { |
| | | this.getCardList(); |
| | | this.getWaterCardList(); |
| | | // this.getWaterCardList(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | this.setData({ |
| | | isWXRefreshing: true |
| | | }) |
| | | this.getCardList(); |
| | | }, |
| | | |
| | | /** |
| | |
| | | } |
| | | }) |
| | | .then((data) => { |
| | | this.setData({ |
| | | isWXRefreshing: false |
| | | }); |
| | | if (data.success && data.code === "0001") { |
| | | this.setData({ |
| | | allCardPoints: data.content |
| | | }); |
| | | this.updateDisplayText(); |
| | | } else { |
| | | wx.showToast({ |
| | | title: data.msg, |
| | |
| | | console.log('Failed to add item:'); |
| | | }) |
| | | .catch((error) => { |
| | | this.setData({ |
| | | isWXRefreshing: false |
| | | }); |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | |
| | | console.error('Failed to add item:', error); |
| | | }); |
| | | }, |
| | | rechargeCard(item) { |
| | | rechargeCard(event) { |
| | | wx.navigateTo({ |
| | | url: '/pages/rechargeMoney/rechargMoney' // 首页的路径,根据实际情况填写 |
| | | url: '/pages/rechargeMoney/rechargMoney?vcId='+event.currentTarget.dataset.item.id // 首页的路径,根据实际情况填写 |
| | | }); |
| | | }, |
| | | ruinCard() { |
| | | this.setData({ |
| | | showDialog: true |
| | | }) |
| | | ruinCard(item) { |
| | | const mItem = item.currentTarget.dataset.item; |
| | | |
| | | if (mItem.money > 0) { |
| | | //金额大于0不能销卡 |
| | | this.setData({ |
| | | showDialog: true |
| | | }) |
| | | } else { |
| | | //金额等于0才可销卡 |
| | | this.deleteID(mItem.id); |
| | | } |
| | | }, |
| | | closeDialog() { |
| | | this.setData({ |
| | | showDialog: false |
| | | }) |
| | | } |
| | | }, |
| | | //添加虚拟卡 |
| | | handleClick() { |
| | | wx.showLoading({ |
| | | title: '正在添加请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | clientId: getApp().globalData.clientId, //临时登录凭证 |
| | | }; |
| | | post({ |
| | | url: "wx/virtual_card/add_vc", |
| | | data: data, |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | if (response.code === "0001") { |
| | | wx.showToast({ |
| | | title: '添加成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | }) |
| | | this.getCardList(); |
| | | } |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | wx.showToast({ |
| | | title: '添加失败', |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }) |
| | | }); |
| | | }, |
| | | //注销虚拟卡 |
| | | deleteID(vcId) { |
| | | wx.showLoading({ |
| | | title: '正在销卡请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | clientId: getApp().globalData.clientId, //临时登录凭证 |
| | | vcId: vcId //虚拟卡id |
| | | }; |
| | | post({ |
| | | url: "wx/virtual_card/cancel", |
| | | data: data, |
| | | }).then(response => { |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | if (response.code === "0001") { |
| | | wx.showToast({ |
| | | title: '销卡成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | }) |
| | | this.getCardList(); |
| | | } |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | wx.showToast({ |
| | | title: '注销失败', |
| | | icon: 'error', |
| | | duration: 2000 |
| | | }) |
| | | }); |
| | | }, |
| | | |
| | | |
| | | |
| | | |
| | | }) |