deming/pageB/search/index.vue

100 lines
2.2 KiB
Vue
Raw Normal View History

2020-06-03 09:17:05 +00:00
<template>
<view class="search">
<view class="list">
<view class="title">搜索发现</view>
<view class="label">
2020-07-25 07:17:52 +00:00
<text v-for="(label, index) in searchwordlist" :key="index" @click="search(label.word)">{{ label.word }}</text>
2020-06-03 09:17:05 +00:00
</view>
</view>
</view>
</template>
<script>
export default {
name:"search",
data(){
return{
2020-07-25 07:17:52 +00:00
keyword: "",
searchwordlist: [],
2020-06-03 09:17:05 +00:00
}
2020-07-25 07:17:52 +00:00
},
created() {
this.getWordList();
},
// 点击搜索按钮
onNavigationBarButtonTap(e) {
if(e.index == 0) this.search(this.keyword);
},
// 输入框文本变化
onNavigationBarSearchInputChanged(e) {
this.keyword = e.text;
},
// 点击键盘搜索按钮
onNavigationBarSearchInputConfirmed(value) {
this.search(this.keyword);
},
2020-07-08 00:43:39 +00:00
methods:{
2020-07-25 07:17:52 +00:00
getWordList() {
this.$u.api.searchwordlist().then(res => {
this.searchwordlist = res.data;
})
},
2020-07-08 00:43:39 +00:00
search(value){
2020-07-25 07:17:52 +00:00
// console.log(value)
2020-07-31 00:45:30 +00:00
if(!value) {
this.$u.toast('搜索内容不可为空');
return false;
}
2020-07-08 00:43:39 +00:00
this.$u.route({
2020-07-25 07:17:52 +00:00
url: "/pageB/search/out",
params: {
value: value,
type: "shop",
order: 'goods_salenum'
2020-07-08 00:43:39 +00:00
}
})
}
2020-06-03 09:17:05 +00:00
}
}
</script>
<style lang="scss" scoped>
.search{
.sosuo{
width: 100%;
height: 88rpx;
border-bottom: 1rpx solid #ececec;
display: flex;
align-items: center;
padding: 0 30rpx;
>image{
width: 18rpx;
height: 32rpx;
margin-right: 24rpx;
flex-shrink: 0;
}
align-items: center;
}
.list{
padding: 30rpx;
.title{
font-size: 26rpx;
color: #999;
}
.label{
display: flex;
2020-07-25 07:17:52 +00:00
flex-wrap: wrap;
> text {
2020-06-03 09:17:05 +00:00
margin-top: 20rpx;
margin-right: 30rpx;
font-size: 26rpx;
color: #666;
text-align: center;
padding: 17rpx 12rpx;
background-color: #ececec;
border-radius: 10rpx;
}
}
}
}
</style>