Browse Source

修改移动端全局搜索上啦加载数据问题

shenjj 7 years ago
parent
commit
95ffdd6fca

+ 4 - 3
components/mobile/applyPurchase/PublishSeek.vue

@@ -5,7 +5,7 @@
         <span><i>*</i>品牌:</span>
         <input type="text" v-model="applyObj.brand" @blur="checkBrand" @input="onBrandChange" placeholder="请勿填中文符号">
         <ul class="similar brand-similar-list" v-show="showSimilarBrandList && applyObj.brand">
-          <li v-for="sBrand in similarBrand" @click="setBrand(sBrand.nameEn)">{{sBrand.nameEn}}</li>
+          <li v-for="sBrand in similarBrand" @click.stop="setBrand(sBrand.nameEn)">{{sBrand.nameEn}}</li>
         </ul>
       </div>
       <div class="content-line">
@@ -16,7 +16,7 @@
         <span><i>*</i>型号:</span>
         <input type="text" v-model="applyObj.code" @blur="checkCode" @input="onCodeChange" placeholder="请勿填中文符号">
         <ul class="similar" v-show="showSimilarCodeList && applyObj.code">
-          <li v-for="sCode in similarCode" @click="setCode(sCode.code)">{{sCode.code}}</li>
+          <li v-for="sCode in similarCode" @click.stop="setCode(sCode.code)">{{sCode.code}}</li>
         </ul>
       </div>
       <div class="content-line">
@@ -54,7 +54,7 @@
         <input type="text" v-model="applyObj.produceDate" @input="onProduceDateChange">
       </div>-->
     </div>
-    <a @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)">确认发布</a>
+    <a @click.stop="authorityInterceptor(baseUrls.userPublishSeek, goPublish)">确认发布</a>
   </div>
 </template>
 <script>
@@ -372,6 +372,7 @@
         input {
           width: 3.49rem;
           height: .52rem;
+          line-height: .52rem;
           border: none;
           font-size: .26rem;
           vertical-align: middle;

+ 80 - 8
pages/mobile/center/user/applyPurchase.vue

@@ -1,16 +1,19 @@
 <template>
-  <div class="apply_purchase_mobile">
+  <div class="apply_purchase_mobile" @click="showSimilarBrandList = false">
     <div class="com-mobile-header mobile-center-header">
-      <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
+      <a @click.stop="goLastPage"><i class="iconfont icon-fanhui"></i></a>
       <p>发布求购</p>
       <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
     </div>
     <div class="mobile-fix-content mobile-centerfix-content" id="mobileFixContent">
-      <div class="search-content search-content2">
-        <input type="text" placeholder="请输入您要询价求购的型号" v-model="keyword" @keyup.13="searchComplist">
-        <span @click="searchComplist" >
+      <div class="search-content search-content2" style="position: relative">
+        <input type="text" placeholder="请输入您要询价求购的型号" @blur="checkBrand" @input="onBrandChange" v-model="keyword" @keyup.13="searchComplist">
+        <span @click.stop="searchComplist" >
           <i class="iconfont icon-sousuo"></i>
-      </span>
+        </span>
+        <ul class="similar brand-similar-list" v-show="showSimilarBrandList && keyword">
+          <li v-for="sBrand in similarBrand" @click.stop="setBrand(sBrand.nameEn)">{{sBrand.nameEn}}</li>
+        </ul>
       </div>
       <publish-seek v-if="showPublishBox" :dataObj="componentSeekObj" @remindAction="onRemind" :isNumberReg="true"></publish-seek>
       <template v-else>
@@ -23,7 +26,7 @@
               <p>规格:<span v-text="comp.spec || '-'"></span></p>
               <p>单位:<span v-text="comp.unit || 'PCS'"></span></p>
             </div>
-            <a class="sa-pub" @click="compInquiry(comp, $event)">立即询价</a>
+            <a class="sa-pub" @click.stop="compInquiry(comp, $event)">立即询价</a>
           </li>
         </ul>
         <empty-status :type="'collect'" :showLink="true" :text="'抱歉,没有相关信息'" v-else></empty-status>
@@ -59,7 +62,9 @@
           spec: '',
           prodTitle: ''
         },
