You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
254 lines
6.6 KiB
254 lines
6.6 KiB
<template>
|
|
<view>
|
|
<view class="xa_sch_wp">
|
|
<!-- 搜索框组件 -->
|
|
<view class="mode_com">
|
|
<view class=" dly_flex_c seh_box">
|
|
<view class="sous_k">
|
|
<input class="ipt_sch" @confirm="search" placeholder="搜索您感兴趣的..." type="text" placeholder-class="ipt_sch_ph" maxlength="16" :value="inputClearValue" @input="changeValue" />
|
|
<image class="clear_pic" @click="clearIcon()" src="/subPageA/images/btn_clear.png"></image>
|
|
</view>
|
|
<view class="sous_n"><button @click="search" class="btn_com sch_btn_suo">搜索</button></view>
|
|
</view>
|
|
<!-- <view class="third_tips">
|
|
<view v-for="(item,index) in searchKeywordsList" :key="index" @tap="searchFun(item.title,index)" :class="item.tapType">{{item.title}}</view>
|
|
</view> -->
|
|
</view>
|
|
</view>
|
|
<!-- 内容部分 -->
|
|
<view class="search_warp mode_com">
|
|
|
|
|
|
<!-- 景区 -->
|
|
<view class="searc_lst">
|
|
<!-- 一条信息 -->
|
|
<view v-if="searchList.length>0" class="anw_inf" v-for="(item, index) in searchList" :key="index" @click="gotoDetail(item.bcode, item.dataid + '&' + item.region)">
|
|
<rich-text :nodes="item.title"></rich-text>
|
|
<text class="after_type" v-if="item.bcode == 3301">景区</text>
|
|
<text class="after_type" v-if="item.bcode == 3302">美食</text>
|
|
<text class="after_type" v-if="item.bcode == 3303">攻略</text>
|
|
<text class="after_type" v-if="item.bcode == 3304">酒店</text>
|
|
<text class="after_type" v-if="item.bcode == 3305">线路</text>
|
|
</view>
|
|
<view class="scroll-empty" v-else>
|
|
<image class="empty-icon" src="http://www.mescroll.com/img/mescroll-empty.png?v=1" mode="widthFix"></image>
|
|
<view class="empty-tip">~ 暂无相关数据 ~</view>
|
|
</view>
|
|
|
|
<!-- 一条信息 -->
|
|
<!-- <view class="anw_inf">
|
|
<view>
|
|
<text class="anw_key"><text class="anw_key">天桂山</text></text>
|
|
自然风
|
|
<text class="anw_key">景区</text>
|
|
</view>
|
|
<text class="after_type">/ 酒店</text>
|
|
</view> -->
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
inputClearValue: '',
|
|
searchList: [],
|
|
searchKeywordsList:[],
|
|
netType:true
|
|
};
|
|
},
|
|
onLoad:function(){
|
|
var that = this;
|
|
this.$util.getNetworkType(
|
|
function(res){
|
|
if(res.networkType === 'none'){
|
|
uni.showToast({
|
|
title:that.$param.netMsg,
|
|
icon:"none",
|
|
duration:2000
|
|
})
|
|
that.netType = false;
|
|
}
|
|
},function(){
|
|
uni.showToast({
|
|
title:that.$param.netMsg,
|
|
icon:"none",
|
|
duration:2000
|
|
})
|
|
that.netType = false;
|
|
}
|
|
)
|
|
if(!that.netType){
|
|
return;
|
|
}
|
|
this.$util.hideLoadingByTime();
|
|
this.getSearchKeywords();
|
|
},
|
|
onShow:function(){
|
|
this.getSearchKeywords();
|
|
},
|
|
methods: {
|
|
searchFun:function(title,index){
|
|
for(var i = 0;i < this.searchKeywordsList.length;i++){
|
|
if(i == index){
|
|
this.searchKeywordsList[i].tapType = "reci_sch cur";
|
|
}else{
|
|
this.searchKeywordsList[i].tapType = "reci_sch";
|
|
}
|
|
}
|
|
this.inputClearValue = title;
|
|
this.search();
|
|
},
|
|
getSearchKeywords:function(){
|
|
var that = this;
|
|
this.searchKeywordsList = [];
|
|
var url = this.$config.getMessageInfoFormFilter_two;
|
|
var data = {
|
|
type: this.$param.keywordsType,
|
|
userkey:this.$param.userkey,
|
|
pageno:1,
|
|
pageSize: 10,
|
|
sort:2,
|
|
};
|
|
this.$Request.post(url, data).then(res => {
|
|
for(var i = 0;i < res.data.length;i++){
|
|
if(that.inputClearValue == res.data[i].title){
|
|
var item = {
|
|
title:res.data[i].title,
|
|
tapType:'reci_sch cur'
|
|
}
|
|
}else{
|
|
var item = {
|
|
title:res.data[i].title,
|
|
tapType:'reci_sch'
|
|
}
|
|
}
|
|
this.searchKeywordsList.push(item);
|
|
}
|
|
})
|
|
},
|
|
clearIcon: function() {
|
|
this.inputClearValue = '';
|
|
},
|
|
changeValue: function(event) {
|
|
this.inputClearValue = event.detail.value;
|
|
},
|
|
gotoDetail: function(type, value) {
|
|
var data = value.split('&');
|
|
switch (type) {
|
|
case '3301':
|
|
uni.navigateTo({
|
|
url: '/subPageA/scenic/scenicdetial/scenicdetial?guid=' + data[0]
|
|
});
|
|
break;
|
|
case '3302':
|
|
uni.navigateTo({
|
|
url: '/subPageA/food/fooddetial/fooddetial?fid=' + data[0] + '&fareacode=' + data[1]
|
|
});
|
|
break;
|
|
case '3303':
|
|
uni.navigateTo({
|
|
url: '/subPageA/method/methoddetail/methoddetail?guid=' + data[0]
|
|
});
|
|
break;
|
|
case '3304':
|
|
uni.navigateTo({
|
|
url: '/subPageA/hotel/hoteldetail/hoteldetail?id=' + data[0]+'®ion='+data[1]
|
|
});
|
|
break;
|
|
case '3305':
|
|
uni.navigateTo({
|
|
url: '/pages/travelroute/travelroutedetail/travelroutedetail?id=' + data[0]
|
|
});
|
|
break;
|
|
}
|
|
},
|
|
search: function() {
|
|
uni.showLoading({
|
|
title: '加载中',
|
|
mask: true
|
|
});
|
|
var content = this.inputClearValue;
|
|
if (content == null || content == '') {
|
|
uni.showToast({
|
|
title: '请输入内容',
|
|
icon: 'none'
|
|
});
|
|
return;
|
|
}
|
|
for(var i = 0;i < this.searchKeywordsList.length;i++){
|
|
if(this.searchKeywordsList[i].title == content){
|
|
this.searchKeywordsList[i].tapType = "reci_sch cur";
|
|
}else{
|
|
this.searchKeywordsList[i].tapType = "reci_sch";
|
|
}
|
|
}
|
|
var data = {
|
|
search: content,
|
|
pageno: 1,
|
|
pagesize: 10,
|
|
userkey: this.$param.userkey
|
|
};
|
|
this.$Request.post(this.$config.searchList, data).then(res => {
|
|
if (res.status == 200) {
|
|
var data = JSON.stringify(res.data.data);
|
|
var wordkey = [];
|
|
wordkey = res.data.wordkey.split('|');
|
|
for (let i = 0; i < wordkey.length; i++) {
|
|
var subStr = new RegExp(wordkey[i], 'ig');
|
|
data = data.replace(subStr, "<span style='color: rgb(22, 119, 255);font-size: 30rpx;'>" + wordkey[i] + '</span>');
|
|
}
|
|
var list = JSON.parse(data);
|
|
this.searchList = list;
|
|
uni.hideLoading();
|
|
return;
|
|
}
|
|
uni.showToast({
|
|
title: '调用失败',
|
|
icon: 'none'
|
|
});
|
|
uni.hideLoading();
|
|
});
|
|
}
|
|
},
|
|
onLoad() {}
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
@import url('/static/css/common.css');
|
|
|
|
page {
|
|
background: #fff;
|
|
}
|
|
|
|
/* @import url('search.css'); */
|
|
|
|
.anw_inf:after {
|
|
content: '';
|
|
display: block;
|
|
width: 32rpx;
|
|
height: 32rpx;
|
|
background: url(/subPageA/images/icn_down_g.png) no-repeat;
|
|
background-size: 100%;
|
|
transform: rotate(-90deg);
|
|
position: absolute;
|
|
right: 0;
|
|
top: 32rpx;
|
|
padding-left: 10rpx;
|
|
}
|
|
|
|
.ipt_sch:before {
|
|
content: '';
|
|
width: 30rpx;
|
|
height: 30rpx;
|
|
background: #fff url(/subPageA/images/icon-search.png) no-repeat;
|
|
background-size: 100%;
|
|
position: absolute;
|
|
right: 10rpx;
|
|
top: 15rpx;
|
|
z-index: 4;
|
|
}
|
|
</style>
|
|
|