courseOrderPayment.js 2.8 KB

1
  1. "use strict";var e=require("../common/vendor.js"),a=require("../api/courseOrder.js");require("../common/request.js");const c={data(){return{payMethod:null,orderId:null,order:null}},onLoad(i){this.orderId=i.orderId,this.payMethod=i.payMethod},onShow(){this.getCourseOrderById()},methods:{copyTest(i){e.index.setClipboardData({data:i,success:()=>{e.index.showToast({title:"\u5185\u5BB9\u5DF2\u6210\u529F\u590D\u5236\u5230\u526A\u5207\u677F",icon:"none"})}})},getCourseOrderById(){var i={orderId:this.orderId};console.log(i),a.getCourseOrderById(i).then(n=>{n.code==200&&(this.order=n.order,this.payMethod!=null&&this.payMethod=="app"&&this.payOrder())},n=>{})},payOrder(){var i={orderId:this.orderId},n=this;e.index.showLoading(),a.payment(i).then(r=>{if(r.code==200)if(r.isPay==1)e.index.redirectTo({url:"/pages_order/courseOrderPaySuccess?orderId="+n.order.orderId});else if(r.type=="tz"&&(e.index.setStorageSync("ztPayUrl",r.data.body.url),e.index.redirectTo({url:"/pages_order/tzPay"})),r.type=="yb"){var o=JSON.parse(r.data.pay_info);console.log(o),e.index.requestPayment({provider:"wxpay",timeStamp:o.timeStamp,nonceStr:o.nonceStr,package:o.package,signType:o.signType,paySign:o.paySign,success:function(d){console.log(n.order.orderId),e.index.hideLoading(),e.index.redirectTo({url:"./courseOrderPaySuccess?orderId="+n.order.orderId})},fail:function(d){e.index.showToast({icon:"none",title:"fail:"+JSON.stringify(d)}),e.index.hideLoading()}})}else if(r.type=="hf"){var o=JSON.parse(r.data.pay_info);console.log(o),e.index.requestPayment({provider:"wxpay",timeStamp:o.timeStamp,nonceStr:o.nonceStr,package:o.package,signType:o.signType,paySign:o.paySign,success:function(t){console.log(n.order.orderId),e.index.hideLoading(),e.index.redirectTo({url:"./courseOrderPaySuccess?orderId="+n.order.orderId})},fail:function(t){e.index.showToast({icon:"none",title:"fail:"+JSON.stringify(t)}),e.index.hideLoading()}})}else r.type=="wx"&&e.index.requestPayment({provider:"wxpay",timeStamp:r.data.timeStamp,nonceStr:r.data.nonceStr,package:r.data.packageValue,signType:r.data.signType,paySign:r.data.paySign,success:function(d){console.log(n.order.orderId),e.index.hideLoading(),e.index.redirectTo({url:"./courseOrderPaySuccess?orderId="+n.order.orderId})},fail:function(d){e.index.showToast({icon:"none",title:"fail:"+JSON.stringify(d)}),e.index.hideLoading()}});else e.index.showToast({icon:"none",title:r.msg})},r=>{})}}};function p(i,n,r,o,d,t){return e.e({a:d.order!=null},d.order!=null?{b:e.t(d.order.payMoney.toFixed(2)),c:e.t(d.order.orderSn),d:e.o(s=>t.copyTest(d.order.orderSn)),e:e.t(d.order.createTime)}:{},{f:d.order!=null},d.order!=null?{g:e.o(s=>t.payOrder())}:{})}var l=e._export_sfc(c,[["render",p],["__file","E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_order/courseOrderPayment.vue"]]);wx.createPage(l);