Browse Source

修改移动端全局搜索

shenjj 7 years ago
parent
commit
4b6f59d7e3
2 changed files with 13 additions and 7 deletions
  1. 3 1
      components/mobile/search/MainSearch.vue
  2. 10 6
      pages/mobile/search/newkeycode.vue

+ 3 - 1
components/mobile/search/MainSearch.vue

@@ -100,7 +100,9 @@
         this.associate.show = true
       },
       onSearch (item) {
-        this.$router.push(`/mobile/search/newkeycode?choosetype=${this.ChooseTop}&keyword=${encodeURIComponent(this.keyword)}`)
+        if (this.keyword) {
+          this.$router.push(`/mobile/search/newkeycode?choosetype=${this.ChooseTop}&keyword=${encodeURIComponent(this.keyword)}`)
+        }
         // if (item) {
         //   this.keyword = item.keyword
         //   if (item.type === 'SEARCH_STORE') {

+ 10 - 6
pages/mobile/search/newkeycode.vue

@@ -12,8 +12,8 @@
        <span :class="ChooseTop === 'brand' ? 'active' : ''" @click="setChangelistHander('brand')"><a>品牌</a></span>
      </div>
    </div>
-   <ul class="associate-list" v-show="associate.show">
-     <li @click="onAssociateClick(similar)" v-for="similar in similarKeywords.result">
+   <ul class="associate-list" v-show="associate.show" @click="associate.show = false">
+     <li @click.stop="onAssociateClick(similar)" v-for="similar in similarKeywords.result">
        <i class="icon-sousuo iconfont"></i>
        <span>{{Getsimilar(similar)}}</span>
        <!--<span v-if="ChooseTop === 'component'">{{similar.code}}</span>-->
@@ -21,11 +21,11 @@
        <!--<span v-else-if="ChooseTop === 'store'">{{similar}}</span>-->
        <!--<span v-else-if="ChooseTop === 'brand'">{{similar.nameEn}}</span>-->
      </li>
-     <li @click="onClickTosearch(keyword)">查找“{{baseUtils.filterStringEllipsis(keyword, 30)}}”</li>
+     <li @click.stop="onClickTosearch(keyword)">查找“{{baseUtils.filterStringEllipsis(keyword, 30)}}”</li>
    </ul>
    <!-- 主体内容 -->
    <div class="main-search-wrapper">
-     <div class="search-title">搜索“<span>{{keyword}}</span>”暂无此{{getNowChooseType}}{{allTotal === 0 ? '' : `,为您找到${allTotal}条相关信息`}}</div>
+     <div class="search-title">搜索“<span>{{displayKeyword}}</span>”暂无此{{getNowChooseType}}{{allTotal === 0 ? '' : `,为您找到${allTotal}条相关信息`}}</div>
      <template v-if="allTotal > 0">
        <!-- 品牌精确查找 -->
        <template v-if="ChooseTop === 'brand' && brandIsAccurate">
@@ -330,7 +330,7 @@
    <!-- 询价 -->
    <publish-supplier-seek :product="currentProduct" :showPublishBox="showPublishBox" @cancelAction="showPublishBox = false" @remindAction="setRemindText"></publish-supplier-seek>
     <!-- 查看品牌更多信息 -->
-   <modal-wrapper :showModal="showBrandDetails" :title="'XXX品牌'" @closeAction="showBrandDetails=false">
+   <modal-wrapper :showModal="showBrandDetails" :title="currentBrandItem.brand && currentBrandItem.brand.nameEn" @closeAction="showBrandDetails=false">
      <div class="store-info" >
        <div class="store-description">
          <h4>主营产品</h4>
@@ -419,7 +419,8 @@
         allTotal: 0, // 总条数
         associate: {
           show: false
-        }
+        },
+        displayKeyword: ''
       }
     },
     computed: {
@@ -500,6 +501,7 @@
       },
       // 搜索点击事件
       onClickSearchHander() {
+        if (!this.keyword) return
         this.$router.push(`/mobile/search/newkeycode?choosetype=${this.ChooseTop}&keyword=${this.keyword}`)
         // this.setChangelistHander(this.ChooseTop)
         // window.location.href =
@@ -558,6 +560,8 @@
         if (document.querySelector('#main-search-wrapper')) document.querySelector('#main-search-wrapper').scrollTop = 0
         this.ChooseTop = str
         this.page = 1
+        if (!this.keyword) return
+        this.displayKeyword = this.keyword
         this.brandIsAccurate = false
         this.isSearchSearchingMore = true
         this.$http.get(`/search/201819`, {params: {count: 10, page: 1, keyword: this.keyword, type: this.ChooseTop}}).then(data => {