diff --git a/pages/login/login.vue b/pages/login/login.vue index 056ae7f..e7ff4b3 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -22,19 +22,38 @@ export default { data() { return { - + openidReady: false } }, onShareAppMessage() {}, onLoad() { - //this.login(); + var that = this; + util.getOpenidInfo(function() { + that.openidReady = true; + }, true); }, onReady() {}, onHide() {}, methods: { + getStoredOpenid: function() { + var user = uni.getStorageSync('userInfo_token') || {}; + return user.openid || (user.user_info ? user.user_info.openid : ''); + }, _getPhoneNumber: function(o) { - null != o.detail.iv ? this.getPhone(o) : util.alert('为了更好的为您服务,请允许访问您的手机号码'); + var that = this; + if (null == o.detail.iv) { + util.alert('为了更好的为您服务,请允许访问您的手机号码'); + return; + } + if (that.openidReady && that.getStoredOpenid()) { + that.getPhone(o); + return; + } + util.getOpenidInfo(function() { + that.openidReady = true; + that.getPhone(o); + }, true); @@ -88,11 +107,13 @@ getPhone: function(t) { var that = this; var code = t.detail.code; + var openid = this.getStoredOpenid(); console.log("code", code); util.request({ api: 'customer/mobile', data: { - code: code + code: code, + openid: openid }, method: 'POST', utilSuccess: function(e) {