纸通宝SAAS仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

76 lines
2.0 KiB

// pages/ztbvip/payment/index.js
import Scene from '../../index/scene'
const util = require('../../../utils/util.js')
const event = require('../../../utils/event.js')
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
requesting: false,
paymodel: {
channelId: '478256441266933760'
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.orderId) {
this.data.paymodel.tradeOrderId = options.orderId
// this.data.payType = Number(options.type)
// if (options.url) {
// this.data.backUrl = options.url
// }
// if (options.status) {
// this.data.status = options.status
// }
wx.showLoading({ title: '加载中', mask: true })
getTradeOrder(options.orderId).then(result => {
this.setData({ payment: result.data.amount, payText: result.data.comment })
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
} else {
util.showBackToast('数据错误,无法支付')
}
},
submitForm: function () {
if (this.data.requesting) {
return
}
wx.showLoading({ title: '加载中', mask: true })
this.data.requesting = true
paymentFor(this.data.paymodel).then(result => {
wx.hideLoading()
this.requestPayment(result.data.extra)
}).catch(err => {
wx.hideLoading()
this.data.requesting = false
util.showToast(err)
})
},
// 微信支付流程
requestPayment: function (data) {
var that = this
data.success = function (res) {
util.showBackToast('支付成功')
event.emit('EventMessage', { what: 200, desc: 'Vip' })
// wx.requestSubscribeMessage({
// tmplIds: app.tmplIds,
// complete(res) {
// that.handlePayment()
// }
// })
}
data.fail = function (res) {
util.showToast('支付失败')
that.data.requesting = false
}
wx.requestPayment(data)
}
})