|
@@ -0,0 +1,176 @@
|
|
|
+const { default: api } = require("../../js/api");
|
|
|
+const util = require('../../utils/util.js')
|
|
|
+
|
|
|
+// pages/orderConfirm/orderConfirm.js
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ nozzleId:0,
|
|
|
+ type:'后支付',
|
|
|
+ order:{},
|
|
|
+ oprationBtn1:'',
|
|
|
+ oprationBtn2:'对此订单有疑问?',
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad(options) {
|
|
|
+ const link = decodeURIComponent(options.q) // 获取到二维码原始链接
|
|
|
+ console.log("link",link);
|
|
|
+ var id = link.split('wxapp?id=')[1];
|
|
|
+ console.log("id1",id);
|
|
|
+ if(id == undefined) {
|
|
|
+ id = options.id;
|
|
|
+ }
|
|
|
+ console.log("id2",id)
|
|
|
+ this.setData({
|
|
|
+ nozzleId:id
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow() {
|
|
|
+ this.getOrder()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 获取订单信息 */
|
|
|
+ getOrder() {
|
|
|
+ api.request_GetMiniProgramTransactionsUnpaidNozzle(Number(this.data.nozzleId))
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.statusCode == 203) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../login/login',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log("获取到未支付订单",res)
|
|
|
+ var order = res.data.data[0];
|
|
|
+ var time = util.formatDateNotSecond(order.fuelItemTransactionEndTime);
|
|
|
+ this.setData({
|
|
|
+ order:{
|
|
|
+ oilName:order.productName,
|
|
|
+ nozzle:order.nozzleId,
|
|
|
+ volume:order.originalQty,
|
|
|
+ amount:order.originalAmount,
|
|
|
+ payAmount:order.actualPaymentAmount,
|
|
|
+ discount:order.originalAmount - order.actualPaymentAmount,
|
|
|
+ orderId:order.id,
|
|
|
+ time:time
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(err => {
|
|
|
+ console.log("未获取到未支付订单")
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 后支付查看更多交易 */
|
|
|
+ toMordOrderPage(){
|
|
|
+ var that = this;
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../moreOrder/moreOrder?nozzle='+this.data.nozzleId,
|
|
|
+ events:{
|
|
|
+ acceptOrderFromMoreOrder:function(data) {
|
|
|
+ console.log("获取到传送过来的订单",data)
|
|
|
+ this.setData({
|
|
|
+ order:data
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ order:data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 支付按钮点击事件 */
|
|
|
+ toPay(){
|
|
|
+ api.request_wechatPay(19).then(res => {
|
|
|
+ console.log("支付结果",res)
|
|
|
+ this.pay()
|
|
|
+ }).catch(err => {
|
|
|
+ console.log("支付失败",err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ pay() {
|
|
|
+ api.request_wechatPay(this.data.order.orderId)
|
|
|
+ .then(res => {
|
|
|
+ wx.requestPayment({
|
|
|
+ timeStamp: res.data.data.unifiedOrderResult.timeStamp,
|
|
|
+ nonceStr: res.data.data.unifiedOrderResult.nonceStr,
|
|
|
+ package: res.data.data.unifiedOrderResult.package,
|
|
|
+ signType: res.data.data.unifiedOrderResult.signType,
|
|
|
+ paySign: res.data.data.unifiedOrderResult.paySign,
|
|
|
+ success: res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ wx.showToast({
|
|
|
+ title: '支付成功!',
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '../scan/scan',
|
|
|
+ })
|
|
|
+ }, 2000)
|
|
|
+ },
|
|
|
+ fail: res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ wx.showModal({
|
|
|
+ title: '支付失败',
|
|
|
+ content: res.errMsg + '请稍后再试',
|
|
|
+ showCancel: false,
|
|
|
+ success(res) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+})
|