Explorar o código

供应商搜索调整

yangc %!s(int64=7) %!d(string=hai) anos
pai
achega
f04f9c8ccd

+ 1 - 1
components/home/displayCard.vue

@@ -86,7 +86,7 @@
         return this.$store.state.count.allCount.data
       },
       payMoney () {
-        return this.formatNumber(this.allCount[0].count)
+        return this.allCount[0] ? this.formatNumber(this.allCount[0].count) : 0
       },
       inquirySheet () {
         return this.$store.state.count.inquirySheet.data

+ 3 - 3
components/mobile/applyPurchase/SayPrice.vue

@@ -6,13 +6,13 @@
         <div>
           <div class="base-info">
             <div class="content-line">
-              类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
+              品牌:<span>{{purchaseDetail.inbrand || '-'}}</span>
             </div>
             <div class="content-line">
-              型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
+              类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
             </div>
             <div class="content-line">
-              品牌:<span>{{purchaseDetail.inbrand || '-'}}</span>
+              型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
             </div>
             <div class="content-line">
               规格:<span>{{purchaseDetail.spec || '-'}}</span>

+ 6 - 6
components/mobile/applyPurchase/SayPriceInfo.vue

@@ -7,13 +7,13 @@
           <div v-if="isBuyer">
             <div class="base-info">
               <div class="content-line">
-                类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
+                品牌:<span>{{purchaseDetail.inbrand || '-'}}</span>
               </div>
               <div class="content-line">
-                型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
+                类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
               </div>
               <div class="content-line">
-                品牌:<span>{{purchaseDetail.inbrand || '-'}}</span>
+                型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
               </div>
               <div class="content-line">
                 规格:<span>{{purchaseDetail.spec || '-'}}</span>
@@ -73,13 +73,13 @@
           <div v-if="!isBuyer">
           <div class="base-info">
             <div class="content-line">
-              类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
+              品牌:<span>{{purchaseDetail.inbrand || '-'}}</span>
             </div>
             <div class="content-line">
-              型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
+              类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
             </div>
             <div class="content-line">
-              品牌:<span>{{purchaseDetail.inbrand || '-'}}</span>
+              型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
             </div>
             <div class="content-line">
               规格:<span>{{purchaseDetail.spec || '-'}}</span>

+ 5 - 5
components/mobile/applyPurchase/SeekList.vue

@@ -8,6 +8,11 @@
         </p>
         <div>
           <div class="fl">
+            <div>
+              品牌:
+              <span>{{item.inbrand || '-'}}</span>
+            </div>
+            <div>
             <div>
               类目(产品名称):
               <span>{{item.title || item.prodTitle || '-'}}</span>
@@ -16,11 +21,6 @@
               型号:
               <span>{{item.cmpCode || '-'}}</span>
             </div>
-            <div>
-              品牌:
-              <span>{{item.inbrand || '-'}}</span>
-            </div>
-            <div>
               规格:
               <span>{{item.spec || '-'}}</span>
             </div>

+ 29 - 4
components/mobile/base/SearchHeader.vue

@@ -88,9 +88,9 @@
         if (e) {
           e.stopPropagation()
         }
-        if (key === this.searchKeyword || this.keyword === this.searchKeyword) {
-          return
-        }
+//        if (key === this.searchKeyword || this.keyword === this.searchKeyword) {
+//          return
+//        }
         if (key) {
           this.keyword = key
           this.$emit('searchAction', {
@@ -98,8 +98,33 @@
             type: type
           })
         } else {
+          let sType = null
+          if (this.type === 'supplier') {
+            if (this.similarList.pCmpCode[0] && this.keyword === this.similarList.pCmpCode[0].pCmpCode) {
+              sType = 'pCmpCode'
+            } else if (this.similarList.pBrandEn[0] && this.keyword === this.similarList.pBrandEn[0].nameCn) {
+              sType = 'pBrandEn'
+            } else if (this.similarList.kind[0] && this.keyword === this.similarList.kind[0].kind) {
+              sType = 'kind'
+            } else {
+              let arr = [...this.similarList.pCmpCode, ...this.similarList.pBrandEn, ...this.similarList.kind]
+              if (arr[0]) {
+                if (arr[0].pCmpCode) {
+                  this.keyword = arr[0].pCmpCode
+                  sType = 'pCmpCode'
+                } else if (arr[0].nameCn) {
+                  this.keyword = arr[0].nameCn
+                  sType = 'pBrandEn'
+                } else if (arr[0].kind) {
+                  this.keyword = arr[0].kind
+                  sType = 'kind'
+                }
+              }
+            }
+          }
           this.$emit('searchAction', {
-            keyword: this.keyword
+            keyword: this.keyword,
+            type: sType
           })
         }
         this.searchKeyword = this.keyword

+ 245 - 0
components/mobile/base/SearchHeader2.vue

@@ -0,0 +1,245 @@
+<template>
+  <div class="search-content com-mobile-header">
+    <div class="options" @click="setShowSearchType(!showSearchType, $event)">
+      {{searchType | typeFilter}}
+      <i></i>
+      <ul v-if="showSearchType">
+        <li v-show="searchType !== type" v-for="type in searchTypeList" @click="setSearchType(type, $event)">{{type | typeFilter}}</li>
+      </ul>
+    </div>
+    <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
+    <input type="text" v-model="keyword" @input="getSimilarList()" :placeholder="placeholder" @keyup.13="onSearch()">
+    <span @click="onSearch()"><i class="iconfont icon-sousuo"></i></span>
+    <ul class="similar-list" v-if="emptyStatus && type == 'supplier' && keyword && keyword !== '' && showSimilarWord">
+      <template v-if="similarList.pCmpCode && similarList.pCmpCode.length && searchType === 'code'">
+        <li class="title text-ellipse">型号</li>
+        <li class="text-ellipse" v-for="code in similarList.pCmpCode.slice(0, 4)" @click="onSearch(code.pCmpCode, 'pCmpCode', $event)">{{code.pCmpCode}}</li>
+      </template>
+      <template v-if="similarList.pBrandEn && similarList.pBrandEn.length && searchType === 'brand'">
+        <li class="title text-ellipse">品牌</li>
+        <li class="text-ellipse" v-for="brand in similarList.pBrandEn.slice(0, 4)" @click="onSearch(brand.nameCn, 'pBrandEn', $event)">{{brand.nameCn}}</li>
+      </template>
+      <template v-if="similarList.kind && similarList.kind.length && searchType === 'kind'">
+        <li class="title text-ellipse">类目</li>
+        <li class="text-ellipse" v-for="kind in similarList.kind.slice(0, 4)" @click="onSearch(kind.kind, 'kind', $event)">{{kind.kind}}</li>
+      </template>
+    </ul>
+    <ul class="similar-list" v-if="emptyStatus && type == 'default' && keyword && keyword !== '' && showSimilarWord">
+      <template v-if="similarList.component && similarList.component.length">
+        <li class="title text-ellipse">型号</li>
+        <li class="text-ellipse" v-for="code in similarList.component.slice(0, 4)" @click="onSearch(code.code, 'code', $event)">{{code.code}}</li>
+      </template>
+      <template v-if="similarList.brand && similarList.brand.length">
+        <li class="title text-ellipse">品牌</li>
+        <li class="text-ellipse" v-for="brand in similarList.brand.slice(0, 4)" @click="onSearch(brand.nameCn, 'brand', $event)">{{brand.nameCn}}</li>
+      </template>
+      <template v-if="similarList.kind && similarList.kind.length">
+        <li class="title text-ellipse">类目</li>
+        <li class="text-ellipse" v-for="kind in similarList.kind.slice(0, 4)" @click="onSearch(kind.nameCn, 'kind', $event)">{{kind.nameCn}}</li>
+      </template>
+    </ul>
+  </div>
+</template>
+<script>
+  import {scrollTo} from '~utils/scroll'
+  export default {
+    props: {
+      placeholder: {
+        type: String,
+        default: '请输入要查找的内容'
+      },
+      similarUrl: { // 联想词url
+        type: String,
+        default: '/search/similarKeywords'
+      },
+      type: { // 搜索类型
+        type: String,
+        default: 'default'
+      },
+      showSimilar: { // 是否显示联想词
+        type: Boolean,
+        default: true
+      }
+    },
+    data () {
+      return {
+        keyword: '',
+        similarList: {},
+        showSimilarWord: false,
+        searchKeyword: '',
+        showSearchType: false,
+        searchType: 'code',
+        searchTypeList: ['code', 'brand', 'kind', 'name']
+      }
+    },
+    filters: {
+      typeFilter: function (val) {
+        switch (val) {
+          case 'code':
+            return '搜型号'
+          case 'brand':
+            return '搜品牌'
+          case 'kind':
+            return '搜类目'
+          case 'name':
+            return '供应商'
+          default:
+            return '全部'
+        }
+      }
+    },
+    mounted () {
+      this.$nextTick(() => {
+        document.onclick = () => {
+          this.showSimilarWord = false
+          this.showSearchType = false
+        }
+      })
+    },
+    computed: {
+      emptyStatus () {
+        let similarList = this.similarList
+        let searchType = this.searchType
+        if (this.type === 'supplier') {
+          return (similarList.pCmpCode && similarList.pCmpCode.length && searchType === 'code') ||
+            (similarList.pBrandEn && similarList.pBrandEn.length && searchType === 'brand') ||
+            (similarList.kind && similarList.kind.length && searchType === 'kind')
+        } else if (this.type === 'default') {
+          return (similarList.component && similarList.component.length) ||
+            (similarList.brand && similarList.brand.length) ||
+            (similarList.kind && similarList.kind.length)
+        }
+      }
+    },
+    methods: {
+      onSearch: function (key, type, e) {
+        if (e) {
+          e.stopPropagation()
+        }
+//        if (key === this.searchKeyword || this.keyword === this.searchKeyword) {
+//          return
+//        }
+        if (key) {
+          this.keyword = key
+          this.$emit('searchAction', {
+            keyword: this.keyword,
+            type: type
+          })
+        } else {
+          let sType = null
+          if (this.searchType === 'code' && this.similarList.pCmpCode[0]) {
+            this.keyword = this.similarList.pCmpCode[0].pCmpCode
+            sType = 'pCmpCode'
+          } else if (this.searchType === 'brand' && this.similarList.pBrandEn[0]) {
+            this.keyword = this.similarList.pBrandEn[0].nameCn
+            sType = 'pBrandEn'
+          } else if (this.searchType === 'kind' && this.similarList.kind[0]) {
+            this.keyword = this.similarList.kind[0].kind
+            sType = 'kind'
+          }
+          this.$emit('searchAction', {
+            keyword: this.keyword,
+            type: sType
+          })
+        }
+        this.searchKeyword = this.keyword
+        scrollTo('body', 10)
+        this.showSimilarWord = false
+      },
+      getSimilarList: function () {
+        if (this.showSimilar && this.keyword && this.keyword !== '') {
+          this.$http.get(this.similarUrl, {params: {keyword: this.keyword}}).then(
+            res => {
+              this.similarList = res.data
+              this.showSimilarWord = true
+            }
+          )
+        }
+      },
+      setShowSearchType: function (flag, e) {
+        if (e) {
+          e.stopPropagation()
+        }
+        this.showSearchType = flag
+      },
+      setSearchType: function (type, e) {
+        if (e) {
+          e.stopPropagation()
+        }
+        this.setShowSearchType(false)
+        this.searchType = type
+      }
+    }
+  }
+</script>
+<style lang="scss" scoped>
+  .search-content {
+    color: #333;
+    input {
+      margin: 0 0 0 .5rem;
+      line-height: normal;
+      padding-left: 1.1rem;
+    }
+    .similar-list {
+      width: 5.45rem;
+      background: #fff;
+      position: absolute;
+      left: 1.65rem;
+      top: .72rem;
+      border: 1px solid #ccc;
+      border-radius: .05rem;
+      max-height: 4.5rem;
+      overflow-y: auto;
+      li {
+        height: .6rem;
+        line-height: .6rem;
+        padding: 0 .1rem;
+        font-size: .26rem;
+        &.title {
+          color: #666;
+          border-bottom: 1px solid #ddd;
+          font-weight: bold;
+          background: #f6f5f5;
+        }
+      }
+    }
+    .options {
+      position: absolute;
+      left: .45rem;
+      width: 1.25rem;
+      padding-left: .25rem;
+      background: url(/images/mobile/@2x/search/select-arrow-blue.jpg) no-repeat;
+      background-size: .14rem .12rem;
+      background-position: 1.02rem .36rem;
+      color: #3e82f5;
+      font-size: .26rem;
+      i {
+        height: .46rem;
+        width: .01rem;
+        background: #eceef0;
+        display: block;
+        position: absolute;
+        left: 1.2rem;
+        top: .04rem;
+        margin-top: .18rem;
+      }
+      ul {
+        position: absolute;
+        left: .15rem;
+        top: .54rem;
+        z-index: -1;
+        width: 1.1rem;
+        border-radius: .05rem;
+        li {
+          height: .99rem;
+          /*border-radius: .05rem;*/
+          background: #666;
+          color: rgba(255, 255, 255, 0.89);
+          text-align: center;
+          line-height: 1.2rem;
+          font-size: .3rem;
+        }
+      }
+    }
+  }
+</style>

+ 2 - 1
components/mobile/base/index.js

@@ -1,3 +1,4 @@
 import SearchHeader from './SearchHeader.vue'
+import SearchHeader2 from './SearchHeader2.vue'
 
-export { SearchHeader }
+export { SearchHeader, SearchHeader2 }

+ 8 - 1
components/mobile/store/StoreDetail.vue

@@ -17,7 +17,7 @@
           {{store.description}}
         </p>
         <div class="com-none-state" v-else>
-          <p>抱歉,主营产品</p>
+          <p>抱歉,暂无主营产品信息</p>
         </div>
       </div>
      <div class="contact-info">
@@ -556,4 +556,11 @@
       }
     }
   }
