From 243c58d505197c0aafc8c1880fea644fb044f4db Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Sat, 28 Sep 2024 10:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BD=8D=E7=BD=AE=E9=80=89?= =?UTF-8?q?=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 21 +++++- common/css/page.css | 2 +- .../choice-location/choice-location.vue | 71 +++++++++++++++++++ locale/en.json | 3 +- locale/zh.json | 3 +- .../open-setting-location.vue | 9 ++- pages/index/index.css | 2 - pages/index/index.vue | 36 ++++------ 8 files changed, 115 insertions(+), 32 deletions(-) create mode 100644 components/choice-location/choice-location.vue diff --git a/App.vue b/App.vue index e829d070..1b635e2f 100644 --- a/App.vue +++ b/App.vue @@ -108,7 +108,7 @@ is_home_logo_use_text: 0, // 首页开启地理位置选择(0否, 1是)优先级高于logo展示 - is_home_location_choice: 0, + is_home_location_choice: 1, // 门店详情顶部导航返回按钮(0否, 1是) is_realstore_top_nav_back: 1, @@ -2583,6 +2583,10 @@ // 扫码解析处理 scan_handle() { + // #ifdef H5 + this.showToast(i18n.t('common.not_supported_scan_tips')); + // #endif + // #ifndef H5 var self = this; uni.scanCode({ success: function (res) { @@ -2653,6 +2657,7 @@ } }, }); + // #endif }, // 获取当前语言 @@ -2662,6 +2667,15 @@ // 选择用户地理位置 choose_user_location_event() { + // 存在数据则改变状态值 + var key = this.data.cache_userlocation_key; + var result = uni.getStorageSync(key) || null; + if(result != null) { + result['status'] = 2; + uni.setStorageSync(key, result); + } + + // 进入页面选择位置 uni.navigateTo({ url: '/pages/common/open-setting-location/open-setting-location', }); @@ -2674,6 +2688,7 @@ // 地址信息初始化 choice_user_location_init() { + // status 0未选择,1已选择,2选择中,3选择失败 var result = uni.getStorageSync(this.data.cache_userlocation_key) || null; var user_location = { status: 0 }; if (result != null) { @@ -2684,11 +2699,11 @@ address: result.address || null, lat: result.latitude || null, lng: result.longitude || null, - status: 1, + status: result.status || 1, }, }; } - user_location['text'] = user_location.status == 0 ? i18n.t('shopxo-uniapp.app.4v6q86') : (user_location.name || user_location.address || ''); + user_location['text'] = user_location.name || user_location.address || i18n.t('shopxo-uniapp.app.4v6q86'); return user_location; }, diff --git a/common/css/page.css b/common/css/page.css index 43ed5f8e..112448e3 100644 --- a/common/css/page.css +++ b/common/css/page.css @@ -72,7 +72,7 @@ uni-page-head { .uni-page-head-btn { position: fixed; left: auto; - bottom: 140rpx; + bottom: 180rpx; background: rgba(0, 0, 0, 0.6); box-shadow: 0 0 20rpx rgb(0 0 0 / 30%); margin: 0 0 0 20rpx; diff --git a/components/choice-location/choice-location.vue b/components/choice-location/choice-location.vue new file mode 100644 index 00000000..6191098d --- /dev/null +++ b/components/choice-location/choice-location.vue @@ -0,0 +1,71 @@ + + + \ No newline at end of file diff --git a/locale/en.json b/locale/en.json index 62d7ac8e..088b0296 100644 --- a/locale/en.json +++ b/locale/en.json @@ -63,7 +63,8 @@ "service_time": "service time ", "apply_time": "Application time", "verification_text": "Verification code", - "verification_message": "Please enter the verification code" + "verification_message": "Please enter the verification code", + "not_supported_scan_tips": "H5 webpage does not support scanning codes" }, "pages": { "goods-category": "Product classification", diff --git a/locale/zh.json b/locale/zh.json index f6700916..bc9470f1 100644 --- a/locale/zh.json +++ b/locale/zh.json @@ -63,7 +63,8 @@ "service_time": "服务时间", "apply_time": "申请时间", "verification_text": "核销码", - "verification_message": "请输入核销码" + "verification_message": "请输入核销码", + "not_supported_scan_tips": "H5网页不支持扫码" }, "pages": { "goods-category": "商品分类", diff --git a/pages/common/open-setting-location/open-setting-location.vue b/pages/common/open-setting-location/open-setting-location.vue index 5860105c..51ee6ce3 100644 --- a/pages/common/open-setting-location/open-setting-location.vue +++ b/pages/common/open-setting-location/open-setting-location.vue @@ -103,7 +103,8 @@ export default { // 调用位置选择组件 uni.chooseLocation({ success: (res) => { - // 位置数据存储缓存中 + // 位置数据存储缓存中,改变状态值(成功) + res['status'] = 1; uni.setStorageSync(this.cache_key, res); // 触发自定义事件并传递参数给上一页 @@ -116,7 +117,11 @@ export default { }, 500); // #endif }, - fail: (res) => { + fail: (res) => { + // 存在数据则改变状态值(失败) + var result = {...(uni.getStorageSync(this.cache_key) || {}), ...{status: 3}}; + uni.setStorageSync(this.cache_key, result); + // 取消则自动返回、则显示错误 // error=11 支付宝取消、msg包含cancel则其他平台 var msg = res.errorMessage || res.chooseLocation || res.errMsg || this.$t('open-setting-location.open-setting-location.hwn386'); diff --git a/pages/index/index.css b/pages/index/index.css index 52919cbb..3db744d8 100644 --- a/pages/index/index.css +++ b/pages/index/index.css @@ -14,8 +14,6 @@ } .home-top-nav-location { max-width: calc(100% - 200rpx); - height: 56rpx; - line-height: 56rpx; } .home-top-nav-logo { text-align: left; diff --git a/pages/index/index.vue b/pages/index/index.vue index 855df477..bba7249f 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -33,14 +33,16 @@ - - + + + + @@ -331,6 +333,7 @@ import componentMagicList from '@/components/magic-list/magic-list'; import componentAppAdmin from '@/components/app-admin/app-admin'; import componentDiy from '@/components/diy/diy'; + import componentChoiceLocation from '@/components/choice-location/choice-location'; // 状态栏高度 var bar_height = parseInt(app.globalData.get_system_info('statusBarHeight', 0, true)); @@ -445,7 +448,8 @@ componentBindingList, componentMagicList, componentAppAdmin, - componentDiy + componentDiy, + componentChoiceLocation }, onLoad(params) { @@ -461,20 +465,6 @@ if (this.is_home_location_choice == 1) { // 用户位置初始化 this.user_location_init(); - // 先解绑自定义事件 - uni.$off('refresh'); - // 监听自定义事件并进行页面刷新操作 - uni.$on('refresh', (data) => { - // 初始位置数据 - if ((data.location_success || false) == true) { - // 用户位置初始化 - this.user_location_init(); - // 重新请求数据 - // #ifdef APP - this.init(); - // #endif - } - }); } // 数据加载 @@ -675,15 +665,17 @@ }, 3000); }, - // 选择用户地理位置 - choose_user_location_event(e) { - app.globalData.choose_user_location_event(); + // 选择用户地理位置回调 + user_back_choice_location(e) { + this.setData({ + user_location: e + }); }, // 用户地理位置初始化 user_location_init() { this.setData({ - user_location: app.globalData.choice_user_location_init(), + user_location: app.globalData.choice_user_location_init() }); },