Browse Source

器件收藏

yangc 7 years ago
parent
commit
c9f4113b9c

+ 2 - 1
components/mobile/applyPurchase/PublishSupplierSeek.vue

@@ -264,9 +264,10 @@
         font-size: .28rem;
         background: #fff;
         margin: .2rem 0;
-        padding-left: .29rem;
+        padding: 0 .29rem;
         .prop {
           padding-top: .2rem;
+          word-break: break-all;
           &:last-child {
             padding-bottom: .2rem;
           }

+ 1 - 1
components/mobile/brand/ComponentDetail.vue

@@ -311,7 +311,7 @@
                   this.collectResult = '收藏成功'
                   this.$store.dispatch('product/saveStores')
                 } else {
-                  this.collectResult = res.data.data || '收藏失败'
+                  this.collectResult = res.data.message || '收藏失败'
                 }
                 this.timeoutCount++
               }, err => {

+ 15 - 6
components/search/GoodList.vue

@@ -64,16 +64,16 @@
           <!--</td>-->
             <td class="brand-code">
               <img v-if="item.status === 602" class="sellout-flag" src="/images/search/sellout-search.png" alt="">
-              <div class="brand" v-if="item.branduuid"><a @click.stop="goRouter(`/product/brand/${item.branduuid}`)" class="text-num" v-text="item.brandNameCn || item.brandNameEn || '-'"></a></div>
-              <div class="brand" v-if="!item.branduuid">{{item.brandNameCn || item.brandNameEn || '-'}}</div>
-              <div class="brand" v-if="item.kindUuid"><a @click.stop="goRouter(`/product/kind/${item.kindUuid}`)" v-text="item.kindNameCn"></a></div>
-              <div class="brand" v-if="!item.kindUuid">{{item.kindNameCn || '—'}}</div>
-              <div class="code"  v-if="item.code">
+              <div class="brand" v-if="item.branduuid" :title="item.brandNameCn || item.brandNameEn"><a @click.stop="goRouter(`/product/brand/${item.branduuid}`)" class="text-num" v-text="item.brandNameCn || item.brandNameEn || '-'"></a></div>
+              <div class="brand" v-if="!item.branduuid" :title="item.brandNameCn || item.brandNameEn">{{item.brandNameCn || item.brandNameEn || '-'}}</div>
+              <div class="brand" v-if="item.kindUuid" :title="item.kindNameCn"><a @click.stop="goRouter(`/product/kind/${item.kindUuid}`)" v-text="item.kindNameCn"></a></div>
+              <div class="brand" v-if="!item.kindUuid" :title="item.kindNameCn">{{item.kindNameCn || '—'}}</div>
+              <div class="code"  v-if="item.code" :title="item.code">
                 <a v-if="item.uuid" @click.stop="goRouter(`/product/component/${item.uuid}`)" class="f16 text-bold text-num" v-text="item.code"></a>
                 <span v-if="!item.uuid">{{item.code}}</span>
               </div>
               <div class="brand" v-if="!item.code">—</div>
-              <div class="brand">{{item.spec || '—'}}</div>
+              <div class="brand" :title="item.spec">{{item.spec || '—'}}</div>
             </td>
             <td>
               <div class="package" v-text="item.packaging"></div>
@@ -462,6 +462,15 @@
   .product-list .brand-code .code {
     font-weight: 600;
   }
+  .product-list .brand-code .brand,
+  .product-list .brand-code .code{
+    max-width: 290px;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    /* text-align: center; */
+    padding: 0 10px;
+  }
 
   .product-list th {
     color: rgb(50,50,50);

+ 32 - 34
pages/mobile/center/user/collect/component/_key.vue

@@ -22,15 +22,15 @@
         <ul>
           <li class="clearfix" :key="comp.componentid" v-for="comp in compList" @click="goUrl('/mobile/brand/componentDetail/' + comp.componentinfo.uuid)">
             <div class="fl">
-              <p>品牌:<span v-text="comp.brand || '-'"></span></p>
-              <p>物料名称:<span v-text="comp.kind || '-'"></span></p>
-              <p>型号:<span v-text="comp.cmpCode || '-'"></span></p>
+              <p>品牌:<span v-text="comp.brand.nameEn || '-'"></span></p>
+              <p>物料名称:<span v-text="comp.kind.nameCn || '-'"></span></p>
+              <p>型号:<span v-text="comp.code || '-'"></span></p>
               <p>规格:<span v-text="comp.spec || '-'"></span></p>
               <p>产品描述:<span v-text="comp.description || '-'"></span></p>
             </div>
             <div class="vir"></div>
             <div class="fr">
-              <i class="iconfont icon-shoucang" :style="comp.isFocus === 'true'?'color:#ff7800':'color: #ddd'" @click="cancelFocus(comp, $event)"></i>
+              <i class="iconfont icon-shoucang" :style="comp.isFocus?'color:#ff7800':'color: #ddd'" @click="cancelFocus(comp, $event)"></i>
               <a class="sa-pub" @click="compInquiry(comp, $event)">立即询价</a>
             </div>
           </li>
@@ -73,12 +73,12 @@
     watch: {
       'compCollectList.data': {
         handler: function (val) {
-          if (val.content) {
+          if (val.components) {
             if (this.isChange) {
-              this.compList = val.content
+              this.compList = this.baseUtils.deepCopy(val.components)
               this.isChange = false
             } else {
-              this.compList = [...this.compList, ...val.content]
+              this.compList = [...this.compList, ...this.baseUtils.deepCopy(val.components)]
             }
           }
         },
@@ -87,7 +87,7 @@
     },
     created () {
       this.keyword = this.$route.params.key
-      this.$store.dispatch('searchData/searchForListInMobile', { page: 1, count: 10, type: 'component', keyword: this.$route.params.key })
+      this.$store.dispatch('searchData/searchForListInMobile', { page: 1, count: 10, w: this.$route.params.key })
     },
     computed: {
       compCollectList () {
@@ -163,37 +163,35 @@
       },
       cancelFocus: function (item, event) {
         event.stopPropagation()
-        if (item.standard === 1) {
-          if (!item.isFocus) {
-            this.$http.post('/trade/collection/save', {cmpuuid: item.cmpUuId, kind: 2})
-              .then(res => {
-                if (res.data.code === 1) {
-                  this.onRemind('收藏成功')
-                } else {
-                  this.onRemind(res.data.data || '收藏失败')
-                }
-              }, err => {
-                this.onRemind(err.response.data || '收藏失败')
-                console.log(err)
-              })
-          } else {
-            this.$http.post('/trade/collection/delete', [item.focusId]).then(response => {
-              if (response.data === 'success') {
-                this.onRemind('取消收藏成功')
+        if (!item.isFocus) {
+          this.$http.post('/trade/collection/save', {componentid: item.id, kind: 2})
+            .then(res => {
+              if (res.data.code === 1) {
+                this.onRemind('收藏成功')
+                item.isFocus = true
               } else {
-                this.onRemind('取消收藏失败')
+                this.onRemind(res.data.message || '收藏失败')
               }
             }, err => {
+              this.onRemind(err.response.data || '收藏失败')
               console.log(err)
-              this.onRemind(err.response.data || '取消收藏失败')
             })
-          }
         } else {
-          this.onRemind('非标物料暂不可收藏')
+          this.$http.post('/trade/collection/delete/cmpId', [item.id]).then(response => {
+            if (response.data === 'success') {
+              this.onRemind('取消收藏成功')
+              item.isFocus = false
+            } else {
+              this.onRemind('取消收藏失败')
+            }
+          }, err => {
+            console.log(err)
+            this.onRemind(err.response.data || '取消收藏失败')
+          })
         }
       },
       reloadList: function () {
-        this.$store.dispatch('searchData/searchForListInMobile', { page: this.page, count: this.count, type: 'component', keyword: this.keyword })
+        this.$store.dispatch('searchData/searchForListInMobile', { page: this.page, count: this.count, w: this.keyword })
       },
       onPullUpAction: function () {
         this.page++
@@ -203,10 +201,10 @@
         if (e) {
           e.stopPropagation()
         }
-        this.componentSeekObj.cmpCode = item.cmpCode ? item.cmpCode : ''
-        this.componentSeekObj.pbranden = item.brand ? item.brand : ''
-        this.componentSeekObj.spec = item.spec ? item.spec : ''
-        this.componentSeekObj.kind = item.kind ? item.kind : ''
+        this.componentSeekObj.cmpCode = item.code
+        this.componentSeekObj.pbranden = item.brand.nameEn
+        this.componentSeekObj.spec = item.spec
+        this.componentSeekObj.kind = item.kind.nameCn
         this.componentSeekObj = JSON.parse(JSON.stringify(this.componentSeekObj))
         this.showPublishBox = true
       },

+ 10 - 8
store/searchData.js

@@ -1,15 +1,17 @@
 import axios from '~plugins/axios'
 
 function reloadListData ({ commit }, listData) {
-  let productList = listData && listData.futures ? listData.futures : {}
+  let productList = listData
   axios.get('/trade/collection/list').then(response => {
     let focusData = response.data
-    for (let i = 0; i < productList.content.length; i++) {
-      for (let j = 0; j < focusData.length; j++) {
-        productList.content[i].isFocus = Boolean(productList.content[i].cmpUuId) && productList.content[i].cmpUuId === focusData[j].cmpuuid
-        if (productList.content[i].isFocus) {
-          productList.content[i].focusId = focusData[j].id
-          break
+    for (let i = 0; i < productList.components.length; i++) {
+      if (!productList.components[i].isFocus) {
+        for (let j = 0; j < focusData.length; j++) {
+          productList.components[i].isFocus = Boolean(productList.components[i].id) && productList.components[i].id === focusData[j].componentid
+          if (productList.components[i].isFocus) {
+            // productList.components[i].focusId = focusData[j].id
+            break
+          }
         }
       }
     }
@@ -72,7 +74,7 @@ export const actions = {
   // 获取手机端搜索list
   searchForListInMobile ({ commit }, params = {}) {
     commit('searchList/REQUEST_LIST', params)
-    return axios.get(`/search/201819`, {params})
+    return axios.get(`/search/component`, {params})
       .then(response => {
         reloadListData({ commit }, response.data)
       }, err => {