tmp
This commit is contained in:
20
app.js
20
app.js
@@ -1,6 +1,7 @@
|
||||
// app.js
|
||||
import config from './config';
|
||||
import createBus from './utils/eventBus';
|
||||
const API = require('./utils/api.js');
|
||||
|
||||
App({
|
||||
onLaunch() {
|
||||
@@ -26,6 +27,25 @@ App({
|
||||
this.connect();
|
||||
},
|
||||
|
||||
onShow(options) {
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
API.user.wxSignin({ code: res.code })
|
||||
.then((data) => {
|
||||
if (data.code == 0) {
|
||||
this.globalData.user = data.data.user
|
||||
this.eventBus.emit('user-login', data.data.user)
|
||||
} else {
|
||||
console.log('登录失败!')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/** 全局事件总线 */
|
||||
eventBus: createBus(),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user