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.
 
 
 
 
high-mini/qianzhu-Starbucks/changeRegin/changeRegin.vue

82 lines
1.6 KiB

<template>
<view>
<city-select @cityClick="cityClick" :formatName="formatName" :activeCity="activeCity" :hotCity="hotCity"
:obtainCitys="obtainCitys" :isSearch="true" ref="citys"></city-select>
</view>
</template>
<script>
import {
getAllCity
} from '../../Utils/Api.js';
import citySelect from '@/components/city-select/city-select.vue';
let app = getApp();
export default {
data() {
return {
//需要构建索引参数的名称(注意:传递的对象里面必须要有这个名称的参数)
formatName: 'cityName',
//当前城市
activeCity: {},
//热门城市
hotCity: [{
id: 0,
cityName: '南京市'
},
{
id: 1,
cityName: '南京市'
}
],
//显示的城市数据
obtainCitys: []
}
},
components: {
citySelect
},
onLoad() {
this.getAllCity();
this.activeCity = {
id: 1,
cityName: app.globalData.qianzhuCityName
}
//热门城市
this.hotCity = [{
id: 0,
cityName: '南京市',
cityCode: 110100
},
{
id: 1,
cityName: '北京市',
cityCode: 110102
}
]
},
methods: {
//选择城市
cityClick(item) {
app.globalData.qianzhuCityName = item.cityName;
uni.navigateBack({
})
},
//查询城市名字
getAllCity() {
uni.showLoading({
title: '加载中...'
})
getAllCity().then(res => {
uni.hideLoading();
if (res.return_code == '000000') {
this.obtainCitys = res.return_data;
}
})
}
}
}
</script>
<style></style>