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} 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 {
state = {
isShow: false, //活动规则
step: 0, // 区分弹窗
data: '', //膨胀券相关
courseList: [], // 预售课程列表
isshowMore: true, // 是否显示查看更多
pageCount: 1, // 页码
helpData: '',// 帮助好友助力数据
courseListMore: '', // 所有课程
state = {
isShow: false, //活动规则
step: 0, // 区分弹窗
data: '', //膨胀券相关
courseList: [], // 预售课程列表
isshowMore: true, // 是否显示查看更多
pageCount: 1, // 页码
helpData: '',// 帮助好友助力数据
courseListMore: '', // 所有课程
}
componentDidMount() {
this.getListorData()
this.getCourseList()
if (browser.isWeixin) {
wxShare({
title: 'AI充电节,预热来袭!80元红包送给你,手要快!',
desc: '积福气享1折秒课,超10万元奖品来就送--七月在线',
link: window.location.href,
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/dj-share-img.png',
})
}
}
componentDidMount() {
this.getListorData()
this.getCourseList()
if(is_weixin()) {
wxShare({
title: 'AI充电节,预热来袭!80元红包送给你,手要快!',
desc: '积福气享1折秒课,超10万元奖品来就送--七月在线',
link: window.location.href,
imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/dj-share-img.png',
})
}
}
// 获取膨胀券相关
getListorData = () => {
http.get(`${API['base-api']}/sys/help_list/${getParam('deposit_code')}`).then((res) => {
const {data, errno, msg} = res.data
if (errno == 200) {
this.setState({
data: data
})
} else {
Toast.info(msg, 2)
}
})
}
// 获取课程列表
getCourseList = () => {
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) == '{}') {
_this.setState({
isshowMore: false,
courseList: []
})
} else if (data.length <= 6) {
_this.setState({
isshowMore: false,
courseList: data
})
} else {
_this.setState({
isshowMore: true,
courseList: data.slice(0, 6),
courseListMore: data
})
}
} else {
Toast.info(msg, 2)
}
})
}
// 获取更多课程
getMoreCourseList = () => {
// 获取膨胀券相关
getListorData = () => {
http.get(`${API['base-api']}/sys/help_list/${getParam('deposit_code')}`).then((res) => {
const {data, errno, msg} = res.data
if (errno === 200) {
this.setState({
courseList: this.state.courseListMore,
isshowMore: false
data: data,
})
}
// 立即付定金
expandPaydj = (courseId) => {
const {user, history} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
Toast.info(msg, 2)
}
})
}
// 获取课程列表
getCourseList = () => {
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) === '{}') {
_this.setState({
isshowMore: false,
courseList: [],
})
} else if (data.length <= 6) {
_this.setState({
isshowMore: false,
courseList: data,
})
} else {
this.props.history.push(
`/deposit-order?oid=${courseId}&source=${1}`,
{
id: courseId,
isexpand: 1,
sourcenum: 1
}
)
_this.setState({
isshowMore: true,
courseList: data.slice(0, 6),
courseListMore: data,
})
}
} else {
Toast.info(msg, 2)
}
})
}
// 获取更多课程
getMoreCourseList = () => {
this.setState({
courseList: this.state.courseListMore,
isshowMore: false,
})
}
// 立即付定金
expandPaydj = (courseId) => {
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
this.props.history.push(
`/deposit-order?oid=${courseId}&source=${1}`,
{
id: courseId,
isexpand: 1,
sourcenum: 1,
},
)
}
// 立即付尾款
expandPaywk = (courseId, time, day) => {
const {user, history} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
let timeStamp = Date.parse(new Date()) / 1000;
if (timeStamp >= time) {
this.props.history.push(
'/final-deposit-order?source=1',
{
id: courseId,
sourcenum: 1
}
)
} else {
Toast.info("付尾款时间将在" + day + "开启", 2);
}
}
}
// 立即付尾款
expandPaywk = (courseId, time, day) => {
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
let timeStamp = Date.parse(new Date()) / 1000;
if (timeStamp >= time) {
this.props.history.push(
'/final-deposit-order?source=1',
{
id: courseId,
sourcenum: 1,
},
)
} else {
Toast.info("付尾款时间将在" + day + "开启", 2);
}
}
// 去学习
tostudy = (courseId) => {
this.props.history.push(`/getDetail?id=${courseId}`)
}
// 去学习
tostudy = (courseId) => {
this.props.history.push(`/getDetail?id=${courseId}`)
}
// 显示活动规则
showRule = () => {
this.setState({
isShow: true,
step: 1,
})
}
// 邀请好友
share = () => {
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,
})
}
// 显示活动规则
showRule = () => {
this.setState({
}
// 帮好友助力
helpFriend = (id) => {
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) {
this.setState({
isShow: true,
step: 1
})
}
// 邀请好友
share = () => {
const {user, history} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
step: 2,
helpData: data,
})
this.getListorData()
} else if (errno === 17018 || errno === 17020) {
this.setState({
isShow: true,
step: 4,
})
} else {
this.setState({
isShow: true,
step: 0
})
Toast.info(msg, 2)
}
})
}
// 帮好友助力
helpFriend = (id) => {
const {user, history} = 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) {
this.setState({
isShow: true,
step: 2,
helpData: data
})
this.getListorData()
} else if (errno === 17018 || errno === 17020) {
this.setState({
isShow: true,
step: 4
})
} else {
Toast.info(msg, 2)
}
}
// 结束助力
isendExpand = (data) => {
const {user} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
const {amount, limit_amount, id} = data
showAlert({
amount,
limit_amount,
onCancel: () => {
this.setState({
isShow: false,
})
},
onConfirm: () => {
http.post(`${API['base-api']}/sys/end_expansion`, {
id,
})
.then(res => {
const {errno, msg} = res.data
if (errno === 200) {
this.setState({
isShow: false,
})
this.getListorData()
} else {
Toast.info(msg)
}
})
}
},
})
}
}
// 结束助力
isendExpand = (data) => {
const {user, history} = this.props;
const uid = user && user.data && user.data.uid;
if (!uid) {
this.props.history.push('/passport/login')
} else {
const {amount, limit_amount, id} = data
showAlert({
amount,
limit_amount,
onCancel: () => {
this.setState({
isShow: false
})
},
onConfirm: () => {
http.post(`${API['base-api']}/sys/end_expansion`, {
id
})
.then(res => {
const {errno, msg} = res.data
if (errno == 200) {
this.setState({
isShow: false
})
this.getListorData()
} else {
Toast.info(msg)
}
})
}
})
}
}
// 关闭弹窗
close = () => {
this.setState({
isShow: false,
})
}
// 关闭弹窗
close = () => {
this.setState({
isShow: false
})
}
render() {
const {isShow, step, data, courseList, isshowMore, helpData} = this.state
return (
<div className="expand-box">
<div className="banner">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/dj-banner.png" alt=""/>
<span onClick={() => this.showRule()}/>
</div>
<div className="all-contnet">
<div className="content">
{/*进度||膨胀券*/}
{
<ExpansionStatus data={data}/>
}
{/*button*/}
{
<ButtonStatus data={data} share={this.share} helpFriend={this.helpFriend}
isendExpand={this.isendExpand}/>
}
</div>
{/*好友助力列表*/}
{
((data.oneself === 1 || data.help_list) && data.help_list.length !== 0) &&
<FriendList data={data}/>
}
{/*预售课程列表*/}
{
<CourseList data={courseList}
isshowMore={isshowMore}
getMoreCourseList={this.getMoreCourseList}
expandPaydj={this.expandPaydj}
expandPaywk={this.expandPaywk}
tostudy={this.tostudy}
/>
}
</div>
render() {
const {isShow, step, data, courseList, isshowMore, helpData} = this.state
return (
<div className="expand-box">
<div className="banner">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/dj-banner.png" alt=""/>
<span onClick={() => this.showRule()}/>
</div>
<div className="all-contnet">
<div className="content">
{/*进度||膨胀券*/}
{
<ExpansionStatus data={data}/>
}
{/*button*/}
{
<ButtonStatus data={data} share={this.share} helpFriend={this.helpFriend}
isendExpand={this.isendExpand}/>
}
</div>
{/*好友助力列表*/}
{
{
isShow &&
<div className='mbc-box'>
{
step === 0 &&
<ShareBox close={this.close} share={this.share} data={data}/>
}
{
step === 1 &&
<ActiveRule/>
}
(data.oneself === 1 || data.help_list && data.help_list.length !== 0) &&
<FriendList data={data}/>
}
{/*预售课程列表*/}
{
<CourseList data={courseList}
isshowMore={isshowMore}
getMoreCourseList={this.getMoreCourseList}
expandPaydj={this.expandPaydj}
expandPaywk={this.expandPaywk}
tostudy={this.tostudy}
/>
}
</div>
{
isShow &&
<div className='mbc-box'>
{
step === 0 &&
<ShareBox close={this.close} share={this.share} data={data}/>
}
{
step === 1 &&
<ActiveRule/>
}
{
step === 2 &&
<AssistanceSuccess share={this.share} data={data} helpData={helpData}/>
}
{
step === 4 &&
<AssistanceErron close={this.close}/>
}
{
(step === 1 || step === 2) &&
<img className="close"
onClick={() => this.close()}
src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/Public/img/guanbi_icon.png"
alt=""/>
}
</div>
}
</div>
)
}
{
step === 2 &&
<AssistanceSuccess share={this.share} data={data} helpData={helpData}/>
}
{
step === 4 &&
<AssistanceErron close={this.close}/>
}
{
(step === 1 || step === 2) &&
<img className="close"
onClick={() => this.close()}
src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/Public/img/guanbi_icon.png"
alt=""/>
}
</div>
}
</div>
)
}
}
// 活动规则
function ActiveRule() {
return (
<div className='content active-rule'>
<div className="title">活动规则</div>
<p>1、本活动期间,可以助力1位好友不同课程发起的膨胀,但是只能为同一好友;</p>
<p>2、好友发起膨胀后,可以随时终止膨胀;</p>
<p>3、膨胀券膨胀完成后,以优惠券形式发放到参与活动的账号(包括所有助力好友),该膨胀券为全场通用券,可在购买任一课程后进行抵扣(包括已付定金课程);</p>
<p>4、如有疑问,可联系七月在线客服微信:julyedukefu</p>
<p>*本活动最终解释权归七月在线所有</p>
</div>
)
return (
<div className='content active-rule'>
<div className="title">活动规则</div>
<p>1、本活动期间,可以助力1位好友不同课程发起的膨胀,但是只能为同一好友;</p>
<p>2、好友发起膨胀后,可以随时终止膨胀;</p>
<p>3、膨胀券膨胀完成后,以优惠券形式发放到参与活动的账号(包括所有助力好友),该膨胀券为全场通用券,可在购买任一课程后进行抵扣(包括已付定金课程);</p>
<p>4、如有疑问,可联系七月在线客服微信:julyedukefu</p>
<p>*本活动最终解释权归七月在线所有</p>
</div>
)
}
// 邀请好友 分享弹窗
function ShareBox(props) {
const {close, data} = props
return (
<div className='content'>
<div onClick={() => close()} className="fiexd"></div>
<div className="share-box">
{
browser.isWeixin &&
<img src="//julyedu-cdn.oss-cn-beijing.aliyuncs.com/share/throw_icon.png" alt=""/>
}
<p>邀请好友助力</p>
<p>膨胀券翻倍膨胀,{data.start_amount}元变{data.limit_amount}元!</p>
<span>送助力好友{data.limit_amount}</span>
</div>
</div>
)
const {close, data} = props
return (
<div className='content'>
<div onClick={() => close()} className="fiexd"></div>
<div className="share-box">
{
browser.isWeixin &&
<img src="//julyedu-cdn.oss-cn-beijing.aliyuncs.com/share/throw_icon.png" alt=""/>
}
<p>邀请好友助力</p>
<p>膨胀券翻倍膨胀,{data.start_amount}元变{data.limit_amount}元!</p>
<span>送助力好友{data.limit_amount}</span>
</div>
</div>
)
}
//助力成功弹窗
function AssistanceSuccess(props) {
const {helpData, share, data} = props
return (
<div className='content assistance-success'>
<div className="title">助力成功</div>
<p className="add-price">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/add-money.png" alt=""/>
+{helpData.help_amount}
</p>
<p className="all-price">
<span>{helpData.sale_amount}</span>
</p>
<p className="assistance-tip">感谢你的助力,你们离{data.limit_amount}元又更近了哦!<br/>可以邀请其他小伙伴一起助力~</p>
<button onClick={() => share()}>邀请更多好友拿{data.limit_amount}</button>
</div>
)
const {helpData, share, data} = props
return (
<div className='content assistance-success'>
<div className="title">助力成功</div>
<p className="add-price">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/add-money.png" alt=""/>
+{helpData.help_amount}
</p>
<p className="all-price">
<span>{helpData.sale_amount}</span>
</p>
<p className="assistance-tip">感谢你的助力,你们离{data.limit_amount}元又更近了哦!<br/>可以邀请其他小伙伴一起助力~</p>
<button onClick={() => share()}>邀请更多好友拿{data.limit_amount}</button>
</div>
)
}
// 助力失败弹窗
function AssistanceErron(props) {
const {close} = props
return (
<div className="content assistance-erron">
<div className="title">温馨提示</div>
<p>很遗憾~</p>
<p>你已经帮别的好友助过力了,</p>
<p>不能再帮这位好友助力!</p>
<button onClick={() => close()}>知道了</button>
</div>
)
const {close} = props
return (
<div className="content assistance-erron">
<div className="title">温馨提示</div>
<p>很遗憾~</p>
<p>你已经帮别的好友助过力了,</p>
<p>不能再帮这位好友助力!</p>
<button onClick={() => close()}>知道了</button>
</div>
)
}
// 判断是否结束膨胀
function ExpansionStatus(props) {
const {data} = props
//is_end: 0 判断活动是否结束 0否1是
// is_end_expansion: 0,是否是自己结束膨胀 0否1是
if (data.is_end === 0 && data.is_end_expansion === 0) {
return (
<ProgressData data={data}/>
)
} else {
return (
<EndExpansion data={data}/>
)
}
const {data} = props
//is_end: 0 判断活动是否结束 0否1是
// is_end_expansion: 0,是否是自己结束膨胀 0否1是
if (data.is_end === 0 && data.is_end_expansion === 0) {
return (
<ProgressData data={data}/>
)
} else {
return (
<EndExpansion data={data}/>
)
}
}
// 没有结束膨胀的情况
function ProgressData(props) {
const data = props.data
return (
<div>
<div className="user-mess">
<img src={data.avatar_file} alt="user"/>
帮我助力,送你{data.limit_amount}
</div>
<div className="progress-box">
<div className="progress-base">
const data = props.data
return (
<div>
<div className="user-mess">
<img src={data.avatar_file} alt="user"/>
帮我助力,送你{data.limit_amount}
</div>
<div className="progress-box">
<div className="progress-base">
<span className="progress-active"
style={{width: (data.amount - data.start_amount) / data.limit_amount * 100 + '%'}}>
<span className="ending">
<span className="tip">{data.amount} <i/></span>
</span>
</span>
</div>
<div className="progress-price">
<span>{data.start_amount}</span>
<span>{data.limit_amount}</span>
</div>
</div>
{
data.help_list.length === 0 &&
<div className="help-mess no">还没有好友为{data.oneself === 1 ? '你' : 'Ta'}助力哦~</div>
}
{
data.help_list.length > 0 &&
<div className="help-mess has">已有<span className="FF19A0">{data.help_list.length}</span>位好友助力</div>
}
</div>
)
<div className="progress-price">
<span>{data.start_amount}</span>
<span>{data.limit_amount}</span>
</div>
</div>
{
data.help_list.length === 0 &&
<div className="help-mess no">还没有好友为{data.oneself === 1 ? '你' : 'Ta'}助力哦~</div>
}
{
data.help_list.length > 0 &&
<div className="help-mess has">已有<span className="FF19A0">{data.help_list.length}</span>位好友助力</div>
}
</div>
)
}
// 结束膨胀的情况
function EndExpansion(props) {
const data = props.data
return (
<div className='coupon-box'>
<div className="coupon">
<p className="coupon-name">红包膨胀优惠券</p>
<p className="coupon-price"><span>{data.amount}</span>元</p>
<p className="coupon-time">有效期至:{data.expire_time}</p>
</div>
<div className="tip">
<ul>
{
new Array(19).fill('1').map((item, index) => {
return <li key={index}/>
})
}
</ul>
全场通用
</div>
<p className="over-mess">该礼券已成功发放至账户</p>
<p className="over-mess">可在七月在线pc/app-我的-优惠券查看</p>
</div>
)
const data = props.data
return (
<div className='coupon-box'>
<div className="coupon">
<p className="coupon-name">红包膨胀优惠券</p>
<p className="coupon-price"><span>{data.amount}</span>元</p>
<p className="coupon-time">有效期至:{data.expire_time}</p>
</div>
<div className="tip">
<ul>
{
new Array(19).fill('1').map((item, index) => {
return <li key={index}/>
})
}
</ul>
全场通用
</div>
<p className="over-mess">该礼券已成功发放至账户</p>
<p className="over-mess">可在七月在线pc/app-我的-优惠券查看</p>
</div>
)
}
// 按钮
function ButtonStatus(props) {
const {data, share, helpFriend, isendExpand} = props
// data.oneself 判断是否是自己 0帮好友助力 1自己
// data.is_help 是否已经帮好友助力 0 未助力 1已助力
// data.s_end: 0 判断活动是否结束 0否1是
// data.is_end_expansion: 0,是否是自己结束膨胀 0否1是
return (
<div>
{
data.is_end === 0 &&
<div className='btns'>
{
data.oneself === 1 && data.is_end_expansion === 0 &&
<button className="active" onClick={() => share()}>邀请好友助力</button>
}
{
data.oneself === 1 && data.is_end_expansion === 1 && data.amount !== data.limit_amount &&
<button className="over">您已结束膨胀</button>
}
{
data.oneself === 1 && data.is_end_expansion === 1 && data.amount === data.limit_amount &&
<button className="over">达到膨胀上限,快去使用吧</button>
}
{
data.oneself === 0 && data.is_help === 0 && data.is_end_expansion === 0 &&
<button className="active" onClick={() => helpFriend(data.id)}>ta助力</button>
}
{
data.oneself === 0 && data.is_help === 1 && data.is_end_expansion === 0 &&
<button className="active" onClick={() => share()}>邀请更多好友拿{data.limit_amount}</button>
}
{
data.oneself === 0 && data.is_end_expansion === 1 && data.amount === data.limit_amount &&
<button className="over">达到膨胀上限,快去使用吧</button>
}
{
data.oneself === 0 && data.is_end_expansion === 1 && data.amount !== data.limit_amount &&
<button className="over">你的好友已结束助力</button>
}
</div>
}
{
data.is_end === 1 &&
<div className="btns">
<button className="over">活动已结束</button>
</div>
}
{
data.is_end === 0 && data.is_end_expansion === 0 && data.oneself === 1 &&
<div className="overBtn">
<p onClick={() => isendExpand(data)}>结束助力使用礼券</p>
</div>
}
const {data, share, helpFriend, isendExpand} = props
// data.oneself 判断是否是自己 0帮好友助力 1自己
// data.is_help 是否已经帮好友助力 0 未助力 1已助力
// data.s_end: 0 判断活动是否结束 0否1是
// data.is_end_expansion: 0,是否是自己结束膨胀 0否1是
return (
<div>
{
data.is_end === 0 &&
<div className='btns'>
{
data.oneself === 1 && data.is_end_expansion === 0 &&
<button className="active" onClick={() => share()}>邀请好友助力</button>
}
{
data.oneself === 1 && data.is_end_expansion === 1 && data.amount !== data.limit_amount &&
<button className="over">您已结束膨胀</button>
}
{
data.oneself === 1 && data.is_end_expansion === 1 && data.amount === data.limit_amount &&
<button className="over">达到膨胀上限,快去使用吧</button>
}
{
data.oneself === 0 && data.is_help === 0 && data.is_end_expansion === 0 &&
<button className="active" onClick={() => helpFriend(data.id)}>ta助力</button>
}
{
data.oneself === 0 && data.is_help === 1 && data.is_end_expansion === 0 &&
<button className="active" onClick={() => share()}>邀请更多好友拿{data.limit_amount}</button>
}
{
data.oneself === 0 && data.is_end_expansion === 1 && data.amount === data.limit_amount &&
<button className="over">达到膨胀上限,快去使用吧</button>
}
{
data.oneself === 0 && data.is_end_expansion === 1 && data.amount !== data.limit_amount &&
<button className="over">你的好友已结束助力</button>
}
</div>
}
{
data.is_end === 1 &&
<div className="btns">
<button className="over">活动已结束</button>
</div>
}
{
data.is_end === 0 && data.is_end_expansion === 0 && data.oneself === 1 &&
<div className="overBtn">
<p onClick={() => isendExpand(data)}>结束助力使用礼券</p>
</div>
)
}
</div>
)
}
// 好友助力列表
function FriendList(props) {
const data = props.data
return (
<div className="friend-list">
<p className="title">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-right.png" alt=""/>
<span>好友助力</span>
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-left.png" alt=""/>
</p>
{
data.help_list.length === 0 &&
<div className="null-list">
<p className="tips first-tips">还没有好友为你助力,</p>
<p className="tips">赶紧去邀请好友吧!</p>
</div>
}
const data = props.data
return (
<div className="friend-list">
<p className="title">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-right.png" alt=""/>
<span>好友助力</span>
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-left.png" alt=""/>
</p>
{
data.help_list.length === 0 &&
<div className="null-list">
<p className="tips first-tips">还没有好友为你助力,</p>
<p className="tips">赶紧去邀请好友吧!</p>
</div>
}
{
data.help_list.length > 0 &&
<div className="all-list">
<p className="friend-status"><span className="FF19A0">{data.help_list.length}</span>位好友共助力<span
className="FF19A0">{data.amount - data.start_amount}</span>元</p>
<ul className="all-list-box">
{
data.help_list.length > 0 &&
<div className="all-list">
<p className="friend-status"><span className="FF19A0">{data.help_list.length}</span>位好友共助力<span
className="FF19A0">{data.amount - data.start_amount}</span>元</p>
<ul className="all-list-box">
{
data.help_list.map((item, index) => {
return (
<li className="item" key={index}>
<img className="avait" src={item.avatar} alt=""/>
<span className="time">助力时间:{item.add_time}</span>
<span className="zlprice FF19A0">{item.amount}</span>
</li>
)
})
}
</ul>
</div>
data.help_list.map((item, index) => {
return (
<li className="item" key={index}>
<img className="avait" src={item.avatar} alt=""/>
<span className="time">助力时间:{item.add_time}</span>
<span className="zlprice FF19A0">{item.amount}</span>
</li>
)
})
}
</ul>
</div>
)
}
</div>
)
}
//预售课程
function CourseList(props) {
const {data, isshowMore, getMoreCourseList, expandPaydj, expandPaywk, tostudy} = props
return (
<div className="advance-sale-course">
<p className="title">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-right.png" alt=""/>
<span>预售课程</span>
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-left.png" alt=""/>
</p>
<div className="course-list">
<ul>
const {data, isshowMore, getMoreCourseList, expandPaydj, expandPaywk, tostudy} = props
return (
<div className="advance-sale-course">
<p className="title">
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-right.png" alt=""/>
<span>预售课程</span>
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-left.png" alt=""/>
</p>
<div className="course-list">
<ul>
{
data.map((item, index) => {
return (
<li className="course-item" key={index}>
<Link to={`/getDetail?id=${item.course_id}`}>
<img className="course-img" src={item.image_name} alt=""/>
</Link>
<p className="old-price">原价:<span>¥{item.price}</span></p>
<p className="handsel">定金¥{item.deposit_amount},可抵扣¥{item.deduction_amount}</p>
<div className="btn">
{
data.map((item, index) => {
return (
<li className="course-item" key={index}>
<Link to={`/getDetail?id=${item.course_id}`}>
<img className="course-img" src={item.image_name} alt=""/>
</Link>
<p className="old-price">原价:<span>¥{item.price}</span></p>
<p className="handsel">定金¥{item.deposit_amount},可抵扣¥{item.deduction_amount}</p>
<div className="btn">
{
item.is_buy === 0 &&
<a className="to-expand-buy1"
onClick={() => expandPaydj(item.course_id)}>立即付定金</a>
}
{
item.is_buy === 1 &&
<a className="to-expand-buy2"
onClick={() => expandPaywk(item.course_id, item.start_timestamp, item.final_start_time)}>立即付尾款</a>
}
{
item.is_buy === 2 &&
<button className="to-study"
onClick={() => tostudy(item.course_id)}>开始学习</button>
}
</div>
</li>
)
})
item.is_buy === 0 &&
/*eslint-disable-next-line*/
<a className="to-expand-buy1"
href={'#'}
onClick={(e) => {
e.preventDefault()
expandPaydj(item.course_id)
}}>立即付定金</a>
}
{
item.is_buy === 1 &&
/*eslint-disable-next-line*/
<a className="to-expand-buy2"
href='#'
onClick={(e) => {
e.preventDefault()
expandPaywk(item.course_id, item.start_timestamp, item.final_start_time)
}}>立即付尾款</a>
}
{
item.is_buy === 2 &&
<button className="to-study"
onClick={() => tostudy(item.course_id)}>开始学习</button>
}
</ul>
</div>
{
isshowMore &&
<div className="more">
<div onClick={() => getMoreCourseList()}>
查看更多
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-btm.png"
alt=""/>
</div>
</div>
}
</div>
</li>
)
})
}
</ul>
</div>
{
isshowMore &&
<div className="more">
<div onClick={() => getMoreCourseList()}>
查看更多
<img src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_717/m/expand-btm.png"
alt=""/>
</div>
</div>
)
}
</div>
)
}
export default connect(
state => ({
user: state.user
}),
state => ({
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,320 +10,322 @@ import classnames from 'classnames'
const RadioItem = Radio.RadioItem
let mockData = []
let mockData
if (browser.isWeixin) {
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'}
]
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
]
} else {
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
{value: 0, label: '支付宝', icon: 'iconalipay'},
]
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
{value: 0, label: '支付宝', icon: 'iconalipay'},
]
}
class PayOrder extends Component {
constructor(props) {
super(props)
this.state = {
pay_amount: 0,
payType: 1,
stageNumber: 0,
checkPeriod: false,
singleMoney: 0,
periodNumber: 0,
orderId: getParam('oid'),
huabei: false,
fenqiList: [
{value: 'zhifubao', qishu: '3', lilv: '2.30%', everyMoney: 300, feiyong: 2.3},
{value: 'weixin', qishu: '6', lilv: '4.50%', everyMoney: 150, feiyong: 4.5},
{value: 'huabei', qishu: '9', lilv: '7.50%', everyMoney: 100, feiyong: 7.5},
],
categoryList: [],
agree: false
}
constructor(props) {
super(props)
this.state = {
pay_amount: 0,
payType: 1,
stageNumber: 0,
checkPeriod: false,
singleMoney: 0,
periodNumber: 0,
orderId: getParam('oid'),
huabei: false,
fenqiList: [
{value: 'zhifubao', qishu: '3', lilv: '2.30%', everyMoney: 300, feiyong: 2.3},
{value: 'weixin', qishu: '6', lilv: '4.50%', everyMoney: 150, feiyong: 4.5},
{value: 'huabei', qishu: '9', lilv: '7.50%', everyMoney: 100, feiyong: 7.5},
],
categoryList: [],
agree: false,
}
}
onChange = (value) => {
this.setState({
payType: value,
checkPeriod: false,
})
if (value === 2) {
this.setState({
huabei: true,
})
}
onChange = (value) => {
this.setState({
payType: value,
checkPeriod: false,
})
if (value === 2) {
this.setState({
huabei: true,
})
}
// 确定购买
pay = () => {
const {payType, orderId} = this.state
if(!this.state.agree){
return
}
if (payType === 0) {
this.alipayPay(orderId)
} else if (payType === 1) {
this.weixinPay(orderId)
}
}
// 确定购买
pay = () => {
const {payType, orderId} = this.state
if (!this.state.agree) {
return
}
// 微信支付
weixinPay = (orderId) => {
// 微信内部-支付
if (is_weixin()) {
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 {
// 微信外部-支付
http.get(`${API['base-api']}/pay/wxpay/wap_charge/oid/${orderId}`).then((res) => {
if (res.data.errno === 0) {
window.location.href = res.data.data.url + "&redirect_url=" + encodeURIComponent(window.location.href + "&weixinpay=1").toLowerCase()
} else {
Toast.info(res.data.msg, 2)
}
})
}
if (payType === 0) {
this.alipayPay(orderId)
} else if (payType === 1) {
this.weixinPay(orderId)
}
// 微信内部支付
isweixinPay = () => {
let _this = this
let weixin_code = getParam('code')
if (weixin_code) {
if (getParam('oid') === undefined) {
return
} else {
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
function onBridgeReady() {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
appId: data.appId, //公众号名称,由商户传入
timeStamp: data.timeStamp, //时间戳,自1970年以来的秒数
nonceStr: data.nonceStr, //随机串
package: data.package,
signType: data.signType, //微信签名方式:
paySign: data.paySign //微信签名
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2)
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus)
_this.intervalPayStatus = null
_this.props.history.replace(`/expand/callback?order_id=${getParam('oid')}`)
}
})
}, 1000)
} else {
alert('支付失败')
}
}
)
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
onBridgeReady()
}
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
// 微信支付
weixinPay = (orderId) => {
// 微信内部-支付
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 {
// 微信外部-支付
http.get(`${API['base-api']}/pay/wxpay/wap_charge/oid/${orderId}`).then((res) => {
if (res.data.errno === 0) {
window.location.href = res.data.data.url + "&redirect_url=" + encodeURIComponent(window.location.href + "&weixinpay=1").toLowerCase()
} else {
Toast.info(res.data.msg, 2)
}
})
}
// 支付完成之后获取状态
payCallback = () => {
const _this = this
// 支付回调
// 定时器轮训获取订单状态
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus)
_this.intervalPayStatus = null
window.location.href = '/expand/callback?order_id=' + getParam('oid')
}
})
}, 1000)
}
onBridgeReady1 = (data) => {
let _this = this
data = data || _this.BridgeData
}
// 微信内部支付
isweixinPay = () => {
let _this = this
let weixin_code = getParam('code')
if (weixin_code) {
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
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": "wx23dac6775ac82877", //公众号名称,由商户传入
"timeStamp": data.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr": data.nonceStr, //随机串
"package": data.package,
"signType": data.signType, //微信签名方式:
"paySign": data.paySign //微信签名
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
function onBridgeReady() {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
appId: data.appId, //公众号名称,由商户传入
timeStamp: data.timeStamp, //时间戳,自1970年以来的秒数
nonceStr: data.nonceStr, //随机串
package: data.package,
signType: data.signType, //微信签名方式:
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 {
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus)
_this.intervalPayStatus = null
_this.props.history.replace(`/expand/callback?order_id=${getParam('oid')}`)
}
})
}, 1000)
} else {
alert('支付失败')
}
}
},
)
}
)
}
// 支付宝支付
alipayPay = (orderId) => {
http.get(`${API['base-api']}/pay/alipay/wap_charge_new/oid/${orderId}`).then((res) => {
if (res.data.errno === 0) {
this.payCallback()
window.location = res.data.data.url
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
Toast.info(res.data.msg, 2)
onBridgeReady()
}
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
}
// 支付完成之后获取状态
payCallback = () => {
const _this = this
// 支付回调
// 定时器轮训获取订单状态
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus)
_this.intervalPayStatus = null
window.location.href = '/expand/callback?order_id=' + getParam('oid')
}
})
}, 1000)
}
componentDidMount() {
onBridgeReady1 = (data) => {
let _this = this
data = data || _this.BridgeData
if (getParam('weixinpay')) {
this.payCallback()
/* eslint-disable-next-line no-undef */
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": "wx23dac6775ac82877", //公众号名称,由商户传入
"timeStamp": data.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr": data.nonceStr, //随机串
"package": data.package,
"signType": data.signType, //微信签名方式:
"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('支付失败')
}
},
)
}
// 支付宝支付
alipayPay = (orderId) => {
http.get(`${API['base-api']}/pay/alipay/wap_charge_new/oid/${orderId}`).then((res) => {
if (res.data.errno === 0) {
this.payCallback()
window.location = res.data.data.url
} else {
Toast.info(res.data.msg, 2)
}
})
}
if (browser.isWeixin) {
this.isweixinPay(getParam('oid'))
}
componentDidMount() {
if (getParam('weixinpay')) {
this.payCallback()
}
http.post(`${API["base-api"]}/m/deposit/detail`, {
order_id: this.state.orderId
}).then(res => {
const {data} = res
if (data.errno == 200) {
this.setState({
categoryList: [data.data.course_info],
salePrice: data.data.course_info.sale_price
})
} else {
Toast.info(data.msg)
}
if (browser.isWeixin) {
this.isweixinPay(getParam('oid'))
}
http.post(`${API["base-api"]}/m/deposit/detail`, {
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,
})
} else {
Toast.info(data.msg)
}
})
}
}
changeAgreement = () => {
this.setState((prevState) => ({agree: !prevState.agree}))
}
changeAgreement = () => {
this.setState((prevState) => ({agree: !prevState.agree}))
}
render() {
const {
orderId,
salePrice,
payType,
checkPeriod,
singleMoney,
periodNumber,
categoryList,
agree
} = this.state
return (
<div className='pay-order'>
<HeaderBar title='确认支付' arrow={true}></HeaderBar>
<WhiteSpace size='sm'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>订单号</span>
<span className='number'>{orderId}</span>
</Flex>
</WingBlank>
</div>
<WhiteSpace size='md'></WhiteSpace>
{
categoryList.map((item, index) => {
const Info = (
<div className="order-info">
<p className='order-title text-overflow-one'>
<Link to={`/detail?id=${item.course_id}`}>{item.course_title}</Link>
</p>
<p className='order-content text-overflow-2'>{item.simpledescription}</p>
<p className='order-des'>
<span className='order-newprice'>¥{item.sale_price}</span>
<span className={'price-des'}>(预付定金)</span>
</p>
</div>
)
return (
<VList key={index} img={item.image_name}
id={item.course_id}
info={Info}></VList>
)
})
}
<WhiteSpace size='md'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>支付金额</span>
<span className='money'>{`¥${salePrice}`}</span>
</Flex>
</WingBlank>
</div>
render() {
const {
orderId,
salePrice,
payType,
checkPeriod,
singleMoney,
periodNumber,
categoryList,
agree,
} = this.state
return (
<div className='pay-order'>
<HeaderBar title='确认支付' arrow={true}></HeaderBar>
<WhiteSpace size='sm'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>订单号</span>
<span className='number'>{orderId}</span>
</Flex>
</WingBlank>
</div>
<WhiteSpace size='md'></WhiteSpace>
{
categoryList.map((item, index) => {
const Info = (
<div className="order-info">
<p className='order-title text-overflow-one'>
<Link to={`/detail?id=${item.course_id}`}>{item.course_title}</Link>
</p>
<p className='order-content text-overflow-2'>{item.simpledescription}</p>
<p className='order-des'>
<span className='order-newprice'>¥{item.sale_price}</span>
<span className={'price-des'}>(预付定金)</span>
</p>
</div>
)
return (
<VList key={index} img={item.image_name}
id={item.course_id}
info={Info}></VList>
)
})
}
<WhiteSpace size='md'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>支付金额</span>
<span className='money'>{`¥${salePrice}`}</span>
</Flex>
</WingBlank>
</div>
<WhiteSpace size='md'></WhiteSpace>
<List renderHeader={() => '支付方式'} className='pay-type-list'>
{mockData.map(i => (
<RadioItem
thumb={<i className={`iconfont ${i.icon} ${payType === i.value ? 'checked' : ''}`}></i>}
key={i.value}
checked={payType === i.value}
onChange={() => this.onChange(i.value)}>
{
i.value === 2 ? (
<Flex direction='column' align='start' style={{width: '100%', marginTop: '6px'}}>
<Flex direction='row' justify='between'
style={{width: '100%', paddingRight: '30px'}}>
<span style={{color: '#555555', fontSize: '14px'}}>{i.label}</span>
{
checkPeriod ? (
<span style={{
color: '#333333',
fontSize: '12px'
}}>{`${singleMoney}元 × ${periodNumber}期`}</span>
) : null
}
</Flex>
<Flex justify='start'>
<span style={{color: '#999999', fontSize: '12px'}}>支付上限受限于您的花呗额度</span>
</Flex>
</Flex>
) : (i.label)
}
</RadioItem>
))}
</List>
<Flex>
<Flex.Item className={'agreement'}>
<Checkbox.AgreeItem onChange={this.changeAgreement}>
我已同意定金不退
</Checkbox.AgreeItem>
</Flex.Item>
</Flex>
{/*<div className='pay-tip'>请在15分钟内完成支付,否则届时系统将关闭该订单。</div>*/}
<WhiteSpace size='md'></WhiteSpace>
<List renderHeader={() => '支付方式'} className='pay-type-list'>
{mockData.map(i => (
<RadioItem
thumb={<i className={`iconfont ${i.icon} ${payType === i.value ? 'checked' : ''}`}></i>}
key={i.value}
checked={payType === i.value}
onChange={() => this.onChange(i.value)}>
{
i.value === 2 ? (
<Flex direction='column' align='start' style={{width: '100%', marginTop: '6px'}}>
<Flex direction='row' justify='between'
style={{width: '100%', paddingRight: '30px'}}>
<span style={{color: '#555555', fontSize: '14px'}}>{i.label}</span>
{
checkPeriod ? (
<span style={{
color: '#333333',
fontSize: '12px',
}}>{`${singleMoney}元 × ${periodNumber}期`}</span>
) : null
}
</Flex>
<Flex justify='start'>
<span style={{color: '#999999', fontSize: '12px'}}>支付上限受限于您的花呗额度</span>
</Flex>
</Flex>
) : (i.label)
}
</RadioItem>
))}
</List>
<Flex>
<Flex.Item className={'agreement'}>
<Checkbox.AgreeItem onChange={this.changeAgreement}>
我已同意定金不退
</Checkbox.AgreeItem>
</Flex.Item>
</Flex>
{/*<div className='pay-tip'>请在15分钟内完成支付,否则届时系统将关闭该订单。</div>*/}
<div className={classnames(['pay-button', !agree && 'invalid'])} onClick={this.pay}>确认支付</div>
</div>
)
}
<div className={classnames(['pay-button', !agree && 'invalid'])} onClick={this.pay}>确认支付</div>
</div>
)
}
}
export default WithFullSize(PayOrder)
import React, { Component } from 'react'
import { Checkbox, Flex, List, Radio, Toast, WhiteSpace, WingBlank } from 'antd-mobile'
import { browser, getParam, http, is_weixin } from 'src/utils'
import { browser, getParam, http } from 'src/utils'
import { HeaderBar } from 'src/common/index'
import VlistBase from 'src/common/v-list-base'
import './index.scss'
import { WithFullSize } from 'src/HOCs'
import { Link } from "react-router-dom"
import app from "src/utils/app"
const RadioItem = Radio.RadioItem
......@@ -25,6 +24,7 @@ function OrderList({courses, toggleSelectedCourse}) {
定金折扣:<span className={'price'}>-¥{course.deduction_amount}</span>
</div>
{
// eslint-disable-next-line eqeqeq
course.coupon_amount != 0 &&
<div className={'coupon-amount'}>
使用优惠券:<span className={'price'}>-¥{course.coupon_amount}</span>
......@@ -67,20 +67,20 @@ function OrderList({courses, toggleSelectedCourse}) {
pathname: `/coupons`,
search: `?id=${course_id}`,
state: {
from: '/order'
}
from: '/order',
},
}}>
<Flex justify='between'>
<span
style={{
color: '#333',
fontSize: '15px'
fontSize: '15px',
}}
>优惠券</span>
<span
style={{
fontSize: '14px',
color: '#999999'
color: '#999999',
}}
>
{!coupon_desc ? (coupon_num === 0 ? '无' : `${coupon_num}张可用`) : (coupon_desc)}
......@@ -98,10 +98,10 @@ function OrderList({courses, toggleSelectedCourse}) {
)
}
let mockData = []
let mockData
if (browser.isWeixin) {
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'}
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
]
} else {
mockData = [
......@@ -129,7 +129,7 @@ class FinalDepositOrder extends Component {
moneyOffRules: [],
finalEndTime: '',
offset: 0,
appliedMoneyOffRule: {}
appliedMoneyOffRule: {},
}
}
......@@ -157,9 +157,9 @@ class FinalDepositOrder extends Component {
//提交
submit = () => {
this.createOrder().then(res => {
if (res.data.errno == 200) {
if (res.data.errno === 200) {
this.setState({
order_id: res.data.data.order_id
order_id: res.data.data.order_id,
}, () => {
if (res.data.data.pay_jump === 1) {
this.props.history.push('/purchased')
......@@ -176,7 +176,7 @@ class FinalDepositOrder extends Component {
//创建订单
createOrder = () => {
const {selectedCourses, salePrice, useBalance, user_account, appliedMoneyOffRule} = this.state
const {selectedCourses, salePrice, useBalance, appliedMoneyOffRule} = this.state
return http.post(`${API["base-api"]}/m/deposit/final/create`, {
course_ids: selectedCourses.map(item => item.course_id),
cut_amount: appliedMoneyOffRule.cut_amount || 0,
......@@ -184,13 +184,13 @@ class FinalDepositOrder extends Component {
is_deduction: useBalance ? 1 : 0,
deduction_amount: useBalance ? this.getBalanceOffset() : 0,
plat_form: 5,
source: getParam('source')
source: getParam('source'),
})
}
// 微信支付
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 {
// 微信外部-支付
......@@ -209,14 +209,13 @@ class FinalDepositOrder 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
function onBridgeReady() {
/* eslint-disable-next-line no-undef */
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
appId: data.appId, //公众号名称,由商户传入
......@@ -224,10 +223,10 @@ class FinalDepositOrder extends Component {
nonceStr: data.nonceStr, //随机串
package: data.package,
signType: data.signType, //微信签名方式:
paySign: data.paySign //微信签名
paySign: data.paySign, //微信签名
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
if (res.err_msg === "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2)
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
......@@ -241,7 +240,7 @@ class FinalDepositOrder extends Component {
} else {
alert('支付失败')
}
}
},
)
}
......@@ -304,17 +303,17 @@ class FinalDepositOrder extends Component {
http.get(`${API["base-api"]}/m/deposit/final/preorder`)
.then(res => {
const {data} = res
if (data.errno == 200) {
if (data.errno === 200) {
this.setState({
categoryList: [...data.data.courses],
salePrice: this.getTotalPrice({
courses: [...data.data.courses],
moneyOffRules: data.data['full_rule']
moneyOffRules: data.data['full_rule'],
}),
selectedCourses: [...data.data.courses],
user_account: data.data.user_account,
moneyOffRules: data.data['full_rule'],
finalEndTime: data.data['final_end_time']
finalEndTime: data.data['final_end_time'],
})
} else {
Toast.info(data.msg)
......@@ -326,7 +325,7 @@ class FinalDepositOrder extends Component {
// 展示余额抵扣规则
showInfo = () => {
this.setState((prevState) => ({
info: !prevState.info
info: !prevState.info,
}))
}
......@@ -334,8 +333,8 @@ class FinalDepositOrder extends Component {
toggleSelectedCourse = course => {
this.setState(prevState => {
const {selectedCourses} = prevState
let index = prevState.selectedCourses.findIndex(item => item.course_id == course.course_id)
if (index == -1) {
let index = prevState.selectedCourses.findIndex(item => item.course_id === course.course_id)
if (index === -1) {
selectedCourses.push(course)
} else {
selectedCourses.splice(index, 1)
......@@ -350,8 +349,8 @@ class FinalDepositOrder extends Component {
{
courses = this.state.selectedCourses,
useBalance = this.state.useBalance,
moneyOffRules = this.state.moneyOffRules
} = {}
moneyOffRules = this.state.moneyOffRules,
} = {},
) => {
let totalPrice = this.getOriginTotalPrice({courses})
totalPrice = this.moneyOff(totalPrice, moneyOffRules)
......@@ -369,7 +368,7 @@ class FinalDepositOrder extends Component {
let rule = rules[i]
if (result >= rule.full_amount) {
this.setState({
appliedMoneyOffRule: rule
appliedMoneyOffRule: rule,
})
return result - parseFloat(rule.cut_amount)
}
......@@ -385,7 +384,7 @@ class FinalDepositOrder extends Component {
return {
useBalance,
salePrice: totalPrice,
offset: this.getBalanceOffset(totalPrice)
offset: this.getBalanceOffset(totalPrice),
}
})
......@@ -408,7 +407,6 @@ class FinalDepositOrder extends Component {
render() {
const {
orderId,
salePrice,
payType,
categoryList,
......@@ -417,12 +415,12 @@ class FinalDepositOrder extends Component {
info,
finalEndTime,
offset,
appliedMoneyOffRule
appliedMoneyOffRule,
} = this.state
return (
<div className='deposit-pay-order'>
<HeaderBar title='课程报名' arrow={true}></HeaderBar>
<WhiteSpace size='sm' />
<WhiteSpace size='sm'/>
{/*<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
......@@ -431,10 +429,10 @@ class FinalDepositOrder extends Component {
</Flex>
</WingBlank>
</div>*/}
<WhiteSpace size='md' />
<WhiteSpace size='md'/>
<div className={'order-list'}>
<OrderList
<OrderList
courses={categoryList}
toggleSelectedCourse={this.toggleSelectedCourse}
/>
......@@ -460,9 +458,9 @@ class FinalDepositOrder extends Component {
<span style={{
color: '#FF2121',
fontSize: '15px',
marginRight: "6px"
marginRight: "6px",
}}>{`-¥${offset}`}</span>
<i
<i
className={`iconfont icondanseshixintubiao-5 balance-used`}
onClick={this.useBalance}
/>
......@@ -524,7 +522,7 @@ class FinalDepositOrder extends Component {
width: '100%',
height: '100%',
backgroundColor: 'rgba(0, 0, 0, 0.8)',
zIndex: '99'
zIndex: '99',
}}>
<div style={{
padding: '20px',
......@@ -535,14 +533,14 @@ class FinalDepositOrder extends Component {
position: 'absolute',
left: '50%',
top: '50%',
transform: 'translate(-50%, -50%)'
transform: 'translate(-50%, -50%)',
}}>
<Flex direction='column' justify='between' align='center' style={{height: '100%'}}>
<p style={{fontSize: '16px', color: '#333333'}}>余额抵扣说明</p>
<p style={{
lineHeight: '20px',
fontSize: '13px',
color: '#666666'
color: '#666666',
}}>分销课程或者参与七月在线的相关活动,可获得资金奖励。账户资金可直接提现,也可抵扣课程费用。</p>
<div onClick={this.showInfo} style={{
width: '260px',
......@@ -552,7 +550,7 @@ class FinalDepositOrder extends Component {
borderRadius: '3px',
border: '1px solid #0099FF',
color: '#0099FF',
fontSize: '15px'
fontSize: '15px',
}}>知道了
</div>
</Flex>
......
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'}
];
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
];
} else {
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
{value: 0, label: '支付宝', icon: 'iconalipay'},
// { value: 2, label: '花呗分期', icon: 'iconhuabei' },
];
mockData = [
{value: 1, label: '微信支付', icon: 'iconweixinzhifu'},
{value: 0, label: '支付宝', icon: 'iconalipay'},
// { value: 2, label: '花呗分期', icon: 'iconhuabei' },
];
}
export default class PayOrder extends Component {
constructor(props) {
super(props);
this.state = {
pay_amount: 0,
payType: 1,
stageNumber: 0,
checkPeriod: false,
singleMoney: 0,
periodNumber: 0,
orderId: getParam('oid'),
huabei: false,
fenqiList: [
{value: 'zhifubao', qishu: '3', lilv: '2.30%', everyMoney: 300, feiyong: 2.3},
{value: 'weixin', qishu: '6', lilv: '4.50%', everyMoney: 150, feiyong: 4.5},
{value: 'huabei', qishu: '9', lilv: '7.50%', everyMoney: 100, feiyong: 7.5},
],
categoryList: [],
}
constructor(props) {
super(props);
this.state = {
pay_amount: 0,
payType: 1,
stageNumber: 0,
checkPeriod: false,
singleMoney: 0,
periodNumber: 0,
orderId: getParam('oid'),
huabei: false,
fenqiList: [
{value: 'zhifubao', qishu: '3', lilv: '2.30%', everyMoney: 300, feiyong: 2.3},
{value: 'weixin', qishu: '6', lilv: '4.50%', everyMoney: 150, feiyong: 4.5},
{value: 'huabei', qishu: '9', lilv: '7.50%', everyMoney: 100, feiyong: 7.5},
],
categoryList: [],
}
}
// 支付成功后,判断并重定向
redirectAfterPay = () => {
// status:0成功,1失败
const status = getParam('status');
const type = getParam('type');
const oid = getParam('oid');
const {history} = this.props;
if (status || type) {
if (parseInt(status, 10) === 0) {
// 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);
const courseId = window.localStorage.getItem('payCourse')
courseId && history.push(`/detail?id=${courseId}`,{oid});
} else {
history.push('/purchased');
}
} else {
Toast.info('支付异常', 2);
}
// 支付成功后,判断并重定向
redirectAfterPay = () => {
// status:0成功,1失败
const status = getParam('status');
const type = getParam('type');
const oid = getParam('oid');
const {history} = this.props;
if (status || type) {
if (parseInt(status, 10) === 0) {
// type订单类型 0普通订单 1团购 2小团 3砍价 4单集购买 5定金课定金 6定金课尾款
if (parseInt(type, 10) === 2) {
history.push(`/togroup?id=${oid}`);
} else if (parseInt(type, 10) === 4) {
const courseId = window.localStorage.getItem('payCourse')
courseId && window.localStorage.setItem('payCourse', courseId);
courseId && history.push(`/detail?id=${courseId}`, {oid});
} else {
history.push('/purchased');
}
} else {
Toast.info('支付异常', 2);
}
}
}
onChange = (value) => {
this.setState({
payType: value,
checkPeriod: false,
});
if (value === 2) {
this.setState({
huabei: true,
});
}
};
checkStaging = (item) => {
// console.log(item);
this.setState({
huabei: false,
stageNumber: item.value,
singleMoney: item.everyTotal,
periodNumber: item.stage,
checkPeriod: true,
});
onChange = (value) => {
this.setState({
payType: value,
checkPeriod: false,
});
if (value === 2) {
this.setState({
huabei: true,
});
}
print = (...e) => {
console.log(e);
};
// 确定购买
pay = () => {
const {payType, orderId} = this.state;
if (payType === 0) {
this.alipayPay(orderId);
} else if (payType === 1) {
this.weixinPay(orderId)
}
// else { // 花呗分期暂时不做
// this.huabeiPay(orderId)
// }
};
checkStaging = (item) => {
// console.log(item);
this.setState({
huabei: false,
stageNumber: item.value,
singleMoney: item.everyTotal,
periodNumber: item.stage,
checkPeriod: true,
});
}
print = (...e) => {
console.log(e);
};
// 确定购买
pay = () => {
const {payType, orderId} = this.state;
if (payType === 0) {
this.alipayPay(orderId);
} else if (payType === 1) {
this.weixinPay(orderId)
}
// 微信支付
weixinPay = (orderId) => {
// 微信内部-支付
if (is_weixin()) {
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', '第一次');
// 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') > 0) {
// localStorage.setItem('a', '多次');
// let newHref = window.location.href.slice(0, window.location.href.indexOf('aa=bb')-1);
// window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=" + encodeURIComponent(newHref + "&aa=bb").toLowerCase() + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
// }
// else { // 花呗分期暂时不做
// this.huabeiPay(orderId)
// }
}
// 微信支付
weixinPay = (orderId) => {
// 微信内部-支付
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', '第一次');
// 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') > 0) {
// localStorage.setItem('a', '多次');
// let newHref = window.location.href.slice(0, window.location.href.indexOf('aa=bb')-1);
// window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=" + encodeURIComponent(newHref + "&aa=bb").toLowerCase() + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
// }
} else {
// 微信外部-支付
http.get(`${API['base-api']}/pay/wxpay/wap_charge/oid/${orderId}`).then((res) => {
// console.log(res);
if (res.data.errno === 0) {
window.location.href = res.data.data.url + "&redirect_url=" + encodeURIComponent(window.location.href + "&weixinpay=1").toLowerCase();
} else {
// 微信外部-支付
http.get(`${API['base-api']}/pay/wxpay/wap_charge/oid/${orderId}`).then((res) => {
// console.log(res);
if (res.data.errno === 0) {
window.location.href = res.data.data.url + "&redirect_url=" + encodeURIComponent(window.location.href + "&weixinpay=1").toLowerCase();
} else {
Toast.info(res.data.msg, 2)
}
})
Toast.info(res.data.msg, 2)
}
})
}
// 微信内部支付
isweixinPay = () => {
let _this = this;
let weixin_code = getParam('code');
if (weixin_code) {
if (getParam('oid') === undefined) {
return
} else {
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;
}
// 微信内部支付
isweixinPay = () => {
let _this = this;
let weixin_code = getParam('code');
if (weixin_code) {
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;
function onBridgeReady() {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
appId: data.appId, //公众号名称,由商户传入
timeStamp: data.timeStamp, //时间戳,自1970年以来的秒数
nonceStr: data.nonceStr, //随机串
package: data.package,
signType: data.signType, //微信签名方式:
paySign: data.paySign //微信签名
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2);
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus);
_this.intervalPayStatus = null;
// 获取课程类型
http.get(`${API['base-api']}/m/app_order/detail/${getParam('oid')}`).then(res => {
if (Number(res.data.data.course_type) === 2) {
_this.props.history.replace(`/togroup?id=${getParam('oid')}`);
} else {
// 跳转到已购课程 /purchased 不需要传递任何参数
_this.props.history.replace(`/purchased`);
}
});
}
})
}, 1000)
} else {
alert('支付失败')
}
}
)
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
function onBridgeReady() {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
appId: data.appId, //公众号名称,由商户传入
timeStamp: data.timeStamp, //时间戳,自1970年以来的秒数
nonceStr: data.nonceStr, //随机串
package: data.package,
signType: data.signType, //微信签名方式:
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 () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus);
_this.intervalPayStatus = null;
// 获取课程类型
http.get(`${API['base-api']}/m/app_order/detail/${getParam('oid')}`).then(res => {
if (Number(res.data.data.course_type) === 2) {
_this.props.history.replace(`/togroup?id=${getParam('oid')}`);
} else {
// 跳转到已购课程 /purchased 不需要传递任何参数
_this.props.history.replace(`/purchased`);
}
} else {
onBridgeReady();
});
}
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
}
// 支付完成之后获取状态
payCallback = () => {
const _this = this;
// 支付回调
// 定时器轮训获取订单状态
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus);
_this.intervalPayStatus = null;
// 获取课程类型
http.get(`${API['base-api']}/m/app_order/detail/${getParam('oid')}`).then(res => {
if (Number(res.data.data.course_type) === 2) {
_this.props.history.replace(`/togroup?id=${getParam('oid')}`);
} else {
// 跳转到已购课程 /purchased 不需要传递任何参数
_this.props.history.replace(`/purchased`);
}
});
}
})
}, 1000)
}
onBridgeReady1 = (data) => {
let _this = this;
data = data || _this.BridgeData;
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": "wx23dac6775ac82877", //公众号名称,由商户传入
"timeStamp": data.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr": data.nonceStr, //随机串
"package": data.package,
"signType": data.signType, //微信签名方式:
"paySign": data.paySign //微信签名
},
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
Toast.info('支付成功', 2);
_this.payCallback();
} else {
})
}, 1000)
} else {
alert('支付失败')
}
}
},
)
}
)
}
// 支付宝支付
alipayPay = (orderId) => {
http.get(`${API['base-api']}/pay/alipay/wap_charge_new/oid/${orderId}`).then((res) => {
if (res.data.errno === 0) {
this.payCallback();
window.location = res.data.data.url;
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
Toast.info(res.data.msg, 2)
onBridgeReady();
}
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
// 花呗分期 暂时不做
huabeiPay = (orderId) => {
const {singleMoney, periodNumber} = this.state;
// console.log('花呗分期支付');
http.get(`/pay/alipay/wap_charge/oid/${orderId}/plat/{plat} /hb_num/${periodNumber}`).then(res => {
// console.log(res);
if (res.data.errno === 0) {
window.location = res.data.data.url;
}
// 支付完成之后获取状态
payCallback = () => {
const _this = this;
// 支付回调
// 定时器轮训获取订单状态
_this.intervalPayStatus = setInterval(function () {
http.get(`${API['base-api']}/m/orderState/oid/${getParam('oid')}`).then(res => {
if (res.data.errno === 401) {
clearInterval(_this.intervalPayStatus);
_this.intervalPayStatus = null;
// 获取课程类型
http.get(`${API['base-api']}/m/app_order/detail/${getParam('oid')}`).then(res => {
if (Number(res.data.data.course_type) === 2) {
_this.props.history.replace(`/togroup?id=${getParam('oid')}`);
} else {
Toast.info(res.data.msg, 2)
// 跳转到已购课程 /purchased 不需要传递任何参数
_this.props.history.replace(`/purchased`);
}
});
}
componentDidMount() {
this.redirectAfterPay()
let data = {}
if(this.props.location.state && this.props.location.state.group){
data = {
order_id: this.state.orderId,
type: 2
}
} else {
data = {
order_id: this.state.orderId,
}
});
}
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) => {
let obj = {};
obj.value = item;
if (item === 1) {
obj.stage = 3; //期数
obj.moneyRate = '2.30%'; // 分期费率展示
obj.rate = 0.023; // 分期费率计算
obj.periodic = (pay_amount / 3).toFixed(2); // 每期本金
} else if (item === 2) {
obj.stage = 6; //期数
obj.moneyRate = '4.50%'; // 分期费率展示
obj.rate = 0.045; // 分期费率计算
obj.periodic = (pay_amount / 6).toFixed(2); // 每期本金
} else {
obj.stage = 12; //期数
obj.moneyRate = '7.50%'; // 分期费率展示
obj.rate = 0.075; // 分期费率计算
obj.periodic = (pay_amount / 9).toFixed(2); // 每期本金
}
obj.serviceFee = ((pay_amount * obj.rate) / obj.stage).toFixed(2); // 每期的手续费 = 总金额 * 费率 / 期数
obj.everyTotal = (parseFloat(obj.periodic) + parseFloat(obj.serviceFee)).toFixed(2);// 每期总费用 = 每期本金 + 每期手续费
fenqiList.push(obj);
});
// console.log(fenqiList);
// { value: 'zhifubao', qishu: '3', lilv: '2.30%', everyMoney: 300, feiyong: 2.3 },
// { value: 'weixin', qishu: '6', lilv: '4.50%', everyMoney: 150, feiyong: 4.5 },
// { value: 'huabei', qishu: '9', lilv: '7.50%', everyMoney: 100, feiyong: 7.5 },
this.setState({
pay_amount,
categoryList: course,
fenqiList,
});
});
if (getParam('is_class') === 1 || getParam('weixinpay')) {
this.payCallback()
})
}, 1000)
}
onBridgeReady1 = (data) => {
let _this = this;
data = data || _this.BridgeData;
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": "wx23dac6775ac82877", //公众号名称,由商户传入
"timeStamp": data.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr": data.nonceStr, //随机串
"package": data.package,
"signType": data.signType, //微信签名方式:
"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('支付失败')
}
if (is_weixin()) {
this.setState({
payType: 1
})
this.isweixinPay()
},
)
}
// 支付宝支付
alipayPay = (orderId) => {
http.get(`${API['base-api']}/pay/alipay/wap_charge_new/oid/${orderId}`).then((res) => {
if (res.data.errno === 0) {
this.payCallback();
window.location = res.data.data.url;
} else {
Toast.info(res.data.msg, 2)
}
})
}
// 花呗分期 暂时不做
huabeiPay = (orderId) => {
const {periodNumber} = this.state;
// console.log('花呗分期支付');
http.get(`/pay/alipay/wap_charge/oid/${orderId}/plat/{plat} /hb_num/${periodNumber}`).then(res => {
// console.log(res);
if (res.data.errno === 0) {
window.location = res.data.data.url;
} else {
Toast.info(res.data.msg, 2)
}
});
}
componentDidMount() {
this.redirectAfterPay()
let data
if (this.props.location.state && this.props.location.state.group) {
data = {
order_id: this.state.orderId,
type: 2,
}
} else {
data = {
order_id: this.state.orderId,
}
}
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].forEach((item) => {
let obj = {};
obj.value = item;
if (item === 1) {
obj.stage = 3; //期数
obj.moneyRate = '2.30%'; // 分期费率展示
obj.rate = 0.023; // 分期费率计算
obj.periodic = (pay_amount / 3).toFixed(2); // 每期本金
} else if (item === 2) {
obj.stage = 6; //期数
obj.moneyRate = '4.50%'; // 分期费率展示
obj.rate = 0.045; // 分期费率计算
obj.periodic = (pay_amount / 6).toFixed(2); // 每期本金
} else {
obj.stage = 12; //期数
obj.moneyRate = '7.50%'; // 分期费率展示
obj.rate = 0.075; // 分期费率计算
obj.periodic = (pay_amount / 9).toFixed(2); // 每期本金
}
obj.serviceFee = ((pay_amount * obj.rate) / obj.stage).toFixed(2); // 每期的手续费 = 总金额 * 费率 / 期数
obj.everyTotal = (parseFloat(obj.periodic) + parseFloat(obj.serviceFee)).toFixed(2);// 每期总费用 = 每期本金 + 每期手续费
fenqiList.push(obj);
});
// console.log(fenqiList);
// { value: 'zhifubao', qishu: '3', lilv: '2.30%', everyMoney: 300, feiyong: 2.3 },
// { value: 'weixin', qishu: '6', lilv: '4.50%', everyMoney: 150, feiyong: 4.5 },
// { value: 'huabei', qishu: '9', lilv: '7.50%', everyMoney: 100, feiyong: 7.5 },
this.setState({
pay_amount,
categoryList: course,
fenqiList,
});
});
if (getParam('is_class') === 1 || getParam('weixinpay')) {
this.payCallback()
}
if (browser.isWeixin) {
this.setState({
payType: 1,
})
this.isweixinPay()
}
}
render() {
const {orderId, pay_amount, payType, checkPeriod, singleMoney, periodNumber, huabei, fenqiList, categoryList, stageNumber} = this.state;
return (
<div className='pay-order'>
<HeaderBar title='确认支付' arrow={true}></HeaderBar>
<WhiteSpace size='sm'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>订单号</span>
<span className='number'>{orderId}</span>
</Flex>
</WingBlank>
</div>
<WhiteSpace size='md'></WhiteSpace>
{
categoryList.map((item, index) => {
const Info = (
<div className="order-info">
<p className='order-title text-overflow-one'>
<Link to={`/detail?id=${item.course_id}`}>{item.course_title}</Link>
</p>
<p className='order-content text-overflow-2'>{item.simpledescription}</p>
<p className='order-des'>
<span className='order-newprice'>¥{item.price1}</span>
<span className='order-price'>¥{item.price0}</span>
</p>
</div>
)
return (
<VList handleClick={this.print} key={index} img={item.image_name}
id={item.course_id}
info={Info}></VList>
)
})
}
<WhiteSpace size='md'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>支付金额</span>
<span className='money'>{`¥${pay_amount}`}</span>
</Flex>
</WingBlank>
</div>
render() {
const {orderId, pay_amount, payType, checkPeriod, singleMoney, periodNumber, huabei, fenqiList, categoryList, stageNumber} = this.state;
return (
<div className='pay-order'>
<HeaderBar title='确认支付' arrow={true}></HeaderBar>
<WhiteSpace size='sm'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>订单号</span>
<span className='number'>{orderId}</span>
</Flex>
</WingBlank>
</div>
<WhiteSpace size='md'></WhiteSpace>
{
categoryList.map((item, index) => {
const Info = (
<div className="order-info">
<p className='order-title text-overflow-one'>
<Link to={`/detail?id=${item.course_id}`}>{item.course_title}</Link>
</p>
<p className='order-content text-overflow-2'>{item.simpledescription}</p>
<p className='order-des'>
<span className='order-newprice'>¥{item.price1}</span>
<span className='order-price'>¥{item.price0}</span>
</p>
</div>
)
return (
<VList handleClick={this.print} key={index} img={item.image_name}
id={item.course_id}
info={Info}></VList>
)
})
}
<WhiteSpace size='md'></WhiteSpace>
<div className='order-number'>
<WingBlank>
<Flex justify='between' align='center' style={{height: '44px'}}>
<span>支付金额</span>
<span className='money'>{`¥${pay_amount}`}</span>
</Flex>
</WingBlank>
</div>
<WhiteSpace size='md'></WhiteSpace>
<List renderHeader={() => '支付方式'} className='pay-type-list'>
{mockData.map(i => (
<RadioItem
thumb={<i className={`iconfont ${i.icon} ${payType === i.value ? 'checked' : ''}`}></i>}
key={i.value}
checked={payType === i.value}
onChange={() => this.onChange(i.value)}>
{/* {i.label} */}
{
i.value === 2 ? (
<Flex direction='column' align='start' style={{width: '100%', marginTop: '6px'}}>
<Flex direction='row' justify='between'
style={{width: '100%', paddingRight: '30px'}}>
<span style={{color: '#555555', fontSize: '14px'}}>{i.label}</span>
{
checkPeriod ? (
<span style={{
color: '#333333',
fontSize: '12px'
}}>{`${singleMoney}元 × ${periodNumber}期`}</span>
) : null
}
</Flex>
<Flex justify='start'>
<span style={{color: '#999999', fontSize: '12px'}}>支付上限受限于您的花呗额度</span>
</Flex>
</Flex>
) : (i.label)
}
</RadioItem>
))}
</List>
<div className='pay-tip'>请在15分钟内完成支付,否则届时系统将关闭该订单。</div>
<WhiteSpace size='md'></WhiteSpace>
<List renderHeader={() => '支付方式'} className='pay-type-list'>
{mockData.map(i => (
<RadioItem
thumb={<i className={`iconfont ${i.icon} ${payType === i.value ? 'checked' : ''}`}></i>}
key={i.value}
checked={payType === i.value}
onChange={() => this.onChange(i.value)}>
{/* {i.label} */}
{
i.value === 2 ? (
<Flex direction='column' align='start' style={{width: '100%', marginTop: '6px'}}>
<Flex direction='row' justify='between'
style={{width: '100%', paddingRight: '30px'}}>
<span style={{color: '#555555', fontSize: '14px'}}>{i.label}</span>
{
checkPeriod ? (
<span style={{
color: '#333333',
fontSize: '12px',
}}>{`${singleMoney}元 × ${periodNumber}期`}</span>
) : null
}
</Flex>
<Flex justify='start'>
<span style={{color: '#999999', fontSize: '12px'}}>支付上限受限于您的花呗额度</span>
</Flex>
</Flex>
) : (i.label)
}
</RadioItem>
))}
</List>
<div className='pay-tip'>请在15分钟内完成支付,否则届时系统将关闭该订单。</div>
<div className='pay-button' onClick={this.pay}>确认支付</div>
<div className='pay-button' onClick={this.pay}>确认支付</div>
{
huabei ? (
<div className='check-staging'>
<div className='container'>
<p className='check-title'>请选择分期</p>
{fenqiList.map(i => (
<RadioItem
key={i.value}
checked={stageNumber === i.value}
onChange={() => this.checkStaging(i)}>
{`${i.everyTotal}元 × ${i.stage}期`}
<List.Item.Brief>{`手续费${i.serviceFee}元/期,费率${i.moneyRate}`}</List.Item.Brief>
</RadioItem>
))}
</div>
</div>
) : null
}
{
huabei ? (
<div className='check-staging'>
<div className='container'>
<p className='check-title'>请选择分期</p>
{fenqiList.map(i => (
<RadioItem
key={i.value}
checked={stageNumber === i.value}
onChange={() => this.checkStaging(i)}>
{`${i.everyTotal}元 × ${i.stage}期`}
<List.Item.Brief>{`手续费${i.serviceFee}元/期,费率${i.moneyRate}`}</List.Item.Brief>
</RadioItem>
))}
</div>
</div>
)
}
) : null
}
</div>
)
}
}
import React, { Component } from 'react';
import { Tabs, WhiteSpace, List, Flex, WingBlank, Modal, ListView, Toast } from 'antd-mobile';
import './scholarship.scss';
import { is_weixin, http } from "src/utils";
import { browser, http } from "src/utils";
import CategoryItem from './CategoryItem/CategoryItem.js';
import SortItem from './SortItem/SortItem.js';
import { connect } from 'react-redux';
import OpenApp from 'src/common/CallApp';
import {getCourses} from './../detail/actions';
const Item = List.Item;
@connect(state => ({
user: state.user
user: state.user,
}))
class _Scholarship extends Component {
constructor(props) {
super(props);
this.state = {
un_affirm: 0,
account: 0.00,
drawCashHtml: false,
drawCashWechat: false,
waitMoneyDetail: false,
codeSrc: '',
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
page: 1,
useBodyScroll: true,
isLoading: false,
showNoData: false,
hasMore: true,
tab: 0,
}
this.downImage = React.createRef();
this.tabIndex = 0;
this.searchObject = {};
this.rData = [];
constructor(props) {
super(props);
this.state = {
un_affirm: 0,
account: 0.00,
drawCashHtml: false,
drawCashWechat: false,
waitMoneyDetail: false,
codeSrc: '',
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
page: 1,
useBodyScroll: true,
isLoading: false,
showNoData: false,
hasMore: true,
tab: 0,
}
tabList = [
{ title: '课程列表', sub: '1' },
{ title: '分销榜单', sub: '2' },
];
// 返回上一页
goback = () => {
this.props.history.push('/my');
this.downImage = React.createRef();
this.tabIndex = 0;
this.searchObject = {};
this.rData = [];
}
tabList = [
{title: '课程列表', sub: '1'},
{title: '分销榜单', sub: '2'},
];
// 返回上一页
goback = () => {
this.props.history.push('/my');
}
// 关闭弹框
closeModal = () => {
this.setState({
drawCashWechat: false,
drawCashHtml: false,
waitMoneyDetail: false,
});
};
// 显示代收款提示modal
showDetail = () => {
this.setState({
waitMoneyDetail: true,
});
}
// 提现按钮 根据是否在微信环境中显示提示
drawCash = () => {
if (browser.isWeixin) {
this.setState({
drawCashWechat: true,
});
} else {
this.setState({
drawCashHtml: true,
});
}
// 关闭弹框
closeModal = () => {
this.setState({
drawCashWechat: false,
drawCashHtml: false,
waitMoneyDetail: false,
});
};
// 显示代收款提示modal
showDetail = () => {
this.setState({
waitMoneyDetail: true,
});
const {hasError, data = {}} = this.props.user;
if (hasError) {
Toast.info("请登录提现!", undefined, undefined, false);
return;
}
// 提现按钮 根据是否在微信环境中显示提示
drawCash = () => {
if (is_weixin()) {
this.setState({
drawCashWechat: true
});
http.get(`${API['base-api']}/wx/user_temporary_qrcode/${data.uid}`).then(res => {
if (res.data.errno === 0) {
if (browser.isWeixin) {
this.setState({
codeSrc: res.data.data.qr_image,
});
} else {
this.setState({
drawCashHtml: true
});
}
const {hasError, data = {}} = this.props.user;
if(hasError) {
Toast.info("请登录提现!", undefined, undefined, false);
return;
this.setState({
codeSrc: res.data.data.qr_image,
});
}
} else {
Toast.info(res.data.data.msg, 2);
}
http.get(`${API['base-api']}/wx/user_temporary_qrcode/${data.uid}`).then(res => {
if(res.data.errno === 0) {
if (is_weixin()) {
this.setState({
codeSrc: res.data.data.qr_image
});
} else {
this.setState({
codeSrc: res.data.data.qr_image
});
}
}else{
Toast.info(res.data.data.msg, 2);
}
});
});
};
// 去登陆
toLogin = () => {
this.props.history.push('/passport');
};
// 跳转到规则说明页
showDocument = () => {
this.props.history.push('/document');
};
// 保存二维码 TODO 失败
saveImage = () => {
};
// 分销赚钱
shareCategory = (course_id, money) => {
const {hasError, data = {}} = this.props.user;
if (hasError) {
Toast.info("请登录后分享!", undefined, undefined, false);
return;
}
http.post(`${API.home}/dist/createCode`, {course_id}).then((res) => {
if (res.data.code === 200) {
this.props.history.push(`/shareposter?courseId=${course_id}&dist_first=${money}&uid=${data.uid}&dist_code=${res.data.data.code}`)
}
})
};
onEndReached = () => {
if (this.state.isLoading || !this.state.hasMore) {
return;
}
};
// 去登陆
toLogin = () => {
this.props.history.push('/passport');
};
// 跳转到规则说明页
showDocument = () => {
this.props.history.push('/document');
};
// 保存二维码 TODO 失败
saveImage = () => {
this.setState({
isLoading: true,
});
};
// 分销赚钱
shareCategory = (course_id, money) => {
const {hasError, data = {}} = this.props.user;
if(hasError) {
Toast.info("请登录后分享!", undefined, undefined, false);
return;
}
http.post(`${API.home}/dist/createCode`, {course_id}).then((res) => {
if (res.data.code === 200) {
this.props.history.push(`/shareposter?courseId=${course_id}&dist_first=${money}&uid=${data.uid}&dist_code=${res.data.data.code}`)
}
})
};
onEndReached = () => {
if (this.state.isLoading || !this.state.hasMore) {
return;
}
let apiUrl = `${API.home}/m/dist/course_list`;
this.setState({
isLoading: true,
});
if (this.tabIndex === 1) {
apiUrl = `${API.home}/m/dist/commission_ranking_list`
}
let apiUrl = `${API.home}/m/dist/course_list`;
if (this.tabIndex === 1) { apiUrl = `${API.home}/m/dist/commission_ranking_list` };
http.get(apiUrl).then((res) => {
if (res.data.code !== 200) {
this.setState({isLoading: false});
return;
}
http.get(apiUrl).then((res) => {
if (res.data.code !== 200) {
this.setState({ isLoading: false });
return;
}
let newData = [];
if (this.tabIndex === 0) {
if (!res.data.data.list || res.data.data.list.length === 0) {
this.setState({isLoading: false, hasMore: false, showNoData: this.searchObject.page === 1});
return;
}
newData = res.data.data.list;
} else {
if (!res.data.data || res.data.data.length === 0) {
this.setState({isLoading: false, hasMore: false, showNoData: this.searchObject.page === 1});
return;
}
newData = res.data.data;
}
let newData = [];
if(this.tabIndex === 0) {
if (!res.data.data.list || res.data.data.list.length === 0) {
this.setState({ isLoading: false, hasMore: false, showNoData: this.searchObject.page === 1 });
return;
}
newData = res.data.data.list;
} else {
if (!res.data.data || res.data.data.length === 0) {
this.setState({ isLoading: false, hasMore: false, showNoData: this.searchObject.page === 1 });
return;
}
newData = res.data.data;
}
this.searchObject.page++;
this.searchObject.page++;
this.rData = [...this.rData, ...newData];
this.rData = [...this.rData, ...newData];
this.setState({
dataSource: this.state.dataSource.cloneWithRows(this.rData),
isLoading: false,
// hasMore: newData.length >= 10,
hasMore: false,
});
})
.catch(() => {
this.setState({isLoading: false});
});
}
this.setState({
dataSource: this.state.dataSource.cloneWithRows(this.rData),
isLoading: false,
// hasMore: newData.length >= 10,
hasMore: false
});
})
.catch(() => {
this.setState({ isLoading: false });
});
componentDidMount() {
if (this.state.useBodyScroll) {
document.body.style.overflow = 'auto';
} else {
document.body.style.overflow = 'hidden';
}
componentDidMount() {
if (this.state.useBodyScroll) {
document.body.style.overflow = 'auto';
} else {
document.body.style.overflow = 'hidden';
}
http.get(`${API.home}/m/user_account`).then(res=>{
if(res.data.code === 200) {
this.setState({
...res.data.data
});
}
http.get(`${API.home}/m/user_account`).then(res => {
if (res.data.code === 200) {
this.setState({
...res.data.data,
});
this.onEndReached();
}
}
});
this.onEndReached();
}
toCourseDetail = (id) => {
const { dispatch, history } = this.props;
// dispatch(getCourses(id, () => {
history.push(`/detail?id=${id}`)
// }));
}
toCourseDetail = (id) => {
const {history} = this.props;
history.push(`/detail?id=${id}`)
}
render() {
const row = (
rowData,
rowID
) => {
return (
<CategoryItem
{...rowData}
key={rowID}
share={this.shareCategory}
toDetail={this.toCourseDetail}
/>
);
};
const row1 = (
rowData,
rowID
) => {
return <SortItem {...rowData} sortNum={this.rData.indexOf(rowData) + 1} key={rowID} />;
};
const separator = (sectionID, rowID) => (
<div key={`${sectionID}-${rowID}`}>
<WhiteSpace />
</div>
);
const {
un_affirm,
account,
drawCashHtml,
drawCashWechat,
waitMoneyDetail,
codeSrc,
} = this.state;
const { hasError } = this.props.user;
return (
<div className={'scholarship'}>
<div className={'account-container'}>
<WhiteSpace></WhiteSpace>
<WingBlank>
<Flex justify='between'>
<i className={'iconfont iconiconfront-68 back'} onClick={this.goback}></i>
<span className={"common-ft-15"}>账户资金</span>
<i className={'iconfont iconiconfront-22 tip-info'} onClick={this.showDocument}></i>
</Flex>
</WingBlank>
<WhiteSpace></WhiteSpace>
<WingBlank>
render() {
const row = (
rowData,
rowID,
) => {
return (
<CategoryItem
{...rowData}
key={rowID}
share={this.shareCategory}
toDetail={this.toCourseDetail}
/>
);
};
const row1 = (
rowData,
rowID,
) => {
return <SortItem {...rowData} sortNum={this.rData.indexOf(rowData) + 1} key={rowID}/>;
};
/* eslint-disable-next-line no-unused-vars*/
const separator = (sectionID, rowID) => (
<div key={`${sectionID}-${rowID}`}>
<WhiteSpace/>
</div>
);
const {
un_affirm,
account,
drawCashHtml,
drawCashWechat,
waitMoneyDetail,
codeSrc,
} = this.state;
const {hasError} = this.props.user;
return (
<div className={'scholarship'}>
<div className={'account-container'}>
<WhiteSpace></WhiteSpace>
<WingBlank>
<Flex justify='between'>
<i className={'iconfont iconiconfront-68 back'} onClick={this.goback}></i>
<span className={"common-ft-15"}>账户资金</span>
<i className={'iconfont iconiconfront-22 tip-info'} onClick={this.showDocument}></i>
</Flex>
</WingBlank>
<WhiteSpace></WhiteSpace>
<WingBlank>
<span className={'common-ft-14'}>
可提现余额:
</span>
</WingBlank>
<WhiteSpace></WhiteSpace>
{
hasError ? (
<>
<WhiteSpace></WhiteSpace>
<Flex justify='center'>
<div className={'login-check'} onClick={this.toLogin}>登录后查看</div>
</Flex>
</>
) : (
<>
<Flex justify='center' align='baseline' className={"drawCash"} >
<span className={'common-ft-25'}>{account}</span>
<span className={'common-ft-15'}></span>
</Flex>
<WhiteSpace></WhiteSpace>
<Flex justify='center'>
<div className={'draw-cash'} onClick={this.drawCash}>提现</div>
</Flex>
</>
)
}
</div>
</WingBlank>
<WhiteSpace></WhiteSpace>
{
hasError ? (
<>
<WhiteSpace></WhiteSpace>
<Flex justify='center'>
<div className={'login-check'} onClick={this.toLogin}>登录后查看</div>
</Flex>
</>
) : (
<>
<Flex justify='center' align='baseline' className={"drawCash"}>
<span className={'common-ft-25'}>{account}</span>
<span className={'common-ft-15'}></span>
</Flex>
<WhiteSpace></WhiteSpace>
<Flex justify='center'>
<div className={'draw-cash'} onClick={this.drawCash}>提现</div>
</Flex>
</>
)
}
</div>
<div className={'over-am-list-item'} >
{
hasError ? (null) : (
<>
<div>
<List>
<Item
arrow="horizontal"
style={{ padding: '0 0 0 15px' }}
onClick={this.showDetail}
>
<Flex direction='row' justify='between'>
<span className={'common-ft-15'}>待确认金额</span>
<span className={'money'}>{un_affirm}</span>
</Flex>
</Item>
</List>
</div>
<WhiteSpace></WhiteSpace>
</>
)
}
<div style={{ backgroundColor: '#FFF' }}>
<Tabs tabs={this.tabList}
initialPage={0}
swipeable={false}
// onChange={this.changeTab}
onChange={(tab, index) => {
this.tabIndex = index;
this.pageIndex = 1;
this.rData = [];
this.searchObject.page = 1;
this.setState(
{
isLoading: false,
hasMore: true,
dataSource: this.state.dataSource.cloneWithRows(this.rData),
tab: index,
},
() => {
this.onEndReached();
}
);
}}
<div className={'over-am-list-item'}>
{
hasError ? null : <>
<div>
<List>
<Item
arrow="horizontal"
style={{padding: '0 0 0 15px'}}
onClick={this.showDetail}
>
</Tabs>
{
this.state.tab === 0 ? (
<div style={{ marginTop: '15px', backgroundColor: '#FFF' }}>
{
this.state.dataSource._cachedRowCount !== 0 ? (
<ListView
useBodyScroll={this.state.useBodyScroll}
dataSource={this.state.dataSource}
renderRow={row}
renderBodyComponent={() => <div />}
onEndReached={this.onEndReached}
pageSize={4}
onEndReachedThreshold={100}
/>
) : (
null
)
}
</div>
) : null
}
{
this.state.tab === 1 ? (
<div>
<Flex justify='center' align='center' className={'runtimeList'}>榜单实时更新,仅显示前50</Flex>
{
this.state.dataSource._cachedRowCount !== 0 ? (
<ListView
useBodyScroll={this.state.useBodyScroll}
dataSource={this.state.dataSource}
renderRow={row1}
renderBodyComponent={() => <div />}
onEndReached={this.onEndReached}
pageSize={4}
onEndReachedThreshold={100}
/>
) : (
null
)
}
</div>
) : null
}
</div>
<Flex direction='row' justify='between'>
<span className={'common-ft-15'}>待确认金额</span>
<span className={'money'}>{un_affirm}</span>
</Flex>
</Item>
</List>
</div>
<WhiteSpace></WhiteSpace>
</>
}
<div style={{backgroundColor: '#FFF'}}>
<Tabs tabs={this.tabList}
initialPage={0}
swipeable={false}
// onChange={this.changeTab}
onChange={(tab, index) => {
this.tabIndex = index;
this.pageIndex = 1;
this.rData = [];
this.searchObject.page = 1;
this.setState(
{
isLoading: false,
hasMore: true,
dataSource: this.state.dataSource.cloneWithRows(this.rData),
tab: index,
},
() => {
this.onEndReached();
},
);
}}
>
</Tabs>
{
this.state.tab === 0 ? (
<div style={{marginTop: '15px', backgroundColor: '#FFF'}}>
{
this.state.dataSource._cachedRowCount !== 0 ? (
<ListView
useBodyScroll={this.state.useBodyScroll}
dataSource={this.state.dataSource}
renderRow={row}
renderBodyComponent={() => <div/>}
onEndReached={this.onEndReached}
pageSize={4}
onEndReachedThreshold={100}
/>
) : null
}
<Modal
visible={drawCashWechat}
transparent
maskClosable={true}
onClose={this.closeModal}
title="提现"
footer={[{ text: '确认', onPress: () => { this.closeModal() } }]}
className={'wechatModal'}
style={{ width: '300px' }}
>
<p style={{ fontSize: '13px', color: '#666666' }}>
提现金额将通过微信零钱转账给您,识别下方二维码,关注【七月在线】服务号申请提现。
</p>
<WhiteSpace size='sm'></WhiteSpace>
<Flex justify='center'>
<img src={codeSrc} style={{ width: '90px', height: '90px', backgroundColor: '#666' }} alt="二维码" />
</Flex>
</Modal>
<Modal
visible={drawCashHtml}
transparent
maskClosable={true}
onClose={this.closeModal}
style={{ width: '300px'}}
>
<p style={{color: '#333333', fontSize: '16px', textAlign: 'center'}}>提现</p>
<WhiteSpace size='lg'></WhiteSpace>
<p style={{ fontSize: '12px', color: '#666666', textAlign: 'left' }}>
提现金额将通过微信零钱转账给您,请微信扫码关注【七月在线】服务号后申请提现。
</p>
<WhiteSpace size='lg'></WhiteSpace>
<Flex justify='center'>
<img src={codeSrc} style={{ width: '90px', height: '90px' }} alt="二维码" />
</Flex>
<WhiteSpace size='sm'></WhiteSpace>
<Flex justify='center' style={{color: '#333333', fontSize: '12px'}}>长按二维码保存到相册</Flex>
<i onClick={this.closeModal} className='iconfont iconiconfront-2' style={{zIndex: 99, fontSize: '40px', color: '#fff', position: "fixed", top: '70%', left: '50%', transform: 'translateX(-50%)'}}></i>
</Modal>
<Modal
visible={waitMoneyDetail}
transparent
maskClosable={true}
onClose={this.closeModal}
title="待确认金额"
footer={[
{ text: '知道了', onPress: () => { this.closeModal() } }
]}
style={{ width: '300px' }}
>
<p style={{ fontSize: '13px', color: '#666666', textAlign: 'left', lineHeight: '20px' }}>
1.尚未开课的直播课程,用户购买后归属您的佣金会暂时存放在『待确认金额』中。
</p>
<p style={{ fontSize: '13px', color: '#666666', textAlign: 'left', lineHeight: '20px' }}>
2.该课程正式开课时,如果用户没有退款,对应的订单金额会自动转入您的账号余额,否则该佣金会自动收回。
</p>
<WhiteSpace></WhiteSpace>
<Flex style={{ fontSize: '14px', color: '#0099FF' }} justify='center'>
<span style={{color: "#333", marginRight: '10px'}}>待确认订单详情可</span>
<OpenApp className='toApp' text='前往APP查看'/>
</Flex>
</Modal>
</div>
)
}
</div>
) : null
}
{
this.state.tab === 1 ? (
<div>
<Flex justify='center' align='center' className={'runtimeList'}>榜单实时更新,仅显示前50</Flex>
{
this.state.dataSource._cachedRowCount !== 0 ? (
<ListView
useBodyScroll={this.state.useBodyScroll}
dataSource={this.state.dataSource}
renderRow={row1}
renderBodyComponent={() => <div/>}
onEndReached={this.onEndReached}
pageSize={4}
onEndReachedThreshold={100}
/>
) : null
}
</div>
) : null
}
</div>
</div>
<Modal
visible={drawCashWechat}
transparent
maskClosable={true}
onClose={this.closeModal}
title="提现"
footer={[{
text: '确认', onPress: () => {
this.closeModal()
},
}]}
className={'wechatModal'}
style={{width: '300px'}}
>
<p style={{fontSize: '13px', color: '#666666'}}>
提现金额将通过微信零钱转账给您,识别下方二维码,关注【七月在线】服务号申请提现。
</p>
<WhiteSpace size='sm'></WhiteSpace>
<Flex justify='center'>
<img src={codeSrc} style={{width: '90px', height: '90px', backgroundColor: '#666'}} alt="二维码"/>
</Flex>
</Modal>
<Modal
visible={drawCashHtml}
transparent
maskClosable={true}
onClose={this.closeModal}
style={{width: '300px'}}
>
<p style={{color: '#333333', fontSize: '16px', textAlign: 'center'}}>提现</p>
<WhiteSpace size='lg'></WhiteSpace>
<p style={{fontSize: '12px', color: '#666666', textAlign: 'left'}}>
提现金额将通过微信零钱转账给您,请微信扫码关注【七月在线】服务号后申请提现。
</p>
<WhiteSpace size='lg'></WhiteSpace>
<Flex justify='center'>
<img src={codeSrc} style={{width: '90px', height: '90px'}} alt="二维码"/>
</Flex>
<WhiteSpace size='sm'></WhiteSpace>
<Flex justify='center' style={{color: '#333333', fontSize: '12px'}}>长按二维码保存到相册</Flex>
<i onClick={this.closeModal} className='iconfont iconiconfront-2' style={{
zIndex: 99,
fontSize: '40px',
color: '#fff',
position: "fixed",
top: '70%',
left: '50%',
transform: 'translateX(-50%)',
}}></i>
</Modal>
<Modal
visible={waitMoneyDetail}
transparent
maskClosable={true}
onClose={this.closeModal}
title="待确认金额"
footer={[
{
text: '知道了', onPress: () => {
this.closeModal()
},
},
]}
style={{width: '300px'}}
>
<p style={{fontSize: '13px', color: '#666666', textAlign: 'left', lineHeight: '20px'}}>
1.尚未开课的直播课程,用户购买后归属您的佣金会暂时存放在『待确认金额』中。
</p>
<p style={{fontSize: '13px', color: '#666666', textAlign: 'left', lineHeight: '20px'}}>
2.该课程正式开课时,如果用户没有退款,对应的订单金额会自动转入您的账号余额,否则该佣金会自动收回。
</p>
<WhiteSpace></WhiteSpace>
<Flex style={{fontSize: '14px', color: '#0099FF'}} justify='center'>
<span style={{color: "#333", marginRight: '10px'}}>待确认订单详情可</span>
<OpenApp className='toApp' text='前往APP查看'/>
</Flex>
</Modal>
</div>
)
}
}
// const mapStateToProps = (state) => {
// return {
// user: {
......
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