var util = require('../../../utils/util.js'); var api = require('../../../config/api.js'); var app = getApp(); Page({ data: { imgUrl: '', type: '', status: false, orderId: 0, payAmount: '', appointShow: false }, onLoad: function (options) { // 页面初始化 options为页面跳转所带来的参数 this.setData({ orderId: options.orderId, payAmount: options.actualPrice, type: app.globalData.infoGoods.type, // status: options.status === '1' ? true : false, imgUrl: app.globalData.infoGoods.type == '2' ? 'https://jzmall.lifejingzhi.com/file/jzmall/weixin/new/icon-jpjzs.png' : app.globalData.infoGoods.picUrl }); var appType = wx.getStorageSync('appType'); if (appType == 0 && (this.data.type == 0||this.data.type == 3)) { this.setData({ appointShow: true }); } }, goIndex() { wx.switchTab({ url: '/pages/index/index', }) }, goOrder() { wx.redirectTo({ url: '/pages/ucenter/order/order', }) }, onReady: function () { }, onShow: function () { // 页面显示 }, onHide: function () { // 页面隐藏 }, onUnload: function () { // 页面关闭 }, payOrder() { let that = this; util.request(api.OrderPrepay, { orderId: that.data.orderId }, 'POST').then(function (res) { if (res.errno === 0) { const payParam = res.data; console.log("支付过程开始") wx.requestPayment({ 'timeStamp': payParam.timeStamp, 'nonceStr': payParam.nonceStr, 'package': payParam.packageValue, 'signType': payParam.signType, 'paySign': payParam.paySign, 'success': function (res) { console.log("支付过程成功") that.setData({ status: true }); }, 'fail': function (res) { console.log("支付过程失败") util.showErrorToast('支付失败'); }, 'complete': function (res) { console.log("支付过程结束") } }); } }); }, onClickHide() { this.setData({ appointShow: false }); }, appointClick() { // this.setData({ // appointShow:false // }); }, goAppoint() { this.setData({ appointShow: false }); wx.navigateTo({ url: '/pages/ucenter/serviceDetail/serviceDetail?orderId=' + this.data.orderId }) // wx.navigateTo({ // url: '/pages/checkout/appointResult/appointResult?id='+this.data.orderId, // }) } })