飞书授权
This commit is contained in:
+48
-9
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view>
|
||||
<web-view style="background-color: #fafafa;height: 100vh;" ref="webview" :src="webUrl"></web-view>
|
||||
<!-- <web-view style="background-color: #fafafa;height: 100vh;" ref="webview" :src="webUrl"></web-view> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -9,18 +9,59 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl:''
|
||||
webUrl:'',
|
||||
datas:{}
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log(options);
|
||||
this.feishugetAuth()
|
||||
if(options.code){
|
||||
console.log(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');
|
||||
console.log(code)
|
||||
var code_url = '';
|
||||
if (code == null || code == '' || !code) {
|
||||
console.log(2222222)
|
||||
request({
|
||||
url:'feishu/getinfo',
|
||||
method:'post',
|
||||
}).then(res => {
|
||||
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 {
|
||||
this.getOpenId(code,state)
|
||||
return;
|
||||
}
|
||||
},
|
||||
getOpenId(code,state) {
|
||||
request({
|
||||
url:'feishu/getAuth',
|
||||
method:'post',
|
||||
data:{
|
||||
code:options.code
|
||||
code: code,
|
||||
state:state
|
||||
}
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
@@ -35,9 +76,7 @@
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
},
|
||||
feishugetAuth(){
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
|
||||
Reference in New Issue
Block a user