Эх сурвалжийг харах

无需支付订单和免费时长处理

zaijin 2 жил өмнө
parent
commit
a29c8589bf

+ 44 - 35
App.vue

@@ -1,40 +1,49 @@
 <script>
-	export default {
-		onLaunch: function() {
-			// console.log('App Launch')
-			//判断客户端类别
-			if (/MicroMessenger/.test(window.navigator.userAgent)) {
-				uni.setStorage({
-					key: 'userAgent',
-					data: 'wxAgent'
-				});
-				// console.log('handleAliPay 微信客户端');
-			} else if (/AlipayClient/.test(window.navigator.userAgent)) {
-				uni.setStorage({
-					key: 'userAgent',
-					data: 'aliAgent'
-				});
-				// console.log('handleAliPay 支付宝客户端');
-			} else {
-				uni.setStorage({
-					key: 'userAgent',
-					data: 'otherAgent'
-				});
-				// console.log('handleAliPay 其他浏览器');
-			};
-			// this.$wxApi.config();
-		},
-		onShow: function() {
-			// console.log('App Show')
-		},
-		onHide: function() {
-			// console.log('App Hide')
-		}
-	}
+export default {
+  onLaunch: function () {
+    // console.log('App Launch')
+    //判断客户端类别
+    if (/MicroMessenger/.test(window.navigator.userAgent)) {
+      uni.setStorage({
+        key: 'userAgent',
+        data: 'wxAgent'
+      });
+      console.log('微信客户端');
+    } else if (/AlipayClient/.test(window.navigator.userAgent)) {
+      uni.setStorage({
+        key: 'userAgent',
+        data: 'aliAgent'
+      });
+      console.log('支付宝客户端');
+    } else {
+      uni.setStorage({
+        key: 'userAgent',
+        data: 'otherAgent'
+      });
+      console.log('其他浏览器');
+    }
+    // 获取参数免费时长
+    this.$u.api
+      .getParamsApi({
+        key: 'park.lock.freetime'
+      })
+      .then((res) => {
+        if (res.code === 200) {
+          this.$u.vuex('free_time', res.msg);
+        }
+      });
+  },
+  onShow: function () {
+    // console.log('App Show')
+  },
+  onHide: function () {
+    // console.log('App Hide')
+  }
+};
 </script>
 
 <style lang="scss">
-	@import "./static/css/iconfont.css";
-	@import "uview-ui/index.scss";
-	/*每个页面公共css */
+@import './static/css/iconfont.css';
+@import 'uview-ui/index.scss';
+/*每个页面公共css */
 </style>

+ 3 - 3
pages/center/order/order.vue

@@ -66,11 +66,11 @@
 										停车时长:{{ orderItem.duration || 0 }}</view> -->
                   <!-- <view class="order-center-item" v-if="orderItem.orderStatus !== 1">
 										免费时长:{{ orderItem.freeDuration || 0 }}</view> -->
-                  <view class="order-center-item" v-if="orderItem.deviceType == 1"> 免费时长:{{ orderItem.freeDuration || 0 }}</view>
+                  <view class="order-center-item" v-if="orderItem.deviceType == 1"> 免费时长:{{ orderItem.freeDuration || `0天0时${free_time}分0秒` }}</view>
                   <!-- <view class="order-center-item" v-if="orderItem.deviceType == 2">
 										免费时长:0天0时15分0秒</view> -->
                   <view class="order-center-item" v-if="orderItem.deviceType == 2">
-                    免费时长:{{ (orderItem.freeDuration || 1) | freeDuration }}</view
+                    免费时长:{{ orderItem.freeDuration || `0天0时${free_time}分0秒` }}</view
                   >
                   <!-- <view class="order-center-item" v-if="orderItem.orderStatus !== 1">
 										计费时长:{{ orderItem.calcDuration || 0 }}</view> -->
