Commit c1cd3d48 by xuzhenghua

bug

parent 45d9078b
...@@ -6,6 +6,7 @@ import CourseItem from '../../../../blessingPreheat/courseItem/index' ...@@ -6,6 +6,7 @@ import CourseItem from '../../../../blessingPreheat/courseItem/index'
import {withRouter} from "react-router-dom" import {withRouter} from "react-router-dom"
import CommonPopup from './../../common/commonPopup/index' import CommonPopup from './../../common/commonPopup/index'
import {Toast} from 'antd-mobile' import {Toast} from 'antd-mobile'
import QRCode from 'qrcode'
import {connect} from "react-redux" import {connect} from "react-redux"
@connect(state => ({ @connect(state => ({
...@@ -21,21 +22,25 @@ class YearCourse extends Component { ...@@ -21,21 +22,25 @@ class YearCourse extends Component {
course: [], course: [],
courseList: [], courseList: [],
isMore: false, isMore: false,
addshowMore: false,
}, },
advanced: { advanced: {
course: [], course: [],
courseList: [], courseList: [],
isMore: false, isMore: false,
addshowMore: false,
}, },
higher: { higher: {
course: [], course: [],
courseList: [], courseList: [],
isMore: false, isMore: false,
addshowMore: false,
}, },
expand: { expand: {
course: [], course: [],
courseList: [], courseList: [],
isMore: false, isMore: false,
addshowMore: false,
}, },
bigcourse: { bigcourse: {
course: [], course: [],
...@@ -57,6 +62,7 @@ class YearCourse extends Component { ...@@ -57,6 +62,7 @@ class YearCourse extends Component {
id: '', id: '',
key: "" key: ""
}, },
followBarcode: ''
} }
} }
...@@ -65,17 +71,17 @@ class YearCourse extends Component { ...@@ -65,17 +71,17 @@ class YearCourse extends Component {
this.fetchFreeCourse() this.fetchFreeCourse()
this.fetchGroupCourse() this.fetchGroupCourse()
// AI之路-基础 // AI之路-基础
this.fetchAICourse('one') this.fetchAICourse('one',false)
// AI之路-进阶 // AI之路-进阶
this.fetchAICourse('two') this.fetchAICourse('two',false)
// AI之路-高阶 // AI之路-高阶
this.fetchAICourse('three') this.fetchAICourse('three',false)
// AI之路-拓展 // AI之路-拓展
this.fetchAICourse('four') this.fetchAICourse('four',false)
} }
shouldComponentUpdate(nextProps, nextState, nextContext) { shouldComponentUpdate(nextProps, nextState, nextContext) {
if(this.props.isAppUpdate !== nextProps.isAppUpdate) { if (this.props.isAppUpdate !== nextProps.isAppUpdate) {
this.fetchBigCourse() this.fetchBigCourse()
this.fetchFreeCourse() this.fetchFreeCourse()
this.fetchGroupCourse() this.fetchGroupCourse()
...@@ -87,9 +93,9 @@ class YearCourse extends Component { ...@@ -87,9 +93,9 @@ class YearCourse extends Component {
this.fetchAICourse('three') this.fetchAICourse('three')
// AI之路-拓展 // AI之路-拓展
this.fetchAICourse('four') this.fetchAICourse('four')
return false; return false
} }
return true; return true
} }
fetchBigCourse = () => { fetchBigCourse = () => {
...@@ -138,50 +144,54 @@ class YearCourse extends Component { ...@@ -138,50 +144,54 @@ class YearCourse extends Component {
}) })
} }
fetchAICourse = (key) => { fetchAICourse = (key,addshowMore) => {
http.get(`${API.home}/activity/four_stage/${key}`).then(res => { http.get(`${API.home}/activity/four_stage/${key}`).then(res => {
const {code, data} = res.data const {code, data} = res.data
if (code === 200) { if (code === 200) {
this.getList(key, data) this.getList(key, data,addshowMore)
} }
}) })
} }
getList = (key, data) => { getList = (key, data, addshowMore) => {
const {basic, advanced, higher, expand} = this.state const {basic, advanced, higher, expand} = this.state
if (key === 'one') { if (key === 'one') {
this.setState({ this.setState({
basic: Object.assign({}, basic, { basic: Object.assign({}, basic, {
isMore: data.length > 4 ? true : false, isMore: data.length > 4 && !addshowMore ? true : false,
course: data.length > 4 ? data.filter((item, index) => index < 4) : data, course: data.length > 4 && !addshowMore ? data.filter((item, index) => index < 4) : data,
courseList: data, courseList: data,
addshowMore: addshowMore,
}) })
}) })
} }
if (key === 'two') { if (key === 'two') {
this.setState({ this.setState({
advanced: Object.assign({}, advanced, { advanced: Object.assign({}, advanced, {
isMore: data.length > 4 ? true : false, isMore: data.length > 4 && !addshowMore ? true : false,
course: data.length > 4 ? data.filter((item, index) => index < 4) : data, course: data.length > 4 && !addshowMore ? data.filter((item, index) => index < 4) : data,
courseList: data, courseList: data,
addshowMore: addshowMore,
}) })
}) })
} }
if (key === 'three') { if (key === 'three') {
this.setState({ this.setState({
higher: Object.assign({}, higher, { higher: Object.assign({}, higher, {
isMore: data.length > 4 ? true : false, isMore: data.length > 4 && !addshowMore ? true : false,
course: data.length > 4 ? data.filter((item, index) => index < 4) : data, course: data.length > 4 && !addshowMore ? data.filter((item, index) => index < 4) : data,
courseList: data, courseList: data,
addshowMore: addshowMore,
}) })
}) })
} }
if (key === 'four') { if (key === 'four') {
this.setState({ this.setState({
expand: Object.assign({}, expand, { expand: Object.assign({}, expand, {
isMore: data.length > 4 ? true : false, isMore: data.length > 4 && !addshowMore ? true : false,
course: data.length > 4 ? data.filter((item, index) => index < 4) : data, course: data.length > 4&& !addshowMore ? data.filter((item, index) => index < 4) : data,
courseList: data, courseList: data,
addshowMore: addshowMore,
}) })
}) })
} }
...@@ -210,7 +220,8 @@ class YearCourse extends Component { ...@@ -210,7 +220,8 @@ class YearCourse extends Component {
data[key] = { data[key] = {
isMore: !this.state[key]['isMore'], isMore: !this.state[key]['isMore'],
course: this.state[key]['courseList'], course: this.state[key]['courseList'],
courseList: this.state[key]['courseList'] courseList: this.state[key]['courseList'],
addshowMore: !this.state[key]['addshowMore']
} }
this.setState({ this.setState({
...data ...data
...@@ -219,7 +230,8 @@ class YearCourse extends Component { ...@@ -219,7 +230,8 @@ class YearCourse extends Component {
data[key] = { data[key] = {
isMore: !this.state[key]['isMore'], isMore: !this.state[key]['isMore'],
course: this.state[key]['courseList'].filter((item, index) => index < 4), course: this.state[key]['courseList'].filter((item, index) => index < 4),
courseList: this.state[key]['courseList'] courseList: this.state[key]['courseList'],
addshowMore: !this.state[key]['addshowMore']
} }
this.setState({ this.setState({
...@@ -261,6 +273,26 @@ class YearCourse extends Component { ...@@ -261,6 +273,26 @@ class YearCourse extends Component {
}, 200) }, 200)
} }
getQRcodeUrl = () => {
let _this = this
http.get(`${API['base-api']}/wx/user_temporary_qrcode/${_this.props.user.data.uid}`)
.then(res => {
const {errno, data, msg} = res.data
QRCode.toDataURL('http://weixin.qq.com/q/02mntn9j4xcw01_VSN1tc2', (err, url) => {
this.setState({
followBarcode: url,
})
})
// _this.followBarcode = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEV8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAybW50bjlqNHhjdzAxX1ZTTjF0YzIAAgR5pfBdAwSAUQEA"
// if (errno == 0) {
// _this.followBarcode = data.url
// } else {
// Message.warning(msg)
// }
})
}
// 点击加入心愿单登录验证,在判断是否关注公众号,已关注的话直接加入,未关注弹出二维码弹窗,点击关闭按钮加入心愿单 // 点击加入心愿单登录验证,在判断是否关注公众号,已关注的话直接加入,未关注弹出二维码弹窗,点击关闭按钮加入心愿单
addWishList = (id, key) => { addWishList = (id, key) => {
const _this = this const _this = this
...@@ -287,8 +319,11 @@ class YearCourse extends Component { ...@@ -287,8 +319,11 @@ class YearCourse extends Component {
_this.setState({ _this.setState({
isshowFollow: data.status == 0 ? true : false isshowFollow: data.status == 0 ? true : false
}) })
if (!_this.state.isshowFollow) { if (!_this.state.isshowFollow) {
_this.toJoinList(id, key) _this.toJoinList(id, key)
} else {
_this.getQRcodeUrl()
} }
} else { } else {
Toast.info(msg, 2) Toast.info(msg, 2)
...@@ -304,16 +339,16 @@ class YearCourse extends Component { ...@@ -304,16 +339,16 @@ class YearCourse extends Component {
if (code == 200) { if (code == 200) {
Toast.success('已成功加入心愿单', 3) Toast.success('已成功加入心愿单', 3)
if (key === '1') { if (key === '1') {
_this.fetchAICourse('one') _this.fetchAICourse('one',_this.state.basic.addshowMore)
} }
if (key === '2') { if (key === '2') {
_this.fetchAICourse('two') _this.fetchAICourse('two',_this.state.advanced.addshowMore)
} }
if (key === '3') { if (key === '3') {
_this.fetchAICourse('three') _this.fetchAICourse('three',_this.state.higher.addshowMore)
} }
if (key === '4') { if (key === '4') {
_this.fetchAICourse('four') _this.fetchAICourse('four',_this.state.expand.addshowMore)
} }
if (key === 'group') { if (key === 'group') {
_this.fetchGroupCourse() _this.fetchGroupCourse()
...@@ -341,7 +376,7 @@ class YearCourse extends Component { ...@@ -341,7 +376,7 @@ class YearCourse extends Component {
return ( return (
<div className={'year-index-course'}> <div className={'year-index-course'}>
<CommonContainer title='重磅好课'> <CommonContainer title='重磅好课' id='year-course'>
<div> <div>
{ {
(bigcourse.course && bigcourse.course.length > 0) && (bigcourse.course && bigcourse.course.length > 0) &&
...@@ -377,7 +412,7 @@ class YearCourse extends Component { ...@@ -377,7 +412,7 @@ class YearCourse extends Component {
} }
</div> </div>
</CommonContainer> </CommonContainer>
<CommonContainer title='人气好课免费学'> <CommonContainer title='人气好课免费学' id='year-free'>
<div> <div>
{ {
(freecourse.course && freecourse.course.length > 0) && (freecourse.course && freecourse.course.length > 0) &&
...@@ -415,7 +450,7 @@ class YearCourse extends Component { ...@@ -415,7 +450,7 @@ class YearCourse extends Component {
} }
</div> </div>
</CommonContainer> </CommonContainer>
<CommonContainer title='精品好课1分开抢'> <CommonContainer title='精品好课1分开抢' id='year-group'>
<div> <div>
{ {
(groupcourse.course && groupcourse.course.length > 0) && (groupcourse.course && groupcourse.course.length > 0) &&
...@@ -486,7 +521,7 @@ class YearCourse extends Component { ...@@ -486,7 +521,7 @@ class YearCourse extends Component {
} }
</div> </div>
</CommonContainer> </CommonContainer>
<CommonContainer title='好课价到,等你抄底'> <CommonContainer title='好课价到,等你抄底' id='year-discount'>
<div> <div>
<h4 className="ai-course__subtitle">基础</h4> <h4 className="ai-course__subtitle">基础</h4>
{ {
...@@ -534,7 +569,7 @@ class YearCourse extends Component { ...@@ -534,7 +569,7 @@ class YearCourse extends Component {
</div> </div>
<div className="price"> <div className="price">
{item.type == 2 ? '到手最低:¥' : '¥'} {item.type == 2 ? '到手最低:¥' : '¥'}
<span className="new-price">{item.price1}</span> <span className="new-price">{item.price1}</span>
<span <span
className="old-price"> className="old-price">
...@@ -625,7 +660,7 @@ class YearCourse extends Component { ...@@ -625,7 +660,7 @@ class YearCourse extends Component {
</div> </div>
<div className="price"> <div className="price">
{item.type == 2 ? '到手最低:¥' : '¥'} {item.type == 2 ? '到手最低:¥' : '¥'}
<span className="new-price">{item.price1}</span> <span className="new-price">{item.price1}</span>
<span <span
className="old-price"> className="old-price">
...@@ -716,7 +751,7 @@ class YearCourse extends Component { ...@@ -716,7 +751,7 @@ class YearCourse extends Component {
</div> </div>
<div className="price"> <div className="price">
{item.type == 2 ? '到手最低:¥' : '¥'} {item.type == 2 ? '到手最低:¥' : '¥'}
<span className="new-price">{item.price1}</span> <span className="new-price">{item.price1}</span>
<span <span
className="old-price"> className="old-price">
...@@ -807,7 +842,7 @@ class YearCourse extends Component { ...@@ -807,7 +842,7 @@ class YearCourse extends Component {
</div> </div>
<div className="price"> <div className="price">
{item.type == 2 ? '到手最低:¥' : '¥'} {item.type == 2 ? '到手最低:¥' : '¥'}
<span className="new-price">{item.price1}</span> <span className="new-price">{item.price1}</span>
<span <span
className="old-price"> className="old-price">
...@@ -877,7 +912,7 @@ class YearCourse extends Component { ...@@ -877,7 +912,7 @@ class YearCourse extends Component {
<p className='sub__title'>提醒服务</p> <p className='sub__title'>提醒服务</p>
<p className='sub__tip'>课程开售立即提醒,不错过任何优惠哦!</p> <p className='sub__tip'>课程开售立即提醒,不错过任何优惠哦!</p>
<img className='sub__qr_code' id={'live-qr-code'} <img className='sub__qr_code' id={'live-qr-code'}
src='//julyedu-cdn.oss-cn-beijing.aliyuncs.com/2018christyear/h5/qrcode.jpg' alt=""/> src={this.state.followBarcode} alt=""/>
{ {
browser.isAndroidApp ? ( browser.isAndroidApp ? (
<button className={'save-image'} onClick={this.saveImage}>保存二维码</button> <button className={'save-image'} onClick={this.saveImage}>保存二维码</button>
......
...@@ -115,7 +115,7 @@ class YarnWish extends Component { ...@@ -115,7 +115,7 @@ class YarnWish extends Component {
</div> </div>
<div className="price"> <div className="price">
{item.type == 2 ? '到手最低:¥' : '¥'} {item.type == 2 ? '到手最低:¥' : '¥'}
<span className="new-price">{item.price1}</span> <span className="new-price">{item.price1}</span>
<span <span
className="old-price"> className="old-price">
......
...@@ -3,7 +3,7 @@ html, body, #root { ...@@ -3,7 +3,7 @@ html, body, #root {
} }
.yarn-wish { .yarn-wish {
height: 100%; min-height: 100%;
background-color: #BA2C21; background-color: #BA2C21;
padding-bottom: 35px; padding-bottom: 35px;
......
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