更新
This commit is contained in:
parent
6fe4e3a4f8
commit
874d34f6df
127
src/api/authorize-api-old.js
Normal file
127
src/api/authorize-api-old.js
Normal file
@ -0,0 +1,127 @@
|
||||
import axios from 'axios'
|
||||
import qs from 'qs'
|
||||
|
||||
const domain_zs = process.env.VUE_APP_ZS_AUTHORIZE_DOMAIN;
|
||||
const domain_xgl = process.env.VUE_APP_XGL_AUTHORIZE_DOMAIN;
|
||||
///////////////////////////
|
||||
|
||||
// get || post 请求方法封装
|
||||
function get(url, params = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(url, {
|
||||
params: params
|
||||
})
|
||||
.then(res => {
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
// 或者return axios.get();
|
||||
}
|
||||
/**
|
||||
* post方法,对应post请求
|
||||
* @param {String} url [请求的url地址]
|
||||
* @param {Object} params [请求时携带的参数]
|
||||
*/
|
||||
function post(url, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.post(url, qs.stringify(params))
|
||||
.then(res => {
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
// 或者return axios.post();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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_xgl}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${1}"`
|
||||
}
|
||||
|
||||
|
||||
// 2.获取微信公众号jssdk
|
||||
// 请求方法:get请求
|
||||
// 请求链接:/wxauth/official/account/jssdk/get
|
||||
// 请求参数:
|
||||
// url 请求链接
|
||||
function get_jssdk(url, params) {
|
||||
// Bus.debug && (params.openid = Bus.testOpenId)
|
||||
// return readyGet(domain_zs + "/wxauth/official/account/jssdk/get", params)
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(url, {
|
||||
params: params
|
||||
})
|
||||
.then(res => {
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function getOpenId(code) {
|
||||
return new Promise((reslove, reject) => {
|
||||
utils.rebuildAjax.post(process.env.VUE_APP_BASE_URL + 'cott-acts/api/wx/oauthInfo', {
|
||||
code
|
||||
}).then((res) => {
|
||||
if (res.ret == 0) {
|
||||
Vue.prototype.$userInfo = {
|
||||
openid: res.data.openid,
|
||||
nickname: res.data.nickname,
|
||||
headimgurl: res.data.headimgurl
|
||||
};
|
||||
reslove();
|
||||
} else {
|
||||
location.replace(window.location.protocol + '//' + window.location.host + window.location.pathname)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 获取wx 授权 code
|
||||
function getCode(activityId, gameId, rankType) {
|
||||
let redirect_uri = `${window.location.protocol}//${window.location.host + window.location.pathname}?activityId=${activityId}&gameId=${gameId}&rankType=${rankType}`;
|
||||
utils.rebuildAjax.post(process.env.VUE_APP_BASE_URL + 'cott-acts/api/wx/getOAuthUrl', {
|
||||
redirect_uri
|
||||
}).then((res) => {
|
||||
if (res.ret == 0) {
|
||||
console.log(res.url)
|
||||
location.replace(res.url);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export {
|
||||
get_authorize,
|
||||
get_jssdk,
|
||||
}
|
||||
@ -1,46 +1,10 @@
|
||||
import axios from 'axios'
|
||||
import qs from 'qs'
|
||||
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;
|
||||
const domain_zs = process.env.VUE_APP_ZS_AUTHORIZE_DOMAIN ;
|
||||
const domain_xgl = process.env.VUE_APP_XGL_AUTHORIZE_DOMAIN ;
|
||||
///////////////////////////
|
||||
|
||||
// get || post 请求方法封装
|
||||
function get(url, params = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(url, {
|
||||
params: params
|
||||
})
|
||||
.then(res => {
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
// 或者return axios.get();
|
||||
}
|
||||
/**
|
||||
* post方法,对应post请求
|
||||
* @param {String} url [请求的url地址]
|
||||
* @param {Object} params [请求时携带的参数]
|
||||
*/
|
||||
function post(url, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.post(url, qs.stringify(params))
|
||||
.then(res => {
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
// 或者return axios.post();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 1.公众号网页授权
|
||||
// 请求方法:get请求
|
||||
@ -55,9 +19,9 @@ function post(url, params) {
|
||||
function get_authorize() {
|
||||
let href = window.location.href
|
||||
let h_idx = window.location.href.indexOf('#')
|
||||
let out_href = href.slice(0, h_idx)
|
||||
let out_href = href.slice(0,h_idx)
|
||||
|
||||
window.location.href = `${domain_xgl}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${1}"`
|
||||
window.location.href = `${domain_zs}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${1}"`
|
||||
}
|
||||
|
||||
|
||||
@ -66,55 +30,9 @@ function get_authorize() {
|
||||
// 请求链接:/wxauth/official/account/jssdk/get
|
||||
// 请求参数:
|
||||
// url 请求链接
|
||||
function get_jssdk(url, params) {
|
||||
function get_jssdk(params) {
|
||||
// Bus.debug && (params.openid = Bus.testOpenId)
|
||||
// return readyGet(domain_zs + "/wxauth/official/account/jssdk/get", params)
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(url, {
|
||||
params: params
|
||||
})
|
||||
.then(res => {
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function getOpenId(code) {
|
||||
return new Promise((reslove, reject) => {
|
||||
utils.rebuildAjax.post(process.env.VUE_APP_BASE_URL + 'cott-acts/api/wx/oauthInfo', {
|
||||
code
|
||||
}).then((res) => {
|
||||
if (res.ret == 0) {
|
||||
Vue.prototype.$userInfo = {
|
||||
openid: res.data.openid,
|
||||
nickname: res.data.nickname,
|
||||
headimgurl: res.data.headimgurl
|
||||
};
|
||||
reslove();
|
||||
} else {
|
||||
location.replace(window.location.protocol + '//' + window.location.host + window.location.pathname)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 获取wx 授权 code
|
||||
function getCode(activityId, gameId, rankType) {
|
||||
let redirect_uri = `${window.location.protocol}//${window.location.host + window.location.pathname}?activityId=${activityId}&gameId=${gameId}&rankType=${rankType}`;
|
||||
utils.rebuildAjax.post(process.env.VUE_APP_BASE_URL + 'cott-acts/api/wx/getOAuthUrl', {
|
||||
redirect_uri
|
||||
}).then((res) => {
|
||||
if (res.ret == 0) {
|
||||
console.log(res.url)
|
||||
location.replace(res.url);
|
||||
}
|
||||
})
|
||||
return readyGet(domain_zs + "/wxauth/official/account/jssdk/get", params)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ import gsap from "gsap";
|
||||
import axios from 'axios'
|
||||
import { Toast, Dialog } from 'vant';
|
||||
import { useStore } from "vuex";
|
||||
import { get_authorize, get_jssdk } from '@/api/authorize-api'
|
||||
// import { get_authorize, get_jssdk } from '@/api/authorize-api'
|
||||
import service from "@/api/httpServe"
|
||||
import qs from 'qs'
|
||||
import h5plugin from '@/utils/plugin'
|
||||
@ -180,6 +180,8 @@ const btn = () => {
|
||||
// 抽奖按钮
|
||||
const drawBtn = ()=>{
|
||||
console.log("抽奖:");
|
||||
console.log("授权:",getAuthorize());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -216,6 +218,23 @@ const hideServicePop = () => {
|
||||
}
|
||||
|
||||
|
||||
// 招商证券授权
|
||||
const getAuthorize = ()=> {
|
||||
// let href = window.location.href
|
||||
// let h_idx = window.location.href.indexOf('#')
|
||||
// let out_href = href.slice(0,h_idx)
|
||||
|
||||
// window.location.href = `${process.env.VUE_APP_ZS_DOMAIN}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${1}"`
|
||||
|
||||
|
||||
let href = window.location.href;
|
||||
let h_idx = window.location.href.indexOf("#");
|
||||
let out_href = href.slice(0, h_idx);
|
||||
|
||||
return `${process.env.VUE_APP_ZS_DOMAIN}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${1}"`;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -13,7 +13,7 @@ import gsap from "gsap";
|
||||
import axios from 'axios'
|
||||
import { Toast, Dialog } from 'vant';
|
||||
import { useStore } from "vuex";
|
||||
import { get_authorize, get_jssdk } from '@/api/authorize-api'
|
||||
// import { get_authorize, get_jssdk } from '@/api/authorize-api'
|
||||
import service from "@/api/httpServe"
|
||||
import qs from 'qs'
|
||||
import h5plugin from '@/utils/plugin'
|
||||
@ -51,10 +51,12 @@ onBeforeMount(() => {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 页面挂载
|
||||
onMounted(() => { });
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user