+  .com-none-state {
+    padding: .6rem;
+    p {
+      margin: 0;
+      font-size: .28rem;
+    }
+  }
 </style>

+ 2 - 2
components/mobile/supplier/List.vue

@@ -12,7 +12,7 @@
       </ul>
       <div class="com-none-state" v-else>
         <img src="/images/mobile/@2x/search-empty.png">
-        <p>抱歉,暂无搜索结果</p>
+        <p>抱歉,请输入精确的关键词进行搜索</p>
         <nuxt-link to="/">返回首页</nuxt-link>
       </div>
       <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
@@ -93,7 +93,7 @@
       search: function (searchObj) {
         if (searchObj) {
           this.keyword = searchObj.keyword
-          console.log(searchObj)
+//          console.log(searchObj)
           this.field = searchObj.type || null
         }
         this.page = 1

+ 196 - 0
components/mobile/supplier/List2.vue

@@ -0,0 +1,196 @@
+<template>
+  <div>
+    <search-header2 @searchAction="search" :similarUrl="similarUrl" :type="'supplier'" :placeholder="'可通过型号/品牌/类目/名称查找供应商'"></search-header2>
+    <div class="supplier-list mobile-content">
+      <ul v-if="listData && listData.length">
+        <li v-for="item in listData" @click="goSupplierDetail(item)">
+          <img v-if="item.isStore == 1" class="open" src="/images/mobile/supplier/is-open.png" alt="">
+          <span>{{item.enName}}</span>
+          <!--<img class="tag" src="/images/mobile/supplier/tag.png" alt="">-->
+          <i class="tag iconfont icon-xiangyou"></i>
+        </li>
+      </ul>
+      <div class="com-none-state" v-else>
+        <img src="/images/mobile/@2x/search-empty.png">
+        <p>抱歉,请输入精确的关键词进行搜索</p>
+        <nuxt-link to="/">返回首页</nuxt-link>
+      </div>
+      <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
+    </div>
+  </div>
+</template>
+<script>
+  import { RemindBox } from '~components/mobile/common'
+  import {SearchHeader2} from '~components/mobile/base'
+  export default {
+    data () {
+      return {
+        keyword: '',
+        isSearchSearchingMore: false,
+        page: 1,
+        size: 10,
+        listData: [],
+        isChange: false,
+        isDataChange: false,
+        remindText: '',
+        timeoutCount: 0,
+        similarUrl: '/search/product/similarKeywords',
+        field: null
+      }
+    },
+    components: {
+      RemindBox,
+      SearchHeader2
+    },
+    mounted: function () {
+      this.$nextTick(() => {
+        window.addEventListener('scroll', this.scroll, false)
+      })
+    },
+    watch: {
+      'list': {
+        handler (val, oldVal) {
+          if (this.isChange) {
+            this.listData = val.content
+            this.page = 1
+            this.isChange = false
+            this.isDataChange = true
+          } else {
+            this.listData = this.listData.concat(val.content)
+            this.isSearchSearchingMore = false
+            this.isDataChange = false
+          }
+        },
+        immediate: true
+      }
+    },
+    computed: {
+      list () {
+        return this.$store.state.supplier.data.list.data
+      },
+      allPage () {
+        return Math.floor(this.list.totalElements / this.list.size) + Math.floor(this.list.totalElements % this.list.size > 0 ? 1 : 0)
+      }
+    },
+    methods: {
+      goLastPage: function () {
+        window.history.back(-1)
+      },
+      scroll: function () {
+        let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
+        if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchSearchingMore && this.page < this.allPage) {
+          this.getMoreSearch()
+        }
+      },
+      getMoreSearch: function () {
+        this.page++
+        this.isSearchSearchingMore = true
+        this.reloadData()
+      },
+      reloadData: function () {
+        this.$store.dispatch('supplier/getSupplierList', {keyword: this.keyword, page: this.page, size: this.size, field: this.field})
+      },
+      search: function (searchObj) {
+        if (searchObj) {
+          this.keyword = searchObj.keyword
+//          console.log(searchObj)
+          this.field = searchObj.type || null
+        }
+        this.page = 1
+        this.isChange = true
+        this.reloadData()
+      },
+      goSupplierDetail: function (item) {
+        // /mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}
+        this.$http.get('/vendor/introduction/product/count', {params: {vendUU: item.enUU}})
+          .then(response => {
+            if (response.data.success && response.data.count > 0) {
+              this.$router.push(`/mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}`)
+            } else {
+              this.onRemind('供应商正在完善产品信息,暂时不能查看更多。')
+            }
+          })
+      },
+      onRemind: function(str) {
+        this.remindText = str
+        this.timeoutCount++
+      }
+    }
+  }
+</script>
+<style lang="scss" scoped>
+    .supplier-list {
+      height: 100%;
+      background: #29a9f9;
+      .mobile-header {
+        position: fixed;
+        top: 0;
+        z-index: 10;
+        width:100%;
+        height:.88rem;
+        line-height: .88rem;
+        background: #3e82f5;
+        padding:0 .2rem 0 .1rem;
+        color:#fff;
+        > a {
+          font-size:.28rem;
+          color:#fff;
+          position: absolute;
+          i {
+            font-size: .48rem;
+            margin-right: -.1rem;
+          }
+        }
+        .search-content {
+          margin-left: .5rem;
+          line-height: normal;
+          padding-top: .14rem;
+          input {
+            color: #333;
+            width: 6.48rem;
+            line-height: normal;
+          }
+          span {
+            height: .46rem;
+            line-height: .46rem;
+          }
+        }
+      }
+      ul {
+        margin: .26rem auto 0;
+        width: 6.91rem;
+        li {
+          position: relative;
+          height: 1.21rem;
+          background: #fff;
+          line-height: 1.21rem;
+          padding-left: .74rem;
+          font-size: .32rem;
+          margin-bottom: .14rem;
+          border-radius: .05rem;
+          .open {
+            width: 1.35rem;
+            position: absolute;
+            top: -.08rem;
+            left: -.1rem;
+          }
+          .tag {
+            position: absolute;
+            right: .35rem;
+            color: #3f84f6;
+          }
+          span {
+            color: #333;
+            width: 4.65rem;
+            overflow: hidden;
+            text-overflow: ellipsis;
+            white-space: nowrap;
+            display: inline-block;
+          }
+        }
+      }
+    }
+  .com-none-state {
+    padding: 1.5rem .5rem .5rem .5rem;
+  }
+</style>

