123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- // 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: '您取消了支付',
- })
- }
- })
- }
- })
|