cuiyalong 4 سال پیش
والد
کامیت
2ba0e0b741

+ 1 - 4
jydocs-mobile/src/components/Recharge.vue

@@ -45,9 +45,6 @@ import { Icon, Popup, Sticky } from 'vant'
       [Popup.name]: Popup,
       [Sticky.name]: Sticky,
       [Icon.name]: Icon
-    },
-    created () {
-      console.log('111')
     }
   })
 export default class extends Vue {
@@ -59,7 +56,7 @@ export default class extends Vue {
     }
 
     buyMoney () {
-      window.location.href = `/page_points_app/pay?id=${this.detailData.id}`
+      window.location.href = `/page_points_app/pay?id=${this.detailData.docId}`
     }
 }
 </script>

+ 16 - 6
jydocs-mobile/src/store/modules/main.ts

@@ -87,7 +87,7 @@ const modulesOption: modulesOption = {
       }
       sessionStorage.setItem('jy-docs-home-page', JSON.stringify(state.homePageData))
     },
-    // 我的文库页面数据
+    // 搜索页面数据
     saveSearchPageState (state, data) {
       console.log(data)
       for (const key in data) {
@@ -95,7 +95,7 @@ const modulesOption: modulesOption = {
       }
       sessionStorage.setItem('jy-docs-search-page', JSON.stringify(data))
     },
-    // 清除提现成功数据
+    // 清除搜索页面数据
     clearSearchPageState (state) {
       state.searchPageData = {}
       sessionStorage.setItem('jy-docs-search-page', JSON.stringify({}))
@@ -107,10 +107,20 @@ const modulesOption: modulesOption = {
       }
       sessionStorage.setItem('jy-docs-user-lib', JSON.stringify(data))
     },
-    // 清除提现成功数据
-    clearMyLibState (state) {
-      state.userLib = {}
-      sessionStorage.setItem('jy-docs-user-lib', JSON.stringify({}))
+    // 清除我的文库页面数据
+    clearMyLibState (state, data = '') { // clearLib,clearCollections
+      if (data === 'clearLib') {
+        if (state.userLib && Object.keys(state.userLib).length !== 0) {
+          delete state.userLib.myLibListState
+        }
+      } else if (data === 'clearCollections') {
+        if (state.userLib && Object.keys(state.userLib).length !== 0) {
+          delete state.userLib.myCollectionListState
+        }
+      } else {
+        state.userLib = {}
+      }
+      sessionStorage.setItem('jy-docs-user-lib', JSON.stringify(state.userLib))
     }
   },
   actions: {

+ 9 - 3
jydocs-mobile/src/views/Search.vue

@@ -139,6 +139,8 @@ export default class extends Vue {
     list: []
   }
 
+  restored = false // 当前数据是否走过缓存
+
   get activeSortType () {
     return this.sortTypeList.find(item => {
       return item.active
@@ -150,17 +152,20 @@ export default class extends Vue {
   }
 
   created () {
-    const y = this.reStoreState()
-    if (!y) {
+    this.restored = this.reStoreState()
+    if (!this.restored) {
       this.getTags()
     }
   }
 
   mounted () {
-    this.onFocus()
+    if (!this.restored) {
+      this.onFocus()
+    }
   }
 
   onFocus () {
+    console.log('fffff')
     const dom = document.querySelector('#mySearch input') as HTMLInputElement
     if (dom) {
       this.$nextTick(() => {
@@ -262,6 +267,7 @@ export default class extends Vue {
     const { data } = await this.doSearchRquesst(query)
     this.listState.loading = false
     this.listState.loaded = true
+    this.$toast.clear()
     if (data && Array.isArray(data.list)) {
       this.listState.pageNum += 1
       this.listState.total = data.total

+ 7 - 3
jydocs-mobile/src/views/details/details.vue

@@ -41,7 +41,7 @@
 
 <script lang="ts">
 import { Component, Vue } from 'vue-property-decorator'
-import { mapActions } from 'vuex'
+import { mapActions, mapMutations } from 'vuex'
 import { Icon, Toast, GoodsAction, GoodsActionIcon, GoodsActionButton } from 'vant'
 import Recharge from '@/components/Recharge.vue'
 import sharePop from '@/components/SharePopup.vue'
@@ -70,10 +70,14 @@ const pdfjsViewer = require('pdfjs-dist/web/pdf_viewer.js')
       getShare: 'main/getShare',
       getAdd: 'main/getAdd',
       getRemove: 'main/getRemove'
+    }),
+    ...mapMutations({
+      clearLibState: 'main/clearMyLibState'
     })
   }
 })
 export default class extends Vue {
+  clearLibState: any
   getDetails: any
   getCoin: any
   getDown: any
@@ -273,16 +277,16 @@ export default class extends Vue {
   canged () {
     if (this.collectd === 0) {
       this.getAdd({ docId: this.docIds }).then((res: any) => {
-        console.log(res)
         if (res.error_code === 0) {
+          this.clearLibState('clearCollections') // 清除我的收藏列表缓存数据
           this.collectd = 1
           Toast('收藏成功')
         }
       })
     } else {
       this.getRemove({ docId: this.docIds }).then((res: any) => {
-        console.log(res)
         if (res.error_code === 0) {
+          this.clearLibState('clearCollections') // 清除我的收藏列表缓存数据
           this.collectd = 0
           Toast('取消收藏')
         }

+ 6 - 3
jydocs-mobile/src/views/purchase/purchasesuccess.vue

@@ -38,14 +38,16 @@
 <script lang="ts">
 import { Component, Vue } from 'vue-property-decorator'
 import { dateFormatter } from '../../utils/globalFunctions'
-// import { mapState } from 'vuex'
+import { mapMutations } from 'vuex'
 
 @Component({
   name: 'test',
-  components: {
-  }
+  ...mapMutations({
+    clearLibState: 'main/clearMyLibState'
+  })
 })
 export default class extends Vue {
+  clearLibState: any
   count = 3
   timer: any
   $router: any
@@ -62,6 +64,7 @@ export default class extends Vue {
     this.query = location.href.split('/')[location.href.split('/').length - 1] // 获取num
     this.setCountDown()
     this.setSession()
+    this.clearLibState('clearLib') // 清除我的文库列表缓存数据
   }
 
   setSession () {

+ 2 - 1
jydocs-pc/src/views/Search.vue

@@ -184,7 +184,8 @@ export default {
       const { docFileSize: size, downTimes, uploadDate, docPageSize } = item
       const subInfoArr = []
       if (uploadDate !== undefined) {
-        subInfoArr.push(dateFormatter(uploadDate, 'yyyy/MM/dd'))
+        const data = uploadDate.replace(/-/g, '/')
+        subInfoArr.push(dateFormatter(data, 'yyyy/MM/dd'))
       }
       if (downTimes !== undefined) {
         subInfoArr.push(`${downTimes}次下载`)