// pages/payMoney/payMoney.js import utils from '../../utils/util' import orderApi from "../../api/order" const app = getApp() Page({ /** * 页面的初始数据 */ data: { show:false }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { console.log(options) const self = this if(!app.globalData.userInfo){ await app.wxLogin({"type":"slince"}) } const url = decodeURIComponent(options.q) console.log(url) const order = utils.getQueryString('https://llzlovesh.top?orderId=412,413') console.log(order) const info = await orderApi.payOrder(order.orderId) self.setData({ info, orderIds:order.orderId, show:true }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, async moneyPay() { const money = this.data.info.money const total = this.data.info.total if (money < total) { wx.showToast({ title: '余额不足支付', }) } let data = { orderIds:this.data.orderIds, type: 'balance' } const rs = await orderApi.createMasterOrder(data) wx.showModal({ title: '提示', content: '支付成功', }).then(()=> { wx.switchTab({ url: '/pages/personorder/personorder', }) }) }, async pay() { let data = { orderIds:this.data.orderIds, type: 'xcx' } const rs = await orderApi.createMasterOrder(data) wx.requestPayment({ timeStamp: rs.timeStamp, nonceStr: rs.nonceStr, package: rs.package, signType: rs.signType, paySign: rs.paySign, success (res) { wx.showModal({ title: '提示', content: '支付成功', }).then(()=> { wx.switchTab({ url: '/pages/personorder/personorder', }) }) }, fail (res) { wx.showToast({ title: '您取消了支付', }) } }) } })