门店搜索支持地图,公共配置获取优化
parent
8a51a7c09a
commit
c54e7687fc
115
App.vue
115
App.vue
|
|
@ -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();
|
||||
},
|
||||
|
||||
// 从前台进入后台
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1216,7 +1216,7 @@
|
|||
{
|
||||
"path": "search/search",
|
||||
"style": {
|
||||
"enablePullDownRefresh": true,
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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: '',
|
||||
// 显示类型(0列表,1地图)
|
||||
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
Loading…
Reference in New Issue