Jacob
2026-10-12 61274af2f456188fa611dd871bc2bcc1a3a85db0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<template>
   <view>
       <view class='searchGood'>
           <view class='search acea-row row-between-wrapper'>
               <view class='input acea-row row-between-wrapper'>
                   <text class='iconfont icon-sousuo2'></text>
                   <input type='text' :value='searchValue' :focus="focus" placeholder='点击搜索商品' placeholder-class='placeholder' @input="setValue"></input>
               </view>
               <view class='bnt' @tap='searchBut'>搜索</view>
           </view>
           <view class='title'>热门搜索</view>
           <view class='list acea-row'>
               <block v-for="(item,index) in hotSearchList" :key="index">
                   <view class='item' @tap='setHotSearchValue(item.title)'>{{item.title}}</view>
               </block>
           </view>
           <view class='line'></view>
           <view class="goodList" v-if="bastList.length > 0" :style="{'minHeight':height+'px'}">
               <view class=" acea-row row-between-wrapper">
                   <GoodBlock v-for="item,index in bastList" :key="index" :size="'big'" :searchType="searchType" :searchValue="searchValue" :pageName="'商品搜索'" :moduleName="'搜索结果'"  :careBeanRate="careBeanRate" :goodsInfo="item"></GoodBlock>
               </view>
               <view class='loadingicon acea-row row-center-wrapper' v-if="bastList.length > 0">
                   <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
               </view>
               <view  v-if="bastList.length > 0" style="height: 30rpx;"></view>
           </view>
           <!-- <goodList :searchType="searchType" :searchValue="searchValue" :bastList="bastList" v-if="bastList.length > 0"></goodList> -->
       </view>
       <view class='noCommodity' style="background-color: #f5f5f5;">
           <view class='pictrue'  v-if="bastList.length == 0 && isbastList">
               <image src='https://ossacmall.bluedeer.com.cn/app/static/images/noSearch.png'></image>
           </view>
           <recommend :pageName="'商品搜索'"  :hostProduct='hostProduct' v-if="bastList.length == 0"></recommend>
       </view>
   </view>
</template>
 
