用户位置选择

master
gongfuxiang 2024-09-28 10:11:19 +08:00
parent f62631eb11
commit 243c58d505
8 changed files with 115 additions and 32 deletions

21
App.vue
View File

@ -108,7 +108,7 @@
is_home_logo_use_text: 0,
// 0, 1logo
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 0123
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;
},

View File

@ -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;

View File

@ -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>

View File

@ -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",

View File

@ -63,7 +63,8 @@
"service_time": "服务时间",
"apply_time": "申请时间",
"verification_text": "核销码",
"verification_message": "请输入核销码"
"verification_message": "请输入核销码",
"not_supported_scan_tips": "H5网页不支持扫码"
},
"pages": {
"goods-category": "商品分类",

View File

@ -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 msgcancel
var msg = res.errorMessage || res.chooseLocation || res.errMsg || this.$t('open-setting-location.open-setting-location.hwn386');

View File

@ -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;

View File

@ -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()
});
},