小程序
小游戏
企业微信
微信支付
扫描小程序码分享
调用wx.login后应该可以收到login的返回,但实际只收到了服务器发来的setting,很疑惑?
6 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
首先你这个过不了审核的,目前微信小程序的机制是不允许强制用户登录,
你这个进入小程序就调用登录接口,会审核失败的。
其次 this.fetch('user/setting') 是干啥的。返回的数据是什么?
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
亮代码? 首先看下res 有收到吗?
走到这里了吧
啥意思呀,你这代码写的就是先调用接口'user/setting
App({ fetch: require('utils/fetch.js'), onLaunch: function() { wx.showLoading({ title: '登录中', mask: true }) this.fetch('user/setting').then(data => { if (data.isLogin) { this.onUserInfoReady() } else { this.login({ success: () => { this.onUserInfoReady() }, fail: () => { this.onLaunch() } }) } }, () => { this.onLaunch() }) }, login: function(options) { wx.login({ success: res => { this.fetch('user/login', { js_code: res.code }).then(data => { if (data && data.isLogin) { options.success() } else { wx.hideLoading() wx.showModal({ title: '登录失败(请使用真实的AppID,并检查服务器端配置)', confirmText: '重试', success: res => { if (res.confirm) { options.fail() } } }) } }, () => { options.fail() }) } }) }, userInfoReady: false, onUserInfoReady: function() { wx.hideLoading() if (this.userInfoReadyCallback) { this.userInfoReadyCallback() } else { this.userInfoReady = true } } })
你代码怎么写的
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
首先你这个过不了审核的,目前微信小程序的机制是不允许强制用户登录,
你这个进入小程序就调用登录接口,会审核失败的。
其次 this.fetch('user/setting') 是干啥的。返回的数据是什么?
亮代码? 首先看下res 有收到吗?
走到这里了吧
啥意思呀,你这代码写的就是先调用接口'user/setting
App({ fetch: require('utils/fetch.js'), onLaunch: function() { wx.showLoading({ title: '登录中', mask: true }) this.fetch('user/setting').then(data => { if (data.isLogin) { this.onUserInfoReady() } else { this.login({ success: () => { this.onUserInfoReady() }, fail: () => { this.onLaunch() } }) } }, () => { this.onLaunch() }) }, login: function(options) { wx.login({ success: res => { this.fetch('user/login', { js_code: res.code }).then(data => { if (data && data.isLogin) { options.success() } else { wx.hideLoading() wx.showModal({ title: '登录失败(请使用真实的AppID,并检查服务器端配置)', confirmText: '重试', success: res => { if (res.confirm) { options.fail() } } }) } }, () => { options.fail() }) } }) }, userInfoReady: false, onUserInfoReady: function() { wx.hideLoading() if (this.userInfoReadyCallback) { this.userInfoReadyCallback() } else { this.userInfoReady = true } } })
你代码怎么写的