<template>
|
<uni-popup ref="area" background-color="#fff">
|
<view class="date">
|
<view class="title">
|
<text>请选择所在地区</text>
|
<view class="title_icon" @click="closeArea">
|
<uni-icons color="#CCCCCB" type="closeempty" size="20"></uni-icons>
|
</view>
|
</view>
|
<view class="content">
|
<picker-view
|
:indicator-style="indicatorStyle"
|
:value="data"
|
:immediate-change="true"
|
@change="bindChangeDate"
|
class="picker-view">
|
<picker-view-column>
|
<view class="item" v-for="(item,index) in economize" :key="index">{{item.name}}</view>
|
</picker-view-column>
|
<picker-view-column>
|
<view class="item" v-for="(item,index) in market" :key="index">{{item.name}}</view>
|
</picker-view-column>
|
<picker-view-column>
|
<view class="item" v-for="(item,index) in area" :key="index">{{item.name}}</view>
|
</picker-view-column>
|
</picker-view>
|
</view>
|
<view class="submit" @click="updateArea">确定</view>
|
</view>
|
</uni-popup>
|
</template>
|
|
<script>
|
import {city} from '@/common/city.js'
|
export default {
|
data() {
|
return {
|
indicatorStyle: 'height: 40px;',
|
data: [1,1,1],
|
economize: [],
|
market: [],
|
area: []
|
};
|
},
|
methods: {
|
open() {
|
city.forEach((item, index) => {
|
if (index === 0) {
|
this.market = item.cityList
|
item.cityList.forEach((child, i) => {
|
if (i === 0) {
|
this.area = child.areaList
|
}
|
})
|
}
|
this.economize.push(item)
|
})
|
this.$refs.area.open('bottom')
|
},
|
bindChangeDate(e) {
|
this.data=e.detail.value
|
console.log(this.economize);
|
this.market = city[e.detail.value[0]].cityList
|
this.area = city[e.detail.value[0]].cityList[e.detail.value[1]].areaList
|
},
|
updateArea() {
|
this.$emit('updata',[this.economize[this.data[0]], this.market[this.data[1]], this.area[this.data[2]] ])
|
this.$refs.area.close()
|
},
|
closeArea() {
|
this.$refs.area.close()
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.date {
|
padding: 44rpx 32rpx;
|
background-color: #FFFFFF;
|
box-sizing: border-box;
|
.title {
|
width: 100%;
|
text-align: center;
|
position: relative;
|
text {
|
font-size: 32rpx;
|
font-family: PingFang SC-Semibold, PingFang SC;
|
font-weight: 600;
|
color: #333333;
|
}
|
.title_icon {
|
position: absolute;
|
right: 0;
|
top: 0;
|
}
|
}
|
.content {
|
width: 100%;
|
margin-top: 80rpx;
|
.picker-view {
|
width: 100%;
|
height: 400rpx;
|
.item {
|
height: 40px;
|
line-height: 40px;
|
text-align: center;
|
}
|
}
|
}
|
.submit {
|
width: 100%;
|
height: 72rpx;
|
line-height: 72rpx;
|
text-align: center;
|
background: linear-gradient(270deg, #D20A0A 0%, #D95A5A 100%);
|
border-radius: 36rpx;
|
font-size: 32rpx;
|
font-family: PingFang SC-Medium, PingFang SC;
|
font-weight: 500;
|
color: #FFFFFF;
|
margin-top: 50rpx;
|
}
|
}
|
</style>
|