config.js 970 B

123456789101112131415161718192021
  1. //公众号ID
  2. const appId = 'wx7e7a38f071b360e9';
  3. //公众号密钥
  4. const appSecret = '4e862f91b48ac85a91380fa0991c9fda';
  5. //经过编码后的回调地址
  6. const redireactUrl = 'https://vote.guosen-fumao.cn/vote-h5/index.html#/pages/activityList/home/home?activityId=';
  7. //获取用户授权信息Code
  8. const authUrl = (activity) => { return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURIComponent(redireactUrl+activity)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`};
  9. //获取用户的Access-token
  10. const atUrl = (code) => { return `https://api.weixin.qq.com/sns/oauth2/access_token?appid=${appId}&secret=${appSecret}&code=${code}&grant_type=authorization_code`}
  11. //拉取用户信息
  12. const getWXUserInfoUrl = (ACCESS_TOKEN, OPENID) => {
  13. return `https://api.weixin.qq.com/sns/userinfo?access_token=${ACCESS_TOKEN}&openid=${OPENID}&lang=zh_CN`
  14. }
  15. export {appId, authUrl, atUrl, getWXUserInfoUrl};