/**
* 储存数据
* Storage
*/
module.exports={
/**
* 设置值
* key:value,
* {
* useName:{
* key:value,
* sex:'sss',
* ...
* }
* }
*
*/
setItem(key,value,module_name){
if(module_name){
let module_name_info=this.getItem(module_name)||{};
module_name_info[key]=value;
wx.setStorageSync(module_name, module_name_info)
}else{
wx.setStorageSync(key,value)
}
},
getItem(key,module_name){
if(module_name){
let val=wx.getStorageSync(module_name);
if(val) return val[key];
return '';
}else{
return wx.getStorageSync(key)
}
},
clear(key){
key?wx.removeStorageSync(key):wx.removeStorageSync()
},
getSystemInfo(){
return wx.getSystemInfoSync();
}
}
网友评论