Commit 0a6e2e3f by zhangleyuan

feat:添加去企业微信授权登录

parent 199a611b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-04-27 20:35:34 * @Date: 2020-04-27 20:35:34
* @LastEditors: zhangleyuan * @LastEditors: zhangleyuan
* @LastEditTime: 2021-01-14 10:48:59 * @LastEditTime: 2021-03-31 16:30:47
* @Description: * @Description:
*/ */
......
...@@ -15,6 +15,9 @@ class Authorize extends React.Component { ...@@ -15,6 +15,9 @@ class Authorize extends React.Component {
} }
} }
componentDidMount() { componentDidMount() {
// console.log("ticket",window.getParameterByName('ticket'))
// const searchParams = this.props.location.search;
// const {code,ticket} = queryString.parse(searchParams);
const code = window.getParameterByName('code'); const code = window.getParameterByName('code');
const ticket = window.getParameterByName('ticket'); const ticket = window.getParameterByName('ticket');
this.setState({ this.setState({
......
import React from 'react';
import Service from '@/common/js/service';
import './index.less';
class WorkWxAuthorize extends React.Component {
constructor(props) {
super(props);
this.state = {
scanState:'',
messageText:''
}
}
componentDidMount() {
const code = window.getParameterByName('code');
if(!code){
this.workWechatAuthorize();
}else{
this.workWechatLogin();
}
}
workWechatLogin= ()=>{
const code = window.getParameterByName('code');
const ticket = window.getParameterByName('ticket');
const storeId = window.getParameterByName('storeId');
Service.hades("/anon/hades/wXWorkUserTicketLogin", {
appTermEnum: appTermEnum,
code,
ticket,
storeId
}, (res) => {
if (res.code == 200) {
this.setState({
scanState:'success'
})
} else {
let message = res.message.split(',').join('<br />')
this.setState({
scanState:'error',
messageText:message
})
}
})
}
workWechatAuthorize = () => {
const params = {}
Service.hades('/anon/hades/getCorpTrainSuiteId',params).then((res)=>{
let path = window.location.href;
const htmlUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.result}&redirect_uri=${encodeURIComponent(path)}&response_type=code&scope=snsapi_privateinfo&state=STATE#wechat_redirect`
window.location.href = htmlUrl;
})
}
render() {
const { scanState,messageText} = this.state;
return (
<div className="work-authorize-page">
<div className="box">
{ scanState === 'success' &&
<div className="success">
<img src="https://image.xiaomaiketang.com/xm/iRkcMHPHba.png" alt=""/>
<p>
扫码成功
</p>
</div>
}
{ scanState === 'error' &&
<div className="error">
<img src="https://image.xiaomaiketang.com/xm/6kSAYFMm2r.png
" alt="" />
<p className='message'>
{ messageText }
</p>
</div>
}
</div>
</div>
)
}
}
export default WorkWxAuthorize;
.work-authorize-page{
.box {
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: rgba(244, 246, 250, 1);
}
img{
width:60px;
}
p {
font-size: 17px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
line-height: 24px;
margin-top: 12px;
}
.hide {
display: none;
text-align: center;
}
}
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-04-29 10:26:32 * @Date: 2020-04-29 10:26:32
* @LastEditors: zhangleyuan * @LastEditors: zhangleyuan
* @LastEditTime: 2021-01-05 10:23:51 * @LastEditTime: 2021-03-31 16:31:55
* @Description: 内容线路由配置 * @Description: 内容线路由配置
*/ */
import { MenuConfig } from '@/routes/interface'; import { MenuConfig } from '@/routes/interface';
import Authorize from '@/modules/authorize'; import Authorize from '@/modules/authorize';
import WorkWxAuthorize from '@/modules/workWxAuthorize';
const CloudClassConfig: MenuConfig = { const CloudClassConfig: MenuConfig = {
key: 'cloudClass', key: 'cloudClass',
name: '云课堂', name: '云课堂',
...@@ -19,7 +19,13 @@ const CloudClassConfig: MenuConfig = { ...@@ -19,7 +19,13 @@ const CloudClassConfig: MenuConfig = {
name: '授权登录', name: '授权登录',
path: '/wechat-authorize', path: '/wechat-authorize',
component: Authorize, component: Authorize,
} },
{
key: 'authorize',
name: '授权登录',
path: '/work-wechat-authorize',
component: WorkWxAuthorize,
},
] ]
}; };
export default CloudClassConfig; export default CloudClassConfig;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment