panhui 5 лет назад
Родитель
Сommit
0ea4728481
3 измененных файлов с 56 добавлено и 90 удалено
  1. 4 2
      src/components/bar/SearchBarBtn.vue
  2. 40 81
      src/pagesHome/Search.vue
  3. 12 7
      src/pagesProduct/FilterVendor.vue

+ 4 - 2
src/components/bar/SearchBarBtn.vue

@@ -11,7 +11,7 @@
                     :color="fontColor"
                 />
                 <van-icon v-else name="arrow-left" :size="24" @click="navigateBack(2)" :color="fontColor" />
-                <div class="search" @click="navigateBack">
+                <div v-if="show" class="search" @click="navigateBack">
                     <!-- <van-icon name="http://imttech.oss-cn-hangzhou.aliyuncs.com/micro/search.png" /> -->
                     <span>{{ value }}</span>
                     <!-- <span>搜索...</span> -->
@@ -49,7 +49,8 @@ export default {
         return {
             menuButtonInfo: {},
             search: '',
-            isHome: false
+            isHome: false,
+            show: false
         };
     },
     computed: {
@@ -97,6 +98,7 @@ export default {
     onReady() {
         this.isHome = getCurrentPages().length === 1;
         this.search = this.value;
+        this.show = true;
     },
     watch: {
         value() {

+ 40 - 81
src/pagesHome/Search.vue

@@ -8,7 +8,7 @@
 'navigationBarTextStyle':'black',
 "usingComponents": {
   "van-sidebar": "../native/vant/sidebar/index",
-  "van-sidebar-item": "../native/vant/sidebar-item/index"
+  "van-sidebar-item": "../native/vant/sidebar-item/index",
 },
 'disableScroll': true
 }
@@ -29,9 +29,13 @@
                     @change="changeSearch"
                     :maxlength="60"
                     @focus="focus = true"
-                    @blur="blurSearch"
+                    always-embed
+                    @click="focus = true"
+                    v-if="focus"
                 />
 
+                <!-- <mp-searchbar @selectresult="confirm" :search="search"></mp-searchbar> -->
+
                 <scroll-view
                     v-if="searchKey"
                     scroll-y
@@ -108,7 +112,8 @@ export default {
             historys: [],
             focus: false,
             hots: ['信息通信', '3D打印', '机床', '机加工', '电子器件', '高精度打印机', '量具仪具'],
-            matchList: []
+            matchList: [],
+            ios: false
         };
     },
     computed: {
@@ -122,78 +127,17 @@ export default {
             } else {
                 return {};
             }
-        },
-        nowCategory() {
-            return { ...(this.getList([...this.categories], this.activeKey) || { children: [] }) };
-        },
-        firstLevelId() {
-            if (this.categories.length > this.activeKey) {
-                return [...this.categories][this.activeKey].id;
-            } else {
-                return '';
-            }
-        },
-        listQuery() {
-            if (this.searchType === 'product') {
-                return {
-                    productSort: this.sort,
-                    categoryIds: this.categoryIds || '',
-                    countries: this.countries,
-                    tagIds: this.tagIds,
-                    applicationField: this.applicationField,
-                    query: JSON.stringify({
-                        vendorInfoId: this.vendorInfoId
-                    })
-                };
-            } else if (this.searchType === 'vendor') {
-                return {
-                    vendorSort: this.sort,
-                    categoryIds: this.categoryIds,
-                    countries: this.countries,
-                    continent: this.continent,
-                    enterpriseType: this.enterpriseType,
-                    applicationField: this.applicationField
-                };
-            } else {
-                return {
-                    sort: 'createdAt,desc'
-                };
-            }
-        },
-        filterQuery() {
-            if (this.searchType === 'product') {
-                return {
-                    pageType: 'product',
-                    categoryIds: this.categoryIds,
-                    countries: this.countries,
-                    continent: this.continent,
-                    searchTop: this.searchTop,
-                    tagIds: this.tagIds,
-                    applicationField: this.applicationField,
-                    brand: this.brand
-                };
-            } else {
-                return {
-                    pageType: 'vendor',
-                    categoryIds: this.categoryIds,
-                    countries: this.countries,
-                    continent: this.continent,
-                    enterpriseType: this.enterpriseType,
-                    searchTop: this.searchTop,
-                    applicationField: this.applicationField
-                };
-            }
         }
     },
     onShow() {
         setTimeout(() => {
             this.$nextTick(() => {
                 this.focus = true;
-                if (this.search) {
-                    this.changeSearch({
-                        detail: this.search
-                    });
-                }
+                // if (this.search) {
+                //     this.changeSearch({
+                //         detail: this.search
+                //     });
+                // }
             });
         }, 100);
     },
@@ -202,6 +146,14 @@ export default {
         this.$http.get('/sysConfig/get/SEARCH_HOT').then(res => {
             this.hots = res.value.split(',');
         });
+
+        wx.getSystemInfo({
+            success: res => {
+                if (res.brand === 'iPhone') {
+                    this.ios = true;
+                }
+            }
+        });
     },
     onReady() {
         this.left = wx.createSelectorQuery().select('#left');
@@ -246,6 +198,8 @@ export default {
             historys = [...new Set(historys)];
             historys = historys.slice(0, 10);
             var _this = this;
+            this.focus = false;
+            this.search = info;
             wx.setStorage({
                 key: 'searchHistory',
                 data: JSON.stringify(historys),
@@ -254,30 +208,25 @@ export default {
 
                     wx.navigateTo({
                         url: '/pagesHome/SearchList?search=' + info,
-                        success: () => {
-                            _this.search = info;
-                            _this.focus = false;
-                        }
+                        success: () => {}
                     });
                 }
             });
         },
         goVendor(info) {
+            this.search = info;
+            this.focus = false;
             wx.navigateTo({
                 url: '/pagesHome/VendorList?search=' + info,
-                success: () => {
-                    this.search = info;
-                    this.focus = false;
-                }
+                success: () => {}
             });
         },
         goInformation(info) {
+            this.search = info;
+            this.focus = false;
             wx.navigateTo({
                 url: '/pagesHome/InformationList?search=' + info,
-                success: () => {
-                    this.search = info;
-                    this.focus = false;
-                }
+                success: () => {}
             });
         },
         getHistory() {
@@ -312,6 +261,9 @@ export default {
                 });
         },
         changeSearch(e) {
+            if (this.ios) {
+                this.search = e.detail;
+            }
             this.searchKey = e.detail;
             if (e.detail) {
                 matchingName(e.detail).then(res => {
@@ -364,6 +316,13 @@ export default {
         line-height: 25px;
         flex-shrink: 0;
     }
+
+    .van-field__body--search {
+        -webkit-user-select: text !important;
+    }
+    .van-field__input {
+        -webkit-user-select: text !important;
+    }
 }
 
 .container {

+ 12 - 7
src/pagesProduct/FilterVendor.vue

@@ -99,14 +99,13 @@ export default {
     methods: {
         getList() {
             this.$http
-                .post('/vendorInfo/show', {
-                    page: 0,
-                    size: 100,
-                    categoryIds: this.categoryIds || '',
-                    vendorSort: 'COMPOSITE'
-                })
+                .get(
+                    this.categoryIds
+                        ? '/vendorInfo/byProductCategory?productCategoryId=' + this.categoryIds
+                        : '/vendorInfo/allList'
+                )
                 .then(res => {
-                    this.list = res.content.map(item => {
+                    this.list = res.map(item => {
                         return {
                             ...item,
                             name: this.getName(item, ['chCompanyName', 'enCompanyName']),
@@ -146,5 +145,11 @@ export default {
     .van-cell__left-icon-wrap {
         margin-right: 12px;
     }
+
+    .van-cell__title {
+        white-space: nowrap;
+        overflow: hidden;
+        text-overflow: ellipsis;
+    }
 }
 </style>