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