代码拉取完成,页面将自动刷新
App({
onLaunch: function () {
console.log('App Launch')
this.getopenId()
this.getVcode()
},
onShow: function (option) {
},
onHide: function () {
},
getUserInfo: function (cb) {
var that = this
if (this.globalData.userInfo) {
typeof cb == "function" && cb(this.globalData.userInfo)
} else {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo)
console.log(res.userInfo,'app.js')
},
fail: res => {
console.log(res)
}
})
}
},
getopenId:function(){
var that = this
if (this.globalData.userId) {
} else {
//调用登录接口
wx.login({
success: function (res) {
console.log(res)
wx.request({
url: "https://mp.orancat.com/puser/getOpenId",
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",
data: { code: res.code },
complete: function (res) {
typeof cb == "function" && cb(that.globalData.userId)
that.globalData.userId = res.data.data.openid
wx.setStorageSync('userId', res.data.data.openid)
console.log(res,23)
if (res == null || res.data == null) {
console.error('网络请求失败');
return;
}
}
});
}
})
}
},
getVcode() {
let self = this;
wx.request({
url: "https://mp.orancat.com/puser/getvcode",
method: "GET",
complete: function (res) {
if (res.data.status == 0) {
self.globalData.vcode = res.data.vcode
console.log(res, 23345)
} else {
wx.showModal({
title: '提示',
content: '请求失败,请联系管理员',
showCancel: false
})
}
console.log(self.globalData.vcode, 2545)
}
});
},
globalData: {
userInfo: null,
userId:'',
checkedProArr:[],
sortBysListArr:[],
account:0,
vcode: 0
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。