门店搜索支持地图,公共配置获取优化

master
gongfuxiang 2024-11-07 00:36:03 +08:00
parent 8a51a7c09a
commit c54e7687fc
8 changed files with 241 additions and 86 deletions

115
App.vue
View File

@ -220,8 +220,8 @@
//
//
common_data_loading_status: 0,
common_data_init_status: 0,
common_data_init_timer: null,
common_data_init_back_timer: null,
//
network_type_page_record_timer: null,
@ -1409,12 +1409,12 @@
/**
* 初始化 配置信息
* status 读取状态如果失败默认或者0则会再次读取一次
* num 读取次数如果失败+1再次读取
* object 回调操作对象
* method 回调操作对象的函数
* params 回调操请求参数
*/
init_config(status = 0, object, method, params) {
init_config(num = 0, object, method, params) {
var self = this;
uni.getNetworkType({
success: function (res) {
@ -1427,46 +1427,54 @@
}
//
uni.request({
url: self.get_request_url('common', 'base'),
method: 'POST',
data: {
is_key: 1,
},
dataType: 'json',
success: (res) => {
if (res.data.code == 0) {
//
var data = res.data.data;
uni.setStorageSync(self.data.cache_config_info_key, data);
if(self.data.common_data_loading_status == 0) {
//
self.data.common_data_loading_status = 1;
uni.request({
url: self.get_request_url('common', 'base'),
method: 'POST',
data: {
is_key: 1,
},
dataType: 'json',
success: (res) => {
//
self.data.common_data_loading_status = 0;
if (res.data.code == 0) {
//
var data = res.data.data;
uni.setStorageSync(self.data.cache_config_info_key, data);
//
self.init_config_result_handle(data, self);
//
self.init_config_result_handle(data, self);
//
if (typeof object === 'object' && (method || null) != null) {
object[method](params);
//
if (typeof object === 'object' && (method || null) != null) {
object[method](params);
}
} else {
self.showToast(res.data.msg);
//
if (res.data.code == -10000) {
self.data.common_data_init_status = 1;
}
//
if (parseInt(num || 0) <= 20 && self.data.common_data_init_status == 0) {
self.init_config(num+1, object, method, params);
}
}
} else {
self.showToast(res.data.msg);
//
if (res.data.code == -10000) {
self.data.common_data_init_status = 1;
},
fail: () => {
//
self.data.common_data_loading_status = 0;
//
if (parseInt(num || 0) <= 20) {
self.init_config(num+1, object, method, params);
}
//
if ((status || 0) == 0 && self.data.common_data_init_status == 0) {
self.init_config(1, object, method, params);
}
}
},
fail: () => {
//
if ((status || 0) == 0) {
self.init_config(1, object, method, params);
}
},
});
},
});
}
}
},
});
@ -1503,16 +1511,9 @@
if (typeof object === 'object' && (method || null) != null) {
object[method](true, params);
}
} else {
//
if(is_config_count < 1 && self.data.common_data_init_status == 1) {
is_config_count++;
self.data.common_data_init_status = 0;
self.init_config();
}
}
count++;
if (count >= 100) {
if (count >= 2300) {
clearInterval(timer);
}
}, 100);
@ -2425,19 +2426,6 @@
});
},
//
common_data_init_handle() {
var self = this;
self.data.common_data_init_timer = setInterval(function () {
if (self.data.common_data_init_status == 0) {
self.init_config(1);
} else {
//
clearInterval(self.data.common_data_init_timer);
}
}, 2000);
},
//
network_type_handle(object, method, params = {}) {
//
@ -2900,8 +2888,6 @@
//
clear_interval_handle() {
//
clearInterval(this.data.common_data_init_timer);
//
clearInterval(this.data.common_data_init_back_timer);
//
@ -3040,7 +3026,7 @@
//tabbar
this.globalData.system_hide_tabbar();
//
//
this.globalData.init_config();
//
@ -3051,9 +3037,6 @@
//
this.globalData.set_scene_data(params);
//
this.globalData.common_data_init_handle();
},
//

View File

@ -2,7 +2,7 @@
<view :class="theme_view">
<!-- 底部菜单 -->
<block v-if="is_tabbar">
<component-diy-footer :propKey="key" :propValue="app_tabber" @onFooterHeight="footer_height_value_event"></component-diy-footer>
<component-diy-footer :propKey="key" :propValue="app_tabbar" @onFooterHeight="footer_height_value_event"></component-diy-footer>
<view v-if="propIsFooterSeat && footer_height_value > 0" :style="'height:'+footer_height_value+'rpx;'"></view>
</block>
@ -54,7 +54,7 @@
privacy_content: null,
key: '',
is_tabbar: false,
app_tabber: null,
app_tabbar: null,
footer_height_value: 0,
};
},
@ -151,7 +151,7 @@
};
if(upd_data['is_tabbar']) {
upd_data['key'] = Math.random();
upd_data['app_tabber'] = app.globalData.get_config('app_tabber');
upd_data['app_tabbar'] = app.globalData.get_config('app_tabbar');
}
this.setData(upd_data);
},

