deming/pageB/search/index.vue

113 lines
2.5 KiB
Vue
Raw Normal View History

2020-06-03 17:17:05 +08:00
<template>
<view class="search">
<view class="list">
<view class="title">搜索发现</view>
<view class="label">
2020-07-25 15:17:52 +08:00
<text v-for="(label, index) in searchwordlist" :key="index" @click="search(label.word)">{{ label.word }}</text>
2020-06-03 17:17:05 +08:00
</view>
</view>
</view>
</template>
<script>
export default {
name:"search",
data(){
return{
2020-08-09 14:23:59 +08:00
type: '', // 1 商家达人社区 2 商品
2020-07-25 15:17:52 +08:00
keyword: "",
searchwordlist: [],
2020-06-03 17:17:05 +08:00
}
2020-07-25 15:17:52 +08:00
},
2020-08-09 14:23:59 +08:00
// type: 2 商品 1: 其他
onLoad(option) {
this.type = option.type;
2020-08-09 18:29:36 +08:00
this.getWordList();
2020-07-25 15:17:52 +08:00
},
// 点击搜索按钮
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 08:43:39 +08:00
methods:{
2020-07-25 15:17:52 +08:00
getWordList() {
2020-08-09 18:29:36 +08:00
this.$u.api.searchwordlist({type:this.type}).then(res => {
console.log(res)
this.searchwordlist = res.data;
2020-07-25 15:17:52 +08:00
})
},
2020-07-08 08:43:39 +08:00
search(value){
2020-07-25 15:17:52 +08:00
// console.log(value)
2020-07-31 08:45:30 +08:00
if(!value) {
this.$u.toast('搜索内容不可为空');
return false;
}
2020-08-09 14:23:59 +08:00
let params = {
value: value,
type: this.type,
}
if(this.type == 2) {
2020-08-09 18:29:36 +08:00
this.$u.route({
url: "/pageB/search/out",
params: params,
})
}else{
this.$u.route({
url: "/pageB/search/searchGoods",
params: params,
})
}
2020-07-08 08:43:39 +08:00
}
2020-06-03 17:17:05 +08: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 15:17:52 +08:00
flex-wrap: wrap;
> text {
2020-06-03 17:17:05 +08: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>