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

138 lines
3.0 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: "",
1 month ago
list: [],
jingweiInfo: {}
3 months ago
};
2 months ago
},
onLoad(o) {
1 month ago
this.city = decodeURIComponent(o.city);
this.jingweiInfo = uni.getStorageSync("jingweiInfo")
2 months ago
},
methods: {
1 month ago
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)
2 months ago
this.city = "";
this.keyword= "";
this.list = [];
this.isShow = false;
1 month ago
uni.$emit("clickTap", a);
2 months ago
uni.navigateBack({
delta:1
})
},
changeInput(e) {
const that = this;
1 month ago
that.keyword = e.detail.value
1 month ago
console.log('https://restapi.amap.com/v3/assistant/inputtips?datatype=poi&citylimit=true&city='+that.city+'&key=4a6e2ba8eac3864f0d88f9b5abd026e6&keywords='+that.keyword)
2 months ago
uni.request({
1 month ago
url: 'https://restapi.amap.com/v3/assistant/inputtips?datatype=poi&citylimit=true&city='+that.city+'&key=4a6e2ba8eac3864f0d88f9b5abd026e6&keywords='+that.keyword,
2 months ago
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>