|
|
@@ -24,7 +24,9 @@ app.use(Elevator);
|
|
|
|
|
|
### 选择自定义地址
|
|
|
|
|
|
+:::demo
|
|
|
```html
|
|
|
+<template>
|
|
|
<nut-cell title="选择地址" :desc="text" is-link @click="showAddress"></nut-cell>
|
|
|
<nut-address
|
|
|
v-model:visible="showPopup"
|
|
|
@@ -36,118 +38,133 @@ app.use(Elevator);
|
|
|
@close="close"
|
|
|
custom-address-title="请选择所在地区"
|
|
|
></nut-address>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import { ref,reactive,toRefs } from 'vue';
|
|
|
+ export default {
|
|
|
+ setup() {
|
|
|
+ const showPopup = ref(false);
|
|
|
+ const address = reactive({
|
|
|
+ province:[
|
|
|
+ { id: 1, name: '北京' },
|
|
|
+ { id: 2, name: '广西' },
|
|
|
+ { id: 3, name: '江西' },
|
|
|
+ { id: 4, name: '四川' }
|
|
|
+ ],
|
|
|
+ city:[
|
|
|
+ { id: 7, name: '朝阳区' },
|
|
|
+ { id: 8, name: '崇文区' },
|
|
|
+ { id: 9, name: '昌平区' },
|
|
|
+ { id: 6, name: '石景山区' }
|
|
|
+ ],
|
|
|
+ country:[
|
|
|
+ { id: 3, name: '八里庄街道' },
|
|
|
+ { id: 9, name: '北苑' },
|
|
|
+ { id: 4, name: '常营乡' }
|
|
|
+ ],
|
|
|
+ town:[]
|
|
|
+ })
|
|
|
+
|
|
|
+ const text = ref('请选择地址')
|
|
|
+
|
|
|
+ const showAddress = () => {
|
|
|
+ showPopup.value = !showPopup.value;
|
|
|
+ };
|
|
|
+
|
|
|
+ const onChange = (cal) => {
|
|
|
+ const name = address[cal.next]
|
|
|
+ if (name.length < 1) {
|
|
|
+ showPopup.value = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const close = val => {
|
|
|
+ console.log(val);
|
|
|
+ text.value = val.data.addressStr;
|
|
|
+ };
|
|
|
+
|
|
|
+ return { showPopup, text, showAddress, onChange, close, ...toRefs(address) };
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
```
|
|
|
-```javascript
|
|
|
-setup() {
|
|
|
- const showPopup = ref(false);
|
|
|
- const address = reactive({
|
|
|
- province:[
|
|
|
- { id: 1, name: '北京' },
|
|
|
- { id: 2, name: '广西' },
|
|
|
- { id: 3, name: '江西' },
|
|
|
- { id: 4, name: '四川' }
|
|
|
- ],
|
|
|
- city:[
|
|
|
- { id: 7, name: '朝阳区' },
|
|
|
- { id: 8, name: '崇文区' },
|
|
|
- { id: 9, name: '昌平区' },
|
|
|
- { id: 6, name: '石景山区' }
|
|
|
- ],
|
|
|
- country:[
|
|
|
- { id: 3, name: '八里庄街道' },
|
|
|
- { id: 9, name: '北苑' },
|
|
|
- { id: 4, name: '常营乡' }
|
|
|
- ],
|
|
|
- town:[]
|
|
|
- })
|
|
|
-
|
|
|
- const text = ref('请选择地址')
|
|
|
-
|
|
|
- const showAddress = () => {
|
|
|
- showPopup.value = !showPopup.value;
|
|
|
- };
|
|
|
-
|
|
|
- const onChange = (cal) => {
|
|
|
- const name = address[cal.next]
|
|
|
- if (name.length < 1) {
|
|
|
- showPopup.value = false;
|
|
|
- }
|
|
|
- };
|
|
|
- const close = val => {
|
|
|
- console.log(val);
|
|
|
- text.value = val.data.addressStr;
|
|
|
- };
|
|
|
-
|
|
|
- return { showPopup, text, showAddress, onChange, close, ...toRefs(address) };
|
|
|
-}
|
|
|
-```
|
|
|
+:::
|
|
|
|
|
|
### 选择自定义地址2
|
|
|
|
|
|
+:::demo
|
|
|
```html
|
|
|
-<nut-cell title="选择地址" :desc="text" type="custom2" is-link @click="showAddress"></nut-cell>
|
|
|
-<nut-address
|
|
|
- v-model:visible="showPopup"
|
|
|
- :province="province"
|
|
|
- :city="city"
|
|
|
- :country="country"
|
|
|
- :town="town"
|
|
|
- @change="onChange"
|
|
|
- @close="close"
|
|
|
- custom-address-title="请选择所在地区"
|
|
|
-></nut-address>
|
|
|
-```
|
|
|
-```javascript
|
|
|
-setup() {
|
|
|
- const showPopup = ref(false);
|
|
|
- const address = reactive({
|
|
|
- province: [
|
|
|
- { id: 1, name: '北京', title: 'B' },
|
|
|
- { id: 2, name: '广西', title: 'G' },
|
|
|
- { id: 3, name: '江西', title: 'J' },
|
|
|
- { id: 4, name: '四川', title: 'S' },
|
|
|
- { id: 5, name: '浙江', title: 'Z' }
|
|
|
- ],
|
|
|
- city: [
|
|
|
- { id: 7, name: '朝阳区', title: 'C' },
|
|
|
- { id: 8, name: '崇文区', title: 'C' },
|
|
|
- { id: 9, name: '昌平区', title: 'C' },
|
|
|
- { id: 6, name: '石景山区', title: 'S' },
|
|
|
- { id: 3, name: '八里庄街道', title: 'B' },
|
|
|
- { id: 9, name: '北苑', title: 'B' }
|
|
|
- ],
|
|
|
- country: [
|
|
|
- { id: 3, name: '八里庄街道', title: 'B' },
|
|
|
- { id: 9, name: '北苑', title: 'B' },
|
|
|
- { id: 4, name: '常营乡', title: 'C' }
|
|
|
- ],
|
|
|
- town:[]
|
|
|
- })
|
|
|
-
|
|
|
- const text = ref('请选择地址')
|
|
|
-
|
|
|
- const showAddress = () => {
|
|
|
- showPopup.value = !showPopup.value;
|
|
|
- };
|
|
|
-
|
|
|
- const onChange = (cal) => {
|
|
|
- const name = address[cal.next]
|
|
|
- if (name.length < 1) {
|
|
|
- showPopup.value = false;
|
|
|
- }
|
|
|
- };
|
|
|
- const close = val => {
|
|
|
- console.log(val);
|
|
|
- text.value = val.data.addressStr;
|
|
|
- };
|
|
|
-
|
|
|
- return { showPopup, text, showAddress, onChange, close, ...toRefs(address) };
|
|
|
-}
|
|
|
+<template>
|
|
|
+ <nut-cell title="选择地址" :desc="text" type="custom2" is-link @click="showAddress"></nut-cell>
|
|
|
+ <nut-address
|
|
|
+ v-model:visible="showPopup"
|
|
|
+ :province="province"
|
|
|
+ :city="city"
|
|
|
+ :country="country"
|
|
|
+ :town="town"
|
|
|
+ @change="onChange"
|
|
|
+ @close="close"
|
|
|
+ custom-address-title="请选择所在地区"
|
|
|
+ ></nut-address>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import { ref,reactive,toRefs } from 'vue';
|
|
|
+ export default {
|
|
|
+ setup() {
|
|
|
+ const showPopup = ref(false);
|
|
|
+ const address = reactive({
|
|
|
+ province: [
|
|
|
+ { id: 1, name: '北京', title: 'B' },
|
|
|
+ { id: 2, name: '广西', title: 'G' },
|
|
|
+ { id: 3, name: '江西', title: 'J' },
|
|
|
+ { id: 4, name: '四川', title: 'S' },
|
|
|
+ { id: 5, name: '浙江', title: 'Z' }
|
|
|
+ ],
|
|
|
+ city: [
|
|
|
+ { id: 7, name: '朝阳区', title: 'C' },
|
|
|
+ { id: 8, name: '崇文区', title: 'C' },
|
|
|
+ { id: 9, name: '昌平区', title: 'C' },
|
|
|
+ { id: 6, name: '石景山区', title: 'S' },
|
|
|
+ { id: 3, name: '八里庄街道', title: 'B' },
|
|
|
+ { id: 9, name: '北苑', title: 'B' }
|
|
|
+ ],
|
|
|
+ country: [
|
|
|
+ { id: 3, name: '八里庄街道', title: 'B' },
|
|
|
+ { id: 9, name: '北苑', title: 'B' },
|
|
|
+ { id: 4, name: '常营乡', title: 'C' }
|
|
|
+ ],
|
|
|
+ town:[]
|
|
|
+ })
|
|
|
+
|
|
|
+ const text = ref('请选择地址')
|
|
|
+
|
|
|
+ const showAddress = () => {
|
|
|
+ showPopup.value = !showPopup.value;
|
|
|
+ };
|
|
|
+
|
|
|
+ const onChange = (cal) => {
|
|
|
+ const name = address[cal.next]
|
|
|
+ if (name.length < 1) {
|
|
|
+ showPopup.value = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const close = val => {
|
|
|
+ console.log(val);
|
|
|
+ text.value = val.data.addressStr;
|
|
|
+ };
|
|
|
+
|
|
|
+ return { showPopup, text, showAddress, onChange, close, ...toRefs(address) };
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
```
|
|
|
+:::
|
|
|
|
|
|
### 选择已有地址
|
|
|
|
|
|
+:::demo
|
|
|
```html
|
|
|
+<template>
|
|
|
<nut-cell title="选择地址" :desc="text" is-link @click="showAddressExist"></nut-cell>
|
|
|
<nut-address
|
|
|
v-model:visible="showPopupExist"
|
|
|
@@ -158,270 +175,287 @@ setup() {
|
|
|
@selected="selected"
|
|
|
exist-address-title="配送至"
|
|
|
></nut-address>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import { ref,reactive,toRefs } from 'vue';
|
|
|
+ export default {
|
|
|
+ setup() {
|
|
|
+ const showPopupExist = ref(false);
|
|
|
+ const existAddress = ref([
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ addressDetail: 'th ',
|
|
|
+ cityName: '石景山区',
|
|
|
+ countyName: '城区',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: true,
|
|
|
+ townName: ''
|
|
|
+ },{
|
|
|
+ id: 2,
|
|
|
+ addressDetail: '12_ ',
|
|
|
+ cityName: '电饭锅',
|
|
|
+ countyName: '扶绥县',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ },{
|
|
|
+ id: 3,
|
|
|
+ addressDetail: '发大水比 ',
|
|
|
+ cityName: '放到',
|
|
|
+ countyName: '广宁街道',
|
|
|
+ provinceName: '钓鱼岛全区',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ },{
|
|
|
+ id: 4,
|
|
|
+ addressDetail: '还是想吧百度吧 ',
|
|
|
+ cityName: '研发',
|
|
|
+ countyName: '八里庄街道',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ }
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const text = ref('请选择地址')
|
|
|
+
|
|
|
+ const showAddressExist = () => {
|
|
|
+ showPopupExist.value = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ const close = val => {
|
|
|
+ if (val.type == 'exist') {
|
|
|
+ const {provinceName,cityName,countyName,townName,addressDetail} = val.data
|
|
|
+ text.value = provinceName + cityName + countyName + townName + addressDetail;
|
|
|
+ } else {
|
|
|
+ text.value = val.data.addressStr;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const selected = (prevExistAdd, nowExistAdd, arr) => {
|
|
|
+ console.log(prevExistAdd);
|
|
|
+ console.log(nowExistAdd);
|
|
|
+ };
|
|
|
+
|
|
|
+ return { showPopupExist, existAddress, showAddressExist, text, close, selected };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </script>
|
|
|
```
|
|
|
-```javascript
|
|
|
-setup() {
|
|
|
- const showPopupExist = ref(false);
|
|
|
- const existAddress = ref([
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- addressDetail: 'th ',
|
|
|
- cityName: '石景山区',
|
|
|
- countyName: '城区',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: true,
|
|
|
- townName: ''
|
|
|
- },{
|
|
|
- id: 2,
|
|
|
- addressDetail: '12_ ',
|
|
|
- cityName: '电饭锅',
|
|
|
- countyName: '扶绥县',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- },{
|
|
|
- id: 3,
|
|
|
- addressDetail: '发大水比 ',
|
|
|
- cityName: '放到',
|
|
|
- countyName: '广宁街道',
|
|
|
- provinceName: '钓鱼岛全区',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- },{
|
|
|
- id: 4,
|
|
|
- addressDetail: '还是想吧百度吧 ',
|
|
|
- cityName: '研发',
|
|
|
- countyName: '八里庄街道',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- }
|
|
|
- ]);
|
|
|
-
|
|
|
- const text = ref('请选择地址')
|
|
|
-
|
|
|
- const showAddressExist = () => {
|
|
|
- showPopupExist.value = true;
|
|
|
- };
|
|
|
-
|
|
|
- const close = val => {
|
|
|
- if (val.type == 'exist') {
|
|
|
- const {provinceName,cityName,countyName,townName,addressDetail} = val.data
|
|
|
- text.value = provinceName + cityName + countyName + townName + addressDetail;
|
|
|
- } else {
|
|
|
- text.value = val.data.addressStr;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- const selected = (prevExistAdd, nowExistAdd, arr) => {
|
|
|
- console.log(prevExistAdd);
|
|
|
- console.log(nowExistAdd);
|
|
|
- };
|
|
|
-
|
|
|
- return { showPopupExist, existAddress, showAddressExist, text, close, selected };
|
|
|
-}
|
|
|
-```
|
|
|
+:::
|
|
|
### 自定义图标
|
|
|
-
|
|
|
+:::demo
|
|
|
```html
|
|
|
-<nut-cell title="选择地址" :desc="text" is-link @click="showCustomImg"></nut-cell>
|
|
|
-<nut-address
|
|
|
- v-model:visible="showPopupCustomImg"
|
|
|
- type="exist"
|
|
|
- :existAddress="existAddress"
|
|
|
- @close="close"
|
|
|
- :is-show-custom-address="false"
|
|
|
- @selected="selected3"
|
|
|
- :default-icon="defaultIcon"
|
|
|
- :selected-icon="selectedIcon"
|
|
|
- :close-btn-icon="closeBtnIcon"
|
|
|
-></nut-address>
|
|
|
-```
|
|
|
-```javascript
|
|
|
-setup() {
|
|
|
- const showPopupCustomImg = ref(false);
|
|
|
- const icon = reactive({
|
|
|
- selectedIcon: 'heart-fill',
|
|
|
- defaultIcon: 'heart1',
|
|
|
- closeBtnIcon: 'close',
|
|
|
- backBtnIcon: 'left'
|
|
|
- });
|
|
|
- const existAddress = ref([
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- addressDetail: 'th ',
|
|
|
- cityName: '石景山区',
|
|
|
- countyName: '城区',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: true,
|
|
|
- townName: ''
|
|
|
- },{
|
|
|
- id: 2,
|
|
|
- addressDetail: '12_ ',
|
|
|
- cityName: '电饭锅',
|
|
|
- countyName: '扶绥县',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- },{
|
|
|
- id: 3,
|
|
|
- addressDetail: '发大水比 ',
|
|
|
- cityName: '放到',
|
|
|
- countyName: '广宁街道',
|
|
|
- provinceName: '钓鱼岛全区',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- },{
|
|
|
- id: 4,
|
|
|
- addressDetail: '还是想吧百度吧 ',
|
|
|
- cityName: '研发',
|
|
|
- countyName: '八里庄街道',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- }
|
|
|
- ]);
|
|
|
-
|
|
|
- const text = ref('请选择地址')
|
|
|
-
|
|
|
- const showCustomImg = () => {
|
|
|
- showPopupCustomImg.value = true;
|
|
|
- };
|
|
|
-
|
|
|
- const close = val => {
|
|
|
- if (val.type == 'exist') {
|
|
|
- const {provinceName,cityName,countyName,townName,addressDetail} = val.data
|
|
|
- text.value = provinceName + cityName + countyName + townName + addressDetail;
|
|
|
- } else {
|
|
|
- text.value = val.data.addressStr;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- const selected = (prevExistAdd, nowExistAdd, arr) => {
|
|
|
- console.log(prevExistAdd);
|
|
|
- console.log(nowExistAdd);
|
|
|
- };
|
|
|
-
|
|
|
- return { showPopupCustomImg, existAddress, text, showCustomImg, close, selected, ...toRefs(icon) };
|
|
|
-}
|
|
|
+<template>
|
|
|
+ <nut-cell title="选择地址" :desc="text" is-link @click="showCustomImg"></nut-cell>
|
|
|
+ <nut-address
|
|
|
+ v-model:visible="showPopupCustomImg"
|
|
|
+ type="exist"
|
|
|
+ :existAddress="existAddress"
|
|
|
+ @close="close"
|
|
|
+ :is-show-custom-address="false"
|
|
|
+ @selected="selected3"
|
|
|
+ :default-icon="defaultIcon"
|
|
|
+ :selected-icon="selectedIcon"
|
|
|
+ :close-btn-icon="closeBtnIcon"
|
|
|
+ ></nut-address>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import { ref,reactive,toRefs } from 'vue';
|
|
|
+ export default {
|
|
|
+ setup() {
|
|
|
+ const showPopupCustomImg = ref(false);
|
|
|
+ const icon = reactive({
|
|
|
+ selectedIcon: 'heart-fill',
|
|
|
+ defaultIcon: 'heart1',
|
|
|
+ closeBtnIcon: 'close',
|
|
|
+ backBtnIcon: 'left'
|
|
|
+ });
|
|
|
+ const existAddress = ref([
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ addressDetail: 'th ',
|
|
|
+ cityName: '石景山区',
|
|
|
+ countyName: '城区',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: true,
|
|
|
+ townName: ''
|
|
|
+ },{
|
|
|
+ id: 2,
|
|
|
+ addressDetail: '12_ ',
|
|
|
+ cityName: '电饭锅',
|
|
|
+ countyName: '扶绥县',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ },{
|
|
|
+ id: 3,
|
|
|
+ addressDetail: '发大水比 ',
|
|
|
+ cityName: '放到',
|
|
|
+ countyName: '广宁街道',
|
|
|
+ provinceName: '钓鱼岛全区',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ },{
|
|
|
+ id: 4,
|
|
|
+ addressDetail: '还是想吧百度吧 ',
|
|
|
+ cityName: '研发',
|
|
|
+ countyName: '八里庄街道',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ }
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const text = ref('请选择地址')
|
|
|
+
|
|
|
+ const showCustomImg = () => {
|
|
|
+ showPopupCustomImg.value = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ const close = val => {
|
|
|
+ if (val.type == 'exist') {
|
|
|
+ const {provinceName,cityName,countyName,townName,addressDetail} = val.data
|
|
|
+ text.value = provinceName + cityName + countyName + townName + addressDetail;
|
|
|
+ } else {
|
|
|
+ text.value = val.data.addressStr;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const selected = (prevExistAdd, nowExistAdd, arr) => {
|
|
|
+ console.log(prevExistAdd);
|
|
|
+ console.log(nowExistAdd);
|
|
|
+ };
|
|
|
+
|
|
|
+ return { showPopupCustomImg, existAddress, text, showCustomImg, close, selected, ...toRefs(icon) };
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
```
|
|
|
+:::
|
|
|
### 自定义地址与已有地址切换
|
|
|
-
|
|
|
+:::demo
|
|
|
```html
|
|
|
-<nut-cell title="选择地址" :desc="text" is-link @click="showAddressOther"></nut-cell>
|
|
|
-<nut-address
|
|
|
- v-model:visible="showPopupOther"
|
|
|
- type="exist"
|
|
|
- :exist-address="existAddress"
|
|
|
- :province="province"
|
|
|
- :city="city"
|
|
|
- :country="country"
|
|
|
- :town="town"
|
|
|
- :back-btn-icon="backBtnIcon"
|
|
|
- @close="close"
|
|
|
- @selected="selected"
|
|
|
- custom-and-exist-title="选择其他地址"
|
|
|
- @switch-module="switchModule"
|
|
|
- @close-mask="closeMask"
|
|
|
-></nut-address>
|
|
|
-```
|
|
|
-```javascript
|
|
|
-setup() {
|
|
|
- const showPopupOther = ref(false);
|
|
|
- const address = reactive({
|
|
|
- province:[
|
|
|
- { id: 1, name: '北京' },
|
|
|
- { id: 2, name: '广西' },
|
|
|
- { id: 3, name: '江西' },
|
|
|
- { id: 4, name: '四川' }
|
|
|
- ],
|
|
|
- city:[
|
|
|
- { id: 7, name: '朝阳区' },
|
|
|
- { id: 8, name: '崇文区' },
|
|
|
- { id: 9, name: '昌平区' },
|
|
|
- { id: 6, name: '石景山区' }
|
|
|
- ],
|
|
|
- country:[
|
|
|
- { id: 3, name: '八里庄街道' },
|
|
|
- { id: 9, name: '北苑' },
|
|
|
- { id: 4, name: '常营乡' }
|
|
|
- ],
|
|
|
- town:[]
|
|
|
- })
|
|
|
- const existAddress = ref([
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- addressDetail: 'th ',
|
|
|
- cityName: '石景山区',
|
|
|
- countyName: '城区',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: true,
|
|
|
- townName: ''
|
|
|
- },
|
|
|
- {
|
|
|
- id: 2,
|
|
|
- addressDetail: '12_ ',
|
|
|
- cityName: '电饭锅',
|
|
|
- countyName: '扶绥县',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- },
|
|
|
- {
|
|
|
- id: 3,
|
|
|
- addressDetail: '发大水比 ',
|
|
|
- cityName: '放到',
|
|
|
- countyName: '广宁街道',
|
|
|
- provinceName: '钓鱼岛全区',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- },
|
|
|
- {
|
|
|
- id: 4,
|
|
|
- addressDetail: '还是想吧百度吧 ',
|
|
|
- cityName: '研发',
|
|
|
- countyName: '八里庄街道',
|
|
|
- provinceName: '北京',
|
|
|
- selectedAddress: false,
|
|
|
- townName: ''
|
|
|
- }
|
|
|
- ]);
|
|
|
- const backBtnIcon = ref('left')
|
|
|
- const text = ref('请选择地址')
|
|
|
-
|
|
|
- const showAddressOther = () => {
|
|
|
- showPopupOther.value = true;
|
|
|
- };
|
|
|
-
|
|
|
- const close = val => {
|
|
|
- if (val.type == 'exist') {
|
|
|
- const {provinceName,cityName,countyName,townName,addressDetail} = val.data
|
|
|
- text.value = provinceName + cityName + countyName + townName + addressDetail;
|
|
|
- } else {
|
|
|
- text.value = val.data.addressStr;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- const selected = (prevExistAdd, nowExistAdd, arr) => {
|
|
|
- console.log(prevExistAdd);
|
|
|
- console.log(nowExistAdd);
|
|
|
- };
|
|
|
-
|
|
|
- const switchModule = cal => {
|
|
|
- if (cal.type == 'custom') {
|
|
|
- console.log('点击了“选择其他地址”按钮');
|
|
|
- } else {
|
|
|
- console.log('点击了自定义地址左上角的返回按钮');
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- const closeMask = val => {
|
|
|
- console.log('关闭弹层', val);
|
|
|
- };
|
|
|
-
|
|
|
- return { showPopupOther, text, showAddressOther, switchModule, closeMask, close, selected, backBtnIcon, ...toRefs(address) };
|
|
|
-}
|
|
|
+<template>
|
|
|
+ <nut-cell title="选择地址" :desc="text" is-link @click="showAddressOther"></nut-cell>
|
|
|
+ <nut-address
|
|
|
+ v-model:visible="showPopupOther"
|
|
|
+ type="exist"
|
|
|
+ :exist-address="existAddress"
|
|
|
+ :province="province"
|
|
|
+ :city="city"
|
|
|
+ :country="country"
|
|
|
+ :town="town"
|
|
|
+ :back-btn-icon="backBtnIcon"
|
|
|
+ @close="close"
|
|
|
+ @selected="selected"
|
|
|
+ custom-and-exist-title="选择其他地址"
|
|
|
+ @switch-module="switchModule"
|
|
|
+ @close-mask="closeMask"
|
|
|
+ ></nut-address>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import { ref,reactive,toRefs } from 'vue';
|
|
|
+ export default {
|
|
|
+ setup() {
|
|
|
+ const showPopupOther = ref(false);
|
|
|
+ const address = reactive({
|
|
|
+ province:[
|
|
|
+ { id: 1, name: '北京' },
|
|
|
+ { id: 2, name: '广西' },
|
|
|
+ { id: 3, name: '江西' },
|
|
|
+ { id: 4, name: '四川' }
|
|
|
+ ],
|
|
|
+ city:[
|
|
|
+ { id: 7, name: '朝阳区' },
|
|
|
+ { id: 8, name: '崇文区' },
|
|
|
+ { id: 9, name: '昌平区' },
|
|
|
+ { id: 6, name: '石景山区' }
|
|
|
+ ],
|
|
|
+ country:[
|
|
|
+ { id: 3, name: '八里庄街道' },
|
|
|
+ { id: 9, name: '北苑' },
|
|
|
+ { id: 4, name: '常营乡' }
|
|
|
+ ],
|
|
|
+ town:[]
|
|
|
+ })
|
|
|
+ const existAddress = ref([
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ addressDetail: 'th ',
|
|
|
+ cityName: '石景山区',
|
|
|
+ countyName: '城区',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: true,
|
|
|
+ townName: ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ addressDetail: '12_ ',
|
|
|
+ cityName: '电饭锅',
|
|
|
+ countyName: '扶绥县',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 3,
|
|
|
+ addressDetail: '发大水比 ',
|
|
|
+ cityName: '放到',
|
|
|
+ countyName: '广宁街道',
|
|
|
+ provinceName: '钓鱼岛全区',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 4,
|
|
|
+ addressDetail: '还是想吧百度吧 ',
|
|
|
+ cityName: '研发',
|
|
|
+ countyName: '八里庄街道',
|
|
|
+ provinceName: '北京',
|
|
|
+ selectedAddress: false,
|
|
|
+ townName: ''
|
|
|
+ }
|
|
|
+ ]);
|
|
|
+ const backBtnIcon = ref('left')
|
|
|
+ const text = ref('请选择地址')
|
|
|
+
|
|
|
+ const showAddressOther = () => {
|
|
|
+ showPopupOther.value = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ const close = val => {
|
|
|
+ if (val.type == 'exist') {
|
|
|
+ const {provinceName,cityName,countyName,townName,addressDetail} = val.data
|
|
|
+ text.value = provinceName + cityName + countyName + townName + addressDetail;
|
|
|
+ } else {
|
|
|
+ text.value = val.data.addressStr;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const selected = (prevExistAdd, nowExistAdd, arr) => {
|
|
|
+ console.log(prevExistAdd);
|
|
|
+ console.log(nowExistAdd);
|
|
|
+ };
|
|
|
+
|
|
|
+ const switchModule = cal => {
|
|
|
+ if (cal.type == 'custom') {
|
|
|
+ console.log('点击了“选择其他地址”按钮');
|
|
|
+ } else {
|
|
|
+ console.log('点击了自定义地址左上角的返回按钮');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const closeMask = val => {
|
|
|
+ console.log('关闭弹层', val);
|
|
|
+ };
|
|
|
+
|
|
|
+ return { showPopupOther, text, existAddress,showAddressOther, switchModule, closeMask, close, selected, backBtnIcon, ...toRefs(address) };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </script>
|
|
|
```
|
|
|
+:::
|
|
|
# API
|
|
|
|
|
|
| 字段 | 说明 | 类型 | 默认值
|