123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- 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 () {
- },
- })
|