Browse Source

规整前后台传参混乱

Joe 4 years ago
parent
commit
a09ceabaed

+ 6 - 1
api/home.js

@@ -29,6 +29,10 @@ const decryptEncryptedData = (params) => mPost("/"+prefix+"/decryptEncryptedData
 const getCustomerGradeList = (params) => mGet("/"+prefix+"/getCustomerGradeList", params);
 const getCustomerGradeList = (params) => mGet("/"+prefix+"/getCustomerGradeList", params);
 //获取优惠信息-直降、立减、满减方案
 //获取优惠信息-直降、立减、满减方案
 const getCustomerGradeInfo = (params) => mPost("/"+prefix+"/getCustomerGradeInfo", params);
 const getCustomerGradeInfo = (params) => mPost("/"+prefix+"/getCustomerGradeInfo", params);
+// 查询用户是否 关注了公众号
+const getOfficialAccounts = (params) => mGet("/" + prefix + "/whetherFollowGzh",params);
+
+
 export {
 export {
   getStationList,
   getStationList,
   getOilGunList,
   getOilGunList,
@@ -39,5 +43,6 @@ export {
   saveAppUserInfo,
   saveAppUserInfo,
   decryptEncryptedData,
   decryptEncryptedData,
   getCustomerGradeList,
   getCustomerGradeList,
-  getCustomerGradeInfo
+  getCustomerGradeInfo,
+  getOfficialAccounts
 };
 };

+ 7 - 13
app.js

@@ -10,13 +10,10 @@ App({
     var logs = wx.getStorageSync('logs') || []
     var logs = wx.getStorageSync('logs') || []
     logs.unshift(Date.now())
     logs.unshift(Date.now())
     wx.setStorageSync('logs', logs)
     wx.setStorageSync('logs', logs)
-
     // 登录
     // 登录
     wx.login({
     wx.login({
       success: res => {
       success: res => {
-        // console.log("code:"+res.code);
-        
-
+        // console.log("code:" + res);
         let code = res.code;
         let code = res.code;
         // console.log("app.js code="+res.code);
         // console.log("app.js code="+res.code);
         // 发送 res.code 到后台换取 openId, sessionKey, unionId
         // 发送 res.code 到后台换取 openId, sessionKey, unionId
@@ -24,14 +21,12 @@ App({
           code: code,
           code: code,
           stationId
           stationId
         }).then(res => { // handle success
         }).then(res => { // handle success
+          console.log(res)
           // console.log("app.js openid:"+res.openid);
           // console.log("app.js openid:"+res.openid);
-
           // console.log("app.js unoiid " + res.unionid)
           // console.log("app.js unoiid " + res.unionid)
-          this.mpOpenId = res.openid;
-          this.globalData.unionId = res.unionId
-          this.unionId = res.unionid
-          // console.log(this.globalData)
-          // console.log(this)
+          this.globalData.openId = res.openId;
+          this.globalData.unionId = res.unionId;
+          console.log(this.globalData.unionId)
         }).catch(error => { // handle error
         }).catch(error => { // handle error
           console.log(error);
           console.log(error);
         })
         })
@@ -62,10 +57,10 @@ App({
     mpVersion:null,//小程序当前是开发版?体验版?正式版?
     mpVersion:null,//小程序当前是开发版?体验版?正式版?
     userInfo: null, //用户信息
     userInfo: null, //用户信息
     phoneNumber:null,//用户手机号
     phoneNumber:null,//用户手机号
-    mpOpenId: null,
+    openId:null,
     unionId:null,
     unionId:null,
     appId,
     appId,
-    stationId: null, //加油站ID
+    stationId, //加油站ID
     stationName: null, //油站名称
     stationName: null, //油站名称
     picUrl: null, //油站图片URL
     picUrl: null, //油站图片URL
     mno: null, //油站绑定的商户号
     mno: null, //油站绑定的商户号
@@ -79,5 +74,4 @@ App({
     youHuiAmount: null, //优惠券金额
     youHuiAmount: null, //优惠券金额
     payAmount: null //实付金额
     payAmount: null //实付金额
   }
   }
-
 })
 })

+ 1 - 0
pages/gasup/index.js

@@ -200,6 +200,7 @@ Page({
       //获取到绑定的数据
       //获取到绑定的数据
       // console.log("stationId:"+e.currentTarget.dataset.sid);
       // console.log("stationId:"+e.currentTarget.dataset.sid);
       // console.log("stationName:"+e.currentTarget.dataset.sname);
       // console.log("stationName:"+e.currentTarget.dataset.sname);
+      console.log(e)
       let stationId = e.currentTarget.dataset.sid;
       let stationId = e.currentTarget.dataset.sid;
       let stationName = e.currentTarget.dataset.sname;
       let stationName = e.currentTarget.dataset.sname;
       let mno = e.currentTarget.dataset.mno;
       let mno = e.currentTarget.dataset.mno;

+ 5 - 4
pages/order/confirm.js

@@ -22,6 +22,7 @@ Page({
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
+    let app = getApp();
     let orderAmt = getApp().orderAmount;
     let orderAmt = getApp().orderAmount;
     let oilPrice = getApp().oilPrice;
     let oilPrice = getApp().oilPrice;
     // console.log("oilGunName:"+oilGunName);
     // console.log("oilGunName:"+oilGunName);
@@ -37,8 +38,8 @@ Page({
         getCustomerGradeInfo({
         getCustomerGradeInfo({
           "stationId": getApp().stationId,
           "stationId": getApp().stationId,
           "userType": "2",
           "userType": "2",
-          "oilName": getApp().oilGunName,
-          "openId": getApp().mpOpenId,
+          "oilName":app.oilGunName,
+          "openId": app.globalData.openId,
           "mobilePhone": mobileValue
           "mobilePhone": mobileValue
         }).then(res => { // handle success
         }).then(res => { // handle success
           if (res.retCode == 0) { //获取优惠信息成功
           if (res.retCode == 0) { //获取优惠信息成功
@@ -201,7 +202,7 @@ Page({
     //请求后台创建订单接口,获取订单号
     //请求后台创建订单接口,获取订单号
     confirmOrder({
     confirmOrder({
       "orderNo": app.orderNo,
       "orderNo": app.orderNo,
-      "openId": app.mpOpenId,
+      "openId": app.globalData.openId,
       "userType": 2
       "userType": 2
     }).then(res => { // handle success 
     }).then(res => { // handle success 
       // console.log("data:" + res.data);
       // console.log("data:" + res.data);
@@ -212,7 +213,7 @@ Page({
         // console.log("orderId="+orderId);
         // console.log("orderId="+orderId);
         getJhPayInfo({
         getJhPayInfo({
           "orderId": orderId,
           "orderId": orderId,
-          "openId": app.mpOpenId,
+          "openId": app.globalData.openId,
           "stationId": app.stationId,
           "stationId": app.stationId,
           "subject": app.stationName + "_" + app.oilGunName + "油品支付订单",
           "subject": app.stationName + "_" + app.oilGunName + "油品支付订单",
           "userType": "2"
           "userType": "2"

+ 17 - 13
pages/order/create.js

@@ -212,12 +212,13 @@ Page({
             let gunType = app.gunType;
             let gunType = app.gunType;
             if (gunType === '1') { //油品订单
             if (gunType === '1') { //油品订单
               console.log("**************计算优惠单开始****************");
               console.log("**************计算优惠单开始****************");
+              console.log(app)
               /**************计算优惠单开始****************/
               /**************计算优惠单开始****************/
               getCustomerGradeInfo({
               getCustomerGradeInfo({
-                "stationId": app.stationId,
+                "openId": app.globalData.openId,
+                "stationId": app.globalData.stationId,
                 "userType": "2",
                 "userType": "2",
                 "oilName": app.oilGunName,
                 "oilName": app.oilGunName,
-                "openId": app.mpOpenId,
                 "mobilePhone": mobileValue
                 "mobilePhone": mobileValue
               }).then(res => { // handle success
               }).then(res => { // handle success
                 if (res.retCode == 0) { //获取优惠信息成功
                 if (res.retCode == 0) { //获取优惠信息成功
@@ -312,7 +313,7 @@ Page({
                     "receivableAmt": app.orderAmount, //应收金额
                     "receivableAmt": app.orderAmount, //应收金额
                     "discountAmt": youHuiAmount, //优惠金额
                     "discountAmt": youHuiAmount, //优惠金额
                     "amt": totalMoney, //实收金额
                     "amt": totalMoney, //实收金额
-                    "token": app.mpOpenId,
+                    "openId": app.globalData.openId,
                     "userType": 2,
                     "userType": 2,
                     "orderType": "1"
                     "orderType": "1"
                   }).then(res => { // handle success 
                   }).then(res => { // handle success 
@@ -347,7 +348,7 @@ Page({
                 "receivableAmt": app.orderAmount, //应收金额
                 "receivableAmt": app.orderAmount, //应收金额
                 "discountAmt": youHuiAmount, //优惠金额
                 "discountAmt": youHuiAmount, //优惠金额
                 "amt": totalMoney, //实收金额
                 "amt": totalMoney, //实收金额
-                "token": app.mpOpenId,
+                "openId": app.openId,
                 "userType": 2,
                 "userType": 2,
                 "orderType": "2"
                 "orderType": "2"
               }).then(res => { // handle success 
               }).then(res => { // handle success 
@@ -384,15 +385,16 @@ Page({
   //金额输入框获取实时输入的值
   //金额输入框获取实时输入的值
   bindKeyInput: function (e) {
   bindKeyInput: function (e) {
     var app = getApp()
     var app = getApp()
-    const reg = /^[1-9]{1,}(\.)?([0-9]{0,2})?/ // 最小数额1   
-    // /^[0-9]{1,}(\.)?([0-9]{0,2})?/        // 不设置最小数额
+    // const reg = /^[1-9]{1,}(\.)?([0-9]{0,2})?/ // 最小数额1   
+    const reg = /^[0-9]{1,}(\.)?([0-9]{0,2})?/ // 不设置最小数额
+
     const res = e.detail.value.match(reg, "");
     const res = e.detail.value.match(reg, "");
-    if(res !== null){
+    if (res !== null) {
       app.orderAmount = res[0]
       app.orderAmount = res[0]
       this.setData({
       this.setData({
         account: res[0]
         account: res[0]
       })
       })
-    }else{
+    } else {
       app.orderAmount = ""
       app.orderAmount = ""
       this.setData({
       this.setData({
         account: ""
         account: ""
@@ -521,8 +523,10 @@ Page({
               stationId: app.stationId
               stationId: app.stationId
             }).then(res => { // handle success 
             }).then(res => { // handle success 
               // console.log("sessionKey:" + res.session_key);
               // console.log("sessionKey:" + res.session_key);
+              console.log("aaaaaaaaaaaa")
+              console.log(app)
               decryptEncryptedData({
               decryptEncryptedData({
-                sessionKey: res.session_key,
+                sessionKey: res.sessionKey,
                 encryptedData: encryptedData,
                 encryptedData: encryptedData,
                 iv: iv
                 iv: iv
               }).then(res => { // handle success
               }).then(res => { // handle success
@@ -530,14 +534,14 @@ Page({
                 //保存appUserInfo信息
                 //保存appUserInfo信息
                 saveAppUserInfo({
                 saveAppUserInfo({
                   "userType": "2",
                   "userType": "2",
-                  "minaOpenid": app.mpOpenId,
+                  "openId": app.globalData.openId,
                   "blogNickName": app.globalData.userInfo.nickName,
                   "blogNickName": app.globalData.userInfo.nickName,
                   "sexFlag": app.globalData.userInfo.gender === 1 ? 'M' : 'F',
                   "sexFlag": app.globalData.userInfo.gender === 1 ? 'M' : 'F',
                   "blogProfilePhoto": app.globalData.userInfo.avatarUrl,
                   "blogProfilePhoto": app.globalData.userInfo.avatarUrl,
                   "mobilePhone": mobilePhone,
                   "mobilePhone": mobilePhone,
-                  "stationId": app.stationId,        //油站Id
-                  "stationName": app.stationName,        //油站名称
-                  "unionId":app.unionId
+                  "stationId": app.stationId, //油站Id
+                  "stationName": app.stationName, //油站名称
+                  "unionId": app.globalData.unionId
 
 
                 }).then(res => { // handle success 
                 }).then(res => { // handle success 
                   // console.log(res.data);
                   // console.log(res.data);

+ 6 - 0
pages/order/success.js

@@ -1,3 +1,4 @@
+import {getOfficialAccounts} from "../../api/home"
 Page({
 Page({
   data: {
   data: {
     iconSize: [20, 30, 40, 50, 60, 70],
     iconSize: [20, 30, 40, 50, 60, 70],
@@ -12,5 +13,10 @@ Page({
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
+    var app = getApp();
+    console.log(app)
+    getOfficialAccounts({}).then((res)=>{
+      console.log(res)
+    })
   }
   }
 })
 })

+ 2 - 0
pages/order/success.wxml

@@ -6,4 +6,6 @@
       <view class="icon-box-title">订单支付成功</view>
       <view class="icon-box-title">订单支付成功</view>
     </view>
     </view>
   </view>
   </view>
+  <view class="text"> 更多活动与优惠,请关注公众号</view>
+  <official-account class="official"></official-account>
 </view>
 </view>

+ 9 - 0
pages/order/success.wxss

@@ -1,9 +1,18 @@
 /* pages/order/success.wxss */
 /* pages/order/success.wxss */
 .my-view {
 .my-view {
   display: flex;
   display: flex;
+  flex-direction: column;
   align-items: center;
   align-items: center;
   justify-content: center;
   justify-content: center;
   width: 100%;
   width: 100%;
   height: 100%;
   height: 100%;
   position: absolute
   position: absolute
+}
+.text{
+  display: inline-block;
+  margin-top: 100rpx;
+  font-weight: 500;
+}
+.official{
+  width: 700rpx;
 }
 }

+ 24 - 0
project.private.config.json

@@ -0,0 +1,24 @@
+{
+  "setting": {},
+  "condition": {
+    "plugin": {
+      "list": []
+    },
+    "game": {
+      "list": []
+    },
+    "gamePlugin": {
+      "list": []
+    },
+    "miniprogram": {
+      "list": [
+        {
+          "name": "pages/order/success",
+          "pathName": "pages/gasup/index",
+          "query": "",
+          "scene": 1011
+        }
+      ]
+    }
+  }
+}