@@ -102,7 +102,7 @@
                   <view class="order-center-item" v-if="orderItem.orderStatus == 1 && orderItem.outTime"> 出场通道:{{ `未出场` }}</view>
                   <view class="order-center-item" v-if="orderItem.orderStatus !== 1"> 出场通道:{{ orderItem.outParkingName }}</view>
                   <view class="order-center-item" v-if="orderItem.orderStatus !== 1"> 出场时间:{{ orderItem.inTime }}</view>
-                  <view class="order-center-item"> 免费时长:{{ orderItem.freeDuration || 0 }}</view>
+                  <view class="order-center-item"> 免费时长:{{ orderItem.freeDuration || `0天0时${free_time}分0秒` }}</view>
                   <view class="order-center-item"> 计费时长:{{ orderItem.calcDuration || 0 }}</view>
                   <view class="order-center-item"> 累计停车时长:{{ orderItem.duration || 0 }}</view>
                   <view class="order-center-item">

+ 28 - 4
pages/center/order/orderDetails/orderDetails.vue

@@ -27,10 +27,22 @@
           <u-cell-item title="结束计费 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.outTime" />
         </template>
         <template v-if="orderInfo.deviceType !== 2">
-          <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.freeDuration || 0" />
+          <u-cell-item
+            title="免费时长 "
+            :arrow="false"
+            :border-bottom="false"
+            :border-top="false"
+            :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
+          />
         </template>
         <template v-else>
-          <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.freeDuration || 0" />
+          <u-cell-item
+            title="免费时长 "
+            :arrow="false"
+            :border-bottom="false"
+            :border-top="false"
+            :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
+          />
         </template>
         <u-cell-item title="计费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.calcDuration" />
         <u-cell-item title="累计停车时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.duration" />
@@ -73,10 +85,22 @@
           <u-cell-item title="结束计费 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.outTime" />
         </template>
         <template v-if="orderInfo.deviceType == 1">
-          <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.freeDuration || 0" />
+          <u-cell-item
+            title="免费时长 "
+            :arrow="false"
+            :border-bottom="false"
+            :border-top="false"
+            :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
+          />
         </template>
         <template v-else>
-          <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.freeDuration || 0" />
+          <u-cell-item
+            title="免费时长 "
+            :arrow="false"
+            :border-bottom="false"
+            :border-top="false"
+            :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
+          />
         </template>
         <u-cell-item title="计费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.calcDuration" />
         <u-cell-item title="累计停车时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.duration" />

+ 1 - 1
pages/geomagnetismLock/geomagnetismLock.vue

@@ -32,7 +32,7 @@
           </view>
           <view class="parking-lock-info-item">
             <view>免费时长</view>
-            <view>{{ orderInfo.freeDuration || '0天0时15分0秒' }}</view>
+            <view>{{ orderInfo.freeDuration || `0天0时${free_time}分0秒` }}</view>
           </view>
           <view class="parking-lock-info-item">
             <view>计费时长</view>

+ 1 - 1
pages/parkexport/parkexport.vue

@@ -37,7 +37,7 @@
 					</view> -->
           <view class="parking-lock-info-item">
             <view>免费时长</view>
-            <view class="weight">{{ infoData.freeDuration }}</view>
+            <view class="weight">{{ infoData.freeDuration || `0天0时${free_time}分0秒` }}</view>
           </view>
           <view class="parking-lock-info-item">
             <view class="weight">计费时长</view>

+ 3 - 11
pages/parkingLists/parkingLists.vue

@@ -89,6 +89,7 @@
 </template>
 
 <script>
