Commit 880ef959 by zhanghaozhe

更新popup通用组件

parent 89ff55f8
...@@ -29,62 +29,6 @@ import { connect } from "react-redux" ...@@ -29,62 +29,6 @@ import { connect } from "react-redux"
class BlessingPreheat extends Component { class BlessingPreheat extends Component {
constructor(props) {
super(props)
this.navTop = 183
this.prevY = 0
this.state = {
userInfoList: [],
// userInfoList: [{
// token:'fcfef221e60ab7a2-92a80d5d30196999',
// uid:'545292',
// uname:'xzhtest2',
// avatar_file:''
// }],
isRule: false,
isCourse: false,
inviteUrl: '',
inviteVisible: false,
joinLotteryVisible: false,
timelineShareVisible: false,
showRecordList: false,
isFormal: false, // 1正式 0 预热
isServer: false,
serverUrl: '',
shareMark: false,
userInfo: {},
isSign: false,
navs: [
{
text: '积福气',
id: 'lucky-value'
},
{
text: '幸运大抽奖',
id: 'lucky-draw'
},
{
text: '预付定金',
id: 'deposit'
},
{
text: '精品特惠',
id: 'best-courses'
},
{
text: 'AI测试',
id: 'ai-test'
},
{
text: '大咖直播',
id: 'live'
},
],
index: 0,
userHasError: props.user.hasError,
isApp: false
}
}
constructor(props) { constructor(props) {
super(props) super(props)
this.navTop = 183 this.navTop = 183
...@@ -99,11 +43,14 @@ class BlessingPreheat extends Component { ...@@ -99,11 +43,14 @@ class BlessingPreheat extends Component {
// }], // }],
isRule: false, isRule: false,
isCourse: false, isCourse: false,
inviteUrl: '',
inviteVisible: false, inviteVisible: false,
joinLotteryVisible: false, joinLotteryVisible: false,
timelineShareVisible: false, timelineShareVisible: false,
showRecordList: false, showRecordList: false,
isFormal: false, // 1正式 0 预热 isFormal: false, // 1正式 0 预热
isServer: false,
serverUrl: '',
shareMark: false, shareMark: false,
userInfo: {}, userInfo: {},
isSign: false, isSign: false,
...@@ -134,7 +81,8 @@ class BlessingPreheat extends Component { ...@@ -134,7 +81,8 @@ class BlessingPreheat extends Component {
}, },
], ],
index: 0, index: 0,
userHasError: props.user.hasError userHasError: props.user.hasError,
isApp: false
} }
} }
...@@ -163,46 +111,44 @@ class BlessingPreheat extends Component { ...@@ -163,46 +111,44 @@ class BlessingPreheat extends Component {
this.handleToAddBlessing(result) this.handleToAddBlessing(result)
} }
}
} }
// 获取app登录数据 // 获取app登录数据
loginInfo = (result) => { loginInfo = (result) => {
this.setState({ this.setState({
userInfoList: result userInfoList: result
}, () => { }, () => {
if(this.state.userInfoList.length){ if (this.state.userInfoList.length) {
this.props.startFetchUser() this.props.startFetchUser()
this.appLogin() this.appLogin()
} }
}) })
} }
// 保存cookie // 保存cookie
appLogin = () => { appLogin = () => {
let expires = addDays(new Date(), 90) let expires = addDays(new Date(), 90)
this.state.userInfoList.map((item, index) => { this.state.userInfoList.map((item, index) => {
Toast.info(item.uid) Toast.info(item.uid)
cookie.set("token", item.token, {expires, path: '/', domain: '.julyedu.com'}); cookie.set("token", item.token, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("plat", item.plat, {expires, path: '/', domain: '.julyedu.com'}); cookie.set("plat", item.plat, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("uid", item.uid, {expires, path: '/', domain: '.julyedu.com'}); cookie.set("uid", item.uid, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("uname", item.uname, {expires, path: '/', domain: '.julyedu.com'}); cookie.set("uname", item.uname, {expires, path: '/', domain: '.julyedu.com'})
cookie.set("avatar_file", item.avatar_file, {expires, path: '/', domain: '.julyedu.com'}); cookie.set("avatar_file", item.avatar_file, {expires, path: '/', domain: '.julyedu.com'})
}); })
if (cookie.get("token") && cookie.get("uid")) {
this.fetchUserBlessing();
this.setState({
isApp: true
})
}
this.props.setCurrentUser(this.transformUser(this.state.userInfoList)) if (cookie.get("token") && cookie.get("uid")) {
this.fetchUserBlessing()
this.setState({
isApp: true
})
} }
transformUser = res => {
let payload this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
}
transformUser = res => {
let payload
res.map((item, index) => { res.map((item, index) => {
payload = { payload = {
...@@ -267,29 +213,29 @@ class BlessingPreheat extends Component { ...@@ -267,29 +213,29 @@ class BlessingPreheat extends Component {
return findIndex(navs, item => item.id === str) return findIndex(navs, item => item.id === str)
} }
fetchUserBlessing() { fetchUserBlessing = () => {
const {userInfo} = this.state; const {userInfo} = this.state
http.get(`${API.home}/sys/user/blessing`).then(res => { http.get(`${API.home}/sys/user/blessing`).then(res => {
const {code, data} = res.data const {code, data} = res.data
alert(code) alert(code)
if (code === 200) { if (code === 200) {
this.setState({ this.setState({
isSign: !!data.today_signed, isSign: !!data.today_signed,
isFormal: data.is_activity, isFormal: data.is_activity,
userInfo: Object.assign({}, userInfo, { userInfo: Object.assign({}, userInfo, {
blessingVal: data.user_blessing_value, blessingVal: data.user_blessing_value,
buyBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.buy_course) ? data.types_total_blessing_value.buy_course : 0, buyBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.buy_course) ? data.types_total_blessing_value.buy_course : 0,
inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0, inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0,
}) })
})
alert(cookie.get('uid'))
if (data.is_login === 1) {
this.handleToSign()
}
this.initNav(data.is_activity)
}
}) })
} alert(cookie.get('uid'))
if (data.is_login === 1) {
this.handleToSign()
}
this.initNav(data.is_activity)
}
})
}
handleToAddBlessing = (key) => { handleToAddBlessing = (key) => {
...@@ -331,18 +277,18 @@ class BlessingPreheat extends Component { ...@@ -331,18 +277,18 @@ class BlessingPreheat extends Component {
// 需要用户登录 并且用户未登录 // 需要用户登录 并且用户未登录
const isLoginnew = !this.props.user.hasError const isLoginnew = !this.props.user.hasError
if (isLogin && !isLoginnew) { if (isLogin && !isLoginnew) {
this.toLogin() this.toLogin()
} else { } else {
let obj = {} let obj = {}
obj[key] = true obj[key] = true
this.setState({ this.setState({
...obj ...obj
}) })
}
} }
}
// 邀请好友注册 // 邀请好友注册
handleToShowInvite = () => { handleToShowInvite = () => {
const isLogin = !this.props.user.hasError const isLogin = !this.props.user.hasError
if (isLogin) { if (isLogin) {
...@@ -474,33 +420,6 @@ class BlessingPreheat extends Component { ...@@ -474,33 +420,6 @@ class BlessingPreheat extends Component {
} }
} }
render() {
const {
navs,
userInfo,
isRule,
isCourse,
inviteUrl,
inviteVisible,
isFormal,
isServer,
serverUrl,
isSign,
showRecordList,
shareMark,
index,
isApp
} = this.state;
const {history} = this.props;
const isLogin = !this.props.user.hasError
return (
<div id={'blessing-preheat'}>
<Banner
isFormal={isFormal}
navs={navs}
toSection={this.toSection}
index={index}
/>
render() { render() {
const { const {
navs, navs,
...@@ -511,7 +430,8 @@ class BlessingPreheat extends Component { ...@@ -511,7 +430,8 @@ class BlessingPreheat extends Component {
isSign, isSign,
showRecordList, showRecordList,
shareMark, shareMark,
index index,
isApp
} = this.state } = this.state
const {history} = this.props const {history} = this.props
const isLogin = !this.props.user.hasError const isLogin = !this.props.user.hasError
...@@ -523,7 +443,6 @@ class BlessingPreheat extends Component { ...@@ -523,7 +443,6 @@ class BlessingPreheat extends Component {
toSection={this.toSection} toSection={this.toSection}
index={index} index={index}
/> />
{/* 积福气 */} {/* 积福气 */}
<ListHeader id={'lucky-value'} text="积福气,享受更多福利" styles={{margin: '60px 0 15px'}}/> <ListHeader id={'lucky-value'} text="积福气,享受更多福利" styles={{margin: '60px 0 15px'}}/>
<Link className="luck-draw__button" to="/blessingRank">福气排行榜></Link> <Link className="luck-draw__button" to="/blessingRank">福气排行榜></Link>
...@@ -550,24 +469,24 @@ class BlessingPreheat extends Component { ...@@ -550,24 +469,24 @@ class BlessingPreheat extends Component {
<button className="luck-draw__button" onClick={() => this.handleToShow('isRule')}>活动规则></button> <button className="luck-draw__button" onClick={() => this.handleToShow('isRule')}>活动规则></button>
<LuckDraw/> <LuckDraw/>
{/*定金--只在预热期间显示*/} {/*定金--只在预热期间显示*/}
{ {
isFormal === 0 && isFormal === 0 &&
<> <>
<ListHeader id={'deposit'} text="预付1元定金,最高可省100元" styles={{margin: '30px 0 15px'}}/> <ListHeader id={'deposit'} text="预付1元定金,最高可省100元" styles={{margin: '30px 0 15px'}}/>
<ReserveCourse isApp={isApp}/> <ReserveCourse isApp={isApp}/>
</> </>
} }
{/* 精品课程特惠专区 */} {/* 精品课程特惠专区 */}
<ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}}/> <ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}}/>
<CourseList <CourseList
isApp={isApp} isApp={isApp}
isFormal={isFormal} isFormal={isFormal}
isLogin={isLogin} isLogin={isLogin}
history={this.props.history} history={this.props.history}
toLogin={this.toLogin} toLogin={this.toLogin}
/> />
{ {
isRule && isRule &&
......
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