Преглед изворни кода

右侧购物车、留言、浏览记录、收藏、关注、产品详情记录获取未登录情况下不请求数据。

ouxq пре 8 година
родитељ
комит
73e1449fdc

+ 16 - 12
components/default/RightBar.vue

@@ -2,7 +2,7 @@
   <div>
     <div class="right-bar">
       <ul class="right-bar-center">
-        <li class="right-bar-item">
+        <li class="right-bar-item" @mouseenter="loadCarCount()">
           <a href="/user#/cart" class="title" target="_blank">
             <i class="iconfont icon-shopping-cart icon-xlg"></i>
           </a>
@@ -37,7 +37,7 @@
         </li>
       </ul>
       <ul class="right-bar-bottom">
-        <li class="right-bar-item">
+        <li class="right-bar-item" @mouseenter="loadHistorys()">
           <a href="http://www.usoftmall.com/user#/browsingHistory" class="title" target="_blank">
             <i class="iconfont icon-zuji icon-xlg"></i>
           </a>
@@ -90,7 +90,9 @@
       }
     },
     created () {
-      this.$store.dispatch('getMessageBoardInformation', {page: 1, count: 3})
+      if (this.user.logged) {
+        this.$store.dispatch('getMessageBoardInformation', {page: 1, count: 3})
+      }
     },
     components: {
       MessageBoard
@@ -114,12 +116,6 @@
         return {}
       }
     },
-    mounted () {
-      this.$nextTick(() => {
-        this.loadHistorys()
-        this.loadCarCount()
-      })
-    },
     methods: {
       listenPage: function (p) {
         this.page = p
@@ -134,10 +130,18 @@
         })
       },
       loadHistorys () {
-        this.$store.dispatch('user/loadHistory')
+        if (this.user.logged) {
+          if (!this.history.length) {
+            this.$store.dispatch('user/loadHistory')
+          }
+        }
       },
       loadCarCount () {
-        this.$store.dispatch('user/CarCount')
+        if (this.user.logged) {
+          if (!this.cartCount.count) {
+            this.$store.dispatch('user/CarCount')
+          }
+        }
       },
       toTop () {
         scrollTo('body', 300)
@@ -150,7 +154,7 @@
       },
       deleteHistory (item, id) {
         this.$store.dispatch('user/deleteHistory', {id: id})
-        this.loadHistorys()
+        this.$store.dispatch('user/loadHistory')
       },
       goWebChat: function () {
         if (!this.$store.state.option.user.logged) {

+ 3 - 1
components/product/component/ComponentDetail.vue

@@ -111,7 +111,9 @@
     },
     methods: {
       loadCollectList () {
-        this.$store.dispatch('product/saveStores')
+        if (this.user.logged) {
+          this.$store.dispatch('product/saveStores')
+        }
       },
       collect (id) {
         if (this.user.logged) {

+ 6 - 1
components/store/CommodityInfo.vue

@@ -175,6 +175,9 @@ export default {
     calculate () {
       this.fragment.total = this.fragment.price * this.fragment.num
       return Math.ceil(this.fragment.total * Math.pow(10, 2)) / Math.pow(10, 2)
+    },
+    user () {
+      return this.$store.state.option.user
     }
   },
   mounted () {
@@ -184,7 +187,9 @@ export default {
   },
   methods: {
     loadSaveHistory () {
-      this.$store.dispatch('shop/saveHistory', {id: this.commodity.batchCode})
+      if (this.user.logged) {
+        this.$store.dispatch('shop/saveHistory', {id: this.commodity.batchCode})
+      }
     },
     changeCurrency () {
       if (this.fragment.currency === 'RMB') {

+ 3 - 1
components/store/common/StoreHeader.vue

@@ -98,7 +98,9 @@ export default {
   },
   methods: {
     loadFocusList () {
-      this.$store.dispatch('shop/StoreFocusList', {id: this.storeInfo.id})
+      if (this.user.logged) {
+        this.$store.dispatch('shop/StoreFocusList', {id: this.storeInfo.id})
+      }
     },
     closeDropDown () {
       this.isOpen = false