+import { qqMapTransBMap } from '@/utils/mapTrans.js';
 export default {
   data() {
     return {
@@ -209,24 +210,15 @@ export default {
       const name = item[0].label;
       switch (name) {
         case '腾讯地图':
-          // uni.navigateTo({
-          //   url:
-          //     '/pages/parkingLists/map_web_view/map_web_view?url=https://3gimg.qq.com/lightmap/v1/marker/?marker=coord:' +
-          //     this.currentPositionHover.latitude +
-          //     ',' +
-          //     this.currentPositionHover.longitude +
-          //     '&referer=myApp&key=BOGBZ-2BZ33-O4L32-Y3QJR-PGN66-RFFEL'
-          // });
           location.href = `https://apis.map.qq.com/uri/v1/routeplan?type=drive&from=我的位置&fromcoord=${this.currentPosition.latitude},${this.currentPosition.longitude}&to=${this.currentPositionHover.areaName}&tocoord=${this.currentPositionHover.latitude},${this.currentPositionHover.longitude}&policy=1&referer=BOGBZ-2BZ33-O4L32-Y3QJR-PGN66-RFFEL`;
           break;
         case '百度地图':
+          const lnglatObj = qqMapTransBMap(this.currentPositionHover.longitude, this.currentPositionHover.latitude);
           location.href = `http://api.map.baidu.com/marker?location=
-			${this.currentPositionHover.latitude},${this.currentPositionHover.longitude}&title=目的地&content=${this.currentPositionHover.areaName}
+			${lnglatObj.lat},${lnglatObj.lng}&title=目的地&content=${this.currentPositionHover.areaName}
 			&output=html&src=webapp.baidu.openAPIdemo`;
           break;
         case '高德地图':
-          // const gdurl = `https://uri.amap.com/navigation?from=${this.currentPosition.longitude},${this.currentPosition.latitude},起点&to=${this.currentPositionHover.longitude},${this.currentPositionHover.latitude},终点&mode=car&policy=1&src=mypage&coordinate=gaode&callnative=0`;
-          // window.location.href = gdurl;
           location.href = `https://uri.amap.com/navigation?from=${this.currentPosition.longitude},${this.currentPosition.latitude},我的位置&to=${this.currentPositionHover.longitude},${this.currentPositionHover.latitude},${this.currentPositionHover.areaName}&mode=car&policy=1&src=mypage&coordinate=gaode&callnative=0`;
           break;
       }

+ 1 - 1
pages/parkingLock/parkingLock.vue

@@ -45,7 +45,7 @@
             </view>
             <view class="parking-lock-info-item">
               <view>免费时长</view>
-              <view>{{ orderInfo.freeDuration || '0天0时15分0秒' }}</view>
+              <view>{{ orderInfo.freeDuration || `0天0时${free_time}分0秒` }}</view>
             </view>
             <view class="parking-lock-info-item">
               <view>计费时长</view>

+ 2 - 2
pages/payLists/payLists.vue

@@ -37,7 +37,7 @@
                       <view class="pay-center-item" v-if="payItem.orderStatus == 1 && payItem.outTime"> 结束计费:{{ `未出场` }}</view>
                       <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 结束计费:{{ payItem.outTime || 0 }}</view>
                     </template>
-                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration || 0 }} </view>
+                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration || `0天0时${free_time}分0秒` }} </view>
                     <!-- 计费时长=停车时长-免费时长 -->
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 计费时长:{{ payItem.calcDuration || 0 }} </view>
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 累计停车时长:{{ payItem.duration || 0 }} </view>
@@ -74,7 +74,7 @@
                     <view class="pay-center-item">入场时间:{{ payItem.inTime || 0 }}</view>
                     <view class="pay-center-item">出场通道:{{ payItem.outEntranceName }}</view>
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 出场时间:{{ payItem.outTime || 0 }} </view>
-                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration || 0 }} </view>
+                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration || `0天0时${free_time}分0秒` }} </view>
                     <!-- 计费时长=停车时长-免费时长 -->
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 计费时长:{{ payItem.calcDuration || 0 }} </view>
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 累计停车时长:{{ payItem.duration || 0 }} </view>

+ 1 - 1
pages/payPage/payPage.vue

@@ -38,7 +38,7 @@
 </template>
 
 <script>