<script>
   import GoodBlock from "@/pages/goods_block/index.vue";
   import {
       getSearchKeyword,
       getProductslist,
       getProductHot
   } from '@/api/store.js';
   import goodList from '@/components/goodList';
   import recommend from '@/components/recommend';
   export default {
       components: {
           GoodBlock,
           goodList,
           recommend
       },
       data() {
           return {
               hostProduct: [],
               searchValue: '',
               focus: true,
               bastList: [],
               hotSearchList: [],
               first: 0,
               limit: 8,
               page: 1,
               loading: false,
               loadend: false,
               loadTitle: '加载更多',
               hotPage:1,
               isScroll:true,
               isbastList: false,
               searchType:'',
               careBeanRate:0,
               height:100,
           };
       },
       onShow: function() {
           let that=this;
           let pages = getCurrentPages(), currPage  = pages[pages.length - 1];
           console.log('------------------page onShow start-----------------');
           console.log('route',currPage.route);
           console.log('options',currPage.options);
           console.log('------------------page onShow end-----------------');
           this.getRoutineHotSearch();
           this.getHostProduct();
       },
       onLoad:function(){
               let that=this;
               uni.getSystemInfo({
                   success: function(res) {
                       that.height = res.windowHeight - 350 / 750 * res.windowWidth;
                   },
               });
               
                   if (!that.$store.getters.careBeanRate) {
                       console.log('has not get careBeanRate')
                       uni.$once('updateCareBeanRate', () => {
                           that.$nextTick(()=>{
                               that.$set(that,'careBeanRate',that.$store.getters.careBeanRate)
                               console.log('get updateCareBeanRate',that.$store.getters.careBeanRate,that.careBeanRate)
                           })
                       });
                   } else {
                       that.$nextTick(()=>{
                           that.$set(that,'careBeanRate',that.$store.getters.careBeanRate)
                           console.log('has updateCareBeanRate',that.careBeanRate)
                       })
                   }
       },
       onReachBottom: function() {
           if(this.bastList.length>0){
               this.getProductList();
           }else{
               this.getHostProduct();
           }
           
       },
       methods: {
           getRoutineHotSearch: function() {
               let that = this;
               getSearchKeyword().then(res => {
                   that.$set(that, 'hotSearchList', res.data);
               });
           },
           getProductList: function(type) {
               let that = this;
               if (that.loadend) return;
               if (that.loading) return;
               that.loading = true;
               that.loadTitle = '';
               if(type){
                   that.searchType=type;
               }
               getProductslist({
                   keyword: that.searchValue,
                   page: that.page,
               }).then(res => {
                   if(type){
                       that.addTrack('yy_searchResultSuccess',{
                           'searchType_var':type=='isInputSearch'?'输入搜索':'热门搜索',
                           'searchWord_var':that.searchValue,
                           'ifSearchResult_var':res.data.total>0?'是':'否',
                           'resultNumber_var':res.data.total
                       });
                   }
                   let list = res.data.list,
                       loadend = list.length < that.limit;
                   that.bastList = that.$util.SplitArray(list, that.bastList);
                   that.$set(that,'bastList',that.bastList);
                   that.loading = false;
                   that.loadend = loadend;
                   that.loadTitle = loadend ? "😕人家是有底线的~~" : "加载更多";
                   that.page = that.page + 1;
                   that.isbastList = true;
               }).catch(err => {
                   that.loading = false,
                   that.loadTitle = '加载更多'
               });
           },
           getHostProduct: function() {
               let that = this;
               if(!this.isScroll) return
               getProductHot(that.hotPage,that.limit).then(res => {
                   that.isScroll = res.data.list.length>=that.limit
                   that.hostProduct = that.hostProduct.concat(res.data.list)
                   that.hotPage += 1;
               });
           },
           setHotSearchValue: function(event) {
               this.$set(this, 'searchValue', event);
               this.page = 1;
               this.loadend = false;
               this.$set(this, 'bastList', []);
               this.getProductList('isHotSearch');
           },
           setValue: function(event) {
               this.$set(this, 'searchValue', event.detail.value);
           },
           searchBut: function() {
               let that = this;
               that.focus = false;
               if (that.searchValue.length > 0) {
                   that.page = 1;
                   that.loadend = false;
                   that.$set(that, 'bastList', []);
                   uni.showLoading({
                       title: '正在搜索中'
                   });
                   that.getProductList('isInputSearch');
                   uni.hideLoading();
               } else {
                   return this.$util.Tips({
                       title: '请输入要搜索的商品',
                       icon: 'none',
                       duration: 1000,
                       mask: true,
                   });
               }
           }
       }
   }
</script>
 
<style lang="scss">
   page {
       margin-top: var(--status-bar-height);
       background-color: #fff !important;
   }
 
   .searchGood .search {
       padding-left: 30rpx;
       background-color: #fff !important;
   }
 
   .searchGood .search {
       padding-top: 20rpx;
   }
 
   .searchGood .search .input {
       width: 598rpx;
       background-color: #f7f7f7;
       border-radius: 33rpx;
       padding: 0 35rpx;
       box-sizing: border-box;
       height: 66rpx;
   }
 
   .searchGood .search .input input {
       width: 472rpx;
       font-size: 26rpx;
   }
 
   .searchGood .search .input .placeholder {
       color: #bbb;
   }
 
   .searchGood .search .input .iconfont {
       color: #000;
       font-size: 35rpx;
   }
 
   .searchGood .search .bnt {
       width: 120rpx;
       text-align: center;
       height: 66rpx;
       line-height: 66rpx;
       font-size: 30rpx;
       color: #282828;
   }
 
   .searchGood .title {
       font-size: 28rpx;
       color: #999;
       margin: 50rpx 30rpx 25rpx 30rpx;
   }
 
   .searchGood .list {
       padding-left: 10rpx;
   }
   .goodList{
       padding: 30rpx;
       background-color: #f5f5f5;
   }
   .searchGood .list .item {
       font-size: 26rpx;
       color: #454545;
       padding: 0 21rpx;
       height: 60rpx;
       border-radius: 30rpx;
       line-height: 60rpx;
       border: 1rpx solid #aaa;
       margin: 0 0 20rpx 20rpx;
   }
 
   .searchGood .line {
       border-bottom: 1rpx solid #eee;
       margin: 20rpx 30rpx 0 30rpx;
   }
</style>