|
@@ -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) {
|