-import getUrlParams from '../../utils/getUrlParams.js';
+import getUrlParams from '@/utils/getUrlParams.js';
 export default {
   data() {
     return {

+ 91 - 47
pages/paymentMethod/paymentMethod.vue

@@ -3,7 +3,7 @@
  * @Author: 空白格
  * @Date: 2022-08-01 11:45:20
  * @LastEditors: 空白格
- * @LastEditTime: 2022-10-09 13:54:07
+ * @LastEditTime: 2022-10-14 14:31:31
  * @FilePath: \parking_h5\pages\paymentMethod\paymentMethod.vue
  * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved. 
 -->
@@ -211,53 +211,75 @@ export default {
       if (this.exportFlag) {
         this.$u.api.parkingWechatPayApi(params).then((res) => {
           if (res.code === 200) {
-            $wxPay.wexinPay(res.data.wx).then((r) => {
-              switch (Number(r.code)) {
-                case 0: // 成功
-                  //#ifdef H5
-                  window.location.reload();
-                  //#endif
-                  break;
-                case 1: // 取消
-                  this.$refs.uToast.show({
-                    title: '已取消支付',
-                    type: 'info'
-                  });
-                  break;
-                case 2: // 支付失败
-                  this.$refs.uToast.show({
-                    title: '支付失败,请检查!',
-                    type: 'error'
-                  });
-                  break;
-              }
-            });
+            if (res.data.needPay) {
+              $wxPay.wexinPay(res.data.wx).then((r) => {
+                switch (Number(r.code)) {
+                  case 0: // 成功
+                    //#ifdef H5
+                    window.location.reload();
+                    //#endif
+                    break;
+                  case 1: // 取消
+                    this.$refs.uToast.show({
+                      title: '已取消支付',
+                      type: 'info'
+                    });
+                    break;
+                  case 2: // 支付失败
+                    this.$refs.uToast.show({
+                      title: '支付失败,请检查!',
+                      type: 'error'
+                    });
+                    break;
+                }
+              });
+            } else {
+              this.$refs.uToast.show({
+                title: '无需支付',
+                type: 'info'
+              });
+              setTimeout(() => {
+                uni.hideLoading();
+                location.reload();
+              }, 1000);
+            }
           }
         });
       } else {
         this.$u.api.wechatPayApi(params).then((res) => {
           if (res.code === 200) {
-            $wxPay.wexinPay(res.data.wx).then((r) => {
-              switch (Number(r.code)) {
-                case 0: // 成功
-                  //#ifdef H5
-                  window.location.reload();
-                  //#endif
-                  break;
-                case 1: // 取消
-                  this.$refs.uToast.show({
-                    title: '已取消支付',
-                    type: 'info'
-                  });
-                  break;
-                case 2: // 支付失败
-                  this.$refs.uToast.show({
-                    title: '支付失败,请检查!',
-                    type: 'error'
-                  });
-                  break;
-              }
-            });
+            if (res.data.needPay) {
+              $wxPay.wexinPay(res.data.wx).then((r) => {
+                switch (Number(r.code)) {
+                  case 0: // 成功
+                    //#ifdef H5
+                    window.location.reload();
+                    //#endif
+                    break;
+                  case 1: // 取消
+                    this.$refs.uToast.show({
+                      title: '已取消支付',
+                      type: 'info'
+                    });
+                    break;
+                  case 2: // 支付失败
+                    this.$refs.uToast.show({
+                      title: '支付失败,请检查!',
+                      type: 'error'
+                    });
+                    break;
+                }
+              });
+            } else {
+              this.$refs.uToast.show({
+                title: '无需支付',
+                type: 'info'
+              });
+              setTimeout(() => {
+                uni.hideLoading();
+                location.reload();
+              }, 1000);
+            }
           }
         });
       }
@@ -284,8 +306,19 @@ export default {
           .polyPayExportApi(params)
           .then((res) => {
             if (res.code === 200) {
-              localStorage.setItem('jumpUrl', this.jumpUrl);
-              location.href = res.data.qrCodeUrl;
+              if (res.data.needPay) {
+                localStorage.setItem('jumpUrl', this.jumpUrl);
+                location.href = res.data.qrCodeUrl;
+              } else {
+                this.$refs.uToast.show({
+                  title: '无需支付',
+                  type: 'info'
+                });
+                setTimeout(() => {
+                  uni.hideLoading();
+                  location.href = this.jumpUrl;
+                }, 1000);
+              }
             } else {
               uni.hideLoading();
             }
@@ -301,8 +334,19 @@ export default {
           .ordinaryWxPay(params)
           .then((res) => {
             if (res.code === 200) {
-              localStorage.setItem('jumpUrl', this.jumpUrl);
-              location.href = res.data.qrCodeUrl;
+              if (res.data.needPay) {
+                localStorage.setItem('jumpUrl', this.jumpUrl);
+                location.href = res.data.qrCodeUrl;
+              } else {
+                this.$refs.uToast.show({
+                  title: '无需支付',
+                  type: 'info'
+                });
+                setTimeout(() => {
+                  uni.hideLoading();
+                  location.href = this.jumpUrl;
+                }, 1000);
+              }
             } else {
               uni.hideLoading();
             }

+ 1 - 1
pages/roadGateSystem/roadGateSystem.vue

@@ -34,7 +34,7 @@
           <view class="parking-lock-info-item">
             <view>免费时长</view>
             <!-- <view>{{ orderInfo.freeDuration || '0天0时15分0秒' }}</view> -->
-            <view>{{ '0天0时15分0秒' }}</view>
+            <view>{{ `0天0时${free_time}分0秒` }}</view>
           </view>
           <view class="parking-lock-info-item">
             <view>计费时长</view>

+ 21 - 22
store/$u.mixin.js

@@ -1,27 +1,26 @@
-import { mapState } from 'vuex'
-import store from "@/store"
+import { mapState } from 'vuex';
+import store from '@/store';
 
 // 尝试将用户在根目录中的store/index.js的vuex的state变量,全部加载到全局变量中
 let $uStoreKey = [];
-try{
-	$uStoreKey = store.state ? Object.keys(store.state) : [];
-}catch(e){
-	
-}
+try {
+  $uStoreKey = store.state ? Object.keys(store.state) : [];
+} catch (e) {}
 
 module.exports = {
-	beforeCreate() {
-		// 将vuex方法挂在到$u中
-		// 使用方法为:如果要修改vuex的state中的user.name变量为"史诗" => this.$u.vuex('user.name', '史诗')
-		// 如果要修改vuex的state的version变量为1.0.1 => this.$u.vuex('version', '1.0.1')
-		this.$u.vuex = (name, value) => {
-			this.$store.commit('$uStore', {
-				name,value
-			})
-		}
-	},
-	computed: {
-		// 将vuex的state中的所有变量,解构到全局混入的mixin中
-		...mapState($uStoreKey)
-	}
-}
+  beforeCreate() {
+    // 将vuex方法挂在到$u中
+    // 使用方法为:如果要修改vuex的state中的user.name变量为"史诗" => this.$u.vuex('user.name', '史诗')
+    // 如果要修改vuex的state的version变量为1.0.1 => this.$u.vuex('version', '1.0.1')
+    this.$u.vuex = (name, value) => {
+      this.$store.commit('$uStore', {
+        name,
+        value
+      });
+    };
+  },
+  computed: {
+    // 将vuex的state中的所有变量,解构到全局混入的mixin中
+    ...mapState($uStoreKey)
+  }
+};

+ 56 - 57
store/index.js

@@ -1,66 +1,65 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-Vue.use(Vuex)
+import Vue from 'vue';
+import Vuex from 'vuex';
+Vue.use(Vuex);
 
 let lifeData = {};
 
-try{
-	// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
-	lifeData = uni.getStorageSync('lifeData');
-}catch(e){
-	
-}
+try {
+  // 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
+  lifeData = uni.getStorageSync('lifeData');
+} catch (e) {}
 
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
-let saveStateKeys = ['vuex_user', 'vuex_token','vuex_wxinfo','vuex_hasLogin'];
+let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_wxinfo', 'vuex_hasLogin', 'free_time'];
 
 // 保存变量到本地存储中
-const saveLifeData = function(key, value){
-	// 判断变量名是否在需要存储的数组中
-	if(saveStateKeys.indexOf(key) != -1) {
-		// 获取本地存储的lifeData对象,将变量添加到对象中
-		let tmp = uni.getStorageSync('lifeData');
-		// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
-		tmp = tmp ? tmp : {};
-		tmp[key] = value;
-		// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
-		uni.setStorageSync('lifeData', tmp);
-	}
-}
+const saveLifeData = function (key, value) {
+  // 判断变量名是否在需要存储的数组中
+  if (saveStateKeys.indexOf(key) != -1) {
+    // 获取本地存储的lifeData对象,将变量添加到对象中
+    let tmp = uni.getStorageSync('lifeData');
+    // 第一次打开APP,不存在lifeData变量,故放一个{}空对象
+    tmp = tmp ? tmp : {};
+    tmp[key] = value;
+    // 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
+    uni.setStorageSync('lifeData', tmp);
+  }
+};
 const store = new Vuex.Store({
-	state: {
-		// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
-		// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
-		vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {},
-		vuex_wxinfo: lifeData.vuex_wxinfo ? lifeData.vuex_wxinfo : {},
-		vuex_hasLogin:lifeData.vuex_hasLogin?lifeData.vuex_hasLogin:false,
-		vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
-		// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
-		vuex_version: '1.0.1',
-		back_url: ''
-	},
-	mutations: {
-		$uStore(state, payload) {
-			// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
-			let nameArr = payload.name.split('.');
-			let saveKey = '';
-			let len = nameArr.length;
-			if(len >= 2) {
-				let obj = state[nameArr[0]];
-				for(let i = 1; i < len - 1; i ++) {
-					obj = obj[nameArr[i]];
-				}
-				obj[nameArr[len - 1]] = payload.value;
-				saveKey = nameArr[0];
-			} else {
-				// 单层级变量,在state就是一个普通变量的情况
-				state[payload.name] = payload.value;
-				saveKey = payload.name;
-			}
-			// 保存变量到本地,见顶部函数定义
-			saveLifeData(saveKey, state[saveKey])
-		}
-	}
-})
+  state: {
+    // 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
+    // 加上vuex_前缀,是防止变量名冲突,也让人一目了然
+    vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {},
+    vuex_wxinfo: lifeData.vuex_wxinfo ? lifeData.vuex_wxinfo : {},
+    vuex_hasLogin: lifeData.vuex_hasLogin ? lifeData.vuex_hasLogin : false,
+    vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
+    free_time: lifeData.free_time || '15',
+    // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
+    vuex_version: '1.0.1',
+    back_url: ''
+  },
+  mutations: {
+    $uStore(state, payload) {
+      // 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
+      let nameArr = payload.name.split('.');
+      let saveKey = '';
+      let len = nameArr.length;
+      if (len >= 2) {
+        let obj = state[nameArr[0]];
+        for (let i = 1; i < len - 1; i++) {
+          obj = obj[nameArr[i]];
+        }
+        obj[nameArr[len - 1]] = payload.value;
+        saveKey = nameArr[0];
+      } else {
+        // 单层级变量,在state就是一个普通变量的情况
+        state[payload.name] = payload.value;
+        saveKey = payload.name;
+      }
+      // 保存变量到本地,见顶部函数定义
+      saveLifeData(saveKey, state[saveKey]);
+    }
+  }
+});
 
-export default store
+export default store;

+ 7 - 5
template.h5.html

@@ -1,5 +1,6 @@
 <!DOCTYPE html>
 <html lang="zh-CN">
+
 	<head>
 		<meta charset="utf-8">
 		<meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -7,18 +8,17 @@
 		<meta http-equiv="Pragma" content="no-cache" />
 		<meta http-equiv="Expires" content="0" />
 		<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico">
-		<meta name="viewport"
-			content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
 		<title>
 			<%= htmlWebpackPlugin.options.title %>
 		</title>
 		<script>
-			document.addEventListener('DOMContentLoaded', function() {
+			document.addEventListener('DOMContentLoaded', function () {
 				document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
 			})
 			window.addEventListener(
 				"error",
-				function(e) {
+				function (e) {
 					var jsLoadedErrorReload = window.sessionStorage.getItem(
 						"jsLoadedErrorReload" // 跳转的标识,存入sessionStorage。用于不可控情况下,防止一直满足条件,触发死循环性的跳转页面
 					);
@@ -37,10 +37,12 @@
 		</script>
 		<link rel="stylesheet" href="<%= BASE_URL %>static/index.css" />
 	</head>
+
 	<body>
 		<noscript>
 			<strong>本站点必须要开启JavaScript才能运行</strong>
 		</noscript>
 		<div id="app"></div>
 	</body>
-</html>
+
+</html>

+ 24 - 21
uni.scss

@@ -3,28 +3,31 @@
  * uView自定义的css类名和scss变量,均以"u-"开头,不会造成冲突,请放心使用 
  */
 @import 'uview-ui/theme.scss';
-.wrap{margin: 0 40rpx;position: relative;}
+.wrap {
+  margin: 0 40rpx;
+  position: relative;
+}
 
-.bottom-btn-wrap{
-	height: 155rpx;
+.bottom-btn-wrap {
+  height: 155rpx;
 }
-.bottom-btn{
-	position: fixed;
-	left: 40rpx;
-	right: 40rpx;
-	bottom: 47rpx;
-	height: 85rpx;
-	line-height: 85rpx;
-	background: #3397FA;
-	box-shadow: 0px 9rpx 9rpx 0px rgba(0, 0, 0, 0.03);
-	border-radius: 10rpx;
-	text-align: center;
-	font-size: 28rpx;
-	font-weight: 500;
-	color: #FFF;
-	letter-spacing: 1px;
-	z-index: 99;
+.bottom-btn {
+  position: fixed;
+  left: 40rpx;
+  right: 40rpx;
+  bottom: 47rpx;
+  height: 85rpx;
+  line-height: 85rpx;
+  background: #3397fa;
+  box-shadow: 0px 9rpx 9rpx 0px rgba(0, 0, 0, 0.03);
+  border-radius: 10rpx;
+  text-align: center;
+  font-size: 28rpx;
+  font-weight: 500;
+  color: #fff;
+  letter-spacing: 1px;
+  z-index: 99;
 }
-.bottom-btn.static{
-	position: static;
+.bottom-btn.static {
+  position: static;
 }

+ 18 - 18
vue.config.js

@@ -1,19 +1,19 @@
 module.exports = {
-	// 配置路径别名
-	configureWebpack: {
-		devServer: {
-			port: '8890',
-			disableHostCheck: true,
-			https: false,
-			proxy:{
-				'/api':{
-					target: 'https://wx.hw.hongweisoft.com/parking/',
-					changeOrigin: true,
-					pathRewrite:{
-						'^/api': ''
-					}
-				}
-			}
-		}
-	}
-}
+  // 配置路径别名
+  configureWebpack: {
+    devServer: {
+      port: '8890',
+      disableHostCheck: true,
+      https: false,
+      proxy: {
+        '/api': {
+          target: 'https://wx.hw.hongweisoft.com/parking/',
+          changeOrigin: true,
+          pathRewrite: {
+            '^/api': ''
+          }
+        }
+      }
+    }
+  }
+};