init
This commit is contained in:
81
app.js
Normal file
81
app.js
Normal file
@@ -0,0 +1,81 @@
|
||||
import authApi from "./api/authApi"
|
||||
import devApi from "./api/configApi"
|
||||
import memberApi from "./api/memberApi"
|
||||
import clientConfig from "./config/index"
|
||||
import tool from "./utils/tool"
|
||||
import CustomHook from 'spa-custom-hooks';
|
||||
|
||||
let globalData = {
|
||||
token: '',
|
||||
userInfo: null,
|
||||
userMemberInfo: null,
|
||||
clientConfig: null
|
||||
}
|
||||
|
||||
CustomHook.install({
|
||||
'Login':{
|
||||
name:'Login',
|
||||
watchKey: 'token',
|
||||
onUpdate(val){
|
||||
return !!val;
|
||||
}
|
||||
},
|
||||
'User':{
|
||||
name:'User',
|
||||
watchKey: 'userInfo',
|
||||
onUpdate(val){
|
||||
return !!val;
|
||||
}
|
||||
},
|
||||
'UserMember':{
|
||||
name:'UserMember',
|
||||
watchKey: 'userMemberInfo',
|
||||
onUpdate(val){
|
||||
return !!val;
|
||||
}
|
||||
},
|
||||
'Config':{
|
||||
name:'Config',
|
||||
watchKey: 'clientConfig',
|
||||
onUpdate(val){
|
||||
return !!val;
|
||||
}
|
||||
}
|
||||
}, globalData || 'globalData')
|
||||
|
||||
|
||||
App({
|
||||
onLaunch() {
|
||||
// wx.login({
|
||||
// success: (res) => {
|
||||
// const code = res.code
|
||||
// authApi.login({code}).then(res=>{
|
||||
// this.globalData.token = res.data
|
||||
// tool.data.set("TOKEN",res.data)
|
||||
|
||||
// authApi.getLoginUser().then(res => {
|
||||
// this.globalData.userInfo = res.data
|
||||
// tool.data.set("USER_INFO",res.data)
|
||||
|
||||
// memberApi.getUserMemberInfo().then(res=>{
|
||||
// this.globalData.userMemberInfo = res.data
|
||||
// tool.data.set('USER_MEMBER_INFO', res.data)
|
||||
|
||||
// devApi.clientBaseList().then(res => {
|
||||
// res.data.forEach(item => {
|
||||
// clientConfig[item.configKey] = item.configValue
|
||||
// });
|
||||
// tool.data.set('CLIENT_CONFIG',clientConfig)
|
||||
// this.globalData.clientConfig = clientConfig
|
||||
// })
|
||||
|
||||
// })
|
||||
|
||||
// })
|
||||
|
||||
// })
|
||||
// },
|
||||
// })
|
||||
},
|
||||
globalData
|
||||
})
|
||||
Reference in New Issue
Block a user