王贵旺 4 gadi atpakaļ
vecāks
revīzija
0cdf0dffbd
4 mainītis faili ar 34 papildinājumiem un 11 dzēšanām
  1. 2 5
      src/main.js
  2. 14 0
      src/store/modules/user.js
  3. 17 5
      src/views/home/index.vue
  4. 1 1
      src/views/home/trail.vue

+ 2 - 5
src/main.js

@@ -31,11 +31,8 @@ window.addEventListener('message', event => {
 
   switch (data.iframeClick) {
     case 'getParams':
-      // eslint-disable-next-line no-case-declarations
-      const localStorageParam = data.params
-      for (const [k, v] of Object.entries(localStorageParam)) {
-        localStorage.setItem(k, v)
-      }
+      store.dispatch('initStoreInfo', data.params).then(response => {}).catch(() => { console.log('lngtruck store error') })
+      break
   }
 })
 

+ 14 - 0
src/store/modules/user.js

@@ -1,4 +1,5 @@
 import { getLocalStorage, removeLocalStorage } from '@/utils/storage'
+import { setLocalStorage } from '../../../../wxmobile/src/utils/storage'
 
 const user = {
   state: {
@@ -27,6 +28,19 @@ const user = {
     }
   },
   actions: {
+    initStoreInfo({ commit, state }, data) {
+      for (const [k, v] of Object.entries(data)) {
+        setLocalStorage(k, v)
+      }
+
+      commit('setmwxtoken', data.mwxtoken)
+      commit('setmwxidntf', data.mwxidntf)
+      commit('setmwxuser', data.mwxuser)
+      commit('setmwxrole', data.mwxrole)
+      commit('setmwxorg', data.mwxorg)
+
+      window.iframeTruckStatus = true
+    },
     login({ commit, state }, data) {
       return new Promise((resolve, reject) => {
 

+ 17 - 5
src/views/home/index.vue

@@ -103,16 +103,14 @@ export default {
         2: '离线中'
       },
       truckList: [],
-      markers: []
+      markers: [],
+      setTimeValue: null
     }
   },
   watch: {},
   computed: {},
   created() {
-    this.dragendPointer()
-    this.timer = setInterval(() => {
-      this.dragendPointer()
-    }, 60000)
+    this.initData()
   },
   mounted() {
     // 重置地图高度
@@ -122,6 +120,20 @@ export default {
     clearInterval(this.timer)
   },
   methods: {
+    initData() {
+      console.log(window.iframeTruckStatus)
+      if (window.iframeTruckStatus) {
+        clearTimeout(this.setTimeValue)
+        this.dragendPointer()
+        this.timer = setInterval(() => {
+          this.dragendPointer()
+        }, 60000)
+      } else {
+        this.setTimeValue = setTimeout(() => {
+          this.initData()
+        }, 200)
+      }
+    },
     async queryCurrAddress(location) {
       const data = await axios.post(process.env.VUE_APP_BAIDU_URL + '?output=json&ak=Zvd6FzmertUwjhZih5Zfq0D8uTUhvqsH&coordtype=wgs84ll&location=' + location).then(response => {
         return response.data

+ 1 - 1
src/views/home/trail.vue

@@ -234,7 +234,7 @@ export default {
       const max = this.slider.max
       let tmpSoliderValue = Number(this.slider.value)
 
-      console.log(len, tmpSoliderValue)
+      this.center = [this.lushu.path[this.lushu.i].lng, this.lushu.path[this.lushu.i].lat]
       if (len > 0) {
         tmpSoliderValue = tmpSoliderValue > max * (index / len) ? tmpSoliderValue : max * (index / len)
         tmpSoliderValue += (index / (len * 10))