进入uniapp

This commit is contained in:
2023-12-01 23:57:44 +08:00
parent a78893ea1f
commit d61f5e6c92
524 changed files with 88081 additions and 12 deletions

56
im-uniapp/common/utils.js Normal file
View File

@@ -0,0 +1,56 @@
export function appInit(ms) {
return new Promise((resolve, reject) => {
var i = 0;
let timer = setInterval(() => {
var im_imUserSign = uni.getStorageSync("im_imUserSign")
var hd_userId = uni.getStorageSync("hd_userid")
if(hd_userId){
uni.setStorageSync("userId",hd_userId)
}else{
console.log("============未获取到hd_userid")
}
var hd_token = localStorage.getItem("hd_token")
i = 100;
if (i < 0) {
reject("error")
}
if (im_imUserSign) {
uni.setStorageSync("imUserSign",im_imUserSign)
uni.setStorageSync("token",hd_token)
if(uni.getStorageSync("userId")!=null&&uni.getStorageSync("imUserSign")!=null&&uni.getStorageSync("token")!=null){
clearInterval(timer)
timer = null
resolve("ok")
}
}else{
uni.setStorageSync("initReady",null)
}
}, ms);
})
}
/**
* getUrlKey 截取地址栏参数
* @param value
* @returns {String}
*/
export function getUrlParam(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
let url = window.location.href
let search = url.split('?')[1];
console.log(search);
if (search) {
var r = search.substr(0).match(reg);
if (r !== null) {
return unescape(r[2]);
}
return null;
} else return null;
}