代码拉取完成,页面将自动刷新
App({
onLaunch: function () {
qq.showShareMenu({
showShareItems: ['qq', 'qzone', 'wechatFriends', 'wechatMoment']
})
var that = this
this.getAccessToken()
var ms = (61 - new Date().getMinutes()) * 60000
setTimeout(function () {
that.getAccessToken()
setInterval(function () {
that.getAccessToken()
}, 3600000)
}, ms)
// //console.log(ms)
this.getUserInfo()
try {
//console.log('s')
const value = qq.getStorageSync('openid')
//console.log(value)
if (value) {
//console.log(value)
that.globalData.openid = value
} else {
qq.login({////////////调用qq登录获取code
success(res) {
that.getOpenID(res.code)
},
})
}
} catch (e) {
//console.log(e)
//console.log("d")
}
},
getUserInfo() {
qq.getSetting({
success(res) {
// //console.log(res)
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称
qq.getUserInfo({
success(res) {
// //console.log(res.userInfo)
}
})
}
}
})
},
getOpenID(code) {
//console.log(code)
var that = this
wx.request({
url: 'https://service-pvyg928b-1257796010.ap-beijing.apigateway.myqcloud.com/release/getOpenID/' + code,//部署在腾讯云函数上的
header: {
'content-type': 'application/json' // 默认值
},
method: "post",
success(res) {
//console.log(res)
that.globalData.openid = res.data
qq.setStorage({
key: 'openid',
data: res.data
})
}
})
},
getAccessToken() {
console.log("d")
var that = this
qq.request({
url: 'https://service-1fypo9xh-1257796010.ap-beijing.apigateway.myqcloud.com/release/getToken',//部署在腾讯云函数上的
header: {
'content-type': 'application/json' // 默认值
},
method: "post",
success(res) {
//console.log("token" + res.data)
that.globalData.access_token = res.data
}
})
},
globalData: {
myEnv: 'test2-biqte',
openid: '',
access_token: '',
userInfo: null,
admin: false
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。