Browse Source

userInfo中添加secert

master
HolyKnightIX 1 year ago
parent
commit
5df8809c54
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      miniprogram/app.js

+ 3
- 3
miniprogram/app.js View File

@@ -12,16 +12,15 @@ App({
// 发送 res.code 到后台换取 openId, sessionKey, unionId
console.log(res, 'wx.login')
doLogin(res.code)
getWxToken()
},
})

// 获取小程序AccessToken
const getWxToken = () => {
const getWxToken = secret => {
const data = {
grant_type: 'client_credential',
appid: 'wxf288a9b8167ff2ca',
secret: 'cf012a9015594f0a95f718a801497fbd'
secret: secret
}
wx.request({
url: 'https://api.weixin.qq.com/cgi-bin/stable_token',
@@ -89,6 +88,7 @@ App({
res.data.validEndTime = res.data.validEndTime ? timestampToTime(res.data.validEndTime, 'YYYY-MM-DD hh:mm:ss') : ''
const userInfo = res.data
that.globalData.userInfo = userInfo
getWxToken(res.data.secret)
// 请求完成后的回调,在index.js中调用防止异步
that.userInfoCallback(res)
}).catch(err => {


Loading…
Cancel
Save