Bläddra i källkod

页面bug修改+本地存储优化

yuwenjun1997 3 år sedan
förälder
incheckning
7b68e04689
41 ändrade filer med 483 tillägg och 19480 borttagningar
  1. 3 2
      .env.development
  2. 6 3
      components/LdmLogin/index.vue
  3. 5 2
      components/SimpleLogin/index.vue
  4. 48 0
      components/SimpleVideoPlayer/index.vue
  5. 30 16
      layouts/app-ldm.vue
  6. 28 17
      layouts/app.vue
  7. 6 1
      nuxt.config.js
  8. 1 19204
      package-lock.json
  9. 12 4
      pages/_template/app/approve/club/detail.vue
  10. 43 35
      pages/_template/app/approve/club/index.vue
  11. 3 9
      pages/_template/app/approve/device/index.vue
  12. 4 9
      pages/_template/app/approve/device/list.vue
  13. 5 5
      pages/_template/app/approve/index.vue
  14. 1 1
      pages/_template/app/approve/personnel/operate/detail.vue
  15. 2 13
      pages/_template/app/approve/personnel/operate/index.vue
  16. 5 7
      pages/_template/app/database/article-detail.vue
  17. 4 6
      pages/_template/app/database/article.vue
  18. 8 7
      pages/_template/app/database/file.vue
  19. 7 5
      pages/_template/app/database/image.vue
  20. 8 7
      pages/_template/app/database/package.vue
  21. 53 10
      pages/_template/app/database/video.vue
  22. 2 3
      pages/_template/app/feedback/index.vue
  23. 5 5
      pages/_template/app/index.vue
  24. 11 8
      pages/_template/ldm/approve/club/detail.vue
  25. 43 37
      pages/_template/ldm/approve/club/index.vue
  26. 3 6
      pages/_template/ldm/approve/index.vue
  27. 5 7
      pages/_template/ldm/approve/personnel/training/detail.vue
  28. 3 3
      pages/_template/ldm/approve/personnel/training/index.vue
  29. 2 8
      pages/_template/ldm/database/package.vue
  30. 11 8
      pages/_template/ldm/index.vue
  31. 7 6
      pages/auth/index.vue
  32. 5 5
      plugins/axios.js
  33. 17 0
      plugins/storage.js
  34. 5 0
      store/app.js
  35. 4 1
      store/getters.js
  36. 8 17
      store/user.js
  37. 21 0
      utils/crypto.js
  38. 1 1
      utils/download-link.js
  39. 2 2
      utils/index.js
  40. 0 0
      utils/libs/crypto-js.min.js
  41. 46 0
      utils/storage.js

+ 3 - 2
.env.development

@@ -2,8 +2,9 @@
 EVN = 'development'
 
 # 网站地址
-LOCALHOSE = 'https://zp-b.caimei365.com'
+# LOCALHOSE = 'https://zp-b.caimei365.com'
 # LOCALHOSE = 'http://192.168.2.81:3000'
+LOCALHOSE = 'http://192.168.1.102:8888'
 
 # 接口api地址
 BASE_URL = 'https://zplma-b.caimei365.com'
@@ -16,7 +17,7 @@ STATIC_URL = 'https://static.caimei365.com/www/authentic'
 CIMEI_LOCAL = 'https://www-b.caimei365.com'
 
 # 项目运行地址
-HOST = '192.168.2.81'
+HOST = '192.168.1.102'
 
 # 项目端口号
 PORT = '8888'

+ 6 - 3
components/LdmLogin/index.vue