View File

@ -1216,7 +1216,7 @@
{
"path": "search/search",
"style": {
"enablePullDownRefresh": true,
"enablePullDownRefresh": false,
"navigationBarTitleText": ""
}
},

View File

@ -207,7 +207,7 @@
<block v-for="(item, index) in plugins_coin_data.accounts_list" :key="index">
<view class="item flex-row jc-sb align-c" :data-value="item.id" @tap="plugins_coin_payment_event">
<view class="item-content pr flex-row align-c">
<image v-if="(item.platform_icon || null) != null" class="icon margin-right-sm va-m" :src="item.platform_icon" mode="widthFix"></image>
<image v-if="(item.platform_icon || null) != null" class="icon margin-right-sm va-m radius" :src="item.platform_icon" mode="widthFix"></image>
<view class="flex-col">
<view class="cr-base">{{ item.platform_name }}</view>
<view class="flex-row align-c margin-top-xs">
@ -227,7 +227,7 @@
<view v-for="(item, index) in payment_list" :key="index">
<view class="item flex-row jc-sb align-c" :data-value="item.id" :data-index="index" @tap="payment_event">
<view class="item-content pr flex-1 flex-width">
<image v-if="(item.logo || null) != null" class="icon margin-right-sm va-m" :src="item.logo" mode="widthFix"></image>
<image v-if="(item.logo || null) != null" class="icon margin-right-sm va-m radius" :src="item.logo" mode="widthFix"></image>
<text class="va-m">{{ item.name }}</text>
<text v-if="(item.tips || null) !== null" class="pay-tips">{{ item.tips }}</text>
</view>

View File

@ -175,14 +175,14 @@
});
} else {
this.setData({
data_list_loding_status: 0,
data_list_loding_status: 3,
data_list_loding_msg: res.data.msg
});
}
},
fail: () => {
this.setData({
data_list_loding_status: 2,
data_list_loding_status: 3,
data_list_loding_msg: this.$t('common.internet_error_tips')
});
}
@ -240,7 +240,7 @@
} else {
this.setData({
map_center_icon_status: 1,
})
});
}
}
},

View File

@ -3,16 +3,35 @@
*/
.nav-location {
max-width: 260rpx;
height: 60rpx;
line-height: 60rpx;
height: 56rpx;
line-height: 56rpx;
}
.nav-search {
width: calc(100% - 260rpx);
}
.nav-search.map {
width: 100%;
}
/**
*
*/
.scroll-box {
height: calc(100vh - 180rpx);
}
.scroll-box.map {
height: calc(100vh - 682rpx);
}
/**
*
*/
.map-container {
height: 500rpx;
}
.map-container .map-center-icon {
top: calc(50% - 30rpx);
left: calc(50% - 30rpx);
width: 60rpx;
height: 60rpx;
}

View File

