Browse Source

修改规格书显示逻辑

yangc 7 years ago
parent
commit
f5596c41b5

+ 18 - 2
components/search/GoodList.vue

@@ -134,8 +134,8 @@
               </div>
               </div>
             </td>
             </td>
             <td>
             <td>
-              <span v-if="item.attach && item.attach !=='1'"><a :href="item.attach" target="_blank"><img src="/images/store/common/pdf.png" alt=""/></a></span>
-              <span v-show="!item.attach || item.attach =='1'">—</span>
+              <span v-if="item.attach"><a @click="goAttach(item.attach, $event)"><img src="/images/store/common/pdf.png" alt=""/></a></span>
+              <span v-if="!item.attach">—</span>
             </td>
             </td>
             <td>
             <td>
               <div v-show="!item.reserve">
               <div v-show="!item.reserve">
@@ -241,6 +241,22 @@
       }
       }
     },
     },
     methods: {
     methods: {
+      goAttach: function (url, event) {
+        event.stopPropagation()
+        if (this.user.logged) {
+          if (url && url !== '1') {
+            window.open(url)
+          } else {
+            this.$message.error('规格书地址错误')
+          }
+        } else {
+          this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
+            if (response.data) {
+              window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
+            }
+          })
+        }
+      },
       listenPage: function (changedPage) {
       listenPage: function (changedPage) {
         this.nowPage = changedPage
         this.nowPage = changedPage
         this.$emit('pageEvent', this.nowPage)
         this.$emit('pageEvent', this.nowPage)

+ 7 - 3
components/store/CommodityInfo.vue

@@ -512,14 +512,18 @@
         }
         }
       },
       },
       toAttach: function (url) {
       toAttach: function (url) {
-        if (url === '1') {
+        if (this.user.logged) {
+          if (url && url !== '1') {
+            window.open(url)
+          } else {
+            this.$message.error('规格书地址错误')
+          }
+        } else {
           this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
           this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
             if (response.data) {
             if (response.data) {
               window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
               window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
             }
             }
           })
           })
-        } else {
-          window.open(url)
         }
         }
       }
       }
     }
     }

+ 18 - 2
components/store/CommodityList.vue

@@ -104,9 +104,9 @@
             </td>
             </td>
             <td>
             <td>
               <div v-if="commodity.attach">
               <div v-if="commodity.attach">
-                <a :href="commodity.attach && commodity.attach !== '1'" target="_blank"><img src="/images/store/common/pdf.png" alt=""/></a>
+                <a @click="goAttach(commodity.attach, $event)" target="_blank"><img src="/images/store/common/pdf.png" alt=""/></a>
               </div>
               </div>
-              <div v-show="!commodity.attach || commodity.attach == '1'">—</div>
+              <div v-if="!commodity.attach">—</div>
             </td>
             </td>
             <td>
             <td>
               <buy :item="commodity" :disabledFlag="commodity.status === 602"></buy>
               <buy :item="commodity" :disabledFlag="commodity.status === 602"></buy>
@@ -227,6 +227,22 @@ export default {
     }
     }
   },
   },
   methods: {
   methods: {
+    goAttach: function (url, event) {
+      event.stopPropagation()
+      if (this.user.logged) {
+        if (url && url !== '1') {
+          window.open(url)
+        } else {
+          this.$message.error('规格书地址错误')
+        }
+      } else {
+        this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
+          if (response.data) {
+            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
+          }
+        })
+      }
+    },
     isSpecificPriceTag: function (tag) {
     isSpecificPriceTag: function (tag) {
       return tag && tag.indexOf('特价') !== -1
       return tag && tag.indexOf('特价') !== -1
     },
     },