Commit 41928359 by xuzhenghua
parents 96f33f94 baec7b62
......@@ -29,7 +29,7 @@ class App extends Component {
super(props)
this.state = {
isShowActivityEntry: 0,
isShowChannel: 0
isShowChannel: 0,
}
this.globalEntry = null
}
......@@ -66,11 +66,13 @@ class App extends Component {
sessionStorage.setItem('enter_url', window.location.href)
}
this.getUser()
this.utm()
const {history} = this.props
this.getUser()
this.setNavigationRecord(this.props.location, this.props.history.action)
this.setPreviousLocation()
......@@ -95,9 +97,9 @@ class App extends Component {
from: {
pathname: this.previousLocation.pathname,
search: this.previousLocation.search,
hash: this.previousLocation.hash
}
}
hash: this.previousLocation.hash,
},
},
}
} else {
this.removeShareCodeCookie()
......@@ -114,7 +116,7 @@ class App extends Component {
// treasure_stage,宝箱阶段,0-不在活动时间,1-活动时间内
this.setState({
isShowActivityEntry: data.treasure_stage,
isShowChannel: data.is_show_site_window_by_channel
isShowChannel: data.is_show_site_window_by_channel,
}, () => {
data.treasure_stage && this.bindGlobalEntry()
})
......@@ -171,7 +173,7 @@ class App extends Component {
if (zhihu_cb) {
let data = {
'zhihu_cb': zhihu_cb
'zhihu_cb': zhihu_cb,
}
http.post(`${API['home']}/sys/zhihu/firstRecord`, data)
......@@ -220,11 +222,12 @@ class App extends Component {
} else {
http.get(`${API.home}/m/user_info`).then(res => {
if (this.props.location.pathname !== '/my') {
http.get(`${API.home}/m/user_info_sample/0`).then(res => {
this.props.setCurrentUser(this.transformUser(res))
})
}
}
}
componentDidUpdate() {
......@@ -253,8 +256,8 @@ class App extends Component {
user_name: username,
is_vip: isVIP,
uid,
code
}
code,
},
} = res.data
payload = {
......@@ -265,15 +268,15 @@ class App extends Component {
isVIP,
avatar,
uid,
code
}
code,
},
}
} else {
payload = {
hasError: true,
msg: res.data.msg,
code: res.data.code,
data: {}
data: {},
}
}
return payload
......@@ -284,7 +287,7 @@ class App extends Component {
if (data.errno == 200) {
//移除红包统计cookie
this.removeShareCodeCookie()
let {uid, token, avatar_file: avatar, uname: username,} = data.data
let {uid, token, avatar_file: avatar, uname: username} = data.data
return {
hasError: false,
......@@ -292,9 +295,9 @@ class App extends Component {
uid,
token,
avatar,
username
username,
},
msg: data.msg
msg: data.msg,
}
} else {
let {code, msg} = data.data
......@@ -302,7 +305,7 @@ class App extends Component {
code,
msg,
hasError: true,
data: {}
data: {},
}
}
}
......@@ -338,7 +341,7 @@ class App extends Component {
closeGlobalEntry = () => {
localStorage.setItem('globalEntryClosedTime', Date.now().toString())
this.setState({
isShowActivityEntry: 0
isShowActivityEntry: 0,
})
}
......@@ -374,7 +377,7 @@ class App extends Component {
export default compose(
connect(
state => ({user: state.user}),
{setCurrentUser, startFetchUser}
{setCurrentUser, startFetchUser},
),
withRouter
withRouter,
)(App)
......@@ -5,19 +5,19 @@ import { WithTab } from '@/HOCs'
// import Swiper from 'react-mobile-swiper'
// import createStyle from './createStyle'
import HomeCourseList from './course-list'
import { http } from '@/utils'
import { http, isValidUrl } from '@/utils'
import LiveRoom from './liveRoom'
import { Link } from "react-router-dom"
import { Toast } from 'antd-mobile'
import { connect } from "react-redux";
import TopSwiper from './TopSwiper'
import ExpandActiveToast from './expandActiveToast'
// import ExpandActiveToast from './expandActiveToast'
import AllCourseNavigation from "./all-course"
// const animateTypes = Swiper.animateTypes
@connect(state => ({
user: state.user
user: state.user,
}))
class Index extends Component {
constructor(props) {
......@@ -33,28 +33,28 @@ class Index extends Component {
{
'src': require('./image/freeclass_icon.png'),
'name': '公开课',
'href': '/study/free-course'
'href': '/study/free-course',
},
{
'src': require('./image/jingpin_icon.png'),
'name': '精品特惠',
'href': '/preferential'
'href': '/preferential',
},
{
'src': require('./image/zjxj_icon.png'),
'name': '赚奖学金',
'href': '/scholarship'
'href': '/scholarship',
},
{
'src': require('./image/mryt_icon.png'),
'name': '每日一题',
'href': '/examination'
'href': '/examination',
},
{
'src': require('./image/shequ_icon.png'),
'name': '社区',
'href': 'https://ask.julyedu.com'
}
'href': 'https://ask.julyedu.com',
},
],
}
}
......@@ -72,7 +72,7 @@ class Index extends Component {
this.setState({
banner: data.banner,
lives: data.lives,
modules
modules,
})
} else {
Toast.info(res.data.msg, 2)
......@@ -93,7 +93,7 @@ class Index extends Component {
this.setState({
isShow: true,
islive: true,
roomMess: item
roomMess: item,
})
} else {
window.location.href = `${window.location.href.includes('pre') ? 'http://www-pre.julyedu.com' : 'http://www.julyedu.com'}/live/m_room/${item.room_id}`
......@@ -131,7 +131,8 @@ class Index extends Component {
<div className='zw_height'></div>
<ExpandActiveToast/>
{/*支付尾款提示*/}
{/*<ExpandActiveToast/>*/}
<div className='index-swiper'>
{
......@@ -146,10 +147,18 @@ class Index extends Component {
this.state.tabdata.map((item, index) => {
return (
<li key={index}>
<a href={item.href}>
{
isValidUrl(item.href)
? <a href={item.href}>
<img src={item.src} alt=""/>
<span>{item.name}</span>
</a>
: <Link to={item.href}>
<img src={item.src} alt=""/>
<span>{item.name}</span>
</Link>
}
</li>
)
})
......
import React, {PureComponent} from 'react'
import {Flex, WhiteSpace, List} from 'antd-mobile'
import React, { PureComponent } from 'react'
import { Flex, WhiteSpace, List } from 'antd-mobile'
import './index.scss'
import Avatar from './image/avatar.png'
import Vip from './image/vip.png'
import {WithTab} from '@/HOCs'
import {Link} from "react-router-dom"
import {connect} from "react-redux"
import {HeaderBar} from "@/common"
import {getCourses} from './../detail/actions';
import { WithTab } from '@/HOCs'
import { Link } from "react-router-dom"
import { connect } from "react-redux"
import { HeaderBar } from "@/common"
import { http } from "@/utils"
import { getCourses } from './../detail/actions';
import { setCurrentUser, startFetchUser } from "@/store/userAction"
const Item = List.Item;
const Brief = Item.Brief;
@connect(state => ({
user: state.user
}))
user: state.user,
}), {startFetchUser, setCurrentUser})
class My extends PureComponent {
constructor(props) {
super(props)
this.state = {
data: []
data: [],
}
}
componentDidMount() {
this.getUser()
}
getUser = () => {
this.props.startFetchUser()
http.get(`${API.home}/m/user_info_sample/1`).then(res => {
this.props.setCurrentUser(this.transformUser(res))
})
}
transformUser = res => {
let payload
if (res.data.code === 200) {
const {
msg, data: {
avatar_file: avatar,
user_name: username,
is_vip: isVIP,
uid,
code,
},
} = res.data
payload = {
hasError: false,
msg,
data: {
username,
isVIP,
avatar,
uid,
code,
},
}
} else {
payload = {
hasError: true,
msg: res.data.msg,
code: res.data.code,
data: {},
}
}
return payload
}
// 去登录
......@@ -29,7 +79,7 @@ class My extends PureComponent {
}
toCourseDetail = (id) => {
const { dispatch, history } = this.props;
const {dispatch, history} = this.props;
// dispatch(getCourses(id, () => {
history.push(`/detail?id=${id}`);
return false;
......@@ -117,8 +167,8 @@ class My extends PureComponent {
<Link to={{
pathname: '/coupons',
state: {
from: this.props.location.pathname
}
from: this.props.location.pathname,
},
}}>
<Item arrow="horizontal" className="no-border">
<i className="iconfont iconiconfront-52"></i>
......
......@@ -2,16 +2,6 @@ import React from 'react'
import { Switch, Route } from 'react-router-dom'
import RouterConfig from './router-config'
import PrivateRoute from './privateRoute'
// 动态改变title
// const RouteWithSubRoutes = route => {
// return (
// <Route
// exact
// {...route}
// onChange={document.title = route.name}
// />
// );
// };
export default function () {
return (
......@@ -21,8 +11,11 @@ export default function () {
if (isPrivate) {
return <PrivateRoute {...rest} key={index}/>
} else {
const {component: Component, ...rest} = item
return (
<Route {...rest} key={index}/>
<Route {...rest} key={index} render={(props) => {
return <Component {...props}/>
}}/>
)
}
})}
......
......@@ -3,7 +3,7 @@ import {
differenceInDays,
differenceInHours,
differenceInMinutes,
differenceInSeconds
differenceInSeconds,
} from 'date-fns'
......@@ -15,7 +15,7 @@ export const getParam = (key, str) => {
}
const html = content => ({
__html: htmlDecode(content)
__html: htmlDecode(content),
})
const htmlDecode = content => {
......@@ -102,7 +102,7 @@ const browser = (function () {
isIOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(ua),
isIPad: /iPad/i.test(ua),
isAndroidApp: /Android/i.test(ua) && getParam('version'),
isIOSApp: /iPhone/i.test(ua) && getParam('version')
isIOSApp: /iPhone/i.test(ua) && getParam('version'),
}
})()
......@@ -119,17 +119,21 @@ const dateCountDown = (later, earlier) => {
d,
h,
m,
s
s,
}
}
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)
}
export {
default as http
default as http,
}
from './http'
export {
default as wxShare
default as wxShare,
}
from './wechat/share'
export {
......@@ -141,8 +145,9 @@ export {
browser,
isLogin,
dateCountDown,
isValidUrl
}
export {
default as SendMessageToApp
default as SendMessageToApp,
}
from './app'
\ 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