// pages/exchange/exchange.js import { documentList } from "../../api/document" import { userEntityRecharge } from '../../api/charge' import { appGetConfigImg } from '../../api/index' const app = getApp() Page({ /** * 页面的初始数据 */ data: { cardNo: '', cardSecret: '', imgUrl: '', overlayShow: false, chargestatus: 0, chargetext: '' }, onShow () { this.appGetConfigImgFn() }, appGetConfigImgFn () { const that = this wx.showNavigationBarLoading() appGetConfigImg({ 'imgType': '4' }).then(configRes => { wx.hideNavigationBarLoading() console.log(configRes, 'configRes') that.setData({ imgUrl: configRes.data[0].imgUrl }) }) }, /** * 确认提交充值 */ handleComfirm() { var cardNo = this.data.cardNo var cardSecret = this.data.cardSecret var that = this console.log(cardNo, cardSecret); if (cardNo == '') { wx.showToast({ title: '请输入卡号', icon: 'error' }) return } else if (cardSecret == '') { wx.showToast({ title: '请输入卡密', icon: 'error' }) return } else { var data = { // CARD202010221647 GBISYX cardNo: cardNo, cardSecret: cardSecret } wx.showLoading({ title: '充值中...', mask: true }) userEntityRecharge(data).then(res => { wx.hideLoading() that.setData({ overlayShow: true, chargestatus: 0, chargetext: res.msg }) }).catch(e => { console.log('é',e) wx.hideLoading() that.setData({ chargestatus: 1, chargetext: e, overlayShow: true }) }) } }, bindCardNo(e) { this.setData({ cardNo: e.detail.value }) }, bindCardPwd(e) { this.setData({ cardSecret: e.detail.value }) }, /** * 生命周期函数--监听页面卸载 */ handleCancle() { wx.navigateBack() }, /** * 页面相关事件处理函数--监听用户下拉动作 */ reInput() { this.setData({ overlayShow: false }) }, // 立即预约 handleAppointment () { this.setData({ overlayShow: false }) if (app.globalData.hasAppointment) { wx.showModal({ content: '您预约的健康筛查还未体验,请先体验', cancelColor: '#666', cancelText: '取消', confirmText: '我的预约', confirmColor: '#333', success (res) { if (res.confirm) { wx.navigateTo({ url: '/pages/myAppointment/myAppointment', }) } } }) } else { this.getDocumentList() } }, // 获取用户档案信息 getDocumentList () { var that = this wx.showLoading({ title: '加载中...', mask: true }) documentList({ currentPage: 1 }).then(res => { wx.hideLoading() const response = res.data.vos || [] if (response.length == 0) { wx.showModal({ content: '预约用户前需要先添加检测人员信息', cancelColor: '#666', confirmColor: '#333', success (res) { if (res.confirm) { wx.navigateTo({ url: '/pages/createFile/createFile?from=index' }) } } }) } else { wx.navigateTo({ url: '/pages/appointment/appointment' }) } }).catch(e => { wx.hideLoading() wx.showModal({ content: e, confirmColor: '#333', showCancel: false }) }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })