参数优化
parent
00e9ddd2a5
commit
b3bf191fbd
66
App.vue
66
App.vue
|
|
@ -64,13 +64,24 @@
|
||||||
/**
|
/**
|
||||||
* 启动参数处理
|
* 启动参数处理
|
||||||
*/
|
*/
|
||||||
launch_params_handle(params) {
|
launch_params_handle(params) {
|
||||||
|
// 原有缓存
|
||||||
|
var cache_params = this.get_launch_cache_info();
|
||||||
|
|
||||||
|
// 当前参数、从query读取覆盖
|
||||||
if ((params.query || null) != null) {
|
if ((params.query || null) != null) {
|
||||||
params = params.query;
|
params = params.query;
|
||||||
}
|
}
|
||||||
|
// query下scene参数解析处理
|
||||||
if ((params.scene || null) != null) {
|
if ((params.scene || null) != null) {
|
||||||
params = this.url_params_to_json(decodeURIComponent(params.scene));
|
params = this.url_params_to_json(decodeURIComponent(params.scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 原始缓存是否存在邀请id、邀请使用最开始的用户id
|
||||||
|
if(cache_params != null && (cache_params.referrer || null) != null) {
|
||||||
|
params['referrer'] = cache_params.referrer;
|
||||||
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -98,6 +109,7 @@
|
||||||
set_scene_data(params) {
|
set_scene_data(params) {
|
||||||
var scene = ((params.scene || null) == null) ? 0 : parseInt(params.scene);
|
var scene = ((params.scene || null) == null) ? 0 : parseInt(params.scene);
|
||||||
uni.setStorageSync(this.data.cache_scene_key, scene);
|
uni.setStorageSync(this.data.cache_scene_key, scene);
|
||||||
|
return scene;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,12 +134,9 @@
|
||||||
/**
|
/**
|
||||||
* 设置设备信息
|
* 设置设备信息
|
||||||
*/
|
*/
|
||||||
set_system_info() {
|
set_system_info() {
|
||||||
var system_info = uni.getSystemInfoSync();
|
var system_info = uni.getSystemInfoSync();
|
||||||
uni.setStorage({
|
uni.setStorageSync(this.data.cache_system_info_key, system_info);
|
||||||
key: this.data.cache_system_info_key,
|
|
||||||
data: system_info
|
|
||||||
});
|
|
||||||
return system_info;
|
return system_info;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -222,10 +231,19 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统参数
|
* 系统参数获取
|
||||||
*/
|
*/
|
||||||
get_launch_cache_info() {
|
get_launch_cache_info() {
|
||||||
return uni.getStorageSync(this.data.cache_launch_info_key) || null;
|
return uni.getStorageSync(this.data.cache_launch_info_key) || null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统参数设置
|
||||||
|
*/
|
||||||
|
set_launch_cache_info(params) {
|
||||||
|
params = this.launch_params_handle(params);
|
||||||
|
uni.setStorageSync(this.data.cache_launch_info_key, params);
|
||||||
|
return params;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1302,21 +1320,23 @@
|
||||||
/**
|
/**
|
||||||
* 小程序初始化
|
* 小程序初始化
|
||||||
*/
|
*/
|
||||||
onLaunch(params) {
|
onLaunch(params) {},
|
||||||
// 启动参数处理+缓存
|
|
||||||
uni.setStorage({
|
/**
|
||||||
key: this.globalData.data.cache_launch_info_key,
|
* 小程序页面显示
|
||||||
data: this.globalData.launch_params_handle(params)
|
*/
|
||||||
});
|
onShow(params) {
|
||||||
|
// 初始化配置
|
||||||
// 设置设备信息
|
|
||||||
this.globalData.set_system_info();
|
|
||||||
|
|
||||||
// 初始化配置
|
|
||||||
this.globalData.init_config();
|
this.globalData.init_config();
|
||||||
|
|
||||||
|
// 设置设备信息
|
||||||
|
this.globalData.set_system_info();
|
||||||
|
|
||||||
|
// 参数处理+缓存
|
||||||
|
this.globalData.set_launch_cache_info(params);
|
||||||
|
|
||||||
// 场景值
|
// 场景值
|
||||||
this.globalData.set_scene_data(params);
|
this.globalData.set_scene_data(params);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {}
|
methods: {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue