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/pages/user/positioning/positioning.vue

178 lines
4.2 KiB

<template>
<view>
<!-- <view class="width100 backcorfff">
<view class="width90 mart20 font15 fcor333">当前定位</view>
<view class="posacname actives mart20">{{posName}}</view>
<view class="width90 mart20 font14 fcor333">其他地区</view>
<view class="posheadname mart20 flleft font14" :class="{'actives':posId===item.regionId}"
v-for="(item,index) in posList" :key="index" @click="change(item)">
{{item.regionName}}
</view>
</view> -->
<city-select @cityClick="cityClick" :formatName="formatName" :activeCity="activeCity" :hotCity="hotCity"
:obtainCitys="obtainCitys" :isSearch="true" ref="citys"></city-select>
</view>
</template>
<script>
// import uSearchBar from '../../../components/uni-search-bar/components/uni-search-bar/uni-search-bar.vue';
// import {
// getDredgeProvince
// } from '../../../Utils/Api.js';
import {
getAllCity,
findCompanyByCityName
} from '../../../Utils/Api.js';
import citySelect from '@/components/city-select/city-select.vue';
let app = getApp();
export default {
components: {
// uSearchBar,
citySelect
},
data() {
return {
// posList: [],
// posId: '',
// posName: ''
//需要构建索引参数的名称(注意:传递的对象里面必须要有这个名称的参数)
formatName: 'cityName',
//当前城市
activeCity: {},
//热门城市
hotCity: [{
id: 0,
cityName: '南京市'
},
{
id: 1,
cityName: '南京市'
}
],
//显示的城市数据
obtainCitys: []
}
},
onLoad() {
// this.getDredgeProvince();
// this.posName = app.globalData.cityName;
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;
this.findCompanyByCityName(item);
},
//查询城市名字
getAllCity() {
uni.showLoading({
title: '加载中...'
})
getAllCity().then(res => {
uni.hideLoading();
if (res.return_code == '000000') {
this.obtainCitys = res.return_data;
}
})
},
//根据市查询
findCompanyByCityName(item) {
uni.showLoading({
title: '加载中...'
})
let datas = {
cityName: item.cityName
}
findCompanyByCityName(datas).then(res => {
uni.hideLoading();
if (res.return_code == '000000') {
app.globalData.cityName = res.return_data.provinceName;
app.globalData.qianzhuCityName = res.return_data.cityName;
app.globalData.cityId = res.return_data.regionId;
app.globalData.companyId = res.return_data.companyId;
uni.navigateBack({})
} else {
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
})
}
// getDredgeProvince() {
// uni.showLoading({
// title: '加载中'
// })
// getDredgeProvince().then(res => {
// uni.hideLoading()
// if (res.return_code == '000000') {
// this.posList = res.return_data;
// }
// });
// },
// change(item) {
// this.posId = item.regionId;
// this.posName = item.regionName;
// app.globalData.cityId = item.regionId;
// app.globalData.cityName = item.regionName;
// uni.navigateBack({
// })
// }
}
}
</script>
<style lang="less">
.posheadname {
background-color: #f5f5f5;
color: #666666;
padding-left: 10px;
padding-right: 10px;
height: 30px;
margin-left: 4%;
line-height: 30px;
text-align: center;
border-radius: 5px;
}
.posacname {
background-color: #f5f5f5;
color: #666666;
display: inline-block;
padding-left: 10px;
padding-right: 10px;
height: 30px;
margin-left: 4%;
line-height: 30px;
text-align: center;
border-radius: 5px;
}
.actives {
color: #089bf5;
background-color: #f4faff;
border: 1px solid #089bf5;
}
</style>