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,
......@@ -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,9 +249,7 @@ class Invite extends Component {
})
}
</div>
) : (
null
)
) : null
}
</div>
{
......@@ -261,9 +261,7 @@ class Invite extends Component {
{
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} from 'react'
import React, { Component } from 'react'
import './share.scss'
import {http, getParam, browser, wxShare,is_weixin} from 'src/utils'
import {Toast} from 'antd-mobile'
import {connect} from "react-redux";
import {Link} from "react-router-dom";
import { http, getParam, browser, wxShare } from 'src/utils'
import { Toast } from 'antd-mobile'
import { connect } from "react-redux";
import { Link } from "react-router-dom";
import showAlert from 'src/common/deposit/end-expansion-alert'
class ExpandShare extends Component {
......@@ -21,7 +21,7 @@ class ExpandShare extends Component {
componentDidMount() {
this.getListorData()
this.getCourseList()
if(is_weixin()) {
if (browser.isWeixin) {
wxShare({
title: 'AI充电节,预热来袭!80元红包送给你,手要快!',
desc: '积福气享1折秒课,超10万元奖品来就送--七月在线',
......@@ -35,9 +35,9 @@ class ExpandShare extends Component {
getListorData = () => {
http.get(`${API['base-api']}/sys/help_list/${getParam('deposit_code')}`).then((res) => {
const {data, errno, msg} = res.data
if (errno == 200) {
if (errno === 200) {
this.setState({
data: data
data: data,
})
} else {
Toast.info(msg, 2)
......@@ -51,22 +51,22 @@ class ExpandShare extends Component {
const _this = this
http.get(`${API['base-api']}/anniversary2019/pre_course`).then((res) => {
const {data, errno, msg} = res.data
if (errno == 200) {
if (JSON.stringify(data) == '{}') {
if (errno === 200) {
if (JSON.stringify(data) === '{}') {
_this.setState({
isshowMore: false,
courseList: []
courseList: [],
})
} else if (data.length <= 6) {
_this.setState({
isshowMore: false,
courseList: data
courseList: data,
})
} else {
_this.setState({
isshowMore: true,
courseList: data.slice(0, 6),
courseListMore: data
courseListMore: data,
})
}
} else {
......@@ -80,12 +80,12 @@ class ExpandShare extends Component {
getMoreCourseList = () => {
this.setState({
courseList: this.state.courseListMore,
isshowMore: false
isshowMore: false,
})
}
// 立即付定金
expandPaydj = (courseId) => {
const {user, history} = this.props;
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
......@@ -95,14 +95,14 @@ class ExpandShare extends Component {
{
id: courseId,
isexpand: 1,
sourcenum: 1
}
sourcenum: 1,
},
)
}
}
// 立即付尾款
expandPaywk = (courseId, time, day) => {
const {user, history} = this.props;
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
......@@ -113,9 +113,9 @@ class ExpandShare extends Component {
'/final-deposit-order?source=1',
{
id: courseId,
sourcenum: 1
sourcenum: 1,
}
},
)
} else {
Toast.info("付尾款时间将在" + day + "开启", 2);
......@@ -131,44 +131,44 @@ class ExpandShare extends Component {
showRule = () => {
this.setState({
isShow: true,
step: 1
step: 1,
})
}
// 邀请好友
share = () => {
const {user, history} = this.props;
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
this.setState({
isShow: true,
step: 0
step: 0,
})
}
}
// 帮好友助力
helpFriend = (id) => {
const {user, history} = this.props;
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
http.post(`${API['base-api']}/sys/help/${id}`).then((res) => {
const {data, errno, msg} = res.data
if (errno == 200) {
if (errno === 200) {
this.setState({
isShow: true,
step: 2,
helpData: data
helpData: data,
})
this.getListorData()
} else if (errno === 17018 || errno === 17020) {
this.setState({
isShow: true,
step: 4
step: 4,
})
} else {
Toast.info(msg, 2)
......@@ -179,7 +179,7 @@ class ExpandShare extends Component {
// 结束助力
isendExpand = (data) => {
const {user, history} = this.props;
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
......@@ -190,25 +190,25 @@ class ExpandShare extends Component {
limit_amount,
onCancel: () => {
this.setState({
isShow: false
isShow: false,
})
},
onConfirm: () => {
http.post(`${API['base-api']}/sys/end_expansion`, {
id
id,
})
.then(res => {
const {errno, msg} = res.data
if (errno == 200) {
if (errno === 200) {
this.setState({
isShow: false
isShow: false,
})
this.getListorData()
} else {
Toast.info(msg)
}
})
}
},
})
}
}
......@@ -216,7 +216,7 @@ class ExpandShare extends Component {
// 关闭弹窗
close = () => {
this.setState({
isShow: false
isShow: false,
})
}
......@@ -244,7 +244,7 @@ class ExpandShare extends Component {
{/*好友助力列表*/}
{
(data.oneself === 1 || data.help_list && data.help_list.length !== 0) &&
((data.oneself === 1 || data.help_list) && data.help_list.length !== 0) &&
<FriendList data={data}/>
}
{/*预售课程列表*/}
......@@ -569,13 +569,23 @@ function CourseList(props) {
<div className="btn">
{
item.is_buy === 0 &&
/*eslint-disable-next-line*/
<a className="to-expand-buy1"
onClick={() => expandPaydj(item.course_id)}>立即付定金</a>
href={'#'}
onClick={(e) => {
e.preventDefault()
expandPaydj(item.course_id)
}}>立即付定金</a>
}
{
item.is_buy === 1 &&
/*eslint-disable-next-line*/
<a className="to-expand-buy2"
onClick={() => expandPaywk(item.course_id, item.start_timestamp, item.final_start_time)}>立即付尾款</a>
href='#'
onClick={(e) => {
e.preventDefault()
expandPaywk(item.course_id, item.start_timestamp, item.final_start_time)
}}>立即付尾款</a>
}
{
item.is_buy === 2 &&
......@@ -607,6 +617,6 @@ function CourseList(props) {
export default connect(
state => ({
user: state.user
user: state.user,
}),
)(ExpandShare)
import React, { Component } from 'react'
import { Flex, WingBlank, WhiteSpace, List, Radio, Toast, Checkbox } from 'antd-mobile'
import { http, getParam, is_weixin, browser } from 'src/utils'
import { OrderItem, HeaderBar } from 'src/common/index'
import { http, getParam, browser } from 'src/utils'
import { HeaderBar } from 'src/common/index'
import { Link } from 'react-router-dom'
import './index.scss'
import { VList } from 'src/common'
......@@ -10,10 +10,10 @@ import classnames from 'classnames'
const RadioItem = Radio.RadioItem
let mockData = []
let mockData
if (browser.isWeixin) {
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'}
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
]
} else {
mockData = [
......@@ -41,7 +41,7 @@ class PayOrder extends Component {
{value: 'huabei', qishu: '9', lilv: '7.50%', everyMoney: 100, feiyong: 7.5},
],
categoryList: [],
agree: false
agree: false,
}
}
......@@ -59,7 +59,7 @@ class PayOrder extends Component {
// 确定购买
pay = () => {
const {payType, orderId} = this.state
if(!this.state.agree){
if (!this.state.agree) {
return
}
if (payType === 0) {
......@@ -71,7 +71,7 @@ class PayOrder extends Component {
// 微信支付
weixinPay = (orderId) => {
// 微信内部-支付
if (is_weixin()) {
if (browser.isWeixin) {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=" + encodeURIComponent(window.location.href + "&aa=bb").toLowerCase() + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
} else {
// 微信外部-支付
......@@ -89,9 +89,7 @@ class PayOrder extends Component {
let _this = this
let weixin_code = getParam('code')
if (weixin_code) {
if (getParam('oid') === undefined) {
return
} else {
if (getParam('oid') !== undefined) {
http.get(`${API['base-api']}/pay/wxpay/pub_charge/oid/${getParam('oid')}/code/${weixin_code}`).then((res) => {
if (res.data.errno === 0) {
let data = res.data.data
......@@ -104,9 +102,10 @@ class PayOrder extends Component {
nonceStr: data.nonceStr, //随机串
package: data.package,
signType: data.signType, //微信签名方式:
paySign: data.paySign //微信签名
paySign: data.paySign, //微信签名
},
function (res) {
// eslint-disable-next-line eqeqeq
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2)
_this.intervalPayStatus = setInterval(function () {
......@@ -121,7 +120,7 @@ class PayOrder extends Component {
} else {
alert('支付失败')
}
}
},
)
}
......@@ -162,6 +161,7 @@ class PayOrder extends Component {
let _this = this
data = data || _this.BridgeData
/* eslint-disable-next-line no-undef */
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": "wx23dac6775ac82877", //公众号名称,由商户传入
......@@ -169,16 +169,17 @@ class PayOrder extends Component {
"nonceStr": data.nonceStr, //随机串
"package": data.package,
"signType": data.signType, //微信签名方式:
"paySign": data.paySign //微信签名
"paySign": data.paySign, //微信签名
},
function (res) {
// eslint-disable-next-line eqeqeq
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2)
_this.payCallback()
} else {
alert('支付失败')
}
}
},
)
}
// 支付宝支付
......@@ -205,13 +206,14 @@ class PayOrder extends Component {
http.post(`${API["base-api"]}/m/deposit/detail`, {
order_id: this.state.orderId
order_id: this.state.orderId,
}).then(res => {
const {data} = res
// eslint-disable-next-line eqeqeq
if (data.errno == 200) {
this.setState({
categoryList: [data.data.course_info],
salePrice: data.data.course_info.sale_price
salePrice: data.data.course_info.sale_price,
})
} else {
Toast.info(data.msg)
......@@ -233,7 +235,7 @@ class PayOrder extends Component {
singleMoney,
periodNumber,
categoryList,
agree
agree,
} = this.state
return (
<div className='pay-order'>
......@@ -297,7 +299,7 @@ class PayOrder extends Component {
checkPeriod ? (
<span style={{
color: '#333333',
fontSize: '12px'
fontSize: '12px',
}}>{`${singleMoney}元 × ${periodNumber}期`}</span>
) : null
}
......
import React, { Component } from 'react';
import { Flex, WingBlank, WhiteSpace, List, Radio, Toast } from 'antd-mobile';
import { http, getParam, is_weixin, browser } from 'src/utils';
import { OrderItem, HeaderBar } from 'src/common/index';
import { http, getParam, browser } from 'src/utils';
import { HeaderBar } from 'src/common/index';
import { Link } from 'react-router-dom';
import './PayOrder.scss';
import { VList } from 'src/common';
const Item = List.Item;
const Brief = Item.Brief;
const RadioItem = Radio.RadioItem;
let mockData = []
let mockData
if (browser.isWeixin) {
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'}
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
];
} else {
mockData = [
......@@ -58,10 +56,10 @@ export default class PayOrder extends Component {
// type订单类型 0普通订单 1团购 2小团 3砍价 4单集购买 5定金课定金 6定金课尾款
if (parseInt(type, 10) === 2) {
history.push(`/togroup?id=${oid}`);
}else if(parseInt(type, 10) === 4) {
courseId && window.localStorage.setItem('payCourse', courseId);
} else if (parseInt(type, 10) === 4) {
const courseId = window.localStorage.getItem('payCourse')
courseId && history.push(`/detail?id=${courseId}`,{oid});
courseId && window.localStorage.setItem('payCourse', courseId);
courseId && history.push(`/detail?id=${courseId}`, {oid});
} else {
history.push('/purchased');
}
......@@ -110,7 +108,7 @@ export default class PayOrder extends Component {
// 微信支付
weixinPay = (orderId) => {
// 微信内部-支付
if (is_weixin()) {
if (browser.isWeixin) {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=" + encodeURIComponent(window.location.href + "&aa=bb").toLowerCase() + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
// if(window.location.href.indexOf('aa=bb') === -1){
// localStorage.setItem('a', '第一次');
......@@ -138,9 +136,7 @@ export default class PayOrder extends Component {
let _this = this;
let weixin_code = getParam('code');
if (weixin_code) {
if (getParam('oid') === undefined) {
return
} else {
if (getParam('oid') !== undefined) {
http.get(`${API['base-api']}/pay/wxpay/pub_charge/oid/${getParam('oid')}/code/${weixin_code}`).then((res) => {
if (res.data.errno === 0) {
let data = res.data.data;
......@@ -153,9 +149,10 @@ export default class PayOrder extends Component {
nonceStr: data.nonceStr, //随机串
package: data.package,
signType: data.signType, //微信签名方式:
paySign: data.paySign //微信签名
paySign: data.paySign, //微信签名
},
function (res) {
// eslint-disable-next-line eqeqeq
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2);
_this.intervalPayStatus = setInterval(function () {
......@@ -178,7 +175,7 @@ export default class PayOrder extends Component {
} else {
alert('支付失败')
}
}
},
)
}
......@@ -235,16 +232,17 @@ export default class PayOrder extends Component {
"nonceStr": data.nonceStr, //随机串
"package": data.package,
"signType": data.signType, //微信签名方式:
"paySign": data.paySign //微信签名
"paySign": data.paySign, //微信签名
},
function (res) {
// eslint-disable-next-line eqeqeq
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2);
_this.payCallback();
} else {
alert('支付失败')
}
}
},
)
}
// 支付宝支付
......@@ -260,7 +258,7 @@ export default class PayOrder extends Component {
}
// 花呗分期 暂时不做
huabeiPay = (orderId) => {
const {singleMoney, periodNumber} = this.state;
const {periodNumber} = this.state;
// console.log('花呗分期支付');
http.get(`/pay/alipay/wap_charge/oid/${orderId}/plat/{plat} /hb_num/${periodNumber}`).then(res => {
......@@ -275,25 +273,25 @@ export default class PayOrder extends Component {
componentDidMount() {
this.redirectAfterPay()
let data = {}
if(this.props.location.state && this.props.location.state.group){
let data
if (this.props.location.state && this.props.location.state.group) {
data = {
order_id: this.state.orderId,
type: 2
type: 2,
}
} else {
data = {
order_id: this.state.orderId,
}
}
http.post(`${API['base-api']}/m/order/detail`,data).then((res) => {
http.post(`${API['base-api']}/m/order/detail`, data).then((res) => {
if (res.data.errno !== 200) {
Toast.info(res.data.msg, 2);
return;
}
const {course, pay_amount} = res.data.data;
const fenqiList = [];
[1, 2, 3].map((item) => {
[1, 2, 3].forEach((item) => {
let obj = {};
obj.value = item;
if (item === 1) {
......@@ -329,9 +327,9 @@ export default class PayOrder extends Component {
if (getParam('is_class') === 1 || getParam('weixinpay')) {
this.payCallback()
}
if (is_weixin()) {
if (browser.isWeixin) {
this.setState({
payType: 1
payType: 1,
})
this.isweixinPay()
}
......@@ -402,7 +400,7 @@ export default class PayOrder extends Component {
checkPeriod ? (
<span style={{
color: '#333333',
fontSize: '12px'
fontSize: '12px',
}}>{`${singleMoney}元 × ${periodNumber}期`}</span>
) : null
}
......
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