Commit 1a7acdfe by zhujian

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

Feature/pangguoming/20210810/wechat audit

See merge request !6
parents 87c1fed2 22ef2d05
...@@ -24,7 +24,7 @@ const getClientEnvironment = require('./env'); ...@@ -24,7 +24,7 @@ const getClientEnvironment = require('./env');
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin'); const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin');
const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
var PREFIX = 'wechat-common-'
const postcssNormalize = require('postcss-normalize'); const postcssNormalize = require('postcss-normalize');
const appPackageJson = require(paths.appPackageJson); const appPackageJson = require(paths.appPackageJson);
...@@ -175,14 +175,14 @@ module.exports = function(webpackEnv) { ...@@ -175,14 +175,14 @@ module.exports = function(webpackEnv) {
// There will be one main bundle, and one file per asynchronous chunk. // There will be one main bundle, and one file per asynchronous chunk.
// In development, it does not produce real files. // In development, it does not produce real files.
filename: isEnvProduction filename: isEnvProduction
? 'static/js/[name].[contenthash:8].js' ?PREFIX+ 'static/js/[name].[contenthash:8].js'
: isEnvDevelopment && 'static/js/bundle.js', : isEnvDevelopment && PREFIX+'static/js/bundle.js',
// TODO: remove this when upgrading to webpack 5 // TODO: remove this when upgrading to webpack 5
futureEmitAssets: true, futureEmitAssets: true,
// There are also additional JS chunk files if you use code splitting. // There are also additional JS chunk files if you use code splitting.
chunkFilename: isEnvProduction chunkFilename: isEnvProduction
? 'static/js/[name].[contenthash:8].chunk.js' ? PREFIX+'static/js/[name].[contenthash:8].chunk.js'
: isEnvDevelopment && 'static/js/[name].chunk.js', : isEnvDevelopment && PREFIX+'static/js/[name].chunk.js',
// webpack uses `publicPath` to determine where the app is being served from. // 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. // 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. // We inferred the "public path" (such as / or /my-project) from homepage.
...@@ -370,7 +370,7 @@ module.exports = function(webpackEnv) { ...@@ -370,7 +370,7 @@ module.exports = function(webpackEnv) {
loader: require.resolve('url-loader'), loader: require.resolve('url-loader'),
options: { options: {
limit: imageInlineSizeLimit, limit: imageInlineSizeLimit,
name: 'static/media/[name].[hash:8].[ext]', name: PREFIX+'static/media/[name].[hash:8].[ext]',
}, },
}, },
// Process application JS with Babel. // Process application JS with Babel.
...@@ -505,7 +505,7 @@ module.exports = function(webpackEnv) { ...@@ -505,7 +505,7 @@ module.exports = function(webpackEnv) {
// by webpacks internal loaders. // by webpacks internal loaders.
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/], exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: { options: {
name: 'static/media/[name].[hash:8].[ext]', name: PREFIX+'static/media/[name].[hash:8].[ext]',
}, },
}, },
// ** STOP ** Are you adding a new loader? // ** STOP ** Are you adding a new loader?
...@@ -578,8 +578,8 @@ module.exports = function(webpackEnv) { ...@@ -578,8 +578,8 @@ module.exports = function(webpackEnv) {
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output // Options similar to the same options in webpackOptions.output
// both options are optional // both options are optional
filename: 'static/css/[name].[contenthash:8].css', filename: PREFIX+'static/css/[name].[contenthash:8].css',
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css', chunkFilename: PREFIX+'static/css/[name].[contenthash:8].chunk.css',
}), }),
// Generate an asset manifest file with the following content: // Generate an asset manifest file with the following content:
// - "files" key: Mapping of all asset filenames to their corresponding // - "files" key: Mapping of all asset filenames to their corresponding
......
...@@ -36,6 +36,21 @@ ...@@ -36,6 +36,21 @@
<script type="text/javascript" src="https://image.xiaomaiketang.com/xm/PhotoClip.js"></script> <script type="text/javascript" src="https://image.xiaomaiketang.com/xm/PhotoClip.js"></script>
</head> </head>
<body> <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> <noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div> <div id="root"></div>
<!-- <!--
......
...@@ -41,7 +41,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { ...@@ -41,7 +41,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
} }
// Tools like Cloud9 rely on this. // 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'; const HOST = process.env.HOST || '0.0.0.0';
if (process.env.HOST) { if (process.env.HOST) {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import { MapInterface } from '@/domains/basic-domain/interface' import { MapInterface } from '@/domains/basic-domain/interface'
// 默认是 dev 环境 // 默认是 dev 环境
const ENV: string = process.env.DEPLOY_ENV || 'prod'; const ENV: string = process.env.DEPLOY_ENV || 'dev';
const BASIC_HOST_MAP: MapInterface = { const BASIC_HOST_MAP: MapInterface = {
dev: 'https://dev-heimdall.xiaomai5.com/', dev: 'https://dev-heimdall.xiaomai5.com/',
......
...@@ -15,9 +15,6 @@ class Authorize extends React.Component { ...@@ -15,9 +15,6 @@ 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({
...@@ -53,19 +50,46 @@ class Authorize extends React.Component { ...@@ -53,19 +50,46 @@ class Authorize extends React.Component {
const code = window.getParameterByName('code'); const code = window.getParameterByName('code');
const ticket = window.getParameterByName('ticket'); const ticket = window.getParameterByName('ticket');
const storeId = window.getParameterByName('storeId'); const storeId = window.getParameterByName('storeId');
const source = window.getParameterByName('_source') === 'sass';
const params = { const params = {
appTermEnum: "XIAOMAI_CLOUD_CLASS_PC_WEB_CUSTOMER", appTermEnum: "XIAOMAI_CLOUD_CLASS_PC_WEB_CUSTOMER",
code, code,
storeId, storeId,
ticket ticket
} }
if(source){
params.source ='SASS'
}
Service.hades('/anon/hades/bindWeChat',params).then((res)=>{ Service.hades('/anon/hades/bindWeChat',params).then((res)=>{
if(res.success){ 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({ this.setState({
hasBindWechat:true, hasBindWechat:true,
headImgUrl:res.result.headImgUrl, headImgUrl:res.result.headImgUrl,
ticketState:"AUTH_SUCCESS" ticketState:"AUTH_SUCCESS"
},()=>{this.changeCodeState()}) },()=>{this.changeCodeState()})
} }
}) })
} }
...@@ -79,7 +103,7 @@ class Authorize extends React.Component { ...@@ -79,7 +103,7 @@ class Authorize extends React.Component {
{ !hasBindWechat && { !hasBindWechat &&
<div> <div>
<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> </div>
<button className="login-btn" onClick={this.wechatAuthorize}>微信登录</button> <button className="login-btn" onClick={this.wechatAuthorize}>微信登录</button>
</div> </div>
...@@ -89,7 +113,7 @@ class Authorize extends React.Component { ...@@ -89,7 +113,7 @@ class Authorize extends React.Component {
<div> <div>
<div> <div>
<img src={headImgUrl} className="avatar-img"></img> <img src={headImgUrl} className="avatar-img" alt=''></img>
</div> </div>
<div className="login-success-text">微信登录成功</div> <div className="login-success-text">微信登录成功</div>
<div className="login-success-instro">已完成微信登录操作,去网页端继续学习吧</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'; ...@@ -11,6 +11,8 @@ import { MenuConfig } from '@/routes/interface';
import Authorize from '@/modules/authorize'; import Authorize from '@/modules/authorize';
import WorkWxAuthorize from '@/modules/workWxAuthorize'; import WorkWxAuthorize from '@/modules/workWxAuthorize';
import EmptyPage from '@/modules/empty-page/EmptyPage' import EmptyPage from '@/modules/empty-page/EmptyPage'
import WechatAudit from '@/modules/wechat-audit/WechatAudit';
import WechatAuditResult from '@/modules/wechat-audit/WechatAuditResult';
const CloudClassConfig: MenuConfig = { const CloudClassConfig: MenuConfig = {
key: 'cloudClass', key: 'cloudClass',
name: '云课堂', name: '云课堂',
...@@ -33,6 +35,18 @@ const CloudClassConfig: MenuConfig = { ...@@ -33,6 +35,18 @@ const CloudClassConfig: MenuConfig = {
path: '/empty-page', path: '/empty-page',
component:EmptyPage, 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; 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