Commit 1a7f8849 by FE

Merge branch 'issue-20190920'

parents 79c23651 bdf2181b
...@@ -28,6 +28,9 @@ $z-max: 999999; //为了应付某些插件z-index 值过高的问题 ...@@ -28,6 +28,9 @@ $z-max: 999999; //为了应付某些插件z-index 值过高的问题
// -------------------------------------------------- // --------------------------------------------------
// //
body {
position: relative;
}
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
border: 0 none; border: 0 none;
font-size: inherit; font-size: inherit;
......
...@@ -41,7 +41,7 @@ class BargainMiddlePage extends Component { ...@@ -41,7 +41,7 @@ class BargainMiddlePage extends Component {
min: '', min: '',
sec: '', sec: '',
day: '', day: '',
amount: '', amount: '', // 每次砍掉的价格
firendBaigainPrice: true, firendBaigainPrice: true,
isshowYindao: false, isshowYindao: false,
isLoaidng: true, isLoaidng: true,
...@@ -124,7 +124,7 @@ class BargainMiddlePage extends Component { ...@@ -124,7 +124,7 @@ class BargainMiddlePage extends Component {
} }
// 获取助理好友 // 获取助理好友
getBargainRankList = (id, type) => { getBargainRankList = (id = '', type) => {
const bargain_code = getParam('bargaincode') || ''; const bargain_code = getParam('bargaincode') || '';
let data = { let data = {
courseId: id, courseId: id,
...@@ -213,7 +213,8 @@ class BargainMiddlePage extends Component { ...@@ -213,7 +213,8 @@ class BargainMiddlePage extends Component {
this.setState({ this.setState({
isShowOverlay: true, isShowOverlay: true,
status: 5, status: 5,
}) });
this.getBargainInfo();
} else { } else {
Toast.info(res.data.msg, 2) Toast.info(res.data.msg, 2)
} }
...@@ -236,6 +237,7 @@ class BargainMiddlePage extends Component { ...@@ -236,6 +237,7 @@ class BargainMiddlePage extends Component {
} }
http.post(`${API.home}/m/bargain/toBargain`, data).then((res) => { http.post(`${API.home}/m/bargain/toBargain`, data).then((res) => {
if (res.data.code === 200) { if (res.data.code === 200) {
// is_success =0一切正常 =1 不能在砍了 =2关注公众号,可以再砍一刀! // is_success =0一切正常 =1 不能在砍了 =2关注公众号,可以再砍一刀!
this.setState({ this.setState({
amount: res.data.data.amount amount: res.data.data.amount
...@@ -244,7 +246,9 @@ class BargainMiddlePage extends Component { ...@@ -244,7 +246,9 @@ class BargainMiddlePage extends Component {
this.setState({ this.setState({
isShowOverlay: true, isShowOverlay: true,
status: 6 status: 6
}) });
this.getBargainInfo();
this.getBargainRankList('', 1);
} }
if (res.data.data.is_success === 1) { if (res.data.data.is_success === 1) {
...@@ -513,6 +517,7 @@ class BargainMiddlePage extends Component { ...@@ -513,6 +517,7 @@ class BargainMiddlePage extends Component {
toDetail={this.toCourseDetail} toDetail={this.toCourseDetail}
bottom={ bottom={
<CourseBottom <CourseBottom
user={this.props.user}
item={item} item={item}
toCartBottom={this.toCartBottom.bind(this, item.course_id)} toCartBottom={this.toCartBottom.bind(this, item.course_id)}
toDetail={this.toCourseDetail} toDetail={this.toCourseDetail}
...@@ -635,39 +640,70 @@ function CourseDes(props) { ...@@ -635,39 +640,70 @@ function CourseDes(props) {
} }
function CourseBottom(props) { function CourseBottom(props) {
// bargain_status 砍价状态 0-砍价中,1砍价结束,待支付,2砍价过期(没有砍价记录没有砍价信息),3已购买
const {course_id = '', bargain_status = '', price1 = '', pay_price = '' } = props.item || {};
const { user: { data = {} } } = props;
const price = bargain_status === 2? price1 : pay_price;
let Buttons let Buttons
if (props.item.bargain_status === 2) { if(data.uid) {
// Buttons = <Link to={`/detail?id=${props.item.course_id}`} className={'bargain'}>我要砍价</Link> if (props.item.bargain_status === 2) {
Buttons = <a onClick={() => props.toDetail(props.item.course_id)} className={'bargain bargian-study'}>我要砍价</a> // Buttons = <Link to={`/detail?id=${props.item.course_id}`} className={'bargain'}>我要砍价</Link>
} else if (props.item.bargain_status === 3) { Buttons = (
Buttons = <Link to={`/play/video?id=${props.item.v_course_id}`} <div className="">
className={classnames('bargain', 'button--study')}>去学习</Link> <a onClick={() => props.toDetail(props.item.course_id)} className={'bargain bargian-study'}>我要砍价</a>
if(props.item.course_id === 139) { </div>
Buttons = <a onClick={() => props.toDetail(props.item.course_id)} className={'bargain bargian-study'}>我要砍价</a>
)
} else if (bargain_status === 3) {
if(course_id === 139) {
Buttons = (
<a
onClick={() => props.toDetail(props.item.course_id)}
className={'bargain bargian-study'}
>我要砍价</a>
);
}else {
Buttons = (
<Link
to={`/play/video?id=${props.item.v_course_id}`}
className={classnames('bargain', 'button--study')}
>去学习</Link>
);
}
} else {
Buttons = (
<div className="btns">
{/*<button className={classnames('bargain-btn', {invalid: props.item.bargain_status === 2})}>*/}
{/*{props.item.bargain_status === 2 ? '砍价结束' : '继续砍价'}*/}
{/*</button>*/}
{
bargain_status === 1 &&
<button className='invalid'>砍价结束</button>
}
{
bargain_status === 0 &&
<a onClick={() => props.toDetail(props.item.course_id)} className={'bargain-btn'}>继续砍价</a>
}
<button
onClick={() => props.toCartBottom(props.item.course_id)}
className={'purchase-btn'}
>
¥{price}去支付
</button>
</div>
)
} }
} else {
}else {
Buttons = ( Buttons = (
<div className="btns"> <a
{/*<button className={classnames('bargain-btn', {invalid: props.item.bargain_status === 2})}>*/} onClick={() => props.toDetail(props.item.course_id)}
{/*{props.item.bargain_status === 2 ? '砍价结束' : '继续砍价'}*/} className={'bargain bargian-study'}
{/*</button>*/} >我要砍价</a>
{ );
props.item.bargain_status === 1 &&
<button className='invalid'>砍价结束</button>
}
{
props.item.bargain_status === 0 &&
<a onClick={() => props.toDetail(props.item.course_id)} className={'bargain-btn'}>我要砍价</a>
}
<button onClick={() => props.toCartBottom(props.item.course_id)}
className={'purchase-btn'}>¥{props.item.pay_price}去支付
</button>
</div>
)
} }
return ( return (
<div className="course-bottom"> <div className="course-bottom">
<div className={'course-price'}> <div className={'course-price'}>
......
...@@ -9,6 +9,7 @@ import Ranking from "@/components/bargainMiddlePage/ranking" ...@@ -9,6 +9,7 @@ import Ranking from "@/components/bargainMiddlePage/ranking"
import { compose } from "redux" import { compose } from "redux"
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import {connect} from "react-redux"; import {connect} from "react-redux";
import { Object } from 'core-js'
class Bargain extends Component { class Bargain extends Component {
...@@ -25,7 +26,9 @@ class Bargain extends Component { ...@@ -25,7 +26,9 @@ class Bargain extends Component {
bargainCode: '', bargainCode: '',
time: '', time: '',
barInfo: {}, barInfo: {},
country: '86' country: '86',
price: 0, // 每次砍价砍掉的价格
sum: 0 // 累计砍掉的价格
} }
} }
...@@ -65,7 +68,7 @@ class Bargain extends Component { ...@@ -65,7 +68,7 @@ class Bargain extends Component {
//获取砍价信息 //获取砍价信息
getBargainInfo = () => { getBargainInfo = (isFetch = true) => {
let data = { let data = {
courseId: getParam('id') courseId: getParam('id')
} }
...@@ -78,13 +81,14 @@ class Bargain extends Component { ...@@ -78,13 +81,14 @@ class Bargain extends Component {
// limitPeople: res.data.data.limit_people, // limitPeople: res.data.data.limit_people,
// bargainCode: res.data.data.bargain_code // bargainCode: res.data.data.bargain_code
}); });
if(isFetch) {
// 砍价状态 0-砍价中,1砍价结束,待支付,2砍价过期(没有砍价记录没有砍价信息),3已购买 // 砍价状态 0-砍价中,1砍价结束,待支付,2砍价过期(没有砍价记录没有砍价信息),3已购买
if (data.bargain_status === 0 || data.bargain_status === 1 ) { if (data.bargain_status === 0 || data.bargain_status === 1 ) {
this.getBargainRankList({ this.getBargainRankList({
type: 0, type: 0,
bargain_code: data.bargain_code bargain_code: data.bargain_code
}); });
}
} }
} else { } else {
Toast.info(msg, 2); Toast.info(msg, 2);
...@@ -113,8 +117,9 @@ class Bargain extends Component { ...@@ -113,8 +117,9 @@ class Bargain extends Component {
if (res.data.code === 200) { if (res.data.code === 200) {
this.setState({ this.setState({
isShowOverlay: true, isShowOverlay: true,
status: 1, status: 1
}) });
this.getBargainInfo(false);
} else { } else {
Toast.info(res.data.msg, 2) Toast.info(res.data.msg, 2)
} }
...@@ -180,6 +185,13 @@ class Bargain extends Component { ...@@ -180,6 +185,13 @@ class Bargain extends Component {
this.setState({ this.setState({
isShowOverlay: true, isShowOverlay: true,
status: 2, status: 2,
price: data.amount,
sum: data.bargain_price
});
this.getBargainInfo(false);
this.getBargainRankList({
type: 0,
bargain_code: data.bargain_code
}); });
}else { }else {
history.push(`/bargain-middle-page?id=${getParam('id')}&bargaincode=${data.bargain_code}&is_originator=1`) history.push(`/bargain-middle-page?id=${getParam('id')}&bargaincode=${data.bargain_code}&is_originator=1`)
...@@ -217,7 +229,7 @@ class Bargain extends Component { ...@@ -217,7 +229,7 @@ class Bargain extends Component {
} }
render() { render() {
const { list, outList, barInfo, country } = this.state; const { list, outList, barInfo, country, price, sum } = this.state;
const {user} = this.props const {user} = this.props
const uid = user && user.data && user.data.uid const uid = user && user.data && user.data.uid
return ( return (
...@@ -259,7 +271,11 @@ class Bargain extends Component { ...@@ -259,7 +271,11 @@ class Bargain extends Component {
{/*使用砍价神器*/} {/*使用砍价神器*/}
{ {
this.state.status === 2 && this.state.status === 2 &&
<UseArtifact toCart={this.toCart}/> <UseArtifact
price={price}
sum={sum}
toCart={this.toCart}
/>
} }
{ {
...@@ -431,13 +447,14 @@ function Artifact(props) { ...@@ -431,13 +447,14 @@ function Artifact(props) {
} }
function UseArtifact(props) { function UseArtifact(props) {
const { sum, price } = props;
return ( return (
<div className='use-artifact-box'> <div className='use-artifact-box'>
<img className='top-img' src={require('./image/kanjia_cg_icon.png')} alt=""/> <img className='top-img' src={require('./image/kanjia_cg_icon.png')} alt=""/>
<p className='top-tip'>厉害了,又砍掉了10元!</p> <p className='top-tip'>厉害了,又砍掉了{price}元!</p>
<p className='middle-tip'> <p className='middle-tip'>
你已经砍了 你已经砍了
<span className={'indicator'}>109</span> <span className={'indicator'}>{sum}</span>
没见过你这么能砍的人... 没见过你这么能砍的人...
</p> </p>
<p className='btm-tip'> <p className='btm-tip'>
......
...@@ -24,7 +24,7 @@ class Search extends PureComponent { ...@@ -24,7 +24,7 @@ class Search extends PureComponent {
if (errno === 0) { if (errno === 0) {
this.setState({ this.setState({
hot_words: data.info.hot_words, hot_words: data.info.hot_words,
defaultWord: data.info.recommend_word, value: data.info.recommend_word,
isLoading: false isLoading: false
}) })
} }
...@@ -60,7 +60,7 @@ class Search extends PureComponent { ...@@ -60,7 +60,7 @@ class Search extends PureComponent {
<div className="search-page"> <div className="search-page">
<SearchHead <SearchHead
searchHistory={this.state.searchHistory} searchHistory={this.state.searchHistory}
value={this.state.value || this.state.defaultWord} value={this.state.value}
handleChange={this.handleChange} handleChange={this.handleChange}
handleSearch={this.handleSearch} handleSearch={this.handleSearch}
/> />
......
...@@ -32,7 +32,9 @@ class SearchResult extends PureComponent { ...@@ -32,7 +32,9 @@ class SearchResult extends PureComponent {
searchHistory: JSON.parse(localStorage.getItem('searchHistory')) || [], searchHistory: JSON.parse(localStorage.getItem('searchHistory')) || [],
fixedHeader: false, fixedHeader: false,
searchHeadStyle: {top: 0}, searchHeadStyle: {top: 0},
swipeDirection: this.swipeUp swipeDirection: this.swipeUp,
isHide: false,
basicTop: 0
} }
componentDidMount() { componentDidMount() {
...@@ -76,61 +78,65 @@ class SearchResult extends PureComponent { ...@@ -76,61 +78,65 @@ class SearchResult extends PureComponent {
} }
handleScroll = throttle(() => { handleScroll = throttle(() => {
let y = window.scrollY, let y = window.scrollY < 0? 0 : window.scrollY,
headY = this.searchHead.current.offsetTop; headY = this.searchHead.current.offsetTop,
console.log(headY,'headY'); h = this.searchHead.current.offsetHeight;
console.log(document.querySelector('body').offsetHeight); if(y > this.prevScrollY) {
// 向上滑动
if (y < this.prevScrollY && y > 0) {
console.log(0);
console.log(this.state.swipeDirection);
if (this.state.swipeDirection === this.swipeDown) {
console.log(1);
y <= headY && this.state.searchHeadStyle.position !== 'fixed' &&
this.setState({
searchHeadStyle: {
top: `0`,
position: 'fixed'
}
})
} else {
console.log(2);
this.setState({
swipeDirection: this.swipeDown
}, () => {
if (this.state.swipeDirection === this.swipeDown) {
let h = y > document.querySelector('body').offsetHeight? document.querySelector('body').offsetHeight: y;
let h1 = this.searchHead.current.offsetHeight
this.setState({
searchHeadStyle: {
// top: `${h > headY ? h - h1 : h}px`
top: `${y}px`
}
})
}
})
}
} else {
console.log(3);
this.state.swipeDirection !== this.swipeUp &&
this.setState({ this.setState({
swipeDirection: this.swipeUp,
searchHeadStyle: { searchHeadStyle: {
position: 'absolute', top : `${-h}px`
top: `${y}px`
} }
}) });
} }
if(y < this.prevScrollY) {
this.setState({
searchHeadStyle: {
top: 0
}
});
}
// 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) {
// let h = y > document.querySelector('body').offsetHeight? document.querySelector('body').offsetHeight: y;
// let h1 = this.searchHead.current.offsetHeight
// this.setState({
// searchHeadStyle: {
// // top: `${h > headY ? h - h1 : h}px`
// top: `${y}px`
// }
// })
// }
// })
// }
// } else {
// this.state.swipeDirection !== this.swipeUp &&
// this.setState({
// swipeDirection: this.swipeUp,
// searchHeadStyle: {
// position: 'absolute',
// top: `${y}px`
// }
// })
// }
this.prevScrollY = y; this.prevScrollY = y;
}, 0) }, 0)
render() { render() {
const {courseList} = this.state const { courseList, isHide } = this.state;
return ( return (
<div <div
...@@ -142,6 +148,7 @@ class SearchResult extends PureComponent { ...@@ -142,6 +148,7 @@ class SearchResult extends PureComponent {
searchHistory={this.state.searchHistory} searchHistory={this.state.searchHistory}
style={this.state.searchHeadStyle} style={this.state.searchHeadStyle}
ref={this.searchHead} ref={this.searchHead}
isHide={isHide}
/> />
{ {
......
.search-result { .search-result {
padding-top: 44px; padding-top: 44px;
.search-head{ .search-head {
position: absolute; // position: absolute;
position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
z-index: 10; z-index: 10;
transition: top 0.5 ease;
&.hide {
top: -44px;
}
} }
ul { ul {
......
...@@ -41,6 +41,7 @@ class SearchHead extends PureComponent { ...@@ -41,6 +41,7 @@ class SearchHead extends PureComponent {
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})
return ( return (
<div className="search-head" style={this.props.style} ref={this.props.forwardedRef}> <div className="search-head" style={this.props.style} ref={this.props.forwardedRef}>
<div className="left" onClick={this.returnPage}> <div className="left" onClick={this.returnPage}>
......
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