连云港陪玩陪聊
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

137 lines
3.0 KiB

<template>
<view class="city">
<view class="city-hd">
<image class="sousuo" src="@/static/city-sousuo.png"></image>
<input type="search" :value="keyword" @input="changeInput" placeholder="请输入" />
<image class="clear" src="@/static/city-close.png"></image>
</view>
<view class="city-bd">
<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">
<image src="@/static/empty.png"></image>
<view class="txt">暂无数据</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
isShow: false,
city: "",
keyword: "",
list: [],
jingweiInfo: {}
};
},
onLoad(o) {
this.city = decodeURIComponent(o.city);
this.jingweiInfo = uni.getStorageSync("jingweiInfo")
},
methods: {
clickTap(a){
console.log(a)
this.jingweiInfo.new_city = this.city
this.jingweiInfo.formatted = a.name
this.jingweiInfo.latitude = a.location.split(",")[1]
this.jingweiInfo.longitude = a.location.split(",")[0]
uni.setStorageSync("jingweiInfo",this.jingweiInfo)
this.city = "";
this.keyword= "";
this.list = [];
this.isShow = false;
uni.$emit("clickTap", a);
uni.navigateBack({
delta:1
})
},
changeInput(e) {
const that = this;
that.keyword = e.detail.value
console.log('https://restapi.amap.com/v3/assistant/inputtips?datatype=poi&citylimit=true&city='+that.city+'&key=4a6e2ba8eac3864f0d88f9b5abd026e6&keywords='+that.keyword)
uni.request({
url: 'https://restapi.amap.com/v3/assistant/inputtips?datatype=poi&citylimit=true&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)
}
}
})
}
}
}
</script>
<style scoped lang="scss">
.city{
min-height: 100vh;
background-color: #fff;
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;
.list{
margin-top: 20rpx;
overflow: hidden;
.item{
padding: 15rpx 0;
font-size: 28rpx;
color: #222222;
}
}
.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>