|
@@ -1,13 +1,19 @@
|
|
|
// pages/order/index.js
|
|
|
import Toast from '@vant/weapp/toast/toast';
|
|
|
-import { isDemo } from '../../setting'
|
|
|
+import {
|
|
|
+ isDemo,
|
|
|
+ stationId
|
|
|
+} from '../../setting'
|
|
|
+
|
|
|
import {
|
|
|
getOilGunList,
|
|
|
postOrderInfo,
|
|
|
saveAppUserInfo,
|
|
|
getMpOpenId,
|
|
|
decryptEncryptedData,
|
|
|
- getCustomerGradeInfo
|
|
|
+ getCustomerGradeInfo,
|
|
|
+ getStationPicList,
|
|
|
+ getStationNoticeInfo
|
|
|
} from "../../api/home"
|
|
|
|
|
|
const app = getApp();
|
|
@@ -42,17 +48,18 @@ Page({
|
|
|
iconType: [
|
|
|
'success', 'success_no_circle', 'info', 'warn', 'waiting', 'cancel', 'download', 'search', 'clear'
|
|
|
],
|
|
|
+ notice: ""
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
+ this.init()
|
|
|
+
|
|
|
var userInfoValue = wx.getStorageSync('userInfo')
|
|
|
try {
|
|
|
if (userInfoValue) {
|
|
|
- // Do something with return value
|
|
|
- // console.log("本地缓存中的userInfo:" + userInfoValue);
|
|
|
try {
|
|
|
var mobileValue = wx.getStorageSync('mobilePhone')
|
|
|
if (mobileValue) {
|
|
@@ -71,25 +78,35 @@ Page({
|
|
|
} catch (e) {
|
|
|
// Do something when catch error
|
|
|
}
|
|
|
- // 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
|
|
|
- // // })
|
|
|
- // }
|
|
|
+ },
|
|
|
+
|
|
|
+ init() {
|
|
|
+ // 加载页面所需资源
|
|
|
+ //获取轮播图
|
|
|
+ getStationPicList({
|
|
|
+ stationId: app.globalData.stationId
|
|
|
+ }).then((res) => {
|
|
|
+ this.setData({
|
|
|
+ images: res.data.map((ele) => {
|
|
|
+ return ele.url
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ //获取通知信息
|
|
|
+ getStationNoticeInfo({
|
|
|
+ stationId: app.globalData.stationId
|
|
|
+ }).then((res) => {
|
|
|
+ this.setData({
|
|
|
+ notice: res.data.notice
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
getOilGunList({
|
|
|
stationId: app.globalData.stationId
|
|
|
}).then(res => { // handle success
|
|
|
// console.log(res.data);
|
|
|
// res.data.length
|
|
|
+ console.log(res)
|
|
|
if (res.retCode == 0) {
|
|
|
var gasArr = [];
|
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
@@ -105,7 +122,9 @@ Page({
|
|
|
}).catch(error => { // handle error
|
|
|
console.log(error);
|
|
|
})
|
|
|
+
|
|
|
},
|
|
|
+
|
|
|
gup: function (name, url) {
|
|
|
if (!url) url = location.href;
|
|
|
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
|
|
@@ -115,6 +134,7 @@ Page({
|
|
|
return results == null ? null : results[1];
|
|
|
},
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
@@ -134,7 +154,7 @@ Page({
|
|
|
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;
|
|
@@ -302,7 +322,7 @@ Page({
|
|
|
}
|
|
|
/**************计算优惠结束****************/
|
|
|
//请求后台创建订单接口,获取订单号
|
|
|
- if(isDemo){
|
|
|
+ if (isDemo) {
|
|
|
console.log("演示项目,已经为您修改实收金额");
|
|
|
totalMoney = "0.01"
|
|
|
}
|
|
@@ -340,7 +360,7 @@ Page({
|
|
|
} else { //非油品订单
|
|
|
totalMoney = orderAmt;
|
|
|
youHuiAmount = 0;
|
|
|
- if(isDemo){
|
|
|
+ if (isDemo) {
|
|
|
console.log("演示项目,已经为您修改实收金额");
|
|
|
totalMoney = "0.01"
|
|
|
}
|
|
@@ -379,7 +399,6 @@ Page({
|
|
|
Toast.fail(e);
|
|
|
}
|
|
|
} else {
|
|
|
- // console.log("app.globalData中的userInfo:" + app.globalData.userInfo);
|
|
|
this.showDialogLogin(); //调用登录弹窗
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -420,10 +439,11 @@ Page({
|
|
|
|
|
|
getUserInfo: function (e) {
|
|
|
let that = this;
|
|
|
- // console.log(e)
|
|
|
+
|
|
|
// 获取用户信息
|
|
|
wx.getSetting({
|
|
|
success(res) {
|
|
|
+ console.log(res)
|
|
|
// console.log("res", res)
|
|
|
if (res.authSetting['scope.userInfo']) {
|
|
|
// console.log("已授权=====")
|
|
@@ -436,10 +456,6 @@ Page({
|
|
|
data: res.userInfo,
|
|
|
key: 'userInfo',
|
|
|
})
|
|
|
- // console.log("minaOpenid:"+app.mpOpenId);
|
|
|
- // console.log("blogNickName:"+res.userInfo.nickName);
|
|
|
- // console.log("sexFlag:"+res.userInfo.gender === 1?'M':'F');
|
|
|
- // console.log("blogProfilePhoto:"+res.userInfo.avatarUrl);
|
|
|
that.showDialogPhone(); //调用一键获取手机号弹窗
|
|
|
that.setData({
|
|
|
userInfo: res.userInfo,
|
|
@@ -496,9 +512,6 @@ Page({
|
|
|
getPhoneNumber: function (e) {
|
|
|
let that = this;
|
|
|
let app = getApp();
|
|
|
- // console.log(e.detail.errMsg)
|
|
|
- // console.log("iv:" + e.detail.iv)
|
|
|
- // console.log("encryptedData:" + e.detail.encryptedData)
|
|
|
if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
|
|
|
that.setData({
|
|
|
showModalPhone: false,
|
|
@@ -526,8 +539,6 @@ Page({
|
|
|
stationId: app.globalData.stationId
|
|
|
}).then(res => { // handle success
|
|
|
// console.log("sessionKey:" + res.session_key);
|
|
|
- console.log("aaaaaaaaaaaa")
|
|
|
- console.log(app)
|
|
|
decryptEncryptedData({
|
|
|
sessionKey: res.sessionKey,
|
|
|
encryptedData: encryptedData,
|
|
@@ -547,7 +558,7 @@ Page({
|
|
|
"unionId": app.globalData.unionId
|
|
|
}).then(res => { // handle success
|
|
|
// console.log(res.data);
|
|
|
- if (res.retCode == 0 || res.retCode == -1) {
|
|
|
+ if (res.retCode == 0) {
|
|
|
// console.log("保存app用户信息成功:"+app.globalData.userInfo);
|
|
|
// console.log("保存app用户信息成功。。。");
|
|
|
app.globalData.phoneNumber = mobilePhone;
|