瀏覽代碼

自测BUG 修复

Darkhorsedamon 2 年之前
父節點
當前提交
172a7e93de

+ 1 - 2
components/BuyTicket.vue

@@ -3,7 +3,7 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-11-01 14:10:22
- * @LastEditTime: 2022-11-14 10:27:40
+ * @LastEditTime: 2022-11-16 09:27:06
 -->
 <template>
   <div>
@@ -161,7 +161,6 @@ export default {
       this.$axios.get('members/getMemberInfo').then((res)=> {
         if(res.code === 200) {
           this.$store.commit('setUser',res.result)
-          localStorage.setItem('userInfo',JSON.stringify(res.result))
           this.$router.push('/members/me/expenses')
         }
       })

+ 3 - 2
components/BuyVip.vue

@@ -3,7 +3,7 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-10-31 20:41:42
- * @LastEditTime: 2022-11-08 17:01:57
+ * @LastEditTime: 2022-11-15 19:24:18
 -->
 <template>
   <div>
@@ -146,7 +146,7 @@ export default {
       this.$axios.get('members/getMemberInfo').then((res)=> {
         if(res.code === 200) {
           this.$store.commit('setUser',res.result)
-          localStorage.setItem('userInfo',JSON.stringify(res.result))
+          // localStorage.setItem('userInfo',JSON.stringify(res.result))
           this.$router.push('/members/me/expenses')
         }
       })
@@ -161,6 +161,7 @@ export default {
       this.$axios.post('subscription/create',params).then((res) => {
         if(res.code === 200) {
           location.href = res.result.order.pagePayUrl
+          this.$store.commit('OPEN_LOGIN',false)
         }
       }) 
     }

+ 0 - 1
components/LoginBar.vue

@@ -79,7 +79,6 @@ export default {
       this.$axios.get('members/getMemberInfo').then((res)=> {
         if(res.code === 200) {
           this.$store.commit('setUser',res.result)
-          localStorage.setItem('userInfo',JSON.stringify(res.result))
           this.logging = false
           this.$emit('loginSucess')
         }

+ 0 - 1
components/RegisterBar.vue

@@ -84,7 +84,6 @@ export default {
       this.$axios.get('members/getMemberInfo').then((res)=> {
         if(res.code === 200) {
           this.$store.commit('setUser',res.result)
-          localStorage.setItem('userInfo',JSON.stringify(res.result))
           this.$emit('loginSucess')
         }
       })

+ 1 - 1
components/UserManage.vue

@@ -92,7 +92,7 @@ export default {
       this.$axios.get('members/getMemberInfo').then((res)=> {
         if(res.code === 200) {
           this.$store.commit('setUser',res.result)
-          localStorage.setItem('userInfo',JSON.stringify(res.result))
+          // localStorage.setItem('userInfo',JSON.stringify(res.result))
         }
       })
     },

+ 1 - 7
layouts/components/NavBar.vue

@@ -3,7 +3,7 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-10-17 15:19:11
- * @LastEditTime: 2022-11-14 19:15:50
+ * @LastEditTime: 2022-11-16 09:27:17
 -->
 <template>
   <div class="h-80px flex relative z-3 justify-between px-[10%] border-b-1 border-b-[#f0f0f0] border-b-solid">
@@ -142,12 +142,6 @@ export default {
       }
     }
   },
-  mounted() {
-    if(localStorage.getItem('userInfo')) {
-      this.$store.commit('setUser',JSON.parse(localStorage.getItem('userInfo')))
-      this.$store.commit('SET_TOKEN',localStorage.getItem('token'))
-    }
-  },
   methods: {
     handleLoginSucess() {
       this.$nextTick(()=> {

+ 1 - 1
layouts/components/navbar2.vue

@@ -94,7 +94,7 @@
                 >注册</a
               >
             </li>
-            <img v-else class="w-36px h-36px rounded-full <tiny:mt-8px mr-0 md-0 cursor-pointer text-[0px] tiny:ml-35px lg:ml-135px xl:ml-190px" :src="userInfo?.memberInfo.subscriberType === 1 ? 'https://user-file.17pdf.com/avatars/2020/11/16/0577b907be980556bdafa23fb0be0732-jpg.jpg' : 'http://user-file.17pdf.com/avatars/2018/01/02/f183029426a996325853fa244e7df661-jpg.jpg'" @click="$router.push('/members/me/expenses')" />
+            <img v-else class="w-36px h-36px rounded-full <tiny:mt-8px mr-0 md-0 cursor-pointer text-[0px] tiny:ml-35px lg:ml-135px xl:ml-190px" :src="userInfo?.memberInfo?.subscriberType === 1 ? 'https://user-file.17pdf.com/avatars/2020/11/16/0577b907be980556bdafa23fb0be0732-jpg.jpg' : 'http://user-file.17pdf.com/avatars/2018/01/02/f183029426a996325853fa244e7df661-jpg.jpg'" @click="$router.push('/members/me/expenses')" />
           </ul>
         </div>
       </nav>

+ 5 - 5
layouts/userCenter.vue

@@ -3,7 +3,7 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-11-01 20:18:40
- * @LastEditTime: 2022-11-15 10:04:42
+ * @LastEditTime: 2022-11-15 19:27:07
 -->
 <template>
   <div class="font-primary min-w-1200px">
@@ -13,7 +13,7 @@
         <div class="person">
           <div>
             <a href="/members/me/expenses" class="members">
-              <img v-if="userInfo?.memberInfo.subscriberType === 1" src="http://user-file.17pdf.com/avatars/2020/11/16/0577b907be980556bdafa23fb0be0732-jpg.jpg" >
+              <img v-if="userInfo?.memberInfo?.subscriberType === 1" src="http://user-file.17pdf.com/avatars/2020/11/16/0577b907be980556bdafa23fb0be0732-jpg.jpg" >
               <img v-else src="http://user-file.17pdf.com/avatars/2018/01/02/f183029426a996325853fa244e7df661-jpg.jpg" >
             </a>
             <br>
@@ -22,13 +22,13 @@
           </div>
           <div class="flex py-14px mt-20px justify-between text-left">
             <div>
-              <p v-if="userInfo?.memberInfo.subscriberType === 1" class="user-vip text-18px mb-6px text-[#333] font-500 leading-24px">17会员</p>
+              <p v-if="userInfo?.memberInfo?.subscriberType === 1" class="user-vip text-18px mb-6px text-[#333] font-500 leading-24px">17会员</p>
               <p v-else class="text-18px text-[#333] font-500 leading-24px mb-6px">免费用户</p>
-              <p v-if="userInfo?.memberInfo.subscriberType === 1" class="text-12px text-[#999] pl-28px mb-6px leading-17px">剩余<span class="text-bg-$btn-color-primary">{{userInfo?.memberInfo?.day}}</span>天到期</p>
+              <p v-if="userInfo?.memberInfo?.subscriberType === 1" class="text-12px text-[#999] pl-28px mb-6px leading-17px">剩余<span class="text-bg-$btn-color-primary">{{userInfo?.memberInfo?.day}}</span>天到期</p>
               <p v-else class="text-12px text-[#999] leading-17px">订阅会员免费格式转换</p>
             </div>
             <button class="btn-renew" @click="handlerBuy('vip')">
-              {{userInfo?.memberInfo.subscriberType === 1 ? '续费' : '订阅会员'}}
+              {{userInfo?.memberInfo?.subscriberType === 1 ? '续费' : '订阅会员'}}
             </button>
           </div>
           <div class="flex py-14px my-8px justify-between text-left">

+ 1 - 2
middleware/user.js

@@ -3,14 +3,13 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-11-08 09:15:06
- * @LastEditTime: 2022-11-14 11:47:05
+ * @LastEditTime: 2022-11-16 09:30:48
  */
 export default function({store, app: {$axios}}) {
   if(store?.state?.token !== '') {
     $axios.get('members/getMemberInfo').then((res)=> {
       if(res.code === 200) {
         store.commit('setUser',res.result)
-        localStorage.setItem('userInfo',JSON.stringify(res.result))
       }
     })
   }

+ 2 - 2
pages/converter.vue

@@ -37,9 +37,9 @@ export default {
       <img src="http://cn-file.17pdf.com/website/common/ic_notice.svg" class="align-middle">
       <div class="text-container">
         <span class="text">
-          转档后的文件支持在云端保留24小时,<span v-if="userInfo?.memberInfo.subscriberType === 1">会员尊享5G容量,</span>请在24小时内下载文件至本地永久保存
+          转档后的文件支持在云端保留24小时,<span v-if="userInfo?.memberInfo?.subscriberType === 1">会员尊享5G容量,</span>请在24小时内下载文件至本地永久保存
         </span>
-        <span v-if="userInfo?.memberInfo.subscriberType === 1" class="vip tip">
+        <span v-if="userInfo?.memberInfo?.subscriberType === 1" class="vip tip">
           <img src="http://cn-file.17pdf.com/website/common/ic_info.svg" alt="">
           <div class="tip-text">
             若已有文件大小超出5G,将按转档时间计算(从最近一次转档往过去推算),即保留最近的5G容量文件,超出部分文件将不再保留

+ 2 - 2
pages/members/me/expenses.vue

@@ -11,9 +11,9 @@
       <img src="http://cn-file.17pdf.com/website/common/ic_notice.svg" class="align-middle">
       <div class="text-container">
         <span class="text">
-          转档后的文件支持在云端保留24小时,<span v-if="userInfo?.memberInfo.subscriberType === 1">会员尊享5G容量,</span>请在24小时内下载文件至本地永久保存
+          转档后的文件支持在云端保留24小时,<span v-if="userInfo?.memberInfo?.subscriberType === 1">会员尊享5G容量,</span>请在24小时内下载文件至本地永久保存
         </span>
-        <span v-if="userInfo?.memberInfo.subscriberType === 1" class="vip tip">
+        <span v-if="userInfo?.memberInfo?.subscriberType === 1" class="vip tip">
           <img src="http://cn-file.17pdf.com/website/common/ic_info.svg" alt="">
           <div class="tip-text">
             若已有文件大小超出5G,将按转档时间计算(从最近一次转档往过去推算),即保留最近的5G容量文件,超出部分文件将不再保留

+ 1 - 1
pages/pricing.vue

@@ -2198,7 +2198,7 @@ export default {
       this.isLogin = false
     }
     // 判断用户是否是VIP
-    if (this.userInfo.memberInfo.subscriberType === 1) {
+    if (this.userInfo.memberInfo?.subscriberType === 1) {
       this.isVIP = true
     } else {
       this.isVIP = false

+ 5 - 1
plugins/axios.js

@@ -3,9 +3,11 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-10-19 13:58:11
- * @LastEditTime: 2022-11-03 15:36:24
+ * @LastEditTime: 2022-11-15 17:34:01
  */
 import { Message } from 'element-ui';
+import { removeToken } from '~/utils/cookie';
+
 
 export default function({store, app:{ $axios }, redirect} ) {
   $axios.onRequest(config => {
@@ -19,6 +21,8 @@ export default function({store, app:{ $axios }, redirect} ) {
       Message.error('登录过期,请重新登录')
       store.commit('OPEN_LOGIN',false)
       store.commit('DEL_TOKEN','')
+      store.commit('setUser', {})
+      removeToken('Token')
       localStorage.removeItem('token')
       localStorage.removeItem('userInfo')
       return Promise.resolve(false)

+ 2 - 2
plugins/localStorage.js

@@ -3,12 +3,12 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-10-26 09:30:22
- * @LastEditTime: 2022-10-26 09:30:32
+ * @LastEditTime: 2022-11-16 09:24:01
  */
 import createPersistedState from 'vuex-persistedstate'
 
 export default ({ store }) => {
     createPersistedState({
-        storage: sessionStorage
+        storage: localStorage
     })(store)
 }

+ 12 - 3
store/index.js

@@ -3,8 +3,10 @@
  * @Author: 欧阳承珺
  * @LastEditors: 欧阳承珺
  * @Date: 2022-10-25 17:19:19
- * @LastEditTime: 2022-11-02 16:03:41
+ * @LastEditTime: 2022-11-16 09:25:49
  */
+import { setToken, cookieParse } from '~/utils/cookie'
+
 export const state = () => ({
   userInfo: {
     memberInfo: {},
@@ -38,15 +40,22 @@ export const mutations = {
 export const actions = {
 
   nuxtServerInit ({commit, state}, {req}) {
-      if (req && req.headers && req.headers.token) {
-        commit('SET_TOKEN', req.headers.token)
+    let token = null
+    if (req && req.headers && req.headers.cookie) {
+      const parsed = cookieParse(req.headers.cookie)
+      try {
+        token = parsed.Token
+      } catch (err) {
       }
+      commit('SET_TOKEN', token)
+    }
   },
 
   login ({ commit }, params) {
     return new Promise((resolve, reject) => {
       this.$axios.get(`auth/getToken?code=${params}`).then(res => {
         const token = res.result.accessToken
+        setToken('Token', token)
         localStorage.setItem('token',token)
         commit('SET_TOKEN', token)
         resolve(token)