115 lines
2.8 KiB
Vue
115 lines
2.8 KiB
Vue
<template>
|
|
<view>
|
|
<!-- <web-view style="background-color: #fafafa;height: 100vh;" ref="webview" :src="webUrl"></web-view> -->
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { request,showToast } from '@/api/apiT.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
webUrl:'',
|
|
datas:{}
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.getCode(options.code,options.state)
|
|
},
|
|
methods: {
|
|
getUrlParam() {
|
|
let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
|
|
let r = window.location.search.substr(1).match(reg)
|
|
if (r != null) {
|
|
return unescape(r[2])
|
|
}
|
|
return null
|
|
},
|
|
getCode(code,state) {
|
|
// var code = this.getUrlParam('code');
|
|
var code_url = '';
|
|
if (code == null || code == '' || !code) {
|
|
request({
|
|
url:'feishu/getinfo',
|
|
method:'post',
|
|
}).then(res => {
|
|
uni.showToast({
|
|
title: res.data.message,
|
|
icon: 'none'
|
|
});
|
|
if(res.data.code ==0){
|
|
var data = res.data.data;
|
|
this.datas = data
|
|
// console.log(data)
|
|
|
|
code_url += 'https://open.feishu.cn/open-apis/authen/v1/authorize'
|
|
code_url += '?app_id=' + data.app_id
|
|
code_url += '&redirect_uri=' + data.redirect_uri
|
|
code_url += '&scope=' + data.scope
|
|
code_url += '&state=' + data.state;
|
|
|
|
// console.log(code_url)
|
|
// return;
|
|
window.location.href = code_url;
|
|
}else{
|
|
setTimeout(() => {
|
|
uni.reLaunch({
|
|
url: '/pages/index/mine',// 替换为你要跳转的页面路径
|
|
});
|
|
}, 1000);
|
|
}
|
|
|
|
})
|
|
} else {
|
|
this.getOpenId(code,state)
|
|
return;
|
|
}
|
|
},
|
|
getOpenId(code,state) {
|
|
request({
|
|
url:'feishu/getAuth',
|
|
method:'post',
|
|
data:{
|
|
code: code,
|
|
state:state
|
|
}
|
|
}).then(res => {
|
|
uni.showToast({
|
|
title: res.data.message,
|
|
icon: 'none'
|
|
});
|
|
if(res.data.code ==0){
|
|
setTimeout(() => {
|
|
uni.reLaunch({
|
|
url: '/pages/index/mine',// 替换为你要跳转的页面路径
|
|
});
|
|
}, 1000);
|
|
}
|
|
})
|
|
},
|
|
feishugetAuth(){
|
|
const pages = getCurrentPages();
|
|
const currentPage = pages[pages.length - 1];
|
|
const route = currentPage.route; // 页面路径
|
|
const options = currentPage.options; // 页面参数
|
|
const fullUrl = `${route}?${Object.keys(options).map(key => `${key}=${options[key]}`).join('&')}`;
|
|
// console.log('当前页面完整 URL:', fullUrl);
|
|
request({
|
|
url:'feishu/getinfo',
|
|
method:'post',
|
|
}).then(res => {
|
|
var data = res.data.data;
|
|
var urls = data.url+fullUrl
|
|
// console.log(data)
|
|
this.webUrl = 'https://open.feishu.cn/open-apis/authen/v1/authorize?app_id='+data.app_id+'&redirect_uri='+urls+'&scope='+data.scope+'&state='+data.state
|
|
// console.log(this.webUrl)
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style>
|