ソースを参照

地址组件添加switchModule

杨小璐 5 年 前
コミット
be6d8c3b1d

+ 2 - 0
src/packages/address/address.vue

@@ -329,6 +329,8 @@ export default {
         switchModule() {
             this.showModule = this.showModule == 'exist' ? 'custom' : 'exist'
             this.initAddress()
+
+            this.$emit('switchModule',{type:this.showModule})
         }
     }
 }

+ 10 - 1
src/packages/address/demo.vue

@@ -30,7 +30,7 @@
 
       <nut-address v-model="showPopupCustomImg" type="exist" :existAddress="existAddress" @onChange="onChange3" @close="close3" :isShowCustomAddress="false" @selected="selected3" :defaultIcon="defaultIcon" :selectedIcon='selectedIcon'></nut-address>
 
-      <nut-address v-model="showPopupOther" type="exist" :existAddress="existAddress" :province="province" :city="city" :country="country" :town="town" @onChange="onChange4" @close="close4" @selected="selected4" customAndExistTitle="选择其他地址"></nut-address>
+      <nut-address v-model="showPopupOther" type="exist" :existAddress="existAddress" :province="province" :city="city" :country="country" :town="town" @onChange="onChange4" @close="close4" @selected="selected4" customAndExistTitle="选择其他地址" @switchModule="switchModule"></nut-address>
     </div>
 </template>
 
@@ -149,6 +149,15 @@ export default {
       selected4(prevExistAdd,nowExistAdd,arr){
         console.log(prevExistAdd)
         console.log(nowExistAdd)
+      },
+
+      switchModule(cal){
+        
+        if(cal.type == 'custom'){
+          console.log('点击了“选择其他地址”按钮')
+        } else {
+          console.log('点击了自定义地址左上角的返回按钮')
+        }
       }
   }
 };

+ 12 - 1
src/packages/address/doc.md

@@ -203,7 +203,8 @@ export default {
     customAndExistTitle="选择其他地址"
     @onChange="onChange4" 
     @close="close4" 
-    @selected="selected4">
+    @selected="selected4"
+    @switchModule="switchModule">
 </nut-address>
 
 
@@ -246,6 +247,14 @@ export default {
     selected4(prevExistAdd,nowExistAdd,arr){
       console.log(prevExistAdd)
       console.log(nowExistAdd)
+    },
+    switchModule(cal){
+        
+        if(cal.type == 'custom'){
+          console.log('点击了“选择其他地址”按钮')
+        } else {
+          console.log('点击了自定义地址左上角的返回按钮')
+        }
     }
   }
 }
@@ -284,6 +293,8 @@ export default {
 | onChange | 自定义选择地址时,选择地区时触发 |  参考 onChange
 | selected | 选择已有地址列表时触发 | 参考 selected
 | close | 地址选择弹框关闭时触发 | 参考 close
+| switchModule | 点击‘选择其他地址’或自定义地址选择左上角返回按钮触发 | {type:'exist'/'custom'}
+
 
 ## onChange 回调参数
 | 参数 | 说明 | 可能值