From 0192681b8f87bb9e54dc74a79a4ef6f526aedb23 Mon Sep 17 00:00:00 2001
From: huliyong <2783385703@qq.com>
Date: Thu, 3 Jul 2025 09:20:29 +0800
Subject: [PATCH] =?UTF-8?q?fix(=E7=BB=84=E4=BB=B6):=20=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=80=89=E6=8B=A9=E5=99=A8=E5=9C=A8=E5=BC=B9?=
=?UTF-8?q?=E7=AA=97=E4=B8=AD=E7=9A=84=E4=BD=BF=E7=94=A8=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 将地址选择器从弹窗内容中移出,改为独立组件引用
- 添加弹窗中地址选择的专用UI和交互逻辑
- 修复地址选择结果处理中的字段错误
- 统一事件总线调用方式为uni.$emit/uni.$on
---
components/screen/screenWork.vue | 81 +++++++++++++++++++++++++++++++++-------
pages/index/index.vue | 2 +-
store/store.js | 2 +-
3 files changed, 70 insertions(+), 15 deletions(-)
diff --git a/components/screen/screenWork.vue b/components/screen/screenWork.vue
index 2d8d8fd..0ea6115 100644
--- a/components/screen/screenWork.vue
+++ b/components/screen/screenWork.vue
@@ -41,9 +41,6 @@
@clickItem="clickItem"
@popupChange="change">
-
-
-
+
+
+
@@ -162,7 +172,8 @@
index : 0,
type : 'areaId',
},
- ]
+ ],
+ popupSelectedAddress: '', // 弹窗中选中的地址
}
},
computed : {
@@ -305,6 +316,7 @@
this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
+ console.log('this.result', this.result);
this.$emit('clickItem', this.result)
},
@@ -313,12 +325,22 @@
this.result = []
this.list.forEach(n => {
- let t = n.tag[n.index]
- this.result.push({
- name: n.type,
- label : t.label,
- value : t.value
- })
+ // 地址选择使用AddressPicker的结果
+ if(n.type === 'areaId' && this.popupSelectedAddress) {
+ this.result.push({
+ name: n.type,
+ label: this.popupSelectedAddress,
+ value: this.popupSelectedAddress
+ })
+ } else {
+ // 其他选项使用tag选择
+ let t = n.tag[n.index]
+ this.result.push({
+ name: n.type,
+ label : t.label,
+ value : t.value
+ })
+ }
})
this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
@@ -327,17 +349,30 @@
this.$refs.popup.close()
},
+ // 弹窗中打开地址选择器
+ openAddressPickerInPopup() {
+ this.$refs.addressPicker.open()
+ },
+
// 地址选择确认回调
onAddressConfirm(addressResult) {
+ // 更新弹窗中的地址显示
+ this.popupSelectedAddress = addressResult.fullAddress
+
// 更新areaId的状态
this.areaId.label = addressResult.fullAddress
- this.areaId.value = addressResult.selectedAddress.selectedAddress
+ this.areaId.value = addressResult.selectedAddress.adress
+
+ console.log('addressResult', addressResult);
// 调用clickItem来更新result数组并触发父组件事件
this.clickItem({
label: addressResult.fullAddress,
- value: addressResult.selectedAddress.selectedAddress
+ value: addressResult.selectedAddress.adress,
})
+
+ // 关闭下拉菜单
+ this.$refs.dropDown.close()
},
}
}
@@ -371,6 +406,26 @@
background: $uni-color;
}
}
+
+ .address-selector {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ background: rgba($uni-color, 0.1);
+ padding: 10rpx 20rpx;
+ margin: 10rpx;
+ border-radius: 10rpx;
+ font-size: 26rpx;
+
+ .selected-address {
+ flex: 1;
+ color: #333;
+ }
+
+ .arrow {
+ margin-left: 10rpx;
+ }
+ }
}
}
.btn {
diff --git a/pages/index/index.vue b/pages/index/index.vue
index e3376f4..5c38803 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -137,7 +137,7 @@
this.$store.commit('getBanner')
},
onLoad(){
- uni.on('initConfig', (e) => {
+ uni.$on('initConfig', (e) => {
this.config_other_job = e.config_other_job
})
},
diff --git a/store/store.js b/store/store.js
index 6fab708..c8d8b47 100644
--- a/store/store.js
+++ b/store/store.js
@@ -33,7 +33,7 @@ const store = new Vuex.Store({
// state.configList[n.keyName + '_keyValue'] = n.keyValue
})
- uni.emit('initConfig', state.configList)
+ uni.$emit('initConfig', state.configList)
}
})