zszq-celebration-88/src/api/authorize-api.js
2022-08-01 15:54:21 +08:00

46 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Bus from "../bus.js";
import {readyPost,readyGet} from "./base.js"
const domain_zs = process.env.VUE_APP_ZS_AUTHORIZE_DOMAIN ;
const domain_xgl = process.env.VUE_APP_XGL_AUTHORIZE_DOMAIN ;
///////////////////////////
// 1.公众号网页授权
// 请求方法get请求
// 请求链接:/wxauth/official/account/authorize
// 请求参数:
// redirectUrl 请求链接
// scope 授权类型0用户授权1静默授权
// 返回值:无
// 备注回调页面URL后可能携带参数token、userid、forceauth。
// 先取token如有表示登录成功登录成功userid会有值
// 如token无值取forceauth为1时表示需要进行0-用户授权跳转。
function get_authorize() {
let href = window.location.href
let h_idx = window.location.href.indexOf('#')
let out_href = href.slice(0,h_idx)
window.location.href = `${domain_zs}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${1}"`
}
// 2.获取微信公众号jssdk
// 请求方法get请求
// 请求链接:/wxauth/official/account/jssdk/get
// 请求参数:
// url 请求链接
function get_jssdk(params) {
// Bus.debug && (params.openid = Bus.testOpenId)
return readyGet(domain_zs + "/wxauth/official/account/jssdk/get", params)
}
export {
get_authorize,
get_jssdk,
}