@@ -40,7 +40,7 @@
 import { mapGetters } from 'vuex'
 import { isMobile } from '@/utils/validator'
 export default {
-  name: 'ldm-login',
+  name: 'simple-login',
   data() {
     return {
       show: false,
@@ -54,7 +54,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['loginVisiable', 'appId', 'authUserId']),
+    ...mapGetters(['loginVisiable', 'authUserId', 'routePrefix']),
     sendCodeBtnText() {
       return this.sendStatus === 0
         ? '发送验证码'
@@ -72,11 +72,14 @@ export default {
         this.formData.authUserId = this.authUserId
         const res = await this.$http.api.customLogin(this.formData)
         this.$store.dispatch('user/login', res.data)
-        this.$store.commit('app/HIDE_LOGIN')
+        this.$setStorage(this.routePrefix, 'userInfo', res.data)
+        // 关闭登录窗口
+        this.onClose()
       } catch (error) {
         console.log(error)
       }
     },
+    // 关闭登录窗口
     onClose() {
       this.$store.commit('app/HIDE_LOGIN')
     },

+ 5 - 2
components/SimpleLogin/index.vue

@@ -50,7 +50,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['loginVisiable', 'authUserId']),
+    ...mapGetters(['loginVisiable', 'authUserId', 'routePrefix']),
     sendCodeBtnText() {
       return this.sendStatus === 0
         ? '发送验证码'
@@ -68,11 +68,14 @@ export default {
         this.formData.authUserId = this.authUserId
         const res = await this.$http.api.customLogin(this.formData)
         this.$store.dispatch('user/login', res.data)
-        this.$store.commit('app/HIDE_LOGIN')
+        this.$setStorage(this.routePrefix, 'userInfo', res.data)
+        // 关闭登录窗口
+        this.onClose()
       } catch (error) {
         console.log(error)
       }
     },
+    // 关闭登录窗口
     onClose() {
       this.$store.commit('app/HIDE_LOGIN')
     },

+ 48 - 0
components/SimpleVideoPlayer/index.vue

@@ -0,0 +1,48 @@
+<template>
+  <div class="simple-video-player">
+    <van-popup v-model="show" position="center" :closeable="true">
+      <div class="pupup-content">
+        <video :src="videoSrc" controls ref="video" class="video"></video>
+      </div>
+    </van-popup>
+  </div>
+</template>
+
+<script>
+export default {
+  props: {
+    videoSrc: {
+      type: String,
+      default: '',
+    },
+  },
+  data() {
+    return {
+      show: false,
+    }
+  },
+  watch: {
+    show(nVal) {
+      nVal ? this.$refs.video.play() : this.$refs.video.pause()
+    },
+  },
+  methods: {
+    open() {
+      this.show = false
+    },
+  },
+}
+</script>
+
+<style scoped lang="scss">
+.simple-video-player {
+  .pupup-content {
+    width: 100vw;
+    background: #000;
+  }
+  .video {
+    margin: 0 auto;
+    height: 100vh;
+  }
+}
+</style>

+ 30 - 16
layouts/app-ldm.vue

@@ -10,11 +10,17 @@
 </template>
 
 <script>
-import { getCookies } from '@/utils/auth'
 import { mapGetters } from 'vuex'
 export default {
   computed: {
-    ...mapGetters(['userInfo', 'type', 'accessToken', 'authUserId']),
+    ...mapGetters([
+      'userInfo',
+      'accessToken',
+      'authUserId',
+      'appId',
+      'accountType',
+      'routePrefix',
+    ]),
   },
   head() {
     return {
@@ -32,7 +38,6 @@ export default {
   },
   beforeDestroy() {
     window.removeEventListener('resize', () => {})
-    localStorage.removeItem('zp-locations')
   },
   methods: {
     init() {
@@ -41,19 +46,18 @@ export default {
     },
     // 初始化数据页面公共数据
     initPageData() {
-      const id = parseInt(this.$route.params.template)
-      // 保存页面入口
-      this.$store.commit('user/SET_TYPE', `${id}/ldm`)
+      // 获取供应商id
+      const authUserId = parseInt(this.$route.params.template)
+      const routePrefix = `/${authUserId}/ldm`
+      // 保存页面路由前缀
+      this.$store.commit('app/SET_ROUTE_PREFIX', routePrefix)
       // 保存用户AppId
-      this.$store.commit('user/SET_AUTHUSERID', id)
+      this.$store.commit('user/SET_AUTH_USER_ID', authUserId)
 
       // 获取用户信息
-      let userInfo = getCookies('userInfo')
-      if (userInfo) {
-        userInfo = JSON.parse(userInfo)
-        if (userInfo.authUserId === id) {
-          this.$store.commit('user/SET_USERINFO', userInfo)
-        }
+      let userInfo = this.$getStorage(routePrefix, 'userInfo')
+      if (userInfo && userInfo.authUserId === authUserId) {
+        this.$store.commit('user/SET_USER_INFO', userInfo)
       }
       // 初始化供应商信息
       this.fetchSupplierInfo()
@@ -67,6 +71,7 @@ export default {
         })
         this.$store.commit('supplier/SET_SUPPLIER_INFO', res.data)
         this.$store.commit('user/SET_APPID', res.data.appId)
+        // 如果appId存在
         if (res.data.appId) {
           this.checkAccountType(res.data.appId)
         }
@@ -74,6 +79,8 @@ export default {
         console.log(error)
       } finally {
         this.isMounted = true
+        // 清除缓存
+        this.refreshCacheData()
       }
     },
 
@@ -91,13 +98,15 @@ export default {
     // 退出登录
     logout() {
       this.$store.dispatch('user/logout')
+      console.log(this.routePrefix)
+      this.$removeStorage(this.routePrefix, 'userInfo')
+      this.backHome()
     },
 
     // 回到首页
     backHome() {
-      const url = '/' + this.type
-      if (this.$route.path === url) return
-      this.$router.replace(url)
+      if (this.$route.path === this.routePrefix) return
+      this.$router.replace(this.routePrefix)
     },
 
     // 响应页面宽度变化
@@ -107,6 +116,11 @@ export default {
         this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
       })
     },
+
+    // 数据初始化刷新浏览器
+    refreshCacheData() {
+      this.$removeStorage(this.routePrefix, 'club_list_data')
+    },
   },
 }
 </script>

+ 28 - 17
layouts/app.vue

@@ -35,7 +35,6 @@
 </template>
 
 <script>
-import { getCookies } from '@/utils/auth'
 import { mapGetters } from 'vuex'
 import { isWeChat } from '~/utils/validator'
 import { toAuthorization } from '~/utils'
@@ -43,11 +42,11 @@ export default {
   computed: {
     ...mapGetters([
       'userInfo',
-      'type',
       'accessToken',
       'authUserId',
       'appId',
       'accountType',
+      'routePrefix',
     ]),
   },
   head() {
@@ -62,10 +61,10 @@ export default {
   },
   mounted() {
     this.init()
+    console.log(1)
   },
   beforeDestroy() {
     window.removeEventListener('resize', () => {})
-    localStorage.removeItem('zp-locations')
   },
   methods: {
     init() {
@@ -74,19 +73,18 @@ export default {
     },
     // 初始化数据页面公共数据
     initPageData() {
-      const id = parseInt(this.$route.params.template)
-      // 保存页面入口
-      this.$store.commit('user/SET_TYPE', `${id}/app`)
+      // 获取供应商id
+      const authUserId = parseInt(this.$route.params.template)
+      const routePrefix = `/${authUserId}/app`
+      // 保存页面路由前缀
+      this.$store.commit('app/SET_ROUTE_PREFIX', routePrefix)
       // 保存用户AppId
-      this.$store.commit('user/SET_AUTHUSERID', id)
+      this.$store.commit('user/SET_AUTH_USER_ID', authUserId)
 
       // 获取用户信息
-      let userInfo = getCookies('userInfo')
-      if (userInfo) {
-        userInfo = JSON.parse(userInfo)
-        if (userInfo.authUserId === id) {
-          this.$store.commit('user/SET_USERINFO', userInfo)
-        }
+      let userInfo = this.$getStorage(routePrefix, 'userInfo')
+      if (userInfo && userInfo.authUserId === authUserId) {
+        this.$store.commit('user/SET_USER_INFO', userInfo)
       }
       // 初始化供应商信息
       this.fetchSupplierInfo()
@@ -100,6 +98,7 @@ export default {
         })
         this.$store.commit('supplier/SET_SUPPLIER_INFO', res.data)
         this.$store.commit('user/SET_APPID', res.data.appId)
+        // 如果appId存在
         if (res.data.appId) {
           this.checkAccountType(res.data.appId)
         }
@@ -107,6 +106,8 @@ export default {
         console.log(error)
       } finally {
         this.isMounted = true
+        // 清除缓存
+        this.refreshCacheData()
       }
     },
 
@@ -124,7 +125,10 @@ export default {
     onLogin() {
       // 在微信浏览器中使用微信授权登录
       if (isWeChat() && this.appId && this.accountType === 2) {
-        const payload = { authUserId: this.authUserId, type: this.type }
+        const payload = {
+          authUserId: this.authUserId,
+          routePrefix: this.routePrefix,
+        }
         return toAuthorization(this.appId, payload)
       }
       this.$store.commit('app/SHOW_LOGIN')
@@ -133,13 +137,15 @@ export default {
     // 退出登录
     logout() {
       this.$store.dispatch('user/logout')
+      console.log(this.routePrefix)
+      this.$removeStorage(this.routePrefix, 'userInfo')
+      this.backHome()
     },
 
     // 回到首页
     backHome() {
-      const url = '/' + this.type
-      if (this.$route.path === url) return
-      this.$router.replace(url)
+      if (this.$route.path === this.routePrefix) return
+      this.$router.replace(this.routePrefix)
     },
 
     // 响应页面宽度变化
@@ -149,6 +155,11 @@ export default {
         this.$store.commit('app/SET_SCREEN', e.target.innerWidth)
       })
     },
+
+    // 数据初始化刷新浏览器
+    refreshCacheData() {
+      this.$removeStorage(this.routePrefix, 'club_list_data')
+    },
   },
 }
 </script>

+ 6 - 1
nuxt.config.js

@@ -35,7 +35,12 @@ export default {
   css: ['vant/lib/index.css', 'swiper/css/swiper.css'],
 
   // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
-  plugins: ['@/plugins/vant', '@/plugins/axios', '@/plugins/vue-filters'],
+  plugins: [
+    '@/plugins/vant',
+    '@/plugins/axios',
+    '@/plugins/vue-filters',
+    '@/plugins/storage',
+  ],
 
   // Auto import components: https://go.nuxtjs.dev/config-components
   components: true,

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 19204
package-lock.json


+ 12 - 4
pages/_template/app/approve/club/detail.vue

@@ -20,6 +20,7 @@
           <div class="navigation" @click="onMapNav">导航</div>
           <div
             class="distance"
+            v-if="clubInfo.distance"
             v-text="'距你' + clubInfo.distance + 'km'"
           ></div>
         </div>
@@ -55,6 +56,7 @@
 <script>
 import { drawLogo } from '@/utils'
 import { mapNavigate } from '@/utils/map-utils'
+import { mapGetters } from 'vuex'
 export default {
   layout: 'app',
   filters: {
@@ -73,6 +75,7 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['routePrefix']),
     address() {
       return this.clubInfo.area + this.clubInfo.address || '未知'
     },
@@ -85,6 +88,9 @@ export default {
   mounted() {
     this.initData()
   },
+  beforeDestroy() {
+    this.$removeStorage(this.routePrefix, 'clubInfo')
+  },
   methods: {
     // 设备详情
     toDetail(item) {
@@ -92,12 +98,12 @@ export default {
     },
     // 初始化
     initData() {
-      this.authId = this.$route.query.id
-      const clubInfo = localStorage.getItem('clubInfo')
+      this.authId = parseInt(this.$route.query.id)
+      const clubInfo = this.$getStorage(this.routePrefix, 'clubInfo')
       if (clubInfo) {
-        this.clubInfo = JSON.parse(clubInfo)
-        this.fetchDetail()
+        this.clubInfo = clubInfo
       }
+      this.fetchDetail()
     },
     // 获取机构详细信息
     async fetchDetail() {
@@ -109,9 +115,11 @@ export default {
       } catch (error) {
         console.log(error)
       }
+      // 默认轮播图
       if (this.clubInfo.bannerList.length <= 0) {
         this.clubInfo.bannerList.push('/placeholder.png')
       }
+      // 默认logo
       if (!this.clubInfo.logo) {
         this.clubInfo.logo = drawLogo(this.clubInfo.authParty)
       }

+ 43 - 35
pages/_template/app/approve/club/index.vue

@@ -100,56 +100,72 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['supplierInfo', 'authUserId', 'authUserId']),
+    ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
     emptyList() {
       return 3 - (this.list.length % 3)
     },
   },
   mounted() {
-    this.initData()
-    this.fetchCityList()
+    const cacheData = this.$getStorage(this.routePrefix, 'club_list_data')
+    if (cacheData) {
+      this.initFromCache(cacheData)
+    } else {
+      this.initData()
+      this.fetchCityList()
+    }
+  },
+  beforeDestroy() {
+    this.$setStorage(this.routePrefix, 'club_list_data', this.$data, {
+      expiredTime: 5 * 60 * 1000,
+    })
+    this.$toast.clear()
   },
   methods: {
     // 绘制logo的方法
     drawLogo,
     // 查看详情
     toDetail(item) {
-      localStorage.setItem('clubInfo', JSON.stringify(item))
-      const url = `/${this.authUserId}/app/approve/club/detail?id=${item.authId}`
+      this.$setStorage(this.routePrefix, 'clubInfo', item)
+      const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
       this.$router.push(url)
     },
+    // 从缓存中获取数据
+    initFromCache(cacheData) {
+      this.isLoadingMore = cacheData.isLoadingMore
+      this.finished = cacheData.finished
+      this.isRequest = cacheData.isRequest
+      this.list = cacheData.list
+      this.listQuery = cacheData.listQuery
+      this.total = cacheData.total
+      this.cityList = cacheData.cityList
+    },
     // 初始化页面数据
     async initData() {
+      this.listQuery.authUserId = this.authUserId
+
       // 自定义加载图标
       this.$toast.loading({
         message: '正在获取您附近的机构...',
         duration: 0,
       })
-      const locations = localStorage.getItem('zp-locations')
 
-      if (!locations) {
-        // 获取定位信息 百度坐标转高德坐标
-        try {
-          const location = await loactionSelf()
-          const result = await this.$http.api.assistant({
-            key: '1bcc97330f6cf517e8dd9d5278957e67',
-            locations: `${location.point.lng},${location.point.lat}`,
-            coordsys: 'baidu',
-            output: 'JSON',
-          })
-          const res = await result.json()
-          this.listQuery.lngAndLat = res.locations
-          localStorage.setItem('zp-locations', res.locations)
-        } catch (error) {
-          this.$toast.clear()
-          this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
-          this.isRequest = false
-        }
-      } else {
-        this.listQuery.lngAndLat = locations
+      // 获取定位信息 百度坐标转高德坐标
+      try {
+        const location = await loactionSelf()
+        const result = await this.$http.api.assistant({
+          key: '1bcc97330f6cf517e8dd9d5278957e67',
+          locations: `${location.point.lng},${location.point.lat}`,
+          coordsys: 'baidu',
+          output: 'JSON',
+        })
+        const res = await result.json()
+        this.listQuery.lngAndLat = res.locations
+      } catch (error) {
+        this.$toast.clear()
+        this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
+        this.isRequest = false
       }
 
-      this.listQuery.authUserId = this.authUserId
       // 获取机构列表
       this.fetchList()
     },
@@ -200,11 +216,6 @@ export default {
       this.list = []
       this.fetchList()
     },
-    // 页码变化
-    onPagiantionChange(index) {
-      this.listQuery.pageNum = index
-      this.fetchList()
-    },
     // 格式化地址
     formatAddress(a1, a2) {
       let resutl = ''
@@ -221,9 +232,6 @@ export default {
       this.fetchList()
     },
   },
-  beforeDestroy() {
-    this.$toast.clear()
-  },
 }
 </script>
 

+ 3 - 9
pages/_template/app/approve/device/index.vue

@@ -73,7 +73,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['supplierInfo', 'authUserId', 'authUserId']),
+    ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
     emptyList() {
       return 3 - (this.list.length % 3)
     },
@@ -102,9 +102,8 @@ export default {
 
     // 设备详情
     toDetail(item) {
-      this.$router.push(
-        `/${this.authUserId}/app/approve/device/list?id=${item.productTypeId}`
-      )
+      const url = `${this.routePrefix}/approve/device/list?id=${item.productTypeId}`
+      this.$router.push(url)
     },
     // 搜索
     onSearch() {
@@ -112,11 +111,6 @@ export default {
       this.list = []
       this.fetchList()
     },
-    // 页码变化
-    onPagiantionChange(index) {
-      this.listQuery.pageNum = index
-      this.fetchList()
-    },
     // 加载更多
     onLoadMore() {
       this.fetchList()

+ 4 - 9
pages/_template/app/approve/device/list.vue

@@ -60,6 +60,7 @@
 
 <script>
 import { debounce } from '@/utils'
+import { mapGetters } from 'vuex'
 export default {
   layout: 'app',
   data() {
@@ -78,6 +79,7 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['routePrefix']),
     isEmpty() {
       return this.list.length === 0
     },
@@ -90,7 +92,7 @@ export default {
   },
   methods: {
     initData() {
-      this.listQuery.productTypeId = this.$route.query.id
+      this.listQuery.productTypeId = parseInt(this.$route.query.id)
       this.fetchList()
     },
     fetchList: debounce(async function () {
@@ -113,20 +115,13 @@ export default {
       this.listQuery.pageNum = 1
       this.fetchList()
     },
-    // 页码变化
-    onPagiantionChange(index) {
-      this.listQuery.pageNum = index
-      this.fetchList()
-    },
     // 设备详情
     toDetail(item) {
       window.location.href = `${process.env.CIMEI_LOCAL}/product/auth/product-${item.productId}.html`
     },
     // 机构详情
     toClubDetail(item) {
-      localStorage.setItem('clubInfo', JSON.stringify({ authId: item.authId }))
-      const authUserId = this.$store.getters.authUserId
-      const url = `/${authUserId}/app/approve/club/detail?id=${item.authId}`
+      const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
       this.$router.push(url)
     },
     // 加载更多

+ 5 - 5
pages/_template/app/approve/index.vue

@@ -37,29 +37,29 @@ export default {
           id: 1,
           name: '机构认证',
           image: 'icon-club.png',
-          path: '/app/approve/club',
+          path: '/approve/club',
         },
         {
           id: 2,
           name: '设备认证',
           image: 'icon-device.png',
-          path: '/app/approve/device',
+          path: '/approve/device',
         },
         {
           id: 3,
           name: '医师认证',
           image: 'icon-doctor.png',
-          path: '/app/approve/personnel/operate',
+          path: '/approve/personnel/operate',
         },
       ],
     }
   },
   computed: {
-    ...mapGetters(['supplierInfo', 'authUserId']),
+    ...mapGetters(['supplierInfo', 'routePrefix']),
   },
   methods: {
     toDetail(item) {
-      const url = `/${this.authUserId}${item.path}`
+      const url = this.routePrefix + item.path
       this.$router.push(url)
     },
   },

+ 1 - 1
pages/_template/app/approve/personnel/operate/detail.vue

@@ -63,7 +63,7 @@ export default {
   },
   methods: {
     initData() {
-      this.doctorId = this.$route.query.id
+      this.doctorId = parseInt(this.$route.query.id)
       this.fetchDetail()
     },
     async fetchDetail() {

+ 2 - 13
pages/_template/app/approve/personnel/operate/index.vue

@@ -79,7 +79,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['supplierInfo', 'authUserId', 'authUserId']),
+    ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
     isEmpty() {
       return this.list.length === 0
     },
@@ -114,20 +114,9 @@ export default {
       this.listQuery.pageNum = 1
       this.fetchList()
     },
-    // 页码变化
-    onPagiantionChange(index) {
-      this.listQuery.pageNum = index
-      this.fetchList()
-    },
-    // 机构详情
-    toClubDetail(item) {
-      localStorage.setItem('clubInfo', JSON.stringify({ authId: item.authId }))
-      const url = `/${this.authUserId}/app/approve/club/detail`
-      this.$router.push(url)
-    },
     // 医师详情
     toDetail(item) {
-      const url = `/${this.authUserId}/app/approve/personnel/operate/detail?id=${item.doctorId}`
+      const url = `${this.routePrefix}/approve/personnel/operate/detail?id=${item.doctorId}`
       this.$router.push(url)
     },
     // 加载更多

+ 5 - 7
pages/_template/app/database/article-detail.vue

@@ -13,6 +13,7 @@ export default {
   layout: 'app',
   data() {
     return {
+      articleId: '',
       articleInfo: {},
       imageList: [],
     }
@@ -31,18 +32,15 @@ export default {
   },
   methods: {
     initData() {
-      const articleInfo = localStorage.getItem('articleInfo')
-      if (articleInfo) {
-        this.articleInfo = JSON.parse(articleInfo)
-        this.fetchArticleDetail()
-      }
+      this.articleId = parseInt(this.$route.query.id)
+      this.fetchArticleDetail()
     },
     async fetchArticleDetail() {
       try {
         const res = await this.$http.api.getArticleDetail({
-          articleId: this.articleInfo.articleId,
+          articleId: this.articleId,
         })
-        this.articleInfo = { ...this.articleInfo, ...res.data }
+        this.articleInfo = res.data
       } catch (error) {
         console.log(error)
       }

+ 4 - 6
pages/_template/app/database/article.vue

@@ -81,7 +81,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['userInfo', 'supplierInfo', 'authUserId']),
+    ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
   },
   mounted() {
     this.fetchList()
@@ -90,7 +90,7 @@ export default {
     fetchList: debounce(async function () {
       try {
         this.isLoadingMore = true
-        this.listQuery.authUserId = this.userInfo.authUserId
+        this.listQuery.authUserId = this.authUserId
         const res = await this.$http.api.getArticleList(this.listQuery)
         this.list = [...this.list, ...res.data.list]
         this.finished = !res.data.hasNextPage
@@ -106,14 +106,12 @@ export default {
 
     // 详情
     toDetail(item) {
-      localStorage.setItem('articleInfo', JSON.stringify(item))
-      const url = `/${this.authUserId}/app/database/article-detail`
+      const url = `${this.routePrefix}/database/article-detail?id=${item.articleId}`
       this.$router.push(url)
     },
     // tab切换
     onTabChange(item) {
-      console.log(item)
-      this.$router.push(`/${this.authUserId}/app${item.path}`)
+      this.$router.push(`${this.routePrefix}${item.path}`)
     },
     // 搜索
     onSearch(keyword) {

+ 8 - 7
pages/_template/app/database/file.vue

@@ -41,7 +41,9 @@
             <div class="info">
               <div class="name" v-text="item.fileName"></div>
               <div class="date">{{ item.createTime | dateFormat }}</div>
-              <div class="download" @click.stop="downloadLink(item)">下载</div>
+              <div class="download" @click.stop="downloadLink(item, $event)">
+                下载
+              </div>
             </div>
           </div>
         </div>
@@ -82,16 +84,16 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['userInfo', 'supplierInfo', 'authUserId']),
+    ...mapGetters(['routePrefix', 'supplierInfo', 'authUserId']),
   },
   mounted() {
     this.fetchList()
   },
   methods: {
     // 下载方法
-    downloadLink(item) {
+    downloadLink(item, $event) {
       const url = `${process.env.BASE_URL}/download/file?ossName=${item.fileDownloadUrl}&fileName=${item.fileName}`
-      downloadLink(url)
+      downloadLink(url, $event)
     },
     // 预览文件
     previewFile(item) {
@@ -101,7 +103,7 @@ export default {
     fetchList: debounce(async function () {
       try {
         this.isLoadingMore = true
-        this.listQuery.authUserId = this.userInfo.authUserId
+        this.listQuery.authUserId = this.authUserId
         const res = await this.$http.api.getFileList(this.listQuery)
         this.list = [...this.list, ...res.data.list]
         this.finished = !res.data.hasNextPage
@@ -116,8 +118,7 @@ export default {
     }, 400),
     // tab切换
     onTabChange(item) {
-      console.log(item)
-      this.$router.push(`/${this.authUserId}/app${item.path}`)
+      this.$router.push(`${this.routePrefix}${item.path}`)
     },
     // 搜索
     onSearch(keyword) {

+ 7 - 5
pages/_template/app/database/image.vue

@@ -36,7 +36,10 @@
             <div class="info">
               <div class="name" v-text="item.imageTitle"></div>
               <div class="date">{{ item.createTime | dateFormat }}</div>
-              <div class="download" @click="downloadLink(item.imageZipUrl)">
+              <div
+                class="download"
+                @click="downloadLink(item.imageZipUrl, $event)"
+              >
                 保存所有图片
               </div>
             </div>
@@ -89,7 +92,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['userInfo', 'supplierInfo', 'authUserId']),
+    ...mapGetters(['routePrefix', 'supplierInfo', 'authUserId']),
   },
   mounted() {
     this.fetchList()
@@ -101,7 +104,7 @@ export default {
     fetchList: debounce(async function () {
       try {
         this.isLoadingMore = true
-        this.listQuery.authUserId = this.userInfo.authUserId
+        this.listQuery.authUserId = this.authUserId
         const res = await this.$http.api.getImageList(this.listQuery)
         this.list = [...this.list, ...res.data.list]
         this.finished = !res.data.hasNextPage
@@ -128,8 +131,7 @@ export default {
     },
     // tab切换
     onTabChange(item) {
-      console.log(item)
-      this.$router.push(`/${this.authUserId}/app${item.path}`)
+      this.$router.push(`${this.routePrefix}${item.path}`)
     },
     // 搜索
     onSearch(keyword) {

+ 8 - 7
pages/_template/app/database/package.vue

@@ -39,7 +39,9 @@
           >
             <div class="info">
               <div class="name" v-text="item.fileName"></div>
-              <div class="download" @click="downloadLink(item)">点击下载</div>
+              <div class="download" @click="downloadLink(item, $event)">
+                点击下载
+              </div>
             </div>
           </div>
         </div>
@@ -81,22 +83,22 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['userInfo', 'supplierInfo', 'authUserId']),
+    ...mapGetters(['routePrefix', 'supplierInfo', 'authUserId']),
   },
   mounted() {
     this.fetchList()
   },
   methods: {
     // 下载方法
-    downloadLink(item) {
+    downloadLink(item, $event) {
       const url = `${process.env.BASE_URL}/download/file?ossName=${item.fileDownloadUrl}&fileName=${item.fileName}`
-      downloadLink(url)
+      downloadLink(url, $event)
     },
     // 获取列表
     fetchList: debounce(async function () {
       try {
         this.isLoadingMore = true
-        this.listQuery.authUserId = this.userInfo.authUserId
+        this.listQuery.authUserId = this.authUserId
         const res = await this.$http.api.getFileList(this.listQuery)
         this.list = [...this.list, ...res.data.list]
         this.finished = !res.data.hasNextPage
@@ -112,8 +114,7 @@ export default {
 
     // tab切换
     onTabChange(item) {
-      console.log(item)
-      this.$router.push(`/${this.authUserId}/app${item.path}`)
+      this.$router.push(`${this.routePrefix}${item.path}`)
     },
     // 搜索
     onSearch(keyword) {

+ 53 - 10
pages/_template/app/database/video.vue

@@ -40,9 +40,14 @@
             <div class="info">
               <div class="name" v-text="item.videoTitle"></div>
               <div class="date">{{ item.createTime | dateFormat }}</div>
-              <div class="download" @click="downloadLink(item)">保存视频</div>
+              <div class="download" @click="downloadLink(item, $event)">
+                保存视频
+              </div>
+            </div>
+            <div class="cover">
+              <video class="cover" src="123"></video>
+              <span @click="onPlayer"></span>
             </div>
-            <video class="cover" :src="item.videoPreviewUrl"></video>
           </div>
         </div>
 
@@ -53,6 +58,8 @@
         ></SimpleEmpty>
       </div>
     </van-list>
+
+    <SimpleVideoPlayer ref="player"></SimpleVideoPlayer>
   </div>
 </template>
 
@@ -77,27 +84,33 @@ export default {
         pageNum: 1,
         pageSize: 4,
       },
-      list: [],
+      list: [{}],
       total: 0,
+      videoUrl: '',
     }
   },
   computed: {
-    ...mapGetters(['userInfo', 'supplierInfo', 'authUserId']),
+    ...mapGetters(['routePrefix', 'supplierInfo', 'authUserId']),
   },
   mounted() {
     this.fetchList()
   },
   methods: {
+    // 视频在线播放
+    onPlayer(item) {
+      this.videoUrl = item.videoPreviewUrl
+      this.$refs.player.open()
+    },
     // 下载方法
-    downloadLink(item) {
+    downloadLink(item, $event) {
       const url = `${process.env.BASE_URL}/download/file?ossName=${item.videoDownloadUrl}&fileName=${item.videoName}`
-      downloadLink(url)
+      downloadLink(url, $event)
     },
     // 获取列表
     fetchList: debounce(async function () {
       try {
         this.isLoadingMore = true
-        this.listQuery.authUserId = this.userInfo.authUserId
+        this.listQuery.authUserId = this.authUserId
         const res = await this.$http.api.getVideoList(this.listQuery)
         this.list = [...this.list, ...res.data.list]
         this.finished = !res.data.hasNextPage
@@ -113,8 +126,7 @@ export default {
 
     // tab切换
     onTabChange(item) {
-      console.log(item)
-      this.$router.push(`/${this.authUserId}/app${item.path}`)
+      this.$router.push(`${this.routePrefix}${item.path}`)
     },
     // 搜索
     onSearch(keyword) {
@@ -215,9 +227,24 @@ export default {
       }
 
       .cover {
+        position: relative;
         width: 216px;
         height: 132px;
-        border-bottom: 1px solid #d8d8d8;
+        background: #333;
+        span {
+          position: absolute;
+          width: 36px;
+          height: 36px;
+          top: 50%;
+          left: 50%;
+          transform: translate(-50%, -50%);
+          background: url(https://static.caimei365.com/www/authentic/h5/icon-play.png)
+            no-repeat center;
+          background-size: 36px;
+          border-radius: 50%;
+          cursor: pointer;
+          box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
+        }
       }
     }
   }
@@ -299,9 +326,25 @@ export default {
       }
 
       .cover {
+        position: relative;
         width: 92vw;
         height: 56vw;
         border-bottom: 0.1vw solid #d8d8d8;
+        background: #333;
+        span {
+          position: absolute;
+          width: 12vw;
+          height: 12vw;
+          top: 50%;
+          left: 50%;
+          transform: translate(-50%, -50%);
+          background: url(https://static.caimei365.com/www/authentic/h5/icon-play.png)
+            no-repeat center;
+          background-size: 12vw;
+          border-radius: 50%;
+          cursor: pointer;
+          box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
+        }
       }
     }
   }

+ 2 - 3
pages/_template/app/feedback/index.vue

@@ -38,7 +38,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['supplierInfo', 'userInfo', 'authUserId', 'type']),
+    ...mapGetters(['supplierInfo', 'userInfo', 'routeProfix']),
     isEmpty() {
       return this.content.length === 0
     },
@@ -60,8 +60,7 @@ export default {
     },
     onConfirm() {
       this.showModal = false
-      const url = `/${this.type}`
-      this.$router.push(url)
+      this.$router.push(this.routeProfix)
     },
   },
 }

+ 5 - 5
pages/_template/app/index.vue

@@ -48,7 +48,7 @@ export default {
           name: '授权认证',
           image: 'icon-approve.png',
           hover: 'icon-approve-active.png',
-          path: '/app/approve',
+          path: '/approve',
           active: false,
         },
         {
@@ -56,7 +56,7 @@ export default {
           name: '资料库',
           image: 'icon-doc.png',
           hover: 'icon-doc-active.png',
-          path: '/app/database/article',
+          path: '/database/article',
           active: false,
         },
         {
@@ -64,7 +64,7 @@ export default {
           name: '意见反馈',
           image: 'icon-feedback.png',
           hover: 'icon-feedback-active.png',
-          path: '/app/feedback',
+          path: '/feedback',
           active: false,
         },
       ],
@@ -75,7 +75,7 @@ export default {
       'supplierInfo',
       'authUserId',
       'appId',
-      'type',
+      'routePrefix',
       'accountType',
     ]),
   },
@@ -93,7 +93,7 @@ export default {
         this.$store.commit('app/SHOW_LOGIN')
         return
       }
-      const url = `/${this.authUserId}${item.path}`
+      const url = this.routePrefix + item.path
       this.$router.push(url)
     },
     onMouseover(item) {

+ 11 - 8
pages/_template/ldm/approve/club/detail.vue

@@ -43,6 +43,7 @@
 <script>
 import { drawLogo } from '@/utils'
 import { mapNavigate } from '@/utils/map-utils'
+import { mapGetters } from 'vuex'
 export default {
   layout: 'app-ldm',
   filters: {
@@ -57,6 +58,7 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['routePrefix']),
     address() {
       return this.clubInfo.area + this.clubInfo.address || '未知'
     },
@@ -69,21 +71,22 @@ export default {
   mounted() {
     this.initData()
   },
+  beforeDestroy() {
+    this.$removeStorage(this.routePrefix, 'clubInfo')
+  },
   methods: {
     toDetail(row) {
-      const authUserId = this.$store.getters.authUserId
-      this.$router.push(
-        `/${authUserId}/ldm/approve/personnel/operate/detail?id=${row.doctorId}`
-      )
+      const url = `${this.routePrefix}/approve/personnel/operate/detail?id=${row.doctorId}`
+      this.$router.push(url)
     },
     // 初始化
     initData() {
-      this.authId = this.$route.query.id
-      const clubInfo = localStorage.getItem('clubInfo')
+      this.authId = parseInt(this.$route.query.id)
+      const clubInfo = this.$getStorage(this.routePrefix, 'clubInfo')
       if (clubInfo) {
-        this.clubInfo = JSON.parse(clubInfo)
-        this.fetchDetail()
+        this.clubInfo = clubInfo
       }
+      this.fetchDetail()
     },
     // 获取机构详细信息
     async fetchDetail() {

+ 43 - 37
pages/_template/ldm/approve/club/index.vue

@@ -87,59 +87,71 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['supplierInfo', 'authUserId']),
+    ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
     emptyList() {
       return 3 - (this.list.length % 3)
     },
   },
   mounted() {
-    this.initData()
-    this.fetchCityList()
+    const cacheData = this.$getStorage(this.routePrefix, 'club_list_data')
+    if (cacheData) {
+      this.initFromCache(cacheData)
+    } else {
+      this.initData()
+      this.fetchCityList()
+    }
+  },
+  beforeDestroy() {
+    this.$setStorage(this.routePrefix, 'club_list_data', this.$data, {
+      expiredTime: 5 * 60 * 1000,
+    })
+    this.$toast.clear()
   },
   methods: {
     // 绘制logo的方法
     drawLogo,
     // 查看详情
     toDetail(item) {
-      localStorage.setItem('clubInfo', JSON.stringify(item))
-      const authUserId = this.$store.getters.authUserId
-      this.$router.push(
-        `/${authUserId}/ldm/approve/club/detail?id=${item.authId}`
-      )
+      this.$setStorage(this.routePrefix, 'clubInfo', item)
+      const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
+      this.$router.push(url)
+    },
+    // 从缓存中获取数据
+    initFromCache(cacheData) {
+      this.isLoadingMore = cacheData.isLoadingMore
+      this.finished = cacheData.finished
+      this.isRequest = cacheData.isRequest
+      this.list = cacheData.list
+      this.listQuery = cacheData.listQuery
+      this.total = cacheData.total
+      this.cityList = cacheData.cityList
     },
     // 初始化页面数据
     async initData() {
+      this.listQuery.authUserId = this.authUserId
       // 自定义加载图标
       this.$toast.loading({
         message: '正在获取您附近的机构...',
         duration: 0,
       })
 
-      const locations = localStorage.getItem('zp-locations')
-
-      if (!locations) {
-        // 获取定位信息 百度坐标转高德坐标
-        try {
-          const location = await loactionSelf()
-          const result = await this.$http.api.assistant({
-            key: '1bcc97330f6cf517e8dd9d5278957e67',
-            locations: `${location.point.lng},${location.point.lat}`,
-            coordsys: 'baidu',
-            output: 'JSON',
-          })
-          const res = await result.json()
-          this.listQuery.lngAndLat = res.locations
-          localStorage.setItem('zp-locations', res.locations)
-        } catch (error) {
-          this.$toast.clear()
-          this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
-          this.isRequest = false
-        }
-      } else {
-        this.listQuery.lngAndLat = locations
+      // 获取定位信息 百度坐标转高德坐标
+      try {
+        const location = await loactionSelf()
+        const result = await this.$http.api.assistant({
+          key: '1bcc97330f6cf517e8dd9d5278957e67',
+          locations: `${location.point.lng},${location.point.lat}`,
+          coordsys: 'baidu',
+          output: 'JSON',
+        })
+        const res = await result.json()
+        this.listQuery.lngAndLat = res.locations
+      } catch (error) {
+        this.$toast.clear()
+        this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
+        this.isRequest = false
       }
 
-      this.listQuery.authUserId = this.authUserId
       // 获取机构列表
       this.fetchList()
     },
@@ -192,8 +204,6 @@ export default {
       this.list = []
       this.fetchList()
     },
-    // 页码变化
-    onPagiantionChange(index) {},
     // 格式化地址
     formatAddress(a1, a2) {
       let resutl = ''
@@ -207,13 +217,9 @@ export default {
     },
     // 加载更多
     onLoadMore() {
-      if (this.isRequest) return
       this.fetchList()
     },
   },
-  beforeDestroy() {
-    this.$toast.clear()
-  },
 }
 </script>
 

+ 3 - 6
pages/_template/ldm/approve/index.vue

@@ -20,16 +20,13 @@
         </div>
       </div>
       <div class="entry">
-        <div
-          class="section"
-          @click="toDetail(`/${authUserId}/ldm/approve/club`)"
-        >
+        <div class="section" @click="toDetail(`${routePrefix}/approve/club`)">
           查询授权商家
         </div>
         <div
           v-if="false"
           class="section"
-          @click="toDetail(`/${authUserId}/ldm/approve/personnel/training`)"
+          @click="toDetail(`${routePrefix}/approve/personnel/training`)"
         >
           > 查询官方培训师
         </div>
@@ -47,7 +44,7 @@ import { mapGetters } from 'vuex'
 export default {
   layout: 'app-ldm',
   computed: {
-    ...mapGetters(['authUserId']),
+    ...mapGetters(['routePrefix']),
   },
   methods: {
     toDetail(path) {

+ 5 - 7
pages/_template/ldm/approve/personnel/training/detail.vue

@@ -30,6 +30,7 @@ export default {
   layout: 'app-ldm',
   data() {
     return {
+      doctorId: '',
       doctorInfo: {
         tagList: [],
         paramList: [],
@@ -41,18 +42,15 @@ export default {
   },
   methods: {
     initData() {
-      const doctorInfo = localStorage.getItem('doctorInfo')
-      if (doctorInfo) {
-        this.doctorInfo = JSON.parse(doctorInfo)
-        this.fetchDetail()
-      }
+      this.doctorId = parseInt(this.$route.query.id)
+      this.fetchDetail()
     },
     async fetchDetail() {
       try {
         const res = await this.$http.api.fetchDoctorDetail({
-          doctorId: this.doctorInfo.doctorId,
+          doctorId: this.doctorId,
         })
-        this.doctorInfo = { ...this.clubInfo, ...res.data }
+        this.doctorInfo = res.data
       } catch (error) {
         console.log(error)
       }

+ 3 - 3
pages/_template/ldm/approve/personnel/training/index.vue

@@ -52,7 +52,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['supplierInfo', 'authUserId']),
+    ...mapGetters(['authUserId', 'routePrefix']),
   },
   mounted() {
     this.fetchList()
@@ -92,9 +92,9 @@ export default {
     },
     // 医师详情
     toDetail(item) {
-      localStorage.setItem('doctorInfo', JSON.stringify(item))
       const authUserId = this.$store.getters.authUserId
-      this.$router.push(`/${authUserId}/ldm/approve/personnel/training/detail`)
+      const url = `${this.routePrefix}/approve/personnel/training/detail?id=${item.doctorId}`
+      this.$router.push(url)
     },
   },
 }

+ 2 - 8
pages/_template/ldm/database/package.vue

@@ -65,7 +65,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['userInfo', 'supplierInfo']),
+    ...mapGetters(['userInfo']),
   },
   mounted() {
     this.fetchList()
@@ -89,14 +89,8 @@ export default {
         this.listQuery.pageNum += 1
       } catch (error) {
         console.log(error)
-      } 
+      }
     }, 400),
-
-    // 页码变化
-    onPagiantionChange(index) {
-      this.listQuery.pageNum = index
-      this.fetchList()
-    },
     // 加载更多
     onLoadMore() {
       this.fetchList()

+ 11 - 8
pages/_template/ldm/index.vue

@@ -29,6 +29,7 @@
 <script>
 import { toAuthorization } from '~/utils'
 import { isWeChat } from '~/utils/validator'
+import { mapGetters } from 'vuex'
 export default {
   layout: 'app-ldm',
   data() {
@@ -43,35 +44,37 @@ export default {
           id: 0,
           name: '正品授权',
           image: 'ldm-icon-approve.png',
-          path: '/ldm/approve',
+          path: '/approve',
         },
         {
           id: 1,
           name: '官方产品资料',
           image: 'ldm-icon-database.png',
-          path: '/ldm/database/package',
+          path: '/database/package',
         },
       ],
     }
   },
 
+  computed: {
+    ...mapGetters(['authUserId', 'appId', 'routePrefix', 'accountType']),
+  },
+
   methods: {
     toDetail(item) {
       const hasLogin = this.$store.getters.accessToken
       if (item.id > 0 && !hasLogin) {
-        const appId = this.$store.getters.appId
-        const accountType = this.$store.getters.accountType
         // 在微信浏览器中使用微信授权登录
-        if (isWeChat() && appId && accountType === 2) {
+        if (isWeChat() && this.appId && this.accountType === 2) {
           const payload = { authUserId: this.authUserId, type: this.type }
-          return toAuthorization(appId, payload)
+          return toAuthorization(this.appId, payload)
         }
         this.$toast({ message: '请先登录', duration: 1000 })
         this.$store.commit('app/SHOW_LOGIN')
         return
       }
-      const authUserId = this.$store.getters.authUserId
-      this.$router.push(`/${authUserId}${item.path}`)
+      const url = this.routePrefix + item.path
+      this.$router.push(url)
     },
   },
 }

+ 7 - 6
pages/auth/index.vue

@@ -33,7 +33,7 @@ export default {
         mobile: '',
         verifyCode: '',
       },
-      path: '',
+      redirectPath: '',
       code: '',
     }
   },
@@ -51,11 +51,11 @@ export default {
     // 初始化数据
     initData() {
       // 获取链接参数
-      const { code, type, id, appId } = this.$route.query
+      const { code, type, authUserId, appId } = this.$route.query
       this.code = code
       this.formData.appId = appId
-      this.formData.authUserId = parseInt(id)
-      this.path = `/${id}/${type}`
+      this.formData.authUserId = parseInt(authUserId)
+      this.redirectPath = `/${authUserId}/${type}`
       // 尝试微信授权自动登录
       this.autoLogin()
     },
@@ -65,10 +65,11 @@ export default {
       try {
         const res = await this.$http.api.customLogin(this.formData)
         this.$store.dispatch('user/login', res.data)
+        this.$setStorage(this.redirectPath, 'userInfo', res.data)
         this.$toast('登录成功')
         setTimeout(() => {
-          this.$router.push(this.path)
-        }, 1000)
+          this.$router.push(this.redirectPath)
+        }, 500)
       } catch (error) {
         console.log(error)
       }

+ 5 - 5
plugins/axios.js

@@ -10,7 +10,8 @@ export default function (context) {
   const apiMap = initApi($axios)
   Vue.prototype.$http = context.$http = { api: apiMap }
 
-  $axios.onRequest((config) => {
+  // 设置请求头
+  $axios.onRequest(() => {
     $axios.setHeader('X-Token', store.getters.accessToken)
   })
 
@@ -21,7 +22,7 @@ export default function (context) {
     if (!res.code) return res
     // 请求失败
     if (res.code === -1) {
-      Toast(res.msg || 'Error')
+      Toast(res.msg || '服务器开小差了')
     }
     // 登录过期
     if (res.code === -99) {
@@ -31,10 +32,9 @@ export default function (context) {
         theme: 'round-button',
         confirmButtonColor: 'linear-gradient(to left, #404040, #101010)',
       })
-      console.log(store.getters.type)
       if (result === 'confirm') {
-        const path = '/' + store.getters.type
-        redirect(path)
+        console.log(store.getters.routePrefix)
+        redirect(store.getters.routePrefix)
       }
     }
     return Promise.reject(res)

+ 17 - 0
plugins/storage.js

@@ -0,0 +1,17 @@
+import Vue from 'vue'
+import { getStorage, setStorage } from '@/utils/storage'
+
+Vue.prototype.$setStorage = (type, key, value, options) => {
+  type = type.slice(1).replace('/', '_')
+  setStorage(`${type}_${key}`, value, options)
+}
+
+Vue.prototype.$getStorage = (type, key) => {
+  type = type.slice(1).replace('/', '_')
+  return getStorage(`${type}_${key}`)
+}
+
+Vue.prototype.$removeStorage = (type, key) => {
+  type = type.slice(1).replace('/', '_')
+  localStorage.removeItem(`zp_${type}_${key}`)
+}

+ 5 - 0
store/app.js

@@ -3,6 +3,7 @@ const state = () => ({
   screen: 'pc',
   static: `${process.env.STATIC_URL}/pc`,
   loginVisiable: false,
+  routePrefix: '', // 路由前缀
 })
 
 const mutations = {
@@ -22,6 +23,10 @@ const mutations = {
   HIDE_LOGIN(state) {
     state.loginVisiable = false
   },
+  // 供应商模板类型
+  SET_ROUTE_PREFIX(state, prefix) {
+    state.routePrefix = prefix
+  },
 }
 
 const actions = {}

+ 4 - 1
store/getters.js

@@ -1,13 +1,16 @@
 export default {
+  // 应用相关
   isPc: (state) => state.app.isPc,
   screen: (state) => state.app.screen,
   static: (state) => state.app.static,
+  routePrefix: (state) => state.app.routePrefix,
   loginVisiable: (state) => state.app.loginVisiable,
+  // 用户相关
   userInfo: (state) => state.user.userInfo,
   authUserId: (state) => state.user.authUserId,
   accessToken: (state) => state.user.accessToken,
   appId: (state) => state.user.appId,
   accountType: (state) => state.user.accountType,
-  type: (state) => state.user.type,
+  // 供应商相关
   supplierInfo: (state) => state.supplier.supplierInfo,
 }

+ 8 - 17
store/user.js

@@ -1,49 +1,40 @@
-import { setCookies, removeCookies } from '@/utils/auth'
-
 const state = () => ({
   authUserId: '',
   userInfo: {},
   accessToken: '',
   appId: '',
   accountType: '',
-  type: '',
 })
 
 const mutations = {
-  SET_USERINFO(state, data) {
+  // 设置用户信息
+  SET_USER_INFO(state, data) {
     state.userInfo = data
     state.accessToken = data.accessToken
     state.appId = data.appId
-    setCookies('userInfo', JSON.stringify(data))
-    setCookies('accessToken', data.accessToken)
   },
+  // 设置appId
   SET_APPID(state, appId) {
     state.appId = appId
-    setCookies('appId', appId)
   },
-  SET_AUTHUSERID(state, authUserId) {
+  // 设置供应商id
+  SET_AUTH_USER_ID(state, authUserId) {
     state.authUserId = authUserId
-    setCookies('authUserId', authUserId)
-  },
-  SET_TYPE(state, type) {
-    state.type = type
   },
+  // 微信公众号状态
   SET_ACCOUNT_TYPE(state, accountType) {
     state.accountType = accountType
-    setCookies('accountType', accountType)
   },
 }
 
 const actions = {
   // 退出登录
   logout({ commit }) {
-    commit('SET_USERINFO', {})
-    removeCookies('userInfo')
-    removeCookies('accessToken')
+    commit('SET_USER_INFO', {})
   },
   // 用户登录
   login({ commit }, data) {
-    commit('SET_USERINFO', data)
+    commit('SET_USER_INFO', data)
   },
 }
 

+ 21 - 0
utils/crypto.js

@@ -0,0 +1,21 @@
+import CryptoJS from './libs/crypto-js.min.js'
+
+const aseKey = 'RENZHENGTONG' //秘钥必须为:8/16/32位
+//加密
+export const encrypt = (data) => {
+  return CryptoJS.AES.encrypt(
+    JSON.stringify(data),
+    CryptoJS.enc.Utf8.parse(aseKey),
+    {
+      mode: CryptoJS.mode.ECB,
+      padding: CryptoJS.pad.Pkcs7,
+    }
+  ).toString()
+}
+//解密
+export const decrypt = (encrypt) => {
+  return CryptoJS.AES.decrypt(encrypt, CryptoJS.enc.Utf8.parse(aseKey), {
+    mode: CryptoJS.mode.ECB,
+    padding: CryptoJS.pad.Pkcs7,
+  }).toString(CryptoJS.enc.Utf8)
+}

+ 1 - 1
utils/download-link.js

@@ -3,7 +3,7 @@ import { isWeChat } from '@/utils/validator'
 import { downloadUrlLink } from '@/utils/index'
 
 // 通过链接下载
-export default function downloadLink(link) {
+export default function downloadLink(link, $event) {
   if (isWeChat()) {
     return handleClipboard(link, $event, '下载链接已复制到剪切板')
   } else {

+ 2 - 2
utils/index.js

@@ -30,8 +30,8 @@ export function drawLogo(text = '', len = 4) {
 
 // 跳转到授权页面
 export function toAuthorization(appId, payload) {
-  const type = payload.type.split('/')[1]
-  const url = `${process.env.LOCALHOSE}/auth?id=${payload.authUserId}&type=${type}&appId=${appId}`
+  const type = payload.routePrefix.split('/')[2]
+  const url = `${process.env.LOCALHOSE}/auth?authUserId=${payload.authUserId}&type=${type}&appId=${appId}`
   const redirect_uri = encodeURIComponent(url)
   window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
 }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
utils/libs/crypto-js.min.js


+ 46 - 0
utils/storage.js

@@ -0,0 +1,46 @@
+import { encrypt, decrypt } from '@/utils/crypto'
+const encryptFlag = process.env.NODE_ENV === 'production'
+
+// 将数据添加到缓存中(期限)
+export function setStorage(key, value, options = {}) {
+  if (!options.expiredTime) {
+    // 默认有效期为45天
+    options.expiredTime = 45 * 24 * 60 * 60 * 1000
+  }
+  const nowTime = Date.now()
+  // 加密
+  if (encryptFlag) {
+    value = encrypt(value)
+  }
+  const payload = {
+    expiredTime: nowTime + options.expiredTime,
+    data: value,
+  }
+  key = 'zp_' + key
+  localStorage.setItem(key, JSON.stringify(payload))
+}
+
+// 从缓存中读取数据(期限)
+export function getStorage(key) {
+  key = 'zp_' + key
+  const nowTime = Date.now()
+  let payload = localStorage.getItem(key)
+
+  if (!payload) {
+    return null
+  }
+
+  payload = JSON.parse(payload)
+
+  if (nowTime > payload.expiredTime) {
+    localStorage.removeItem(key)
+    return null
+  }
+
+  // 解密
+  if (encryptFlag) {
+    payload.data = decrypt(payload.data)
+  }
+
+  return payload.data
+}

Vissa filer visades inte eftersom för många filer har ändrats