Commit 104df056 by zhanghaozhe

周年庆

parent 979ed9ac
import React, {Component} from 'react' import React, { Component } from 'react'
import {VList} from '../../common' import { VList } from '../../common'
import {Tabs, WhiteSpace, Toast} from 'antd-mobile' import { Tabs, WhiteSpace, Toast } from 'antd-mobile'
import './index.scss' import './index.scss'
import HeaderSearch from '../../common/HeaderSearch/index' import HeaderSearch from '../../common/HeaderSearch/index'
import {http} from "@/utils" import { http } from "@/utils"
import Loading from '@/common/Loading' import Loading from '@/common/Loading'
import {connect} from 'react-redux'; import { connect } from 'react-redux';
@connect(({user}) => ({ @connect(({user}) => ({
user user,
})) }))
class Preferential extends Component { class Preferential extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
dataList: [], dataList: [],
courseStatus: 0, courseStatus: 0,
isLoading: true isLoading: true,
}
} }
}
componentDidMount() { componentDidMount() {
this.specialSale() this.specialSale()
} }
// 限时特惠
specialSale = () => {
http.get(`${API.home}/m/home/weekDiscounts`).then((res) => {
if (res.data.code === 200) {
this.setState({
dataList: res.data.data,
isLoading: false
})
} else {
Toast.info(res.data.msg, 2)
}
// 限时特惠
specialSale = () => {
http.get(`${API.home}/m/home/weekDiscounts`).then((res) => {
if (res.data.code === 200) {
this.setState({
dataList: res.data.data,
isLoading: false,
}) })
} } else {
// 砍价专区 Toast.info(res.data.msg, 2)
bargain = () => { }
http.get(`${API.home}/m/home/bargainZone`).then((res) => {
if (res.data.code === 200) { })
this.setState({ }
dataList: JSON.stringify(res.data.data) == '{}' ? []:res.data.data, // 砍价专区
isLoading: false, bargain = () => {
}) http.get(`${API.home}/m/home/bargainZone`).then((res) => {
} else { if (res.data.code === 200) {
Toast.info(res.data.msg, 2) this.setState({
} dataList: JSON.stringify(res.data.data) == '{}' ? [] : res.data.data,
}) isLoading: false,
}
// 一键拼团
group = () => {
http.get(`${API.home}/m/home/grouponList`).then((res) => {
if (res.data.code === 200) {
this.setState({
dataList: res.data.data,
isLoading: false,
})
} else {
Toast.info(res.data.msg, 2)
}
}) })
} } else {
// tab 切换 Toast.info(res.data.msg, 2)
ontabclick = (tab, index) => { }
})
}
// 一键拼团
group = () => {
http.get(`${API.home}/m/home/grouponList`).then((res) => {
if (res.data.code === 200) {
this.setState({ this.setState({
courseStatus: index, dataList: res.data.data,
isLoading: true, isLoading: false,
}) })
switch (index) { } else {
case 0: Toast.info(res.data.msg, 2)
this.specialSale() }
break })
case 1: }
this.bargain() // tab 切换
break ontabclick = (tab, index) => {
default: this.setState({
this.group() courseStatus: index,
} isLoading: true,
})
switch (index) {
case 0:
this.specialSale()
break
case 1:
this.bargain()
break
default:
this.group()
} }
}
toCourseDetail = (id) => { toCourseDetail = (id) => {
const {dispatch, history} = this.props; const {dispatch, history} = this.props;
// dispatch(getCourses(id, () => { // dispatch(getCourses(id, () => {
history.push(`/detail?id=${id}`) history.push(`/detail?id=${id}`)
// })); // }));
} }
render() { render() {
const tabs = [ const tabs = [
{title: '限时特惠'}, {title: '限时特惠'},
{title: '砍价专区'}, {title: '砍价专区'},
{title: '一键拼团'} {title: '一键拼团'},
] ]
const {user = {}} = this.props; const {user = {}} = this.props;
let isLogin = user.data && user.data.uid ? true : false; let isLogin = user.data && user.data.uid ? true : false;
return ( return (
<div className='preferential'> <div className='preferential'>
<HeaderSearch isLogin={isLogin}/> <HeaderSearch isLogin={isLogin}/>
<Loading isLoading={this.state.isLoading}> <Loading isLoading={this.state.isLoading}>
<div className='class-content'> <div className='class-content'>
<WhiteSpace/> <WhiteSpace/>
<Tabs <Tabs
tabs={tabs} tabs={tabs}
animated={false} animated={false}
onChange={(tab, index) => this.ontabclick(tab, index)} onChange={(tab, index) => this.ontabclick(tab, index)}
swipeable={false} swipeable={false}
page={this.state.courseStatus} page={this.state.courseStatus}
renderTabBar={props => <div className={'custom-tab-bar'}> renderTabBar={props => <div className={'custom-tab-bar'}>
<Tabs.DefaultTabBar {...props}/> <Tabs.DefaultTabBar {...props}/>
</div>} </div>}
> >
</Tabs> </Tabs>
<div className='tabs'> <div className='tabs'>
{ {
this.state.dataList.length>0? this.state.dataList.length > 0 ?
<ul> <ul>
{this.state.dataList.map((item, index) => { {this.state.dataList.map((item, index) => {
const Info = ( const Info = (
<div className="info"> <div className="info">
<p className='title' <p className='title'
onClick={() => this.toCourseDetail(item.course_id)}> onClick={() => this.toCourseDetail(item.course_id)}>
{/* <Link to={`/detail?id=${item.course_id}`}> */} {/* <Link to={`/detail?id=${item.course_id}`}> */}
{item.course_title} {item.course_title}
{/* </Link> */} {/* </Link> */}
</p> </p>
<p className='contact text-overflow-2'>{item.course_desc}</p> <p className='contact text-overflow-2'>{item.course_desc}</p>
<div className='des'> <div className='des'>
{!item.is_buy && {!item.is_buy &&
<p className="course-price"> <p className="course-price">
{this.state.courseStatus === 0 && {this.state.courseStatus === 0 &&
<span className='price'>特惠价:</span> <span className='price'>特惠价:</span>
} }
<span className="new">¥{item.price1}</span> <span className="new">¥{item.price1}</span>
<span className="old">¥{item.price0}</span> <span className="old">¥{item.price0}</span>
</p> </p>
}
{item.is_buy &&
<a className="isbuy">已购买</a>
}
</div>
</div>
)
const status = (
!item.is_buy &&
<div>
{this.state.courseStatus === 1 &&
<p className='course-status'>砍价减{item.bargain_price}</p>
}
{this.state.courseStatus === 2 &&
<p className='course-status'>拼团价{item.price}</p>
}
{
item.is_aist && <span className='return_cash'></span>
}
</div>
)
return (
<VList
key={index}
img={item.image_name}
id={item.course_id}
status={status}
info={Info}
toDetail={this.toCourseDetail}
/>
)
})}
</ul>:<div className={'notdata'}>砍价的课程已被设置为双十一活动课程,参加双十一活动购买课程优惠更多哦!</div>
} }
{item.is_buy &&
<a className="isbuy">已购买</a>
}
</div>
</div>
)
const status = (
!item.is_buy &&
<div>
{this.state.courseStatus === 1 &&
<p className='course-status'>砍价减{item.bargain_price}</p>
}
{this.state.courseStatus === 2 &&
<p className='course-status'>拼团价{item.price}</p>
}
{
item.is_aist && <span className='return_cash'></span>
}
</div> </div>
<WhiteSpace/> )
</div> return (
</Loading> <VList
key={index}
img={item.image_name}
id={item.course_id}
status={status}
info={Info}
toDetail={this.toCourseDetail}
/>
)
})}
</ul> : <div className={'notdata'}>特惠课程都去参加活动了,可以去活动页看看哦~</div>
}
</div> </div>
) <WhiteSpace/>
} </div>
</Loading>
</div>
)
}
} }
......
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