const app = getApp() const httpUtils = require('../../utils/http.js') const ui = require('../../utils/ui.js') Page({ data: { tab: 1, money: 100 }, deviceid: '', onLoad(options) { this.deviceid = options.deviceid }, changeTab(e){ console.log(e) this.setData({ tab: e.target.dataset.info }) if(e.target.dataset.info == 1){ this.setData({ money: 100 }) }else if(e.target.dataset.info == 2){ this.setData({ money: 200 }) }else if(e.target.dataset.info == 3){ this.setData({ money: 500 }) } }, toRecharge(){ let obj = { url: '/api/erp/we/wePhoneCharge', data: { deviceId: this.deviceid, deposit: 100, token: wx.getStorageSync('token'), } } httpUtils.request(obj).then(res=>{ console.log("pay",res) let payInfo = res.data.data // 调取后端接口后微信下单 wx.requestPayment({ timeStamp: payInfo.timeStamp, nonceStr: payInfo.nonceStr, package: payInfo.package, signType: payInfo.signType, paySign: payInfo.paySign, success (res1) { console.log("支付",res1) }, fail (res1) { } }) }).catch(err=>{ console.log('ERROR') }); } })