瀏覽代碼

修改测试BUG

shenjj 7 年之前
父節點
當前提交
129703f702
共有 3 個文件被更改,包括 14 次插入10 次删除
  1. 10 7
      components/main/Search.vue
  2. 3 3
      pages/mobile/search/newkeycode.vue
  3. 1 0
      pages/search/_keyword.vue

+ 10 - 7
components/main/Search.vue

@@ -16,9 +16,10 @@
                :placeholder="placeholderByType"
                @focus.stop.prevent="onFocus()"
                @blur.stop.prevent="onBlur()"
+               @keyup.13="onSearch()"
                @keyup.40="onSelectChange(1)"
                @keyup.38="onSelectChange(-1)"
-               @keyup.13="onSearch()"/>
+        />
         <span class="input-group-btn" @click="onSearch()" style="z-index: 10">
           <button class="btn btn-primary search-btn" type="button" :class="{'Isblue':!SelectItem}">搜&nbsp;索</button>
         </span>
@@ -39,7 +40,8 @@
         :class="{'association2': !SelectItem, 'pcb-asso': isPcb}"
         v-show="showAssociate"
         @mouseenter="associate.focus=true"
-        @mouseleave="associate.focus=false">
+        @mouseleave="associate.focus=false"
+    >
       <li v-for="(v, index) in similarKeywords.result" class="item"
           :class="{'active': index==associate.activeIndex}"
           @click.stop.prevent="onAssociateClick(v.value)">{{v.value}}
@@ -198,7 +200,7 @@
       'keyword': {
         handler (val, oldVal) {
           let keywords = this.similarKeywords
-          if (!keywords.result || !keywords.result.length || this.associate.activeIndex === null || val !== keywords[this.associate.activeIndex]) {
+          if (!keywords.result || !keywords.result.length || this.associate.activeIndex === null || val !== keywords.result[this.associate.activeIndex].value) {
             this.onChange()
           }
         }
@@ -230,20 +232,21 @@
         this.associate.show = this.associate.focus
       },
       onSelectChange (count) {
+        console.log(1)
         let keywords = this.similarKeywords
-        if (keywords && keywords.length) {
+        if (keywords && keywords.result.length) {
           let index = this.associate.activeIndex
           if (index === null) {
             index = -1
           }
           index += count
-          if (index >= keywords.length) {
+          if (index >= keywords.result.length) {
             index = 0
           } else if (index < 0) {
-            index = keywords.length - 1
+            index = keywords.result.length - 1
           }
           this.associate.activeIndex = index
-          this.keyword = keywords[index]
+          this.keyword = keywords.result[index].value || keywords.result[index].code || keywords.result[index].nameCn || keywords.result[index].name
         }
       },
       onChange () {

+ 3 - 3
pages/mobile/search/newkeycode.vue

@@ -511,7 +511,7 @@
       // 搜索点击事件
       onClickSearchHander() {
         console.log(this.keyword)
-        if (!this.keyword) return
+        if (!this.keyword) {this.setRemindText('请输入关键字')}
         this.$router.push(`/mobile/search/newkeycode?choosetype=${this.ChooseTop}&keyword=${this.keyword}`)
         // this.setChangelistHander(this.ChooseTop)
         // window.location.href =
@@ -529,7 +529,7 @@
         // 如果有值,则代表 是品牌 模糊到精确
         // 这里发送数据请求
         this.isSearchSearchingMore = true
-        this.$http.get(`/search/201819`, {params: {count: 10, page: this.page, keyword: this.keyword, type: this.ChooseTop}}).then(res => {
+        this.$http.get(`/search/201819`, {params: {count: 10, page: this.page, keyword: this.displayKeyword, type: this.ChooseTop}}).then(res => {
           this.isSearchSearchingMore = false
           if (!this.brandIsAccurate && this.ChooseTop === 'brand') {
             // 品牌模糊查询
@@ -574,7 +574,7 @@
         if (document.querySelector('#main-search-wrapper')) document.querySelector('#main-search-wrapper').scrollTop = 0
         this.ChooseTop = str
         this.page = 1
-        if (!this.keyword) return
+        if (!this.keyword) { this.setRemindText('请输入关键字') }
         this.displayKeyword = this.keyword
         this.brandIsAccurate = false
         this.isSearchSearchingMore = true

+ 1 - 0
pages/search/_keyword.vue

@@ -78,6 +78,7 @@
       '$route.query': {
         handler: function (val) {
           this.key = val.w
+          this.nowPage = 1
           this.reloadAll()
         },
         immediate: false