-        showPublishBox: true
+        showPublishBox: true,
+        showSimilarBrandList: false,
+        similarBrand: []
       }
     },
     watch: {
@@ -93,6 +98,47 @@
       PublishSeek
     },
     methods: {
+      checkBrand: function () {
+        if (!this.keyword) {
+          this.setRemindText('品牌不能为空')
+        }
+        return this.keyword
+      },
+      onBrandChange: function () {
+        this.keyword = this.keyword.trim()
+        if ((/[^\x00-\xff]/g).test(this.keyword)) {
+          let chineseIndex = -1
+          for (let i = 0; i < this.keyword.length; i++) {
+            if ((/[^\x00-\xff]/g).test(this.keyword.charAt(i)) && !(/[\u4e00-\u9fa5]/).test(this.keyword.charAt(i))) {
+              chineseIndex = i
+              break
+            }
+          }
+          if (chineseIndex > -1) {
+            this.keyword = this.keyword.substring(0, chineseIndex)
+          }
+        } else if (this.keyword && this.baseUtils.getRealLen(this.keyword) > 50) {
+          this.keyword = this.baseUtils.cutOutString(this.keyword, 50)
+        } else {
+          this.getSimilarBrand()
+        }
+      },
+      getSimilarBrand: function () {
+        if (this.keyword) {
+          this.$http.get('/search/similarBrands', {params: {keyword: this.keyword}})
+            .then(response => {
+              this.similarBrand = response.data
+              this.showSimilarBrandList = response.data.length > 0
+            })
+        } else {
+          this.showSimilarBrandList = false
+        }
+      },
+      setBrand: function (brand) {
+        this.keyword = brand
+        this.showSimilarBrandList = false
+        this.searchComplist()
+      },
       searchComplist () {
         this.showPublishBox = false
         this.page = 1
@@ -131,6 +177,32 @@
 </script>
 <style lang="scss" scoped>
   .mobile-fix-content {
+    .similar {
+      position: absolute;
+      width: 6.5rem;
+      max-height: 2.5rem;
+      overflow-y: auto;
+      z-index: 12;
+      border: 1px solid #7e7e7e;
+      border-radius: .05rem;
+      top: .7rem;
+      background: #fff;
+      left: 0.1rem;
+      right: 0;
+      margin: 0 auto;
+      li {
+        height: .5rem;
+        line-height: .5rem;
+        font-size: .26rem;
+        color: #999;
+        padding-left: .19rem;
+        margin-top: 0px;
+        &:focus, &:active, &:hover {
+          background: #999;
+          color: #fff;
+        }
+      }
+    }
     .search-content {
       text-align: center;
       input {

+ 8 - 4
pages/mobile/center/vendor/product.vue

@@ -733,10 +733,14 @@
         this.MaterielItem.pbranden = this.MaterielItem.brand
         this.MaterielItem.pbranden = this.MaterielItem.brand
         this.$http.post('/trade/products/update/product', this.MaterielItem).then(res => {
-          this.setRemindText('修改成功')
-          this.showMateriel = false
-          this.page = 1
-          this.getResourceProvidor()
+          if (res.data.success) {
+            this.setRemindText('修改成功')
+            this.showMateriel = false
+            this.page = 1
+            this.getResourceProvidor()
+          } else {
+            this.setRemindText(res.data.message)
+          }
         })
       },
       update (e) {

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

@@ -160,7 +160,7 @@
                        <div class="fl" @click.stop="goAttach(item.attach)">
                          <div class="name">规格书:</div>
                          <div class="text">
-                           <i class="iconfont icon-pdf" :class="{'active': item.attach && item.attach !== '' && item.attach !== '1'}"></i>
+                           <a :href="item.attach" target="_blank"><i class="iconfont icon-pdf" :class="{'active': item.attach && item.attach !== '' && item.attach !== '1'}"></i></a>
                          </div>
                        </div>
                        <div class="fl">