const app = getApp() const util = require("../../utils/util"); const api = require('../../config/api.js'); Page({ data: { difNo:'', orderDiff:{}, diffItemList:[], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options); if(options.difNo){ this.setData({ difNo:options.difNo }); } if(options.scene){ let scene = decodeURIComponent(options.scene); let difNo=scene.split("=")[1]; this.setData({ difNo:difNo }); } }, getDiffOrderDetail(){ wx.showLoading({ title: '加载中...', }); util.request(api.getDiffDetail, { diffOrderNo:this.data.difNo }, 'GET').then(res => { wx.hideLoading(); if (res.errno === 0) { this.setData({ orderDiff:res.data.orderDiff, diffItemList:res.data.diffItemList }); }else{ wx.showToast({ title: res.errmsg, icon: 'none', duration:3000, mask:true, }); } }).catch(err => { wx.hideLoading(); }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, goPay(){ let that=this; wx.showLoading({ title: '加载中' }); util.request(api.prepayDiff, { diffOrderNo: this.data.difNo }).then(res=> { wx.hideLoading(); if (res.errno === 0) { let payParam=res.data; wx.requestPayment({ 'timeStamp': payParam.timeStamp, 'nonceStr': payParam.nonceStr, 'package': payParam.packageValue, 'signType': payParam.signType, 'paySign': payParam.paySign, success: function(res) { console.log("支付过程成功"); wx.showToast({ title: '支付成功', duration:3000, mask:true, }); setTimeout(()=>{ that.getDiffOrderDetail(); },4000); }, fail: function(res) { console.log("支付过程失败"); util.showErrorToast('支付失败'); }, complete: function(res) { console.log("支付过程结束") } }); } }).catch(err=> { console.log(err); wx.hideLoading(); }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getDiffOrderDetail(); }, onHide: function () { }, onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { wx.showNavigationBarLoading(); //在标题栏中显示加载 this.getDiffOrderDetail(); wx.hideNavigationBarLoading(); //完成停止加载 wx.stopPullDownRefresh(); //停止下拉刷新 }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, })