Commit 2da66b1e by wangshuo

合并代码

parents 89915984 f590eef5
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import ListFrame from './../listFrame/index';
import ListHeader from './../listHeader';
import './index.scss';
......@@ -48,26 +49,33 @@ class CollectBlessing extends Component {
}
render() {
const { handleToShowNotice, handleToShowList, handleToShowInvite, handleToShow } = this.props;
const {
isSign,
userInfo: { isLogin = false, blessingVal = 0 },
handleToShowNotice,
handleToShowList,
handleToShowInvite,
handleToShow
} = this.props;
const { rules, welfareRuleList } = this.state;
return (
<>
<div className="collect-blessing">
{
this.props.userLogin ? (
<ListHeader size="middle" styles={{margin: '20px 0 0 0'}} >{`我的福气值: ${this.props.blessingNumber}`}</ListHeader>
) : (
isLogin
? (
<ListHeader text={`我的福气值: ${blessingVal}分`} size="middle" styles={{margin: '20px 0 0 0'}} />
)
: (
<ListHeader size="middle" styles={{margin: '20px 0 0 0'}} >
<span className="text_nologin">我的福气值:</span>
<div className="login__btn" onClick={this.props.toLogin}>登录</div>
<Link to='/passport' className="login__btn">登录</Link>
</ListHeader>
)
}
<p className='activity__over'>活动结束 福气榜前20名可获奖品一份</p>
<div className='blessing__rules'>
{
welfareRuleList.map((item, index) => {
return <div className="rules__item" key={index}>
welfareRuleList.map((item, index) => (
<div className="rules__item" key={index}>
<div className="item__left">
<div className='tip__bubble'>
<div className="tip__text">福气值</div>
......@@ -88,24 +96,27 @@ class CollectBlessing extends Component {
}
</div>
</div>
})
))
}
</div>
</div>
<div className="collect-blessing">
<ListHeader text="福气值积攒规则" size="middle" styles={{}} />
<ListHeader text="福气值积攒规则" size="middle" styles={{margin: '30px 0 0'}} />
{
rules.map((item, index) => (
<div className="collect-blessing__item" key={index}>
<i className="collect-blessing__num">{index+1}</i>
<p className="collect-blessing__title">{item}</p>
{
index === 0 &&
index === 0 && (isLogin && isSign) &&
<a className="collect-blessing__content" onClick={handleToShowNotice}>
点击<br/>签到
+5<br/>福气值
</a>
}
{
index === 0 && (!isLogin || !isSign) &&
<Link to='/passport' className="collect-blessing__content">
点击<br/>签到
</Link>
}
{
index === 1 &&
<a className="collect-blessing__content" onClick={handleToShowNotice}>
关注<br/>二维码
......@@ -141,7 +152,6 @@ class CollectBlessing extends Component {
))
}
</div>
</>
)
}
}
......
......@@ -92,6 +92,7 @@
margin: 10px auto;
text-align: center;
}
.login__btn {
width:34px;
height:18px;
......@@ -103,6 +104,7 @@
text-align: center;
margin-right: 12px;
}
.text_nologin {
font-size:16px;
font-weight:600;
......@@ -115,7 +117,8 @@
background-size: 100% 100%;
width: 336px;
padding: 18px 18px 10px 18px;
margin: 10px auto;
margin: 10px auto 0;
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: space-between;
......@@ -175,6 +178,8 @@
p {
margin-bottom: 10px;
line-height: 1;
&:last-child {
margin-bottom: 0;
}
......
......@@ -33,6 +33,8 @@ class BlessingPreheat extends Component {
isServer: false,
serverUrl: '',
shareMark: false,
userInfo: {},
isSign: false,
}
}
......@@ -41,12 +43,35 @@ class BlessingPreheat extends Component {
}
fetchUserBlessing() {
const { userInfo } = this.state;
http.get(`${API.home}/sys/user/blessing`).then(res => {
const { code, data } = res.data;
if(code === 200) {
this.setState({
isFormal: data.is_activity
isFormal: data.is_activity,
userInfo: Object.assign({}, userInfo, {
isLogin: !!data.is_login,
blessingVal: data.user_blessing_value,
})
});
if(data.is_login === 1) {
this.handleToSign();
}
}
});
}
handleToSign = () => {
console.log(2,2);
http.post(`${API.home}/sys/add/blessing`, {
type: 1 // 1:签到;3:分享;4:浏览课程;
}).then(res => {
const {code } = res.data;
if (code === 200) {
this.setState({
isSign: true,
});
Toast.info('+5点福气值~', 2, null, false);
}
});
}
......@@ -59,14 +84,18 @@ class BlessingPreheat extends Component {
})
}
handleToShow = (key) => {
console.log(key);
handleToShow = (key, isLogin = false) => {
const { history } = this.props;
if(isLogin) {
history.push('/passport')
}else {
let obj = {};
obj[key] = true;
this.setState({
...obj
});
}
}
handleToShowInvite = () => {
QRCode.toDataURL('http://m.julyedu.com/invite', {
......@@ -114,12 +143,14 @@ class BlessingPreheat extends Component {
}
render() {
const {isRule, isCourse, inviteUrl, inviteVisible, isFormal, isServer, serverUrl, showRecordList, shareMark} = this.state
const { userInfo, isRule, isCourse, inviteUrl, inviteVisible, isFormal, isServer, serverUrl, isSign, showRecordList, shareMark} = this.state
return (
<div id={'blessing-preheat'}>
{/* 积福气 */}
<ListHeader text="积福气,享受更多福利" styles={{margin: '0 0 15px'}} />
<CollectBlessing
isSign={isSign}
userInfo={userInfo}
handleToShowList={() => this.handleToShow('isCourse')}
handleToShowInvite={this.handleToShowInvite}
handleToShowNotice={this.handleToShowNotice}
......
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