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.
139 lines
3.2 KiB
139 lines
3.2 KiB
// subpages/OCRCard/pages/deposit/deposit.js
|
|
import {
|
|
pay,
|
|
selectMzGraduateInfo
|
|
} from "../../../../api/index"
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
show: false,
|
|
status: 2,
|
|
chooseRoomId: null, //选房记录ID
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.setData({
|
|
chooseRoomId: options.chooseRoomId || app.globalData.userInfo.chooseRoomId
|
|
})
|
|
|
|
},
|
|
goback() {
|
|
wx.switchTab({
|
|
url: '/pages/index/index',
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
},
|
|
toCheckInRecord() {
|
|
wx.navigateTo({
|
|
url: '/subpages/mine/checkInRecord/checkInRecord',
|
|
})
|
|
},
|
|
submit() {
|
|
const that = this;
|
|
pay({
|
|
chooseRoomId: this.data.chooseRoomId
|
|
}).then(res => {
|
|
if (res.data.code === 200) {
|
|
const {
|
|
timeStamp,
|
|
nonceStr,
|
|
paySign,
|
|
packageValue,
|
|
appId,
|
|
payId
|
|
} = res.data
|
|
wx.requestPayment({
|
|
// 必填参数
|
|
timeStamp, // 时间戳,从1970年1月1日00:00:00至今的秒数
|
|
nonceStr, // 随机字符串,32位以内
|
|
package: packageValue, // 统一下单接口返回的 prepay_id 格式如:prepay_id=xxx
|
|
signType: 'RSA', // 签名算法,固定为RSA
|
|
paySign, // 签名,使用微信支付平台证书和商户私钥生成
|
|
// 可选参数
|
|
appId, // 小程序/公众号的appId
|
|
// 回调函数
|
|
success(res) {
|
|
console.log('支付成功', res);
|
|
// 支付成功后的业务逻辑
|
|
that.paySuccess(payId)
|
|
// 可跳转到订单详情页等
|
|
},
|
|
fail(res) {
|
|
that.paySuccess(payId)
|
|
},
|
|
complete(res) {
|
|
that.paySuccess(payId)
|
|
console.log('支付完成', res);
|
|
// 无论成功失败都会执行
|
|
}
|
|
});
|
|
}
|
|
})
|
|
|
|
},
|
|
paySuccess(payId) {
|
|
paySuccess({
|
|
payId
|
|
}).then(res => {
|
|
this.setData({
|
|
show: true,
|
|
status: res.data ? 0 : 1
|
|
})
|
|
})
|
|
}
|
|
})
|