参数优化

master
gongfuxiang 2022-02-10 11:33:06 +08:00
parent 00e9ddd2a5
commit b3bf191fbd
1 changed files with 43 additions and 23 deletions

66
App.vue
View File

@ -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;
} }
// queryscene
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: {}