连云港陪玩陪聊
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.
chunwan/pages/index/citySearch.vue

130 lines
2.5 KiB

3 months ago
<template>
<view class="city">
<view class="city-hd">
<image class="sousuo" src="@/static/city-sousuo.png"></image>
2 months ago
<input type="search" :value="keyword" @input="changeInput" placeholder="请输入" />
3 months ago
<image class="clear" src="@/static/city-close.png"></image>
</view>
<view class="city-bd">
2 months ago
<view class="list">
<view class="item" v-for="(a,index) in list" :key="index" @click="clickTap(a)">{{a.name}}</view>
</view>
<view class="empty" v-if="isShow">
3 months ago
<image src="@/static/empty.png"></image>
<view class="txt">暂无数据</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
2 months ago
isShow: false,
2 months ago
city: "",
2 months ago
keyword: "",
list: []
3 months ago
};
2 months ago
},
onLoad(o) {
this.city = decodeURIComponent(o.city);
2 months ago
console.log(this.city)
2 months ago
},
methods: {
2 months ago
clickTap(a){
uni.$emit("clickTap", a);
this.city = "";
this.keyword= "";
this.list = [];
this.isShow = false;
uni.navigateBack({
delta:1
})
},
changeInput(e) {
const that = this;
that.keyword = e.detail.value
2 months ago
uni.request({
2 months ago
url: 'https://restapi.amap.com/v3/assistant/inputtips?datatype=all&type=分类代码&city='+that.city+'&key=4a6e2ba8eac3864f0d88f9b5abd026e6&keywords='+that.keyword,
success(res) {
console.log(res.data.tips)
if(res.data.tips && res.data.tips.length > 0){
that.list = res.data.tips;
that.isShow = false;
console.log(22233)
}else{
that.list = []
that.isShow = true;
console.log(222)
}
2 months ago
}
})
}
3 months ago
}
}
</script>
<style scoped lang="scss">
.city{
2 months ago
min-height: 100vh;
background-color: #fff;
3 months ago
padding: 0 25rpx;
overflow: hidden;
&-hd{
margin-top: 30rpx;
height: 90rpx;
background: #F5F5F5;
border-radius: 90rpx;
border: 1px solid #EAEAEA;
padding: 0 30rpx;
box-sizing: border-box;
display: flex;
align-items: center;
.sousuo{
width: 30rpx;
height: 30rpx;
margin-right: 15rpx;
}
input{
flex: 1;
font-weight: 500;
font-size: 28rpx;
color: #222222;
height: 90rpx;
}
.clear{
width: 45rpx;
height: 45rpx;
margin-left: 15rpx;
}
}
&-bd{
padding: 0 25rpx 25rpx;
overflow: hidden;
2 months ago
.list{
margin-top: 20rpx;
overflow: hidden;
.item{
padding: 15rpx 0;
font-size: 28rpx;
color: #222222;
}
}
3 months ago
.empty{
padding: 150rpx 0;
text-align: center;
font-weight: 500;
font-size: 28rpx;
color: #222222;
image{
display: block;
width: 460rpx;
height: 400rpx;
margin: 0 auto;
}
}
}
}
</style>