0
点赞
收藏
分享

微信扫一扫

两种ajax请求模式

/新版的获取微信用户信息——即用户授权/

onGotUserInfo: function (e) {

//这里需要先处理当前验证码是否有效=》有效则走下一步,无效则停留在当前页,并给出提示

var self = this;

let sendData = {

phone: self.data.phone,

code: self.data.code,

};

    /* let apiData = {
apiUrl: app.apiConfig.authCode,
type: 'post',
sendData: sendData,
};
apiData.success = res => {
if (res.data) {
debugger
}
};
app.apiConfig.getApi(apiData);
debugger*/

//这种写法可以自己处理后端返回的错误提示 @zxyuns 2018-10-20
appJs.apiConfig.getData(appJs.apiConfig.authCode, 'post', sendData, function (res) {
if (res) {
if (res.error === 0) {
console.log('errMsg', e.detail.errMsg)
console.log('userInfo', e.detail.userInfo)
console.log('rawData', e.detail.rawData)
self.setData({
userInfo: e.detail.userInfo
})
self.setData({
divShow: 2
})
console.log('查看数据源3', self.data);
} else {
appJs.mainJs.showTip(res.message);
return
}
} else {
appJs.mainJs.showTip('服务器错误,请稍候重试!');
}

});
},

举报

相关推荐

0 条评论