用户位置选择
parent
f62631eb11
commit
243c58d505
21
App.vue
21
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;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
<template>
|
||||
<view :class="theme_view">
|
||||
<view class="choice-location single-text padding-right pr" @tap="choose_user_location_event">
|
||||
<view class="dis-inline-block va-m lh">
|
||||
<iconfont name="icon-location" size="32rpx" propClass="lh" color="#fff"></iconfont>
|
||||
</view>
|
||||
<text class="va-m margin-left-xs text-size-md">{{ location.text || '' }}</text>
|
||||
<view class="lh pa right-0 top-xxxl">
|
||||
<iconfont name="icon-arrow-bottom" size="24rpx" propClass="lh-xs" color="#fff"></iconfont>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
const app = getApp();
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
theme_view: app.globalData.get_theme_value_view(),
|
||||
location: {},
|
||||
cloice_location_timer: null
|
||||
};
|
||||
},
|
||||
props: {},
|
||||
// 页面被展示
|
||||
created: function () {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
this.setData({
|
||||
location: app.globalData.choice_user_location_init()
|
||||
});
|
||||
console.log(this.location)
|
||||
},
|
||||
|
||||
// 选择位置监听
|
||||
choose_user_location_event(e) {
|
||||
// 定时任务
|
||||
clearInterval(this.cloice_location_timer);
|
||||
var self = this;
|
||||
var timer = setInterval(function () {
|
||||
var result = app.globalData.choice_user_location_init() || null;
|
||||
console.log(result);
|
||||
if(result != null && (result.status == 1 || result.status == 3)) {
|
||||
self.setData({
|
||||
location: result
|
||||
});
|
||||
clearInterval(self.cloice_location_timer);
|
||||
|
||||
// 回调事件
|
||||
self.$emit('onback', result);
|
||||
}
|
||||
}, 1000);
|
||||
this.setData({
|
||||
cloice_location_timer: timer
|
||||
});
|
||||
|
||||
// 进入位置选择
|
||||
app.globalData.choose_user_location_event();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.choice-location {
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@
|
|||
"service_time": "服务时间",
|
||||
"apply_time": "申请时间",
|
||||
"verification_text": "核销码",
|
||||
"verification_message": "请输入核销码"
|
||||
"verification_message": "请输入核销码",
|
||||
"not_supported_scan_tips": "H5网页不支持扫码"
|
||||
},
|
||||
"pages": {
|
||||
"goods-category": "商品分类",
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -33,14 +33,16 @@
|
|||
<view :class="'search-content-fixed-content ' + (common_app_is_enable_search == 1 ? 'nav-enable-search' : '')" :style="(common_app_is_header_nav_fixed == 1 ? top_content_style : '') + (common_app_is_header_nav_fixed == 1 ? top_content_search_content_style : '')">
|
||||
<view class="home-top-nav margin-bottom-sm pr padding-right-main">
|
||||
<!-- 定位 -->
|
||||
<view v-if="is_home_location_choice == 1" class="home-top-nav-location dis-inline-block va-m single-text cr-white pr bs-bb padding-left-main padding-right-lg" @tap="choose_user_location_event">
|
||||
<view class="dis-inline-block va-m lh">
|
||||
<view v-if="is_home_location_choice == 1" class="home-top-nav-location dis-inline-block va-m single-text cr-white pr bs-bb padding-left-main padding-right-lg" >
|
||||
<!-- <view class="dis-inline-block va-m lh">
|
||||
<iconfont name="icon-location" size="32rpx" propClass="lh" color="#fff"></iconfont>
|
||||
</view>
|
||||
<text class="va-m margin-left-xs text-size-md">{{ user_location.text || '' }}</text>
|
||||
<view class="lh pa right-0 top-xxxl">
|
||||
<iconfont name="icon-arrow-bottom" size="24rpx" propClass="lh-xs" color="#fff"></iconfont>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<component-choice-location @onback="user_back_choice_location"></component-choice-location>
|
||||
</view>
|
||||
<block v-else>
|
||||
<!-- logo/标题 -->
|
||||
|
|
@ -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()
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue