Commit 5da5a1f6 by zhanghaozhe

Merge branch 'master' of gitlab.julyedu.com:baiguangyao/mr-julyedu

parents 409ba221 2eba5b19
...@@ -172,7 +172,7 @@ class Index extends Component { ...@@ -172,7 +172,7 @@ class Index extends Component {
{ {
this.state.islive && this.state.islive &&
<LiveRoom isShow={this.state.isShow} colseBox={this.colseBox} <LiveRoom isShow={this.state.isShow} colseBox={this.colseBox}
roomMess={this.state.roomMess}></LiveRoom> roomMess={this.state.roomMess} getIndexData={this.getIndexData}></LiveRoom>
} }
</div> </div>
...@@ -282,13 +282,17 @@ function ScrollBox(props) { ...@@ -282,13 +282,17 @@ function ScrollBox(props) {
<h2 className="item-title">{item.live_title}</h2> <h2 className="item-title">{item.live_title}</h2>
<p className="item-teacher">讲师:{item.live_teacher_name}</p> <p className="item-teacher">讲师:{item.live_teacher_name}</p>
{ {
item.is_prepare && item.is_prepare && item.live_status === 0 &&
<p className="item-time">时间:{item.live_start_time}</p> <p className="item-time">时间:{item.live_start_time}</p>
} }
{ {
!item.is_prepare && !item.is_prepare && item.live_status === 0 &&
<p className='item-btn'>预约</p> <p className='item-btn'>预约</p>
} }
{
(item.live_status === 1 || item.live_status === 10) &&
<p className='item-btn'>正在直播</p>
}
</div> </div>
</div> </div>
</li> </li>
......
...@@ -211,10 +211,10 @@ ...@@ -211,10 +211,10 @@
} }
.item-btn { .item-btn {
width: 49px; padding: 0 5px;
height: 20px; height: 20px;
text-align: center; text-align: center;
line-height: 20px; line-height: 18px;
background: linear-gradient(60deg, $bg_active 0%, $bg_0080FF 100%); background: linear-gradient(60deg, $bg_active 0%, $bg_0080FF 100%);
border-radius: 10px; border-radius: 10px;
font-size: 14px; font-size: 14px;
......
...@@ -82,6 +82,7 @@ class LiveRoom extends Component { ...@@ -82,6 +82,7 @@ class LiveRoom extends Component {
success: true, success: true,
toSubscribe: false toSubscribe: false
}) })
this.props.getIndexData()
} }
} else if (res.data.data.status === 1) { } else if (res.data.data.status === 1) {
...@@ -275,10 +276,10 @@ class LiveRoom extends Component { ...@@ -275,10 +276,10 @@ class LiveRoom extends Component {
} }
</div> </div>
} }
{ {/*{*/}
this.state.success && {/*this.state.success &&*/}
<div className='success'>预约成功</div> {/*<div className='success'>预约成功</div>*/}
} {/*}*/}
</div> </div>
); );
} }
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
display: flex; display: flex;
flex-flow: column; flex-flow: column;
justify-content: space-between; justify-content: space-between;
width: 100%;
} }
.v-list-item { .v-list-item {
......
...@@ -17,9 +17,25 @@ class BtnStatus extends Component { ...@@ -17,9 +17,25 @@ class BtnStatus extends Component {
group_status: 3, group_status: 3,
in_cart: false, in_cart: false,
countdown: 0, countdown: 0,
barInfo: ''
} }
} }
componentDidMount() {
this.getBargainInfo()
}
// componentDidUpdate(prevProps) {
// let {courseInfo} = this.props
// let {courseInfo: prevCourseInfo} = prevProps
// if (courseInfo && courseInfo.is_bargain) {
// if (prevCourseInfo && courseInfo.is_bargain !== prevCourseInfo.is_bargain) {
// this.getBargainInfo()
// }
// }
// }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
this.setState({ this.setState({
...nextProps.data.course_info, ...nextProps.data.course_info,
...@@ -39,13 +55,11 @@ class BtnStatus extends Component { ...@@ -39,13 +55,11 @@ class BtnStatus extends Component {
// this.props.getCourses() // this.props.getCourses()
document.location.reload() document.location.reload()
} else { } else {
// window.location.href = '/shopcart'
this.props.history.replace('/shopcart'); this.props.history.replace('/shopcart');
} }
} else if (res.data.code === 15001) { } else if (res.data.code === 15001) {
// window.location.href = '/shopcart'
this.props.history.replace('/shopcart'); this.props.history.replace('/shopcart');
} else { } else {
Toast.info(res.data.msg, 2); Toast.info(res.data.msg, 2);
...@@ -54,14 +68,20 @@ class BtnStatus extends Component { ...@@ -54,14 +68,20 @@ class BtnStatus extends Component {
} }
// 直接购买 // 直接购买
tobuy = () => { tobuy = () => {
if (this.props.barInfo.bargain_status === 2) { const {user} = this.props
this.toCart(2) const uid = user && user.data && user.data.uid
if (!uid) {
this.props.history.push('/passport/login')
} else { } else {
// 取消砍价记录 if (this.state.barInfo.bargain_status === 2) {
this.setState({ this.toCart(2)
isShowOverlay: true, } else {
bargainStatus: 1, // 取消砍价记录
}) this.setState({
isShowOverlay: true,
bargainStatus: 1,
})
}
} }
} }
...@@ -91,15 +111,40 @@ class BtnStatus extends Component { ...@@ -91,15 +111,40 @@ class BtnStatus extends Component {
} }
// 砍价接口 // 砍价接口
toKanjia = () => { toKanjia = () => {
const {user} = this.props
const uid = user && user.data && user.data.uid
if (!uid) {
this.props.history.push('/passport/login')
} else {
let data = {
course_id: getParam('id'),
type: 1, // 1 用户自己砍价 2 使用砍价神器 3 好友助力砍价 4 好友第二次助力
parent_uid: 0 // 被助力人id 【自己本人操作传0】
}
http.post(`${api.home}/m/bargain/toBargain`, data).then((res) => {
if (res.data.code === 200) {
// this.props.getBargainInfo()
document.location.reload()
} else {
Toast.info(res.data.msg, 2)
}
})
}
}
//获取砍价信息
getBargainInfo = () => {
const {user} = this.props
const uid = user && user.data && user.data.uid
let data = { let data = {
course_id: getParam('id'), courseId: getParam('id')
type: 1, // 1 用户自己砍价 2 使用砍价神器 3 好友助力砍价 4 好友第二次助力
parent_uid: 0 // 被助力人id 【自己本人操作传0】
} }
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) {
// this.props.getBargainInfo() this.setState({
document.location.reload() barInfo: res.data.data
})
} else { } else {
Toast.info(res.data.msg, 2) Toast.info(res.data.msg, 2)
} }
...@@ -111,8 +156,10 @@ class BtnStatus extends Component { ...@@ -111,8 +156,10 @@ class BtnStatus extends Component {
if (this.props.data && this.props.data.course_info) { if (this.props.data && this.props.data.course_info) {
info = this.props.data.course_info info = this.props.data.course_info
} }
let barInfo = this.props.barInfo && this.props.barInfo
const {countdown} = this.state; const {countdown} = this.state;
const {user} = this.props
const uid = user && user.data && user.data.uid
return ( return (
<div> <div>
...@@ -196,15 +243,15 @@ class BtnStatus extends Component { ...@@ -196,15 +243,15 @@ class BtnStatus extends Component {
<span onClick={this.tobuy}>直接购买</span> <span onClick={this.tobuy}>直接购买</span>
</button> </button>
{ {
barInfo.bargain_status === 2 && (this.state.barInfo.bargain_status === 2 || !uid) &&
<button className='btn btn-s bg-E02E24' onClick={this.toKanjia}> <button className='btn btn-s bg-E02E24' onClick={this.toKanjia}>
我要砍价 我要砍价
</button> </button>
} }
{ {
(barInfo.bargain_status === 0 || barInfo.bargain_status === 1) && (this.state.barInfo.bargain_status === 0 || this.state.barInfo.bargain_status === 1) && (uid) &&
<button className='btn btn-s bg-E02E24'> <button className='btn btn-s bg-E02E24'>
<span>¥{barInfo.amount}</span> <span>¥{this.state.barInfo.amount}</span>
<span onClick={e => this.toCart(2)}>去支付</span> <span onClick={e => this.toCart(2)}>去支付</span>
</button> </button>
} }
...@@ -256,6 +303,8 @@ function CancelBargain(props) { ...@@ -256,6 +303,8 @@ function CancelBargain(props) {
} }
export default connect( export default connect(
null, state => ({
user: state.user
}),
{getCourses} {getCourses}
)(BtnStatus) )(BtnStatus)
...@@ -13,6 +13,7 @@ import {connect} from "react-redux" ...@@ -13,6 +13,7 @@ import {connect} from "react-redux"
import {fetchCoursesListIfNeeded} from "./actions" import {fetchCoursesListIfNeeded} from "./actions"
import {api, getParam, http, browser} from "@/utils" import {api, getParam, http, browser} from "@/utils"
import {Toast} from 'antd-mobile' import {Toast} from 'antd-mobile'
import {compose} from "redux";
class Detail extends Component { class Detail extends Component {
...@@ -35,29 +36,30 @@ class Detail extends Component { ...@@ -35,29 +36,30 @@ class Detail extends Component {
this.props.fetchCoursesListIfNeeded(); this.props.fetchCoursesListIfNeeded();
} }
componentDidUpdate(prevProps) {
let {courseInfo} = this.props
let {courseInfo: prevCourseInfo} = prevProps
if (courseInfo && courseInfo.is_bargain) {
if (prevCourseInfo && courseInfo.is_bargain !== prevCourseInfo.is_bargain) {
this.getBargainInfo()
}
}
}
// 点击子组件试听按钮 // 点击子组件试听按钮
toAudition = () => { toAudition = () => {
this.setState(status => ({ const {user} = this.props
auditionBox: true, const uid = user && user.data && user.data.uid
})); if (!uid) {
this.props.history.push('/passport/login')
} else {
this.setState({
auditionBox: true,
})
}
} }
// 点击子组件单集购买按钮 // 点击子组件单集购买按钮
toSingleset = (item) => { toSingleset = (item) => {
this.setState(status => ({ const {user} = this.props
singleBox: true, const uid = user && user.data && user.data.uid
singMess: item if (!uid) {
})); this.props.history.push('/passport/login')
} else {
this.setState({
singleBox: true,
singMess: item
})
}
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
...@@ -154,7 +156,6 @@ class Detail extends Component { ...@@ -154,7 +156,6 @@ class Detail extends Component {
}) })
} }
// 自组件传给父组件的boxHide // 自组件传给父组件的boxHide
boxHide = (val) => { boxHide = (val) => {
this.setState({auditionBox: val, singleBox: val}) this.setState({auditionBox: val, singleBox: val})
...@@ -262,7 +263,6 @@ class Detail extends Component { ...@@ -262,7 +263,6 @@ class Detail extends Component {
{/*课程按钮*/} {/*课程按钮*/}
<BtnStatus countdown={countdown} <BtnStatus countdown={countdown}
data={this.props.courseInfo} data={this.props.courseInfo}
barInfo={this.state.barInfo}
getBargainInfo={this.getBargainInfo} getBargainInfo={this.getBargainInfo}
invitedFriends={this.invitedFriends} invitedFriends={this.invitedFriends}
history={this.props.history}></BtnStatus> history={this.props.history}></BtnStatus>
...@@ -290,13 +290,12 @@ class Detail extends Component { ...@@ -290,13 +290,12 @@ class Detail extends Component {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
courseInfo: state.courseInfo courseInfo: state.courseInfo,
user: state.user
} }
} }
const mapDispatchToProps = { const mapDispatchToProps = {
fetchCoursesListIfNeeded fetchCoursesListIfNeeded
} }
export default connect(mapStateToProps, mapDispatchToProps)(Detail) export default connect(mapStateToProps, mapDispatchToProps)(Detail)
\ No newline at end of file
...@@ -38,6 +38,9 @@ class ShareRank extends Component { ...@@ -38,6 +38,9 @@ class ShareRank extends Component {
// 获取分销码 // 获取分销码
getCode = () => { getCode = () => {
const {user} = this.props
const uid = user && user.data && user.data.uid
if (!uid) return
let data = { let data = {
course_id: getParam('id') course_id: getParam('id')
} }
...@@ -54,11 +57,17 @@ class ShareRank extends Component { ...@@ -54,11 +57,17 @@ class ShareRank extends Component {
// 点击分销跳转到海报页 // 点击分销跳转到海报页
share = (info) => { share = (info) => {
const courseId = getParam('id') const {user} = this.props
const dist_first = info.dist_first_level_ti const uid = user && user.data && user.data.uid
const uid = info.uid if (!uid) {
const dist_code = this.state.code this.props.history.push('/passport/login')
this.props.history.push(`/shareposter?courseId=${courseId}&dist_first=${dist_first}&uid=${uid}&dist_code=${dist_code}`) } else {
const courseId = getParam('id')
const dist_first = info.dist_first_level_ti
const uid = info.uid
const dist_code = this.state.code
this.props.history.push(`/shareposter?courseId=${courseId}&dist_first=${dist_first}&uid=${uid}&dist_code=${dist_code}`)
}
} }
...@@ -146,7 +155,10 @@ class ShareRank extends Component { ...@@ -146,7 +155,10 @@ class ShareRank extends Component {
export default compose( export default compose(
connect( connect(
state => ({courseInfo: state}), state => ({
courseInfo: state,
user: state.user
}),
null null
), ),
withRouter withRouter
......
...@@ -130,7 +130,7 @@ class Cart extends Component { ...@@ -130,7 +130,7 @@ class Cart extends Component {
tobuy = () => { tobuy = () => {
http.get(`${API['base-api']}/m/cart/addtopreorder/[${this.state.courseIdarr}]`).then((res) => { http.get(`${API['base-api']}/m/cart/addtopreorder/[${this.state.courseIdarr}]`).then((res) => {
if (res.data.errno == 0) { if (res.data.errno == 0) {
this.props.history.push('/order') this.props.history.push(`/order?id=[${this.state.courseIdarr}]`)
} else { } else {
Toast.info(res.data.msg, 2); Toast.info(res.data.msg, 2);
} }
......
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