1 Star 1 Fork 3

李福连/河大小精灵_QQ小程序源码(校园信息平台)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app.js 2.27 KB
一键复制 编辑 原始数据 按行查看 历史
李福连 提交于 2021-03-16 17:08 . commit
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
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
QML
1
https://gitee.com/FulianLi/henu_qq_miniprogram.git
git@gitee.com:FulianLi/henu_qq_miniprogram.git
FulianLi
henu_qq_miniprogram
河大小精灵_QQ小程序源码(校园信息平台)
master

搜索帮助