From 7f693ebe71d34fd84b3618ff0d5a66f004e46db5 Mon Sep 17 00:00:00 2001 From: xuxueyang <xuxy@fengyuntec.com> Date: 星期日, 11 八月 2024 22:33:33 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/main' --- pages/user/address/address.vue | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pages/user/address/address.vue b/pages/user/address/address.vue index 5deb06e..8b2c9e5 100644 --- a/pages/user/address/address.vue +++ b/pages/user/address/address.vue @@ -219,10 +219,19 @@ }, async init_area() { if (this.regionDataPlus && this.regionDataPlus.length > 0) { - const res = await this.$http.request('get', '/api/pub/china/area/json') - this.regionDataPlus = res.data && JSON.parse(res.data.replaceAll('code', 'value').replaceAll( - 'name', - 'text')) || [] + + } else { + var a = this.$storage.getItem('cache_area') + if (a) { + this.regionDataPlus = JSON.parse(a) || [] + } else { + const res = await this.$http.request('get', '/api/pub/china/area/json') + // console.log('area', JSON.parse(res.data)) + this.regionDataPlus = res.data && JSON.parse(res.data.replaceAll('code', 'value').replaceAll( + 'name', + 'text')) || [] + this.$storage.setItem('cache_area', JSON.stringify(this.regionDataPlus)) + } } }, @@ -395,11 +404,18 @@ if (code === 0) { this.$refs.popup_form.close() this.$message.showToast(this.submitForm.id ? '修改成功' : '新增成功') + let tmp = this setTimeout(() => { tmp.page.current = 1 tmp.refreshList() }, 300) + //如果当前选择的地址是这个,需要更新一下数据 + if (this.address.id && this.submitForm.id === this.address.id) { + this.$store.commit('setDefaultAddress', { + ...this.submitForm + }) + } } }, -- Gitblit v1.9.3