48 lines
903 B
JavaScript
48 lines
903 B
JavaScript
import{mark,bind,unbind,updatePassword} from'@/apis/user.js'
|
|
class userUtils{
|
|
constructor(){
|
|
this.login();
|
|
// this.getImage();
|
|
|
|
}
|
|
//获取用户code的同步封装
|
|
getCode(){
|
|
return new Promise((resolve, reject) => {
|
|
uni.login({
|
|
success: (res) => {
|
|
resolve(res.code);
|
|
},
|
|
fail: (error) => {
|
|
reject(error);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
/**
|
|
* 登录方法,存储登录的所有信息
|
|
*/
|
|
async login(){
|
|
//获取code
|
|
let code=await this.getCode();
|
|
let res=await mark(code);
|
|
console.log("结果2",res)
|
|
if(res.code==200){
|
|
uni.setStorageSync('rds-token',res.msg);
|
|
uni.showToast({
|
|
icon: "none",
|
|
title: "登录成功"
|
|
})
|
|
}else{
|
|
uni.removeStorageSync('rds-token');
|
|
uni.showToast({
|
|
icon: "none",
|
|
title: "登录失败,请检查网络"
|
|
})
|
|
|
|
}
|
|
|
|
return res;
|
|
}
|
|
}
|
|
|
|
export default new userUtils() |