@ -2,15 +2,34 @@
<view :class="theme_view">
<block v-if="(data_base || null) != null">
<!-- 顶部 -->
<view class="bg-white padding-top-main padding-horizontal-main oh flex-row jc-sb align-c cr-grey">
<view class="bg-white padding-top-main padding-horizontal-main oh flex-row jc-sb align-c cr-grey" :class="show_type == 1 ? 'map padding-bottom' : ''">
<!-- 位置 -->
<view class="nav-location flex-row align-c single-text margin-right-sm">
<view v-if="show_type == 0" class="nav-location flex-row align-c single-text margin-right-sm">
<component-choice-location ref="choice_location" propBaseColor="#666" propTextMaxWidth="180rpx" @onBack="user_back_choice_location"></component-choice-location>
</view>
<!-- 搜索 -->
<view class="nav-search">
<view class="nav-search" :class="show_type == 1 ? 'map' : ''">
<component-search @onsearch="search_button_event" :propIsOnEvent="true" :propIsRequired="false" :propDefaultValue="search_keywords_value" :propPlaceholder="$t('index.index.c5273j')" propPlaceholderClass="cr-grey-c" propBgColor="#f5f5f5"></component-search>
</view>
<view v-if="is_search_map == 1" class="dis-inline-block margin-left" @tap="show_event">
<iconfont :name="show_type == 1 ? 'icon-list-dot' : 'icon-map-location'" color="#666" size="38rpx"></iconfont>
</view>
</view>
<!-- 地图 -->
<view v-show="show_type == 1" class="map-container pr">
<map class="wh-auto ht-auto"
:enable-zoom="true"
:enable-scroll="true"
:show-location="true"
:latitude="latitude"
:longitude="longitude"
:scale="map_scale"
:markers="markers"
@regionchange="region_change_event"
@markertap="marker_tap_event"
></map>
<image v-if="map_center_icon_status == 1" class="map-center-icon pa" :src="map_location_icon" mode="aspectFit"></image>
</view>
<!-- 分类 -->
@ -22,13 +41,13 @@
</scroll-view>
<!-- 列表 -->
<scroll-view :scroll-y="true" class="scroll-box scroll-box-ece-nav" @scrolltolower="scroll_lower" lower-threshold="60">
<scroll-view :scroll-y="true" :scroll-top="scroll_top" :scroll-with-animation="true" class="scroll-box scroll-box-ece-nav" :class="show_type == 1 ? 'map' : ''" @scrolltolower="scroll_lower" lower-threshold="60">
<view v-if="(data_list || null) != null && data_list.length > 0" class="padding-top-main padding-horizontal-main">
<component-realstore-list :propData="{data: data_list}" :propRealstoreDetailQuery="realstore_detail_query" :propFavorUser="favor_user"></component-realstore-list>
</view>
<view v-else>
<!-- 提示信息 -->
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg" :propLoadingLogoTop="show_type == 1 ? '20%' : ''"></component-no-data>
</view>
<!-- 结尾 -->
@ -48,6 +67,7 @@
import componentSearch from "@/components/search/search";
import componentRealstoreList from "@/components/realstore-list/realstore-list";
import componentChoiceLocation from '@/components/choice-location/choice-location';
var plugins_static_url = app.globalData.get_static_url('realstore', true);
export default {
data() {
return {
@ -67,6 +87,20 @@
nav_active_value: 0,
favor_user: [],
realstore_detail_query: '',
// 01
show_type: 0,
//
is_search_map: 0,
map_location_icon: plugins_static_url+'app/map/location-icon.png',
markers_icon: plugins_static_url+'app/map/markers-icon.png',
markers_icon_active: plugins_static_url+'app/map/markers-icon-active.png',
map_scale: 12,
latitude: 39.909,
longitude: 116.39742,
markers: [],
map_center_icon_status: 1,
markers_active_index: null,
scroll_top: 0,
//
user_location: {},
//
@ -135,10 +169,16 @@
uni.stopPullDownRefresh();
if (res.data.code == 0) {
var data = res.data.data;
var data_base = data.base || {};
this.setData({
data_base: data.base || null,
category: data.category || [],
favor_user: data.favor_user || [],
is_search_map: parseInt(data_base.is_search_map || 0),
map_scale: parseInt(data_base.search_map_scale || 12),
markers_icon: data_base.search_map_store_icon || this.markers_icon,
markers_icon_active: data_base.search_map_store_icon_active || this.markers_icon_active,
map_location_icon: data_base.search_map_location_icon || this.map_location_icon,
});
//
@ -204,8 +244,8 @@
keywords: this.search_keywords_value,
category_id: this.nav_active_value || 0,
goods_id: this.params.goods_id || 0,
lng: lng,
lat: lat,
lng: this.longitude || lng,
lat: this.latitude || lat,
},
dataType: "json",
success: (res) => {
@ -250,6 +290,25 @@
});
}
}
//
var temp_markers = [];
if(this.data_list.length > 0) {
this.data_list.forEach((item, index) => {
temp_markers.push({
id: index,
width: 25,
height: 25,
latitude: item.lat,
longitude: item.lng,
iconPath: this.markers_icon
});
});
}
this.setData({
markers: temp_markers,
markers_active_index: null
});
} else {
this.setData({
data_list_loding_status: 0,
@ -329,10 +388,88 @@
//
user_location_init() {
var user_location = app.globalData.choice_user_location_init();
var upd_data = {
user_location: user_location
};
if ((user_location || null) != null) {
upd_data['longitude'] = user_location.lng;
upd_data['latitude'] = user_location.lat;
}
this.setData(upd_data);
},
//
show_event(e) {
this.setData({
user_location: app.globalData.choice_user_location_init()
show_type: (this.show_type == 1) ? 0 : 1
});
},
//
marker_tap_event(e) {
//
var index = e.detail.markerId;
//
this.data_markers_active_handle(index);
//
this.setData({
scroll_top: (index*252)+'rpx'
});
},
//
data_markers_active_handle(index) {
//
var temp_markers = this.markers;
for(var i in temp_markers) {
if(i == index) {
temp_markers[i]['iconPath'] = this.markers_icon_active;
} else {
temp_markers[i]['iconPath'] = this.markers_icon;
}
}
//
var temp_data_list = this.data_list;
for(var i in temp_data_list) {
if(i == index) {
temp_data_list[i]['active'] = 'active';
} else {
temp_data_list[i]['active'] = '';
}
}
//
this.setData({
markers_active_index: index,
markers: temp_markers,
data_list: temp_data_list,
map_center_icon_status: 0
});
},
//
region_change_event(e) {
//
if(e.causedBy == 'drag' || e.causedBy == 'gesture') {
// 1.
// 2.
if(e.type == 'end') {
this.setData({
latitude: e.detail.centerLocation.latitude,
longitude: e.detail.centerLocation.longitude,
data_page: 1,
data_list: [],
data_list_loding_status: 1,
data_bottom_line_status: false,
});
this.get_data_list(1);
} else {
this.setData({
map_center_icon_status: 1,
});
}
}
},
},
};
</script>

File diff suppressed because one or more lines are too long