Commit ea4bd874 by zhanghaozhe

eslint

parent ed0bb3a3
src/
\ No newline at end of file
......@@ -121,7 +121,12 @@
"build-storybook": "build-storybook"
},
"eslintConfig": {
"extends": "react-app"
"extends": "react-app",
"globals": {
"API": "readonly",
"NoCaptcha": "readonly",
"WeixinJSBridge": "readonly"
}
},
"browserslist": {
"production": [
......
import React, { Component } from 'react';
import {connect} from "react-redux"
import { connect } from "react-redux"
import './index.scss';
import { http, getParam, is_weixin, wxShare, getC, SendMessageToApp } from 'src/utils';
import {Toast} from "antd-mobile";
import { http, getParam, browser, wxShare, SendMessageToApp } from 'src/utils';
import { Toast } from "antd-mobile";
import jsCookie from 'js-cookie';
......@@ -16,16 +16,16 @@ class Invite extends Component {
hot_schedule: '',
userList: [],
inviteCode: '',
isshowAppTip:false
isshowAppTip: false,
}
}
componentWillMount() {
let uid = jsCookie.get('uid');
let shareuid = getParam('shareuid');
if(uid === shareuid) {
if (uid === shareuid) {
} else {
if(getParam('new')) {
if (getParam('new')) {
this.props.history.push(`/activity?shareuid=${shareuid}&inviteCode=${getParam('inviteCode')}`);
}
}
......@@ -36,23 +36,25 @@ class Invite extends Component {
distinguishVersion = () => {
// plat_form 1ios 2android
// version 1->3.704 2->4.5.1.20191105
if(getParam('plat_form') == 1){
// eslint-disable-next-line eqeqeq
if (getParam('plat_form') == 1) {
let version = Number(getParam('version'))
this.setState({
isshowAppTip: version < 3.704 ? true : false
isshowAppTip: version < 3.704,
});
}
if(getParam('plat_form') == 2){
// eslint-disable-next-line eqeqeq
if (getParam('plat_form') == 2) {
let version = getParam('version').replace(/\./g, '').slice(0, 3)
this.setState({
isshowAppTip: Number(version) < 451 ? true:false
isshowAppTip: Number(version) < 451,
});
}
}
componentDidMount() {
if(!this.props.user.hasError) {
if (!this.props.user.hasError) {
this.getUserList();
this.getHotValue();
this.getInviteCode();
......@@ -61,7 +63,7 @@ class Invite extends Component {
componentWillReceiveProps(nextProps) {
console.log('componentWillReceiveProps');
if(!nextProps.user.hasError) {
if (!nextProps.user.hasError) {
this.getUserList();
this.getHotValue();
this.getInviteCode();
......@@ -71,9 +73,9 @@ class Invite extends Component {
getUserList = () => {
http.get(`${API.home}/sys/user/invite/list`).then(res => {
let {code, data, msg} = res.data;
if(code === 200) {
if (code === 200) {
this.setState({
userList: data
userList: data,
});
} else {
Toast.info(msg, 2);
......@@ -84,10 +86,10 @@ class Invite extends Component {
getHotValue = () => {
http.get(`${API.home}/sys/user/hot/value`).then(res => {
let {code, data, msg} = res.data;
if(code === 200) {
if (code === 200) {
this.setState({
hot_schedule: data.hot_schedule,
hotValue: data.hot_value
hotValue: data.hot_value,
});
} else {
Toast.info(msg, 2);
......@@ -98,36 +100,36 @@ class Invite extends Component {
getInviteCode = () => {
http.get(`${API.home}/sys/user/invite/link`).then(res => {
let {code, data, msg} = res.data;
if(code === 200) {
if (code === 200) {
let inviteCode = data.blessing_invite_code;
if(is_weixin()) {
if (browser.isWeixin) {
wxShare({
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
desc: '把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线',
link: encodeURI(location.origin + `/invite?shareuid=${jsCookie.get('uid')}&new=1&inviteCode=${inviteCode}`),
link: encodeURI(window.location.origin + `/invite?shareuid=${jsCookie.get('uid')}&new=1&inviteCode=${inviteCode}`),
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png',
});
}
this.setState(()=>({
inviteCode: inviteCode
this.setState(() => ({
inviteCode: inviteCode,
}))
}else if(code === 4030 || code === 4040) {
history.push('/passport');
}else{
} else if (code === 4030 || code === 4040) {
this.props.history.push('/passport');
} else {
Toast.info(msg, 2);
}
});
}
inviteFriends = () => {
const { user, history } = this.props;
const {inviteCode,isshowAppTip} = this.state;
const {user, history} = this.props;
const {inviteCode, isshowAppTip} = this.state;
// 未登录先去登录
if (getParam('version')) {
if(user.hasError) {
if (user.hasError) {
SendMessageToApp("toLogin");
}else {
if(isshowAppTip){
} else {
if (isshowAppTip) {
Toast.info('请前往h5/pc端使用该功能', 2);
} else {
let data = {
......@@ -139,23 +141,23 @@ class Invite extends Component {
SendMessageToApp("toShare", data)
}
}
}else {
if(user.hasError) {
} else {
if (user.hasError) {
history.push('/passport');
}else {
if(is_weixin()) {
} else {
if (browser.isWeixin) {
history.push(`/invite?shareuid=${jsCookie.get('uid')}&new=1&inviteCode=${inviteCode}`);
wxShare({
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
desc: '把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线',
link: encodeURI(location.origin + `/invite?shareuid=${jsCookie.get('uid')}&new=1&inviteCode=${inviteCode}`),
link: encodeURI(window.location.origin + `/invite?shareuid=${jsCookie.get('uid')}&new=1&inviteCode=${inviteCode}`),
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png',
});
this.setState({
showTip: true,
isWeiXin: true,
});
}else{
} else {
history.push(`/invite?shareuid=${jsCookie.get('uid')}&new=1&inviteCode=${inviteCode}`);
this.setState({
showTip: true,
......@@ -202,7 +204,7 @@ class Invite extends Component {
<div className="but__con">
<div className="button__content" onClick={this.inviteFriends}>
立即邀请
立即邀请
</div>
</div>
......@@ -215,7 +217,7 @@ class Invite extends Component {
<p className="show__new">(仅显示新用户)</p>
</>
) : (null)
) : null
}
{
......@@ -226,7 +228,7 @@ class Invite extends Component {
return (
<div className="user__item-info item__con-only" key={index}>
<div className="item__con">
<img className="user_avatar" src={item.head_image} />
<img className="user_avatar" alt={item.user_name} src={item.head_image}/>
<div className="user_name">{item.user_name}</div>
</div>
</div>
......@@ -239,7 +241,7 @@ class Invite extends Component {
return (
<div className="user__item-info" key={index}>
<div className="item__con">
<img className="user_avatar" src={item.head_image} />
<img className="user_avatar" alt={item.user_name} src={item.head_image}/>
<div className="user_name">{item.user_name}</div>
</div>
</div>
......@@ -247,23 +249,19 @@ class Invite extends Component {
})
}
</div>
) : (
null
)
) : null
}
</div>
{
showTip && (
<div className="share__mark" onClick={this.closeMark}>
<div className="share__tip">
立即分享给好友增加中奖概率
立即分享给好友增加中奖概率
</div>
{
isWeiXin ? (
<div className="share__row"></div>
) : (
null
)
) : null
}
</div>
)
......@@ -276,5 +274,5 @@ class Invite extends Component {
export default connect(
state => ({user: state.user}),
null
null,
)(Invite);
import React, { Component } from 'react'
import QRCode from 'qrcode'
import { http, SendMessageToApp, wxShare, is_weixin, getParam } from 'src/utils'
import { http, SendMessageToApp, wxShare, browser, getParam } from 'src/utils'
import { Link } from 'react-router-dom'
import { throttle, findIndex, debounce } from 'lodash'
import RulePopup from './rulePopup/index'
......@@ -142,14 +142,8 @@ class BlessingPreheat extends Component {
}
componentDidMount() {
const _this = this;
this.fetchUserBlessing()
// setTimeout(function(){
// // 这里有获取ID的步骤,由于运营过多的调整,导致顺序不定,所以包含ID的title必须要放到判断中(防止出现多个title),设置定时器是因为如果返回较慢 获取不到ID导致报错
// _this.setInitialNavActiveStatus()
// }, 50);
// window.addEventListener('scroll', throttle(this.calcNavActive, 100))
if (is_weixin()) {
if (browser.isWeixin) {
wxShare({
title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
desc: '把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线',
......@@ -163,7 +157,7 @@ class BlessingPreheat extends Component {
this.loginInfo(result)
}
window['getNewData'] = result => {
window['getNewData'] = () => {
this.fetchUserBlessing()
}
window['QQWXWBshare'] = result => {
......@@ -208,7 +202,7 @@ class BlessingPreheat extends Component {
// 保存cookie
appLogin = () => {
let expires = addDays(new Date(), 90)
this.state.userInfoList.map((item, index) => {
this.state.userInfoList.forEach((item) => {
cookie.set("token", item.token, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("plat", item.plat, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("uid", item.uid, {expires, path: '/', domain: '.julyedu.com'})
......@@ -228,7 +222,7 @@ class BlessingPreheat extends Component {
transformUser = res => {
let payload
res.map((item, index) => {
res.forEach((item) => {
payload = {
hasError: false,
data: {
......@@ -347,21 +341,6 @@ class BlessingPreheat extends Component {
}
})
}
handleToAddBlessing = (key) => {
http.post(`${API.home}/sys/add/blessing`, {
share_platform: key, // 1 朋友圈 2 微博 3 qq
type: 3 // 1:签到;3:分享;4:浏览课程;
}).then(res => {
const {code} = res.data
if (code === 200) {
Toast.info('+2点福气值~', 2, null, false)
}
})
}
handleToSign = () => {
const {userInfo} = this.state
http.post(`${API.home}/sys/add/blessing`, {
......@@ -448,11 +427,6 @@ class BlessingPreheat extends Component {
SendMessageToApp("toLogin")
}
}
onCopy = () => {
Toast.info('复制成功', 2, null, false)
}
toSection = (i, e) => {
const {navs} = this.state
e.preventDefault()
......@@ -524,6 +498,7 @@ class BlessingPreheat extends Component {
http.get(`${API.home}/sys/activity/my_lotteries`)
.then(res => {
const {code, data, msg} = res.data
// eslint-disable-next-line eqeqeq
if (code == 200) {
this.recordInstance = Popup({
title: '我的中奖纪录',
......@@ -564,7 +539,8 @@ class BlessingPreheat extends Component {
...this.state.address
})
.then(res => {
const {data, code, msg} = res.data
const {code, msg} = res.data
// eslint-disable-next-line eqeqeq
if (code == 200) {
this.setState({
......@@ -597,6 +573,7 @@ class BlessingPreheat extends Component {
http.get(`${API.home}/sys/user_address_info`)
.then(res => {
const {data, code, msg} = res.data
// eslint-disable-next-line eqeqeq
if (code == 200) {
this.recordInstance && this.recordInstance.close()
this.setState({
......@@ -819,8 +796,8 @@ class BlessingPreheat extends Component {
}}
value={address.address}
/>
<button type='button'
className={(address.name != '' && address.phone != '' && address.address != '') ? 'active' : ''}
{/* eslint-disable-next-line eqeqeq */}
<button type='button' className={(address.name != '' && address.phone != '' && address.address != '') ? 'active' : ''}
onClick={this.submitAddress}
>提交
</button>
......
import React, {Component, useState, useEffect, useLayoutEffect, useRef} from 'react';
import {withRouter, RouteComponentProps} from 'react-router-dom'
import React, { useState} from 'react';
import {withRouter} from 'react-router-dom'
const TSTest: React.FC = () => {
const [count, setCount] = useState(0);
......@@ -23,14 +23,4 @@ const TSTest: React.FC = () => {
);
}
function Message({text}: { text: string }) {
const [message, setMessage] = useState<string | null>(null)
useEffect(() => {
setMessage(text)
})
return <span>{message}</span>
}
export default withRouter(TSTest);
\ No newline at end of file
const config = require('./utils/proxy-config')
const proxy = require('http-proxy-middleware')
module.exports = function (app) {
Object.keys(config).forEach(item => {
app.use(proxy(
config[item]['development'], {
target: config[item]['test'],
changeOrigin: true,
// secure: false,
pathRewrite: {
[`^${config[item]['development']}`]: ''
},
// cookieDomainRewrite: 'localhost',
...config[item]['proxy']
}
))
})
};
\ No newline at end of file
export const getParam = (key, str) => {
const _s = str ? str : location.href;
const re = new RegExp(`(?:\\?|#|&)(${key})=([^=&#\\?]+)`, 'ig');
let found;
return (found = re.exec(_s)) ? found[2] : null;
const _s = str ? str : window.location.href;
const re = new RegExp(`[?#&](${key})=([^=&#?]+)`, 'ig');
let found = re.exec(_s);
return found ? found[2] : null;
}
const html = content => ({
......@@ -23,8 +23,8 @@ function getTimestamp(msec) {
}
function loadScript(src, cb) {
var head = document.head || document.getElementsByTagName('head')[0]
var script = document.createElement('script')
let head = document.head || document.getElementsByTagName('head')[0]
let script = document.createElement('script')
cb = cb || function () {
}
......@@ -52,7 +52,7 @@ function initCaptcha(cb) {
if (window.initNECaptcha) {
cb()
} else {
const url = '//cstaticdun.126.net/load.min.js' + '?t=' + getTimestamp(1 * 60 * 1000)
const url = '//cstaticdun.126.net/load.min.js?t=' + getTimestamp(60 * 1000)
loadScript(url, cb)
}
......@@ -62,26 +62,17 @@ function initCaptchaNC(cb) {
if (window.NoCaptcha && typeof window.NoCaptcha.init === 'function') {
cb()
} else {
const url = '//g.alicdn.com/sd/nch5/index.js' + '?t=' + getTimestamp(1 * 60 * 1000)
const url = '//g.alicdn.com/sd/nch5/index.js?t=' + getTimestamp(60 * 1000)
loadScript(url, cb)
}
}
export const is_weixin = () => {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
}
return false;
}
function validateTel(tel) {
return /^1[3-9](\d{9})$/.test(tel)
}
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
let re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
......@@ -98,7 +89,7 @@ const browser = (function () {
})()
const isValidUrl = (str) => {
return /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/.test(str)
return /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/.test(str)
}
......
const config = {
home: {
development: '/local-api',
test: 'http://fast-test.julyedu.com',
pre: 'https://fast-pre.julyedu.com',
production: 'https://fast.julyedu.com',
proxy: {}
},
'search-api': {
development: '/search-api',
test: 'https://search.julyedu.com',
pre: 'https://search.julyedu.com',
production: 'https://search.julyedu.com',
proxy: {}
},
'passport-api': {
development: '/passport-api',
test: 'http://passport-test.julyedu.com',
pre: 'https://passport-pre.julyedu.com',
production: 'http://passport.julyedu.com',
proxy: {}
},
'base-api': {
development: '/base-api',
test: 'http://api-test.julyedu.com',
pre: 'https://api-pre.julyedu.com',
production: 'https://api.julyedu.com',
proxy: {
secure: false
}
},
}
module.exports = config
\ No newline at end of file
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