82 lines
1.8 KiB
Plaintext
82 lines
1.8 KiB
Plaintext
<style lang="less">
|
|
@import "style/zanui/index.wxss";
|
|
.container {
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
box-sizing: border-box;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
import wepy from 'wepy'
|
|
import 'wepy-async-function'
|
|
|
|
export default class extends wepy.app {
|
|
config = {
|
|
pages: [
|
|
'pages/index',
|
|
'pages/game',
|
|
'pages/gameInfo',
|
|
'pages/login'
|
|
],
|
|
window: {
|
|
backgroundTextStyle: 'light',
|
|
navigationBarBackgroundColor: '#fff',
|
|
navigationBarTitleText: 'WeChat',
|
|
navigationBarTextStyle: 'black'
|
|
}
|
|
}
|
|
|
|
globalData = {
|
|
userInfo: null
|
|
}
|
|
|
|
constructor () {
|
|
super()
|
|
this.use('requestfix')
|
|
}
|
|
|
|
onLaunch() {
|
|
}
|
|
|
|
getUserInfo() {
|
|
return this.globalData.userInfo
|
|
}
|
|
checkClientLogin() {
|
|
let self = this;
|
|
let needLogin = true;
|
|
if (!self.globalData.userInfo) {
|
|
if (wepy.getStorageSync('userInfo')) {
|
|
self.globalData.userInfo = JSON.parse(wepy.getStorageSync('userInfo'));
|
|
needLogin = false;
|
|
}
|
|
} else {
|
|
needLogin = false;
|
|
}
|
|
return needLogin;
|
|
}
|
|
updateGlobalData(name, obj) {
|
|
// 校验: globalData
|
|
if (!this.globalData) return;
|
|
// 校验: 操作字段
|
|
if (typeof name !== 'string' || name === '') return {};
|
|
// 取已有信息
|
|
const info = this.globalData[name] || {};
|
|
// 更新缓存
|
|
if (obj) {
|
|
// Object合并第一层
|
|
this.globalData[name] = Object.assign({}, info, obj);
|
|
} else if (!this.isUndefined(obj)) {
|
|
// 其他非undefined数据直接覆盖
|
|
this.globalData[name] = obj;
|
|
}
|
|
this.$apply;
|
|
console.info(`[${obj ? 'UPDATE' : 'GET'} GlobalData ${name}]:`, this.globalData[name]);
|
|
return this.globalData[name];
|
|
}
|
|
}
|
|
</script>
|