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.
shop-app/components/BsSelectCity.vue

100 lines
1.6 KiB

<!--
* @Author: ch
* @Date: 2022-03-29 16:05:06
* @LastEditors: ch
* @LastEditTime: 2022-03-29 16:20:03
* @Description: file content
-->
<template>
<view>
<UiCell title="所在区域" @click="show = true">
<template slot="value">
<input class="cityInput" disabled value="我的" placeholder="请选择省市区" />
</template>
</UiCell>
<u-picker
:show="show"
keyName="label"
:columns="data"
@cancel="show = false"
@change="changeRegion"
@confirm="onConfirm"
/>
</view>
</template>
<script>
import UiCell from "./UiCell";
export default {
components: { UiCell },
props: ["value"],
data() {
return {
show: false,
data: [
[
{
label: "北京",
id: 11000000,
children: [
{
label: "东城",
id: 11100000,
},
{
label: "西城",
id: 11200000,
},
],
},
{
label: "湖南",
id: 43000000,
children: [
{
label: "长沙",
id: 11100000,
},
{
label: "邵阳",
id: 11200000,
},
],
},
],
[
{
label: "东城",
id: 11100000,
},
{
label: "西城",
id: 11200000,
},
],
],
};
},
computed:{
valueText(){
// this.va
},
},
methods: {
changeCity(val) {
this.data = [this.options[0],val.value[0].children]
},
confirm(value) {
this.$emit('input', value)
this.$emit('change', value)
},
},
};
</script>
<style lang="scss" scoped>
.cityInput{
flex: 1;
font-size: 28rpx;
padding-left: 40rpx;
}
</style>