Commit 2e1f61b5 by guomingpang

Merge branch 'feature/pangguoming/20210810/wechat_audit' into rc

parents ed244027 22ef2d05
......@@ -24,19 +24,16 @@ const getClientEnvironment = require('./env');
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin');
const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
var PREFIX = 'wechat-common-'
const postcssNormalize = require('postcss-normalize');
// const vConsolePlugin = require('vconsole-webpack-plugin');
const appPackageJson = require(paths.appPackageJson);
// Source maps are resource heavy and can cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
// Some apps do not need the benefits of saving a web request, so not inlining the chunk
// makes for a smoother build process.
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
const isExtendingEslintConfig = process.env.EXTEND_ESLINT === 'true';
const imageInlineSizeLimit = parseInt(
process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
......@@ -178,14 +175,14 @@ module.exports = function(webpackEnv) {
// There will be one main bundle, and one file per asynchronous chunk.
// In development, it does not produce real files.
filename: isEnvProduction
? 'static/js/[name].[contenthash:8].js'
: isEnvDevelopment && 'static/js/bundle.js',
?PREFIX+ 'static/js/[name].[contenthash:8].js'
: isEnvDevelopment && PREFIX+'static/js/bundle.js',
// TODO: remove this when upgrading to webpack 5
futureEmitAssets: true,
// There are also additional JS chunk files if you use code splitting.
chunkFilename: isEnvProduction
? 'static/js/[name].[contenthash:8].chunk.js'
: isEnvDevelopment && 'static/js/[name].chunk.js',
? PREFIX+'static/js/[name].[contenthash:8].chunk.js'
: isEnvDevelopment && PREFIX+'static/js/[name].chunk.js',
// webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path.
// We inferred the "public path" (such as / or /my-project) from homepage.
......@@ -373,7 +370,7 @@ module.exports = function(webpackEnv) {
loader: require.resolve('url-loader'),
options: {
limit: imageInlineSizeLimit,
name: 'static/media/[name].[hash:8].[ext]',
name: PREFIX+'static/media/[name].[hash:8].[ext]',
},
},
// Process application JS with Babel.
......@@ -508,7 +505,7 @@ module.exports = function(webpackEnv) {
// by webpacks internal loaders.
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: {
name: 'static/media/[name].[hash:8].[ext]',
name: PREFIX+'static/media/[name].[hash:8].[ext]',
},
},
// ** STOP ** Are you adding a new loader?
......@@ -581,8 +578,8 @@ module.exports = function(webpackEnv) {
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'static/css/[name].[contenthash:8].css',
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
filename: PREFIX+'static/css/[name].[contenthash:8].css',
chunkFilename: PREFIX+'static/css/[name].[contenthash:8].chunk.css',
}),
// Generate an asset manifest file with the following content:
// - "files" key: Mapping of all asset filenames to their corresponding
......@@ -608,9 +605,6 @@ module.exports = function(webpackEnv) {
};
},
}),
// new vConsolePlugin({
// enable: (process.env.DEPLOY_ENV === 'prod' || process.env.DEPLOY_ENV === 'beta') ? false : true
// }),
// Moment.js is an extremely popular library that bundles large locale files
// by default due to how webpack interprets its code. This is a practical
// solution that requires the user to opt into importing specific locales.
......
......@@ -89,7 +89,9 @@
"build:dev1": "cross-env DEPLOY_ENV=dev node scripts/build.js",
"build:rc": "cross-env DEPLOY_ENV=rc node scripts/build.js",
"build:gray": "cross-env DEPLOY_ENV=gray node scripts/build.js",
"build:prod": "cross-env DEPLOY_ENV=prod node scripts/build.js"
"build:prod": "cross-env DEPLOY_ENV=prod node scripts/build.js",
"build:gray-syoo": "cross-env DEPLOY_ENV=prod node scripts/build.js",
"build:prod-syoo": "cross-env DEPLOY_ENV=prod node scripts/build.js"
},
"eslintConfig": {
"extends": "react-app"
......
<!--
* @Author: 吴文洁
* @Date: 2020-08-24 12:20:57
......@@ -17,10 +16,10 @@
<meta name="theme-color" content="#000000" />
<!-- <link rel="apple-touch-icon" href="../src/common/images/logo.png" /> -->
<link rel="shortcut icon" href="https://image.xiaomaiketang.com/xm/KGSYFEpcHT.png">
<title>小麦企培</title>
<title>扫码登陆</title>
<script type="text/javascript" charset="utf-8" src="./jquery.min.js"></script>
<script src="./lottie.js"></script>
<script type="text/javascript" src='./animation.json'></script>
<script type="text/javascript" src='./animation.json'></script>
<style type="text/css">
.box {
width: 100%;
......@@ -41,20 +40,24 @@
line-height: 24px;
margin-top: 12px;
}
.desc{
font-size:14px;
color:#999;
.desc {
font-size: 14px;
color: #999;
}
.hide {
display: none;
text-align: center;
}
#lottie{
#lottie {
width: 150px;
height: 150px;
margin: 0 auto;
}
#tenant-config-error-message{
#tenant-config-error-message {
max-width: 70%;
margin: 25px auto;
font-size: 14px;
......@@ -109,10 +112,10 @@
const code = getParameterByName('code');
const ticket = getParameterByName('ticket');
const storeId = getParameterByName('storeId');
const corpType = getParameterByName('corpType');
if (!code) {
postJSON('hades/anon/hades/getCorpTrainSuiteId', {}, (res) => {
GetJSON('hades/anon/hades/getCorpTrainSuiteId', {}, (res) => {
const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.result}&redirect_uri=${encodeURIComponent(location.href)}&response_type=code&scope=snsapi_privateinfo&state=STATE#wechat_redirect`
location.href = url
})
......@@ -123,26 +126,44 @@
appTermEnum: 'XIAOMAI_CLOUD_CLASS_PC_WEB_CUSTOMER',
code: code,
ticket: ticket,
storeId:storeId
corpType,
storeId: storeId
}, (res) => {
if (res.code == 200) {
$('#success').show()
}else if(res.code === 'DEPLOY_CROP_ADD_USER_NO'){
} else if (res.code === 'DEPLOY_CROP_ADD_USER_NO') {
//租户配置到限,跳转空白提示缺省页
$('#tenant-config-error').show();
$('#tenant-config-error-message').html(res.message)
emptyAnimation()
} else {
emptyAnimation()
} else {
$('#error').show();
var message = res.message.split(',').join('<br />')
if(message === "非当前企业学院"){
if (message === "非当前企业学院") {
$('#message').html("<div><div>非当前企业学院</div><div class='desc'>尝试扫描「企业外部客户」二维码登录</div></div>");
}else{
} else {
$('#message').html(message);
}
}
})
}
function GetJSON(url, data, callback) {
const ajaxOptions = {
type: 'GET',
url: BASIC_HOST_MAP[env] + url + `?corpType=${corpType}`,
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
timeout: 20000,
success(res, status, xhr) {
callback(res)
},
};
$.ajax(ajaxOptions)
}
function postJSON(url, data, callback) {
const ajaxOptions = {
data: JSON.stringify(data),
......@@ -159,7 +180,7 @@
$.ajax(ajaxOptions)
}
function emptyAnimation(){
function emptyAnimation() {
let params = {
container: document.getElementById('lottie'),
renderer: 'svg',
......
......@@ -32,10 +32,25 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>登录</title>
<title>扫码登录</title>
<script type="text/javascript" src="https://image.xiaomaiketang.com/xm/PhotoClip.js"></script>
</head>
<body>
<script>
(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt =
"orientationchange" in window ? "orientationchange" : "resize",
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
docEl.style.fontSize = (clientWidth / 375) * 50 + "px";
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener("DOMContentLoaded", recalc, false);
})(document, window);
</script>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
......
......@@ -41,7 +41,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
}
// Tools like Cloud9 rely on this.
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3002;
const HOST = process.env.HOST || '0.0.0.0';
if (process.env.HOST) {
......
......@@ -68,6 +68,7 @@ class Axios {
if (success || resultCode === 0) {
return response;
}else if(code === 'DEPLOY_CROP_ADD_USER_NO'){
//租户配置到限,跳转空白提示缺省页
window.location.replace("/wechat-common/#/empty-page")
return Promise.reject(response.data)
}
......
......@@ -6,8 +6,9 @@
* @Description: 描述一下
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
declare var process:any;
const APP_ID_MAP = {
const APP_ID_MAP:any = {
dev: 'wx3ea60e78ddfa277e',
rc:'wx5c5a1fb71ecab7bc',
gray:'wx3dda02036493ada6',
......
......@@ -9,7 +9,7 @@
import { MapInterface } from '@/domains/basic-domain/interface'
// 默认是 dev 环境
const ENV: string = process.env.DEPLOY_ENV || 'prod';
const ENV: string = process.env.DEPLOY_ENV || 'dev';
const BASIC_HOST_MAP: MapInterface = {
dev: 'https://dev-heimdall.xiaomai5.com/',
......
......@@ -15,9 +15,6 @@ class Authorize extends React.Component {
}
}
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 ticket = window.getParameterByName('ticket');
this.setState({
......@@ -53,19 +50,46 @@ class Authorize extends React.Component {
const code = window.getParameterByName('code');
const ticket = window.getParameterByName('ticket');
const storeId = window.getParameterByName('storeId');
const source = window.getParameterByName('_source') === 'sass';
const params = {
appTermEnum: "XIAOMAI_CLOUD_CLASS_PC_WEB_CUSTOMER",
code,
storeId,
ticket
}
if(source){
params.source ='SASS'
}
Service.hades('/anon/hades/bindWeChat',params).then((res)=>{
if(res.success){
localStorage.setItem('wechat-common_user_avatar_url',res.result.headImgUrl || 'https://image.xiaomaiketang.com/xm/HsCjyKTbWw.png')
localStorage.setItem('wechat-common_user_open_id',res.result.openId)
localStorage.setItem('wechat-common_user_nick_name',res.result.nickName)
if(!res.result.whetherOld){
//1.审核开关打开,并且新用户第一次登陆,未提交过审核(审核状态为空)跳转提交审核页面
if(res.result.auditSwitch === 'OPEN'&& !res.result.applyStatus ){
window.RCHistory.replace(`/wechat-audit?storeId=${storeId}`);
return
}
//2.用户之前的审核状态是"PASSED",被删除了,之后登录时whetherExist=false,跳转提交审核页面
if( res.result.auditSwitch === 'OPEN' && res.result.applyStatus ==='PASSED' && res.result.whetherExist === false){
window.RCHistory.replace(`/wechat-audit?storeId=${storeId}`);
return
}
//3.审核开关打开,已提交过审核,审核状态为WAIT(等待审核)或者REJECTED(已被拒绝)时;跳转审核等待页;
if(res.result.auditSwitch === 'OPEN' && (res.result.applyStatus === 'WAIT' || res.result.applyStatus==='REJECTED' )){
window.RCHistory.replace(`/wechat-audit-result?storeId=${storeId}`);
return
}
}
this.setState({
hasBindWechat:true,
headImgUrl:res.result.headImgUrl,
ticketState:"AUTH_SUCCESS"
},()=>{this.changeCodeState()})
}
})
}
......@@ -79,7 +103,7 @@ class Authorize extends React.Component {
{ !hasBindWechat &&
<div>
<div>
<img src="https://image.xiaomaiketang.com/xm/HsCjyKTbWw.png" className="avatar-img"></img>
<img src="https://image.xiaomaiketang.com/xm/HsCjyKTbWw.png" className="avatar-img" alt=''></img>
</div>
<button className="login-btn" onClick={this.wechatAuthorize}>微信登录</button>
</div>
......@@ -89,7 +113,7 @@ class Authorize extends React.Component {
<div>
<div>
<img src={headImgUrl} className="avatar-img"></img>
<img src={headImgUrl} className="avatar-img" alt=''></img>
</div>
<div className="login-success-text">微信登录成功</div>
<div className="login-success-instro">已完成微信登录操作,去网页端继续学习吧</div>
......
import React from "react";
import { createHashHistory } from 'history';
import { Route, Router, Switch ,Redirect} from 'react-router-dom';
import EmptyPage from './EmptyPage'
import WechatAudit from './WechatAudit'
import WechatAuditResult from "./WechatAuditResult";
const XMHistory = createHashHistory();
window.XMHistory = XMHistory;
const App =function(){
return <Router history={XMHistory}>
<Switch>
<Redirect from='/' to='/empty' exact />
<Route exact path='/empty' render={() => <EmptyPage />} />
<Route path='/wechat-audit' render={() => <WechatAudit />} />
<Route path='/wechat-audit-result' render={() => <WechatAuditResult />} />
</Switch>
</Router>
}
export default App;
\ No newline at end of file
import React, { useState } from "react";
import { Form, Button, Input } from "antd";
import Service from "@/common/js/service";
import "./WechatAudit.less";
const WechatAudit = function () {
const storeId = window.getParameterByName("storeId");
const [realName, setRealName] = useState("");
const avatarUrl= localStorage.getItem('wechat-common_user_avatar_url')
const openId= localStorage.getItem('wechat-common_user_open_id')
const nickName = localStorage.getItem('wechat-common_user_nick_name')
function saveUserInfo() {
const params = {
openId,
nickName,
avatarUrl,
storeId,
realName
};
Service.hades("anon/customerHades/applyJoin", params).then((res) => {
if(res.success === true ){
window.location.href = `${window.location.origin}${window.location.pathname}#/wechat-audit-result?storeId=${storeId}`
}
});
}
return (
<div className="wechat-audit">
<div className="box">
<div className="title">登录申请</div>
<div className="tip">
请输入您的真实姓名并提交申请,通过申请后即可登录学院
</div>
<Form>
<div className="name-item">
<Input
placeholder="请输入姓名,最多6个字符"
style={{ width: 300, height: 32 }}
value={realName}
maxLength={6}
onChange={(e) => {
let value = e.target.value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,'')
if(value.length>6){
return
}
setRealName(value);
}}
/>
</div>
<div className={realName ? "save-btn" : "save-btn disable"}>
<Button
type="primary"
disabled={realName.length === 0}
onClick={() => {
saveUserInfo();
}}
>
申请加入
</Button>
</div>
</Form>
</div>
</div>
);
};
export default WechatAudit;
.wechat-audit{
background: #F2F5F9;
min-height: 100vh;
width: 100%;
max-width: 1200px;
display: flex;
justify-content: center;
text-align: center;
margin: 0 auto;
.box{
margin-top: 2.02rem;
.title{
font-size: .34rem;
color: #333;
margin-bottom: .2rem;
}
.tip{
font-size: .26rem;
color: #999;
margin-bottom: .32rem;
}
.name-item input{
width: 100% !important;
height: 44px !important;
font-size: .3rem !important;
}
.save-btn{
button{
background: #2966FF;
border-color:#2966FF;
width: 100% !important;
height: 44px !important;
margin-top: .6rem;
font-size: .3rem !important;
}
&.disable{
opacity: 0.5;
}
}
}
}
\ No newline at end of file
import React, { useEffect, useState } from "react";
import { debounce } from "underscore";
import Service from "@/common/js/service";
import "./WechatAuditResult.less";
const WechatAuditResult = function () {
const [status, setStatus] = useState("WAIT");
const storeId =window.getParameterByName("storeId");
const [headImgUrl,setHeadImgUrl] = useState(localStorage.getItem('wechat-common_user_avatar_url'))
const openId = localStorage.getItem('wechat-common_user_open_id')
useEffect(() => {
getStatus();
}, []);
function getStatus() {
const params={
openId,
storeId
}
Service.hades("anon/customerHades/getCustomerAudit", params).then((res) => {
const {result:{applyStatus,auditSwitch}}= res
if(auditSwitch === 'CLOSE'){
setStatus('PASSED')
}else{
setStatus(applyStatus)
}
});
}
return (
<div className="wechat-audit-result">
<Choose>
<When condition={status === "WAIT"}>
<div className="box">
<img
className="img"
src="https://image.xiaomaiketang.com/xm/6isseQhcTh.png"
alt=""
/>
<div className="desc">申请审核中</div>
<div className="tip">
您已成功提交申请,待系统审核通过后,才能登录学院
</div>
<div
className="btn reload"
onClick={debounce(() => getStatus("fail"), 3000, true)}
>
刷新
</div>
</div>
</When>
<When condition={status === "PASSED"}>
<div className='box'>
<img src={headImgUrl} className="avatar-img" alt=''></img>
<div className="login-success-text">微信登录成功</div>
<div className="login-success-instro">已完成微信登录操作,去网页端继续学习吧</div>
</div>
</When>
<Otherwise>
<div className="box">
<img
className="img"
src="https://image.xiaomaiketang.com/xm/cQzJDFZDsp.png"
alt=""
/>
<div className="desc">审核失败</div>
<div className="tip">
请输入您的真实姓名并提交申请,通过申请后就可以登录学院
</div>
<div
className="btn reload"
onClick={() => {
window.location.href =
window.location.origin +
window.location.pathname +
`#/wechat-audit?storeId=${storeId}`;
}}
>
重新申请
</div>
</div>
</Otherwise>
</Choose>
</div>
);
};
export default WechatAuditResult;
.wechat-audit-result{
background: #F2F5F9;
min-height: 100vh;
width: 100%;
max-width: 1200px;
display: flex;
flex-direction: column;
text-align: center;
margin: 0 auto;
.box{
margin-top: 3.42rem;
.img{
width: 1.2rem;
height: 1.2rem;
}
.desc{
font-size: #333;
font-size: .3rem;
font-weight: 500;
margin:.32rem 0 .2rem;
}
.tip{
font-size: .26rem;
color: #999;
width: 85%;
margin: 0 auto;
line-height: 1.8;
}
.btn{
color: #2966ff;
font-size: .3rem;
cursor: pointer;
margin-top: 1.6rem;
&:active{
opacity: 0.7;
}
}
}
.avatar-img{
width:16vw;
height:16vw;
border-radius:50%;
}
.login-btn{
width: 91.2vw;
height: 11.7vw;
background: #1CAC1B;
border-radius: 1.3vw;
display:inline-block;
color:#FFF;
border:none;
margin-top:10.6vw;
font-size:4vw;
}
.login-success-text{
margin-top:10.6vw;
font-size:4vw;
color:#333333;
}
.login-success-instro{
font-size:13px;
color:#999;
margin-top:5px;
}
}
\ No newline at end of file
......@@ -11,6 +11,8 @@ import { MenuConfig } from '@/routes/interface';
import Authorize from '@/modules/authorize';
import WorkWxAuthorize from '@/modules/workWxAuthorize';
import EmptyPage from '@/modules/empty-page/EmptyPage'
import WechatAudit from '@/modules/wechat-audit/WechatAudit';
import WechatAuditResult from '@/modules/wechat-audit/WechatAuditResult';
const CloudClassConfig: MenuConfig = {
key: 'cloudClass',
name: '云课堂',
......@@ -29,10 +31,22 @@ const CloudClassConfig: MenuConfig = {
},
{
key: 'empty-page',
name: '授权登录',
name: '提示',
path: '/empty-page',
component:EmptyPage,
},
{
key: 'wechat-audit',
name: '',
path: '/wechat-audit',
component: WechatAudit,
},
{
key: 'wechat-audit-result',
name: '提示',
path: '/wechat-audit-result',
component:WechatAuditResult,
},
]
};
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