Преглед на файлове

修改演示项目的实收金额、加载后直接跳转到支付界面

Joe преди 4 години
родител
ревизия
26dccac87a
променени са 7 файла, в които са добавени 93 реда и са изтрити 90 реда
  1. 1 0
      app.js
  2. 3 4
      app.json
  3. 35 29
      pages/gasup/index.js
  4. 12 11
      pages/order/confirm.js
  5. 32 30
      pages/order/create.js
  6. 1 14
      project.private.config.json
  7. 9 2
      setting.js

+ 1 - 0
app.js

@@ -58,6 +58,7 @@ App({
     openId:null,
     unionId:null,
     appId,
+    stationList:[], //加油站列表
     stationId, //加油站ID
     stationName: null, //油站名称
     picUrl: null, //油站图片URL

+ 3 - 4
app.json

@@ -1,12 +1,11 @@
 {
   "pages": [
-    "pages/order/success",
+    "pages/order/create",
     "pages/gasup/index",
     "pages/logs/logs",
     "pages/orders/myorder",
-    "pages/order/create",
-    "pages/order/confirm"
- 
+    "pages/order/confirm",
+    "pages/order/success"
   ],
   "permission": {
     "scope.userLocation": {

+ 35 - 29
pages/gasup/index.js

@@ -3,6 +3,8 @@ import {
   getStationList
 } from "../../api/home"
 
+// import { showIndex } from "../../setting";
+const app = getApp();
 Page({
   data: {
     list: [], // 列表数据
@@ -22,13 +24,11 @@ Page({
     ]
   },
 
-
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
     // console.log("@@@@@@@@@@@@@@@@" + "onLoad" + "@@@@@@@@@@@@@@@@");
-    var app = getApp()
     // console.log("openId:"+app.MpOpenId);
     let that = this; //将this赋值给that,以区别js本身的this
     that.bindAuthLocation(); //授权位置
@@ -113,21 +113,23 @@ Page({
     })
   },
   getStations: function (longitude, latitude) {
-    // console.log("longitude:"+longitude);
-    // console.log("latitude:"+latitude);
     getStationList({
       stationLongitude: longitude,
       stationLatitude: latitude,
       pageNum: 1,
       pageSize: 4,
       appId:getApp().globalData.appId
-    }).then(res => { // handle success 
-      // console.log(res.data);
+    }).then(res => { // handle success
       if (res.retCode == 0) {
+        app.globalData.stationList = res.data.stationInfoResponseList; // 暂时没用到
         this.setData({
           list: res.data.stationInfoResponseList
         })
+        // if(!showIndex){
+        //   this.skipIndex()
+        // }
       }
+      console.log(this.data.list)
     }).catch(error => { // handle error
       console.log(error);
     })
@@ -191,32 +193,36 @@ Page({
   },
 
   toAddOil: function (e) {
-    // console.log("@@@@@@@@@@@@@@@@" + " 去加油"+ "@@@@@@@@@@@@@@@@");
-    var app = getApp()
-    // if (app.globalData.userInfo == null) {
-    //   console.log("app.globalData中的userInfo:" + app.globalData.userInfo);
-    //   this.showDialogLogin(); //调用登录弹窗
-    // } else {
-      //获取到绑定的数据
-      // console.log("stationId:"+e.currentTarget.dataset.sid);
-      // console.log("stationName:"+e.currentTarget.dataset.sname);
-      console.log(e)
-      let stationId = e.currentTarget.dataset.sid;
-      let stationName = e.currentTarget.dataset.sname;
-      let mno = e.currentTarget.dataset.mno;
-      let thumb = e.currentTarget.dataset.pic;
+      // let stationId = e.currentTarget.dataset.sid;
+      // let stationName = e.currentTarget.dataset.sname;
+      // let mno = e.currentTarget.dataset.mno;
+      // let thumb = e.currentTarget.dataset.pic;
 
-      app.stationId = stationId;
-      app.stationName = stationName;
-      app.picUrl = thumb;
-      app.mno = mno;
-      // console.log("picUrl:"+app.picUrl);
-      wx.navigateTo({
-        url: "/pages/order/create"
-      });
-    // }
+      // 待删除
+      // app.stationId = stationId;
+      // app.stationName = stationName;
+      // app.picUrl = thumb;
+      // app.mno = mno;
+      // 
+      app.globalData.stationId = app.globalData.stationList[0].stationId
+      app.globalData.stationName = app.globalData.stationList[0].stationName
+      app.globalData.stationPic = app.globalData.stationList[0].stationPic
+      app.globalData.mno = app.globalData.stationList[0].mno      
+      wx.redirectTo({
+        url: "/pages/order/create",
+      })
 
   },
+  // skipIndex:function(){
+  //   app.globalData.stationId = app.globalData.stationList[0].stationId
+  //   app.globalData.stationName = app.globalData.stationList[0].stationName
+  //   app.globalData.stationPic = app.globalData.stationList[0].stationPic
+  //   app.globalData.mno = app.globalData.stationList[0].mno
+
+  //   wx.navigateTo({
+  //     url: "/pages/order/create"
+  //   });
+  // },
   //到这里去,调用地图
   goMap: function (e) {
     let latitude = Number(e.target.dataset.latitude);

+ 12 - 11
pages/order/confirm.js

@@ -33,10 +33,11 @@ Page({
     let gasoilDiscountAmount = null; //优惠金额-满减,立减,直降
     let discountAmount = null; //优惠起点金额
     var mobileValue = wx.getStorageSync('mobilePhone')
+
     if (mobileValue) {
       if (getApp().gunType === '1') {
         getCustomerGradeInfo({
-          "stationId": getApp().stationId,
+          "stationId": app.globalData.stationId,
           "userType": "2",
           "oilName":app.oilGunName,
           "openId": app.globalData.openId,
@@ -129,12 +130,12 @@ Page({
 
 
             this.setData({
-              stationName: getApp().stationName,
-              imageURL: getApp().picUrl,
-              gunNo: getApp().oilGunNum,
-              oilName: getApp().oilGunName,
-              oilPrice: getApp().oilPrice,
-              orderMoney: getApp().orderAmount,
+              stationName: app.globalData.stationName,
+              imageURL: app.globalData.stationPic,
+              gunNo: app.oilGunNum,
+              oilName: app.oilGunName,
+              oilPrice: app.oilPrice,
+              orderMoney: app.orderAmount,
               discountPrice: discountPrice,
               oilLitre: oilLitre,
               manJian: 0,
@@ -156,8 +157,8 @@ Page({
         youHuiAmount = 0;
         oilLitre = 0;
         this.setData({
-          stationName: getApp().stationName,
-          imageURL: getApp().picUrl,
+          stationName: app.globalData.stationName,
+          imageURL: app.globalData.stationPics,
           gunNo: getApp().oilGunNum,
           oilName: getApp().oilGunName,
           oilPrice: getApp().oilPrice,
@@ -214,8 +215,8 @@ Page({
         getJhPayInfo({
           "orderId": orderId,
           "openId": app.globalData.openId,
-          "stationId": app.stationId,
-          "subject": app.stationName + "_" + app.oilGunName + "油品支付订单",
+          "stationId": app.globalData.stationId,
+          "subject": app.globalData.stationName + "_" + app.oilGunName + "油品支付订单",
           "userType": "2"
         }).then(res => { // handle success
           //判断封装接口请求成功

+ 32 - 30
pages/order/create.js

@@ -1,5 +1,6 @@
 // pages/order/index.js
 import Toast from '@vant/weapp/toast/toast';
+import { isDemo } from '../../setting'
 import {
   getOilGunList,
   postOrderInfo,
@@ -9,8 +10,8 @@ import {
   getCustomerGradeInfo
 } from "../../api/home"
 
+const app = getApp();
 Page({
-
   /**
    * 页面的初始数据
    */
@@ -47,7 +48,6 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    var app = getApp();
     var userInfoValue = wx.getStorageSync('userInfo')
     try {
       if (userInfoValue) {
@@ -71,21 +71,22 @@ Page({
     } catch (e) {
       // Do something when catch error
     }
-    if (options.q) {
-      let scan_url = decodeURIComponent(options.q);
-      app.stationId = this.gup('stationId', scan_url);
-      // wx.showToast({
-      //   title: 'id1:' +app.stationId
-      // })
-    } else {
-      // var stationId = app.stationId;
-      // wx.showToast({
-      //   title: 'id2:' + stationId
-      // })
-    }
+    // console.log(options)
+    // if (options.q) {
+    //   let scan_url = decodeURIComponent(options.q);
+    //   app.stationId = this.gup('stationId', scan_url);
+    //   // wx.showToast({
+    //   //   title: 'id1:' +app.stationId
+    //   // })
+    // } else {
+    //   // var stationId = app.stationId;
+    //   // wx.showToast({
+    //   //   title: 'id2:' + stationId
+    //   // })
+    // }
 
     getOilGunList({
-      stationId: app.stationId
+      stationId: app.globalData.stationId
     }).then(res => { // handle success 
       // console.log(res.data);
       // res.data.length
@@ -98,7 +99,7 @@ Page({
           gasallarr: res.data,
           gasarr: gasArr
         })
-        app.stationName = res.data[0].stationName;
+        app.globalData.stationName = res.data[0].stationName;
       }
       // console.log("gasArr lengh:"+gasArr.length);
     }).catch(error => { // handle error
@@ -130,11 +131,10 @@ Page({
     });
   },
   selectGas: function (event) {
-    var app = getApp()
     let gunNo = event.target.dataset.index;
     let gunName = event.target.dataset.oilname;
     let oilPrice = event.target.dataset.oilprice;
-    let gunType = event.target.dataset.guntype;
+    let gunType = event.target.dataset.guntype; 
     app.oilGunNum = gunNo;
     app.oilGunName = gunName;
     app.oilPrice = oilPrice;
@@ -147,7 +147,6 @@ Page({
     // console.log("gas is :" + event.target.dataset.index);
   },
   selectGasAll: function (event) {
-    var app = getApp()
     var gasarr = [];
     var arrLength = this.data.gasallarr.length;
     if (event.target.dataset.index > 5) {
@@ -176,7 +175,6 @@ Page({
     });
   },
   clickAccount: function (event) {
-    var app = getApp()
     app.orderAmount = event.target.dataset.money;
     this.setData({
       account: event.target.dataset.money
@@ -191,7 +189,6 @@ Page({
     }
   },
   toConfirm: function () {
-    var app = getApp();
     var userInfoValue = wx.getStorageSync('userInfo')
     try {
       if (userInfoValue) {
@@ -305,8 +302,12 @@ Page({
                   }
                   /**************计算优惠结束****************/
                   //请求后台创建订单接口,获取订单号
+                  if(isDemo){
+                    console.log("演示项目,已经为您修改实收金额");
+                    totalMoney = "0.01"
+                  }
                   postOrderInfo({
-                    "stationId": app.stationId,
+                    "stationId": app.globalData.stationId,
                     "oilGun": app.oilGunNum,
                     "oilName": app.oilGunName,
                     "oilPrice": app.oilPrice,
@@ -339,16 +340,20 @@ Page({
             } else { //非油品订单
               totalMoney = orderAmt;
               youHuiAmount = 0;
+              if(isDemo){
+                console.log("演示项目,已经为您修改实收金额");
+                totalMoney = "0.01"
+              }
               //请求后台创建订单接口,获取订单号
               postOrderInfo({
-                "stationId": app.stationId,
+                "stationId": app.globalData.stationId,
                 "oilGun": app.oilGunNum,
                 "oilName": app.oilGunName,
                 "oilPrice": app.oilPrice,
                 "receivableAmt": app.orderAmount, //应收金额
                 "discountAmt": youHuiAmount, //优惠金额
                 "amt": totalMoney, //实收金额
-                "openId": app.openId,
+                "openId": app.globalData.openId,
                 "userType": 2,
                 "orderType": "2"
               }).then(res => { // handle success 
@@ -384,7 +389,6 @@ Page({
   },
   //金额输入框获取实时输入的值
   bindKeyInput: function (e) {
-    var app = getApp()
     // const reg = /^[1-9]{1,}(\.)?([0-9]{0,2})?/ // 最小数额1   
     const reg = /^[0-9]{1,}(\.)?([0-9]{0,2})?/ // 不设置最小数额
 
@@ -415,7 +419,6 @@ Page({
   },
 
   getUserInfo: function (e) {
-    var app = getApp()
     let that = this;
     // console.log(e)
     // 获取用户信息
@@ -520,7 +523,7 @@ Page({
             //发起网络请求  
             getMpOpenId({
               code: code,
-              stationId: app.stationId
+              stationId: app.globalData.stationId
             }).then(res => { // handle success 
               // console.log("sessionKey:" + res.session_key);
               console.log("aaaaaaaaaaaa")
@@ -539,10 +542,9 @@ Page({
                   "sexFlag": app.globalData.userInfo.gender === 1 ? 'M' : 'F',
                   "blogProfilePhoto": app.globalData.userInfo.avatarUrl,
                   "mobilePhone": mobilePhone,
-                  "stationId": app.stationId, //油站Id
-                  "stationName": app.stationName, //油站名称
+                  "stationId": app.globalData.stationId, //油站Id
+                  "stationName": app.globalData.stationName, //油站名称
                   "unionId": app.globalData.unionId
-
                 }).then(res => { // handle success 
                   // console.log(res.data);
                   if (res.retCode == 0 || res.retCode == -1) {

+ 1 - 14
project.private.config.json

@@ -11,20 +11,7 @@
       "list": []
     },
     "miniprogram": {
-      "list": [
-        {
-          "name": "pages/order/success",
-          "pathName": "pages/gasup/index",
-          "query": "",
-          "scene": 1011
-        },
-        {
-          "name": "pages/order/success",
-          "pathName": "pages/order/success",
-          "query": "",
-          "scene": 1011
-        }
-      ]
+      "list": []
     }
   }
 }

+ 9 - 2
setting.js

@@ -1,11 +1,18 @@
 // 接口  定义接口前缀:demo-演示版  api-正式版
-// 小程序的appid
-// 站点Id
 
+// 是否为演示项目
+export const isDemo = true;
+export const showIndex = false;
+export const gasupList = true; 
+// 是否开始
+
+// appid
+// 站点Id
 
 // 智慧油驿站
 // 山东石化879站
 
+
 export const prefix='demo';
 export const appId = 'wxe1135cd390b38a54'
 export const stationId = 1