+ 2 - 1
components/mobile/supplier/index.js

@@ -1,3 +1,4 @@
 import List from './List.vue'
+import List2 from './List2.vue'
 import SupplierDetail from './SupplierDetail.vue'
-export { List, SupplierDetail }
+export { List, SupplierDetail, List2 }

+ 2 - 2
components/store/BaseInfo.vue

@@ -19,7 +19,7 @@
           </h3>
           <nuxt-link class="col-xs-10" :to="'/store/' + storeInfo.uuid">返回店铺</nuxt-link>
         </div>
-        <div class="intro-text" v-text="storeInfo.description"></div>
+        <div class="intro-text" v-text="storeInfo.description || '暂无主营产品信息'"></div>
       </div>
     </div>
     <div id="contact-fragment">
@@ -50,7 +50,7 @@
         </div>
         <div v-if="storeInfo.enterprise">
           <div class="contact-text">
-            <div class="intro-text" v-text="storeInfo.enterprise.description || '暂无'"></div>
+            <div class="intro-text" v-text="storeInfo.enterprise.description || '暂无企业简介'"></div>
           </div>
         </div>
       </div>

+ 17 - 0
pages/mobile/supplier/list2.vue

@@ -0,0 +1,17 @@
+<template>
+  <list2></list2>
+</template>
+<script>
+  import { List2 } from '~components/mobile/supplier'
+  export default {
+    layout: 'mobileNoHeader',
+    fetch ({ store }) {
+      return Promise.all([
+        store.dispatch('supplier/getSupplierList', {page: 1, size: 10})
+      ])
+    },
+    components: {
+      List2
+    }
+  }
+</script>

+ 1 - 1
pages/mobile/user/storeinfo.vue

@@ -188,7 +188,7 @@
           }
         } else {
           this.Islook = false
-          return this.normalText
+          return this.normalText && this.normalText.length ? this.normalText.length : '暂无信息'
         }
       },
       storeInfosave(_tp) {