123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { config } from "../config/config"
- import { log } from "./log"
- import { tools } from "./tools"
- export class util {
- /**
- * 获取本地数据
- */
- public static getStorage(key:string){
- let d = uni.getStorageSync(key)
- if(util.isNull(d)){
- return null
- }
- return d
- }
-
- /**
- * 设置本地数据
- */
- public static setStorage(key:string,value:string){
- uni.setStorageSync(key,value)
- }
-
-
- /**
- * 清除本地key数据
- */
- public static clearStorageForKey(key:string){
- let d = util.getStorage(key)
- if(util.isNull(d)){
- log.Error(`${key} is null!`);
- }else{
- util.setStorage(key,null)
- }
- }
-
- /**
- * 清除本地数据
- */
- public static clearAllStorage(){
- uni.clearStorageSync()
- }
-
- public static isNull(v:any){
- if(v==null||v==undefined||v==""){
- return true
- }
- return false
- }
-
- public static alert(v:string){
- let Platform = tools.getCurPlatform()
- if(Platform==config.Platform.H5){
- alert(v)
- }else if(Platform==config.Platform.TOUTIAO){
- log.Debug("TOUTIAO",v)
- }else if(Platform==config.Platform.WEIXIN){
- log.Debug("WEIXIN",v)
- }
- }
-
-
- }
|