参数优化

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) {
params = params.query;
}
}
// queryscene
if ((params.scene || null) != null) {
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;
},
@ -98,6 +109,7 @@
set_scene_data(params) {
var scene = ((params.scene || null) == null) ? 0 : parseInt(params.scene);
uni.setStorageSync(this.data.cache_scene_key, scene);
return scene;
},
/**
@ -122,12 +134,9 @@
/**
* 设置设备信息
*/
set_system_info() {
var system_info = uni.getSystemInfoSync();
uni.setStorage({
key: this.data.cache_system_info_key,
data: system_info
});
set_system_info() {
var system_info = uni.getSystemInfoSync();
uni.setStorageSync(this.data.cache_system_info_key, system_info);
return system_info;
},
@ -222,10 +231,19 @@
},
/**
* 系统参数
* 系统参数获取
*/
get_launch_cache_info() {
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) {
// +
uni.setStorage({
key: this.globalData.data.cache_launch_info_key,
data: this.globalData.launch_params_handle(params)
});
//
this.globalData.set_system_info();
//
onLaunch(params) {},
/**
* 小程序页面显示
*/
onShow(params) {
//
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: {}