diff --git a/pages/index/index.js b/pages/index/index.js index d9da88c..012c41c 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -79,6 +79,7 @@ Page({ wx.setStorageSync('imgurl', imgurl); if (app.globalData.token) { + this.updateUserInfo(); if (options.couponChannelId || options.orderId || options.id) { that.userStatus(options); } else { @@ -88,6 +89,7 @@ Page({ // 由于 token 是网络请求,可能会在 Page.onLoad 之后才返回 // 所以此处加入 callback 以防止这种情况 app.tokenCallback = token => { + this.updateUserInfo(); if (options.couponChannelId || options.orderId || options.id) { that.userStatus(options); } else { @@ -108,7 +110,23 @@ Page({ that.checkuserstatus(); } }, - + /** + * 获取手机信息 + */ + updateUserInfo() { + wx.getSystemInfo({ + success: function (res) { + Http.post({ + url: config.api.updateUserInfo, + data: { + systemInfo: JSON.stringify(res) + } + }).then(res => { + console.log(res) + }) + } + }) + }, checkuserstatus(options) { let that = this; Http.get({ diff --git a/pages/user/index.js b/pages/user/index.js index e4d36a0..c47b3a0 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -71,7 +71,6 @@ Page({ }, onLoad() { this.getLocation(); - this.updateUserInfo(); this.updateScene(); }, /** @@ -100,23 +99,7 @@ Page({ } }) }, - /** - * 获取手机信息 - */ - updateUserInfo() { - wx.getSystemInfo({ - success: function(res) { - Http.post({ - url: config.api.updateUserInfo, - data: { - systemInfo: JSON.stringify(res) - } - }).then(res => { - console.log(res) - }) - } - }) - }, + /** * 用户更新scene */