lex-xin 5 months ago
parent
commit
6b1610afbf
2 changed files with 18 additions and 6 deletions
  1. 16 4
      miniprogram/pages/address/index.ts
  2. 2 2
      miniprogram/pages/address/index.wxml

+ 16 - 4
miniprogram/pages/address/index.ts

@@ -14,6 +14,7 @@ Page({
     showDialog: false,
     cacheArea: [] as { cityCode: string, shiftCityCode: string }[], // 临时存储的对应关系
     showArea: false,
+    showAreaAfterLeave: false,
     areaList: [] as any,
     currentValues: [] as any,
 
@@ -22,9 +23,9 @@ Page({
     name: '',
     phoneNumber: '',
     detailAddress: '',
-    cityCode: 0,
+    cityCode: null,
     cityName: "",
-    provinceCode: 0,
+    provinceCode: null,
     provinceName: "",
     regionCode: '',
     regionName: "",
@@ -158,6 +159,16 @@ Page({
       showArea: false
     })
   },
+  onAreaBeforeEnter() {
+    this.setData({
+      showAreaAfterLeave: false
+    })
+  },
+  onAreaAfterLeave() {
+    this.setData({
+      showAreaAfterLeave: true
+    })
+  },
   /** 确定选择地区 */
   submitArea(e: any) {
     const selectedOptions: any = e.detail.values
@@ -185,14 +196,15 @@ Page({
   onAddressAfterLeave() {
     this.setData({
       addressAfterLeave: true,
+      selectAddressId: '',
       name: '',
       phoneNumber: '',
       detailAddress: '',
-      cityCode: 0,
+      cityCode: null,
       cityName: "",
       provinceCode: 0,
       provinceName: "",
-      regionCode: '',
+      regionCode: null,
       regionName: "",
     })
   },

+ 2 - 2
miniprogram/pages/address/index.wxml

@@ -56,8 +56,8 @@
   </van-popup>
 
   <!-- 地区 -->
-  <van-popup round="{{true}}" lock-scroll="{{true}}" z-index="{{103}}" show="{{showArea}}" position="bottom" safe-area-inset-bottom="{{false}}" bind:close="onCloseAreaList">
-    <van-area id='area1' areaList="{{areaList}}" visible-item-count="9" item-height="46" value="{{ regionCode }}" bind:cancel="onCloseAreaList" bind:confirm="submitArea" />
+  <van-popup round="{{true}}" lock-scroll="{{true}}" z-index="{{103}}" show="{{showArea}}" position="bottom" safe-area-inset-bottom="{{false}}" bind:close="onCloseAreaList" bind:after-leave="onAreaAfterLeave" bind:before-enter="onAreaBeforeEnter">
+    <van-area  wx:if="{{ !showAreaAfterLeave }}" id='area1' areaList="{{areaList}}" visible-item-count="9" item-height="46" value="{{ regionCode || cityCode }}" bind:cancel="onCloseAreaList" bind:confirm="submitArea" />
   </van-popup>
 
   <van-popup round lock-scroll="{{true}}" z-index="{{102}}" show="{{showDialog}}">