市北人才赋能平台 --小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

46 lines
996 B

const StoreKey = {
UserStoreKey: 'UserInfoStoreKey',
TokenStoreKey: 'TokenStoreKey'
}
class Store {
constructor () {
}
// public
// Token的存取方法
saveToken(data) {
this._save(StoreKey.TokenStoreKey, data)
}
readToken() {
return this._read(StoreKey.TokenStoreKey) || ''
}
// User的存取
saveUserInfo(data) {
this._save(StoreKey.UserStoreKey, data)
}
readUserInfo(){
return this._read(StoreKey.UserStoreKey) || ''
}
// 是否有手机号码
hasPhone () {
const {phone} = this.readUserInfo()
return phone ? true : false
}
// 是否绑定微信和人才库
hasBindUserInfo () {
const {avatarUrl, nickName} = this.readUserInfo()
console.log(avatarUrl, nickName)
return (avatarUrl && nickName) ? true : false
}
// 私有存取方法
_save(key, data) {
wx.setStorageSync(key, data)
}
_read(key) {
return wx.getStorageSync(key)
}
}
let store = new Store() // 唯一个对象实例
export {store}