// pages/pay/pay.ts import { cleanPhoneDate } from "../../apis/phone"; import { sysConfig } from "../../apis/config"; import { bindPhoneList } from "../../apis/consumer"; Page({ /** * 页面的初始数据 */ data: { phone: '' }, goPay() { let userInfo = wx.getStorageSync('userInfo'); return new Promise((resolve, reject) => { cleanPhoneDate(this.data.phone).then((res: any) => { wx.requestPayment({ ...res.d, success: (res: any) => { resolve(res) bindPhoneList().then((resp: any) => { wx.showToast({ icon: 'none', title: '支付完成' }) wx.setStorageSync('userInfo', resp.d.find((consumer: any) => consumer.id === userInfo.id)) }) // userInfo.evaluatedTimes = 0 // wx.setStorageSync('userInfo', userInfo) wx.navigateBack({ delta: 1 }) }, fail: (err: any) => { wx.showToast({ icon: 'none', title: '支付失败, 请稍后再试!' }) reject(err) } }) }) }) }, goMy() { wx.redirectTo({ url: '/pages/my/my' }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options); this.setData({ // phone: options.phone result: options.result }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { // this.goPay() }, /** * 生命周期函数--监听页面显示 */ onShow() { sysConfig().then(res => { this.setData({ money: res.d.refreshAmount / 100 }) }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })