index.vue
6.18 KB
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
<template>
<view>
<!-- 搜索商品 -->
<view>
<view class="flex-items-plus flex-row mar-top-20">
<view class="searchImg-box flex-items-plus">
<image class="searchImg" src="https://jy.scjysm.asia:18086/cdwlMall/questionnaire/file/static/img//searchImg.png"></image>
<input class="search-box" v-model="keyWord" placeholder-class="searchboxPlace"
placeholder="请输入您想要的宝贝" />
</view>
<view class="mar-left-40 fs26" @click="getList">搜索</view>
</view>
</view>
<!-- 热门搜索 -->
<view class="hotSearchBox tipsBox">
<view class="boxTitle mar-leftgetList-30" v-if="hotSearchList.length>0">
<label class="fs30 font-color-999 fs-weight-300">热门搜索</label>
<image class="seeIcon hotSearchListSee-icon" v-if="isSee" @click="changeHotSearchListIsSee"
src="https://jy.scjysm.asia:18086/cdwlMall/questionnaire/file/static/img//see.png"></image>
<image class="seeIcon hotSearchListNotSee-icon" v-else @click="changeHotSearchListIsSee"
src="https://jy.scjysm.asia:18086/cdwlMall/questionnaire/file/static/img//notSee.png"></image>
</view>
<view>
<view class="flex-wrap-1 flex-row" v-if="isSee">
<view v-for="(item, index) in hotSearchList" :key="index"
class="historySearDel-box flex-items-plus mar-right-30">
<view class="boxContent" @click="historyKeyword(item)">{{item}}</view>
</view>
</view>
<view v-else class="notSeeContent">当前热门搜索已隐藏</view>
</view>
</view>
<view class="line" color="#F3F4F5" />
<!-- 历史搜索 -->
<view class="historyBox tipsBox">
<view class="boxTitle mar-leftgetList-30" v-if="historyList.length>0">
<label class="fs30 font-color-999 fs-weight-300 ">历史搜索</label>
<image class="historyDel-icon" @click="historyDelAll" src="https://jy.scjysm.asia:18086/cdwlMall/questionnaire/file/static/img//index/historyDel_icon.png">
</image>
</view>
<view class="historySear-box flex-wrap-1 flex-row">
<view
v-for="(item, index) in historyList"
:key="item.searchId"
class="historySearDel-box flex-items-plus flex-sp-between mar-right-30"
>
<view class="boxContent historyText line1" @click="historyKeyword(item.search)">{{item.search}}</view>
<label class="font-color-DDD fs22 pad-topbot-10 text-align">|</label>
<view class="historyIconBox" @click="historyDelOne(item.searchId)">
<image class="historySearDel-icon text-align"
src="https://jy.scjysm.asia:18086/cdwlMall/questionnaire/file/static/img//index/historySearDel_icon.png"></image>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
const NET = require('../../../utils/request')
const API = require('../../../config/api')
export default {
data() {
return {
keyWord: '',
historyList: [],
hotSearchList: [],
list: [],
isSee: true
}
},
onLoad() {
},
onShow() {
this.findSearchHistory()
this.findHotSearch()
},
methods: {
searchTextDel() {
this.keyWord = ''
},
getList() {
if (!this.keyWord) {
uni.showToast({
title: '请输入要搜索内容!',
duration: 2000,
icon: 'none'
});
} else {
uni.navigateTo({
url: '../../goodsModule/goodsList?keyWord=' + this.keyWord,
})
}
},
historyKeyword(keyWord) {
uni.navigateTo({
url: '../../goodsModule/goodsList?keyWord=' + keyWord,
})
},
//热门搜索
findHotSearch() {
NET.request(API.SelectHotSearch, {}, 'GET').then(res => {
this.hotSearchList = res.data
})
},
changeHotSearchListIsSee() {
this.isSee = !this.isSee
},
//历史记录
findSearchHistory() {
NET.request(API.SearchHistory, {}, 'GET').then(res => {
this.historyList = res.data
}).catch(res => {
})
},
historyDelAll() {
uni.showModal({
title: '温馨提示',
content: '您确定要清空搜索记录吗?',
confirmText: '确定清空',
cancelText: '点错了',
success: (res) => {
if (res.confirm) {
this.deleteAllSearch()
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
deleteAllSearch() {
NET.request(API.DeleteAllSearch, {}, 'POST').then(res => {
this.historyList = res.data
}).catch(res => {
})
},
historyDelOne(searchId) {
uni.showModal({
title: '温馨提示',
content: '您确定要删除这一条记录吗?',
confirmText: '确定删除',
cancelText: '点错了',
success: (res) => {
if (res.confirm) {
NET.request(API.DeleteSearch, {
searchId: searchId
}, 'POST').then(res => {
this.findSearchHistory()
}).catch(res => {})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
}
}
</script>
<style lang='scss' scoped>
input {
padding-left: 80upx;
}
.searchImg-box{
.searchImg {
width: 36upx;
height: 36upx;
position: absolute;
left: 60upx;
}
.search-box {
background-color: #F1F1F1;
width: 530upx;
height: 66upx;
}
.searchboxPlace {
font-size: 26upx;
color: #A9A9A9;
padding-right: 30upx;
}
.searchClose-icon {
width: 30upx;
height: 30upx;
margin-left: -50upx;
z-index: 99999;
}
}
// 热门搜索
.hotSearchBox{
padding: 0 36upx;
.historyText{
flex: 1;
}
.hotSearchListSee-icon {
height: 24upx;
}
.hotSearchListNotSee-icon {
height: 36upx;
}
.seeIcon {
width: 40upx;
position: absolute;
right: 30upx;
}
.notSeeContent {
margin-top: 20upx;
text-align: center;
font-size: 24upx;
color: #CCCCCC;
}
}
.line{
margin: 70upx 0;
height: 2upx;
background: #F3F4F5;
}
// 历史搜索
.historyBox{
padding: 0 36upx;
.historySear-box{
width: 100%;
}
.historyDel-icon {
width: 30upx;
height: 30upx;
position: absolute;
right: 30upx;
}
.historyIconBox{
width: 50upx;
.historySearDel-icon {
position: relative;
width: 16upx;
height: 16upx;
}
}
}
.tipsBox{
padding: 15rpx 24rpx;
}
.boxTitle{
margin: 30rpx 0;
}
.historySearDel-box {
height: 54upx;
line-height: 54upx;
margin: 15rpx 15rpx;
background-color: #F1F1F1;
text-align: center;
overflow: hidden;
.boxContent{
font-size: 28rpx;
padding: 0 30rpx;
}
}
</style>