Commit db7aed83 by FE

pull pre

parent 429a2a21
...@@ -1508,11 +1508,6 @@ ...@@ -1508,11 +1508,6 @@
"minimist": "^1.2.0" "minimist": "^1.2.0"
} }
}, },
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"resolve": { "resolve": {
"version": "1.10.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz",
...@@ -1598,6 +1593,11 @@ ...@@ -1598,6 +1593,11 @@
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA=="
}, },
"lodash": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"ms": { "ms": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
...@@ -3984,6 +3984,14 @@ ...@@ -3984,6 +3984,14 @@
"resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
"integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40="
}, },
"copy-to-clipboard": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.2.0.tgz",
"integrity": "sha512-eOZERzvCmxS8HWzugj4Uxl8OJxa7T2k1Gi0X5qavwydHIfuSHq2dTD09LOg/XyGq4Zpb5IsR/2OJ5lbOegz78w==",
"requires": {
"toggle-selection": "^1.0.6"
}
},
"core-js": { "core-js": {
"version": "2.6.5", "version": "2.6.5",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz",
...@@ -5405,9 +5413,12 @@ ...@@ -5405,9 +5413,12 @@
} }
}, },
"eslint-utils": { "eslint-utils": {
"version": "1.3.1", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz",
"integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==" "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==",
"requires": {
"eslint-visitor-keys": "^1.0.0"
}
}, },
"eslint-visitor-keys": { "eslint-visitor-keys": {
"version": "1.0.0", "version": "1.0.0",
...@@ -9252,9 +9263,9 @@ ...@@ -9252,9 +9263,9 @@
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=" "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4="
}, },
"lodash.mergewith": { "lodash.mergewith": {
"version": "4.6.1", "version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz",
"integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==" "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ=="
}, },
"lodash.sortby": { "lodash.sortby": {
"version": "4.7.0", "version": "4.7.0",
...@@ -9736,9 +9747,9 @@ ...@@ -9736,9 +9747,9 @@
} }
}, },
"mixin-deep": { "mixin-deep": {
"version": "1.3.1", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
"integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
"requires": { "requires": {
"for-in": "^1.0.2", "for-in": "^1.0.2",
"is-extendable": "^1.0.1" "is-extendable": "^1.0.1"
...@@ -12068,6 +12079,15 @@ ...@@ -12068,6 +12079,15 @@
} }
} }
}, },
"react-copy-to-clipboard": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/react-copy-to-clipboard/-/react-copy-to-clipboard-5.0.1.tgz",
"integrity": "sha512-ELKq31/E3zjFs5rDWNCfFL4NvNFQvGRoJdAKReD/rUPA+xxiLPQmZBZBvy2vgH7V0GE9isIQpT9WXbwIVErYdA==",
"requires": {
"copy-to-clipboard": "^3",
"prop-types": "^15.5.8"
}
},
"react-dev-utils": { "react-dev-utils": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-8.0.0.tgz", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-8.0.0.tgz",
...@@ -13325,9 +13345,9 @@ ...@@ -13325,9 +13345,9 @@
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
}, },
"set-value": { "set-value": {
"version": "2.0.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
"integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
"requires": { "requires": {
"extend-shallow": "^2.0.1", "extend-shallow": "^2.0.1",
"is-extendable": "^0.1.1", "is-extendable": "^0.1.1",
...@@ -14472,6 +14492,11 @@ ...@@ -14472,6 +14492,11 @@
"repeat-string": "^1.6.1" "repeat-string": "^1.6.1"
} }
}, },
"toggle-selection": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz",
"integrity": "sha1-bkWxJj8gF/oKzH2J14sVuL932jI="
},
"topo": { "topo": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/topo/-/topo-2.0.2.tgz", "resolved": "https://registry.npmjs.org/topo/-/topo-2.0.2.tgz",
...@@ -14657,35 +14682,14 @@ ...@@ -14657,35 +14682,14 @@
} }
}, },
"union-value": { "union-value": {
"version": "1.0.0", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
"integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
"requires": { "requires": {
"arr-union": "^3.1.0", "arr-union": "^3.1.0",
"get-value": "^2.0.6", "get-value": "^2.0.6",
"is-extendable": "^0.1.1", "is-extendable": "^0.1.1",
"set-value": "^0.4.3" "set-value": "^2.0.1"
},
"dependencies": {
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"requires": {
"is-extendable": "^0.1.0"
}
},
"set-value": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
"integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
"requires": {
"extend-shallow": "^2.0.1",
"is-extendable": "^0.1.1",
"is-plain-object": "^2.0.1",
"to-object-path": "^0.3.0"
}
}
} }
}, },
"uniq": { "uniq": {
......
...@@ -44,6 +44,8 @@ class App extends Component { ...@@ -44,6 +44,8 @@ class App extends Component {
script.language = 'JavaScript'; script.language = 'JavaScript';
document.body.appendChild(script); document.body.appendChild(script);
this.setNavigationRecord(this.props.location)
//平台信息 //平台信息
cookie.set('plat', '5', {domain: '.julyedu.com'}) cookie.set('plat', '5', {domain: '.julyedu.com'})
...@@ -56,8 +58,9 @@ class App extends Component { ...@@ -56,8 +58,9 @@ class App extends Component {
const routeMatchRule = /binding-tel|forgot|set-password/ const routeMatchRule = /binding-tel|forgot|set-password/
const {history} = this.props const {history} = this.props
history.listen(location => { history.listen((location, action) => {
if(cookie.get('uid') && this.props.user.hasError){ this.setNavigationRecord(location)
if (cookie.get('uid') && this.props.user.hasError) {
this.getUser() this.getUser()
} }
const {pathname} = location const {pathname} = location
...@@ -70,9 +73,19 @@ class App extends Component { ...@@ -70,9 +73,19 @@ class App extends Component {
}) })
}
setNavigationRecord = (location) => {
let {location: _location} = this.props
let {state: _state = {}} = _location
let {state = {}} = location
location.state = {
...state, ...{
record: _state.record ?
[..._state.record, {pathname: location.pathname}] :
[{pathname: location.pathname}]
}
}
} }
getUser = () => { getUser = () => {
......
...@@ -9,10 +9,15 @@ class HeaderBar extends Component { ...@@ -9,10 +9,15 @@ class HeaderBar extends Component {
} }
goBack = () => { goBack = () => {
const {state} = this.props.location
if(browser.isWeixin && getParam('code') && getParam('state')){ if(browser.isWeixin && getParam('code') && getParam('state')){
window.history.go(-2) window.history.go(-2)
} }
if(state.record && state.record.length > 1){
window.history.go(-1); window.history.go(-1);
}else{
window.location.href = window.location.origin
}
} }
toLink = () => { toLink = () => {
......
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import {connect} from 'react-redux';
import SearchHeader from './searchHead' import SearchHeader from './searchHead'
import VList from '@/common/VList' import VList from '@/common/VList'
import { http, getParam } from '@/utils' import { http, getParam } from '@/utils'
import './search-result.scss' import './search-result.scss'
import Recommendation from './recommendation' import Recommendation from './recommendation'
import {getCourses} from './../detail/actions'; import throttle from 'lodash/throttle'
const ForwardRefSearchHead = React.forwardRef((props, ref) => {
return <SearchHeader {...props} forwardedRef={ref}/>
})
const Bottom = ({item}) => { const Bottom = ({item}) => {
return ( return (
...@@ -16,17 +20,28 @@ const Bottom = ({item}) => { ...@@ -16,17 +20,28 @@ const Bottom = ({item}) => {
) )
} }
@connect()
class SearchResult extends PureComponent { class SearchResult extends PureComponent {
prevScrollY = 0
searchHead = React.createRef()
swipeUp = 'up'
swipeDown = 'down'
state = { state = {
courseList: [], courseList: [],
value: '', value: decodeURIComponent(getParam('word')) || '',
searchHistory: JSON.parse(localStorage.getItem('searchHistory')) || [] searchHistory: JSON.parse(localStorage.getItem('searchHistory')) || [],
fixedHeader: false,
searchHeadStyle: {top: 0},
swipeDirection: this.swipeUp
} }
componentDidMount() { componentDidMount() {
this.getCourses(getParam('word')) this.getCourses(getParam('word'))
document.addEventListener('scroll', this.handleScroll)
}
componentWillUnmount() {
document.removeEventListener('scroll', this.handleScroll)
} }
...@@ -56,22 +71,65 @@ class SearchResult extends PureComponent { ...@@ -56,22 +71,65 @@ class SearchResult extends PureComponent {
} }
toCourseDetail = (id) => { toCourseDetail = (id) => {
const { dispatch, history } = this.props; const {history} = this.props;
// dispatch(getCourses(id, () => {
history.push(`/detail?id=${id}`) history.push(`/detail?id=${id}`)
// }));
} }
handleScroll = throttle(() => {
let y = window.scrollY, headY = this.searchHead.current.offsetTop
if (y < this.prevScrollY) {
if (this.state.swipeDirection === this.swipeDown) {
y <= headY && this.state.searchHeadStyle.position !== 'fixed' && this.setState({
searchHeadStyle: {
top: `0`,
position: 'fixed'
}
})
} else {
this.setState({
swipeDirection: this.swipeDown
}, () => {
if (this.state.swipeDirection === this.swipeDown) {
this.setState({
searchHeadStyle: {
top: `${y > headY ? y - 44 : y}px`
}
})
}
})
}
} else {
this.state.swipeDirection !== this.swipeUp &&
this.setState({
swipeDirection: this.swipeUp,
searchHeadStyle: {
position: 'absolute',
top: `${y}px`
}
})
}
this.prevScrollY = y
}, 0)
render() { render() {
const {courseList} = this.state const {courseList} = this.state
return ( return (
<div className='search-result'> <div
<SearchHeader className={'search-result'}>
<ForwardRefSearchHead
handleSearch={this.handleSearch} handleSearch={this.handleSearch}
value={this.state.value} value={this.state.value}
handleChange={this.handleChange} handleChange={this.handleChange}
searchHistory={this.state.searchHistory} searchHistory={this.state.searchHistory}
style={this.state.searchHeadStyle}
ref={this.searchHead}
/> />
{ {
...@@ -115,7 +173,8 @@ class SearchResult extends PureComponent { ...@@ -115,7 +173,8 @@ class SearchResult extends PureComponent {
抱歉!没有搜到相关内容 抱歉!没有搜到相关内容
</div> </div>
} }
<Recommendation /> <Recommendation/>
</div> </div>
); );
} }
......
.search-result { .search-result {
padding-top: 44px;
.search-head{
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 10;
}
ul { ul {
list-style: none; list-style: none;
} }
......
...@@ -38,9 +38,8 @@ class SearchHead extends PureComponent { ...@@ -38,9 +38,8 @@ class SearchHead extends PureComponent {
render() { render() {
const { isFocus } = this.state; const { isFocus } = this.state;
const cls = classnames('submit-btn', {'submit-btn--active': isFocus}) const cls = classnames('submit-btn', {'submit-btn--active': isFocus})
console.log(isFocus);
return ( return (
<div className="search-head"> <div className="search-head" style={this.props.style} ref={this.props.forwardedRef}>
<div className="left" onClick={this.returnPage}> <div className="left" onClick={this.returnPage}>
<i className="iconfont iconiconfront-68"/> <i className="iconfont iconiconfront-68"/>
...@@ -57,6 +56,7 @@ class SearchHead extends PureComponent { ...@@ -57,6 +56,7 @@ class SearchHead extends PureComponent {
placeholder="搜索课程" placeholder="搜索课程"
onFocus={() => this.changeFontColor(true)} onFocus={() => this.changeFontColor(true)}
onBlur={() => this.changeFontColor(false)} onBlur={() => this.changeFontColor(false)}
onSubmit={this.search}
/> />
</div> </div>
<div className="right right-btn" onClick={this.search}> <div className="right right-btn" onClick={this.search}>
......
...@@ -403,7 +403,7 @@ class Video extends Component { ...@@ -403,7 +403,7 @@ class Video extends Component {
//告诉服务端计算进度 普通课程不发送 //告诉服务端计算进度 普通课程不发送
countSchedule = () => { countSchedule = () => {
const {videoList, activeIndex, vCourseId, course={}} = this.state const {videoList, activeIndex, vCourseId, course={}} = this.state
if(!this.state.course.course_id) { if(Number(course.course_id) === 0 || course.course_id === '') {
console.log('免费课程 拦截'); console.log('免费课程 拦截');
return; return;
} }
...@@ -433,7 +433,7 @@ class Video extends Component { ...@@ -433,7 +433,7 @@ class Video extends Component {
sendWatchTime = (sec, rate) => { sendWatchTime = (sec, rate) => {
const {videoList, activeIndex, vCourseId, course = {}} = this.state const {videoList, activeIndex, vCourseId, course = {}} = this.state
// 免费课程不发送 // 免费课程不发送
if(!course.course_id) { if(Number(course.course_id) === 0 || course.course_id === '') {
console.log('免费课程 拦截'); console.log('免费课程 拦截');
return; return;
} }
...@@ -493,7 +493,6 @@ class Video extends Component { ...@@ -493,7 +493,6 @@ class Video extends Component {
this.player.addChild('CustomPlayButtonCover') this.player.addChild('CustomPlayButtonCover')
this.player.on('ready', () => { this.player.on('ready', () => {
this.recordSocket.emit('load', this.recordUserInfo()) this.recordSocket.emit('load', this.recordUserInfo())
this.countSchedule();
}) })
this.player.on('ratechange', () => { this.player.on('ratechange', () => {
this.currentPlaybackRate = this.player.playbackRate() this.currentPlaybackRate = this.player.playbackRate()
...@@ -503,6 +502,7 @@ class Video extends Component { ...@@ -503,6 +502,7 @@ class Video extends Component {
}) })
this.player.on('ended', () => { this.player.on('ended', () => {
this.sendWatchTime(this.watchSec, this.currentPlaybackRate) this.sendWatchTime(this.watchSec, this.currentPlaybackRate)
this.countSchedule(); // 计算进度
this.getShareProgressInfo() this.getShareProgressInfo()
clearInterval(this.timer) clearInterval(this.timer)
}) })
...@@ -589,9 +589,12 @@ class Video extends Component { ...@@ -589,9 +589,12 @@ class Video extends Component {
playSetup = () => { playSetup = () => {
// is_aist,是否AI特训营 // is_aist,是否AI特训营
const { course={} } = this.state; const { course={} } = this.state;
if (course.is_aist) { if (Number(course.course_id) === 0 || course.course_id === '') {
console.log('免费课程 拦截');
}else{
this.setupWS(); this.setupWS();
this.setupTimer(); this.setupTimer();
this.countSchedule();
} }
let index = this.getLastVideoIndex(course.last_video_id); let index = this.getLastVideoIndex(course.last_video_id);
index = index >= 0 ? index : 0; index = index >= 0 ? index : 0;
......
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