Commit 69ac4857 by xuzhenghua

新用户大礼包

parent 8b94577e
import React, {Component} from 'react'
import './index.scss'
import {http} from '@/utils'
class UserGift extends Component {
state = {
user_gift: ''
}
componentDidMount() {
http.get(`${API['base-api']}/web/home/popup`).then((res) => {
const {errno, data} = res.data
if (errno === 200) {
this.setState({
user_gift: data.new_user_gift.prize_img
})
}
})
}
get_newerModal = () => {
this.props.history.push('/passport/login')
}
close = () => {
this.props.close()
}
render() {
const {user_gift} = this.state
return (
<div className={'user-gift-popup'}>
<div className={'user-gift-bgimg'}>
<img onClick={this.get_newerModal} src={user_gift} alt=""/>
<img className={'close_gift_box'}
src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/tinypng-common/close_icon.png"
onClick={this.close} alt=""/>
</div>
</div>
)
}
}
export default UserGift
\ No newline at end of file
.user-gift-popup {
background: rgba(0, 0, 0, .3);
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 100;
.user-gift-bgimg {
position: relative;
top: 50%;
margin-top: -200px;
.close_gift_box {
position: absolute;
left: 50%;
margin-left: -13px;
width: 26px;
height: 26px;
bottom: -45px;
}
}
}
\ No newline at end of file
......@@ -11,5 +11,6 @@ export { default as Loading } from './Loading'
export { default as RenderTabBar } from './renderTabBar'
export { default as Popup } from './closable-popup'
export { default as WxLogin } from './WxLogin'
export { default as UserGift } from './UserGift'
......@@ -20,6 +20,7 @@ import { delCountryNum } from './../country/countryRedux';
import { Popup } from "@common/index"
import RedPacket from './redPacket';
import ExpandActiveToast from "../Index/expandActiveToast";
import {UserGift} from "@common"
class Detail extends Component {
......@@ -50,12 +51,16 @@ class Detail extends Component {
isRedPacket: true,
countDownTime: '20s',
isShowChannel: window.sessionStorage.getItem('isShowSiteWindowByChannel')
isShowChannel: window.sessionStorage.getItem('isShowSiteWindowByChannel'),
isShowUserGift:false
}
}
componentDidMount() {
this.fetchCourseInfo();
this.showUserGiftFun();
this.userStatus();
const {location: {state = {}}} = this.props;
if (state.oid) {
this.check(state.oid);
......@@ -81,6 +86,47 @@ class Detail extends Component {
}
}
userStatus =()=>{
http.get(`${API['base-api']}/sys/user/new_user_status`).then((res) => {
const {errno, data} = res.data
if (errno === 0) {
if (data.status == 1) {
// 新用户登录之后判断是否是新用户,是新用户先显示大礼包
this.setState({
isShowUserGift: true
})
} else {
// 老用户
this.setState({
isShowUserGift: false
})
}
}
})
}
showUserGiftFun = () => {
let newer_last_time = localStorage.getItem('newer_last_time') // 获取用户关闭大礼包的时间
let now_time = (new Date()).valueOf()
console.log(newer_last_time)
if (!newer_last_time || now_time - newer_last_time > 86400000) {
this.setState({
isShowUserGift: true
})
} else {
this.setState({
isShowUserGift: false
})
}
}
close = () => {
this.setState({
isShowUserGift: false
})
let now_time = (new Date()).valueOf() // 获取当前时间
localStorage.setItem('newer_last_time', now_time) // 存储关闭时间
}
getBorwerCourse = () => {
http.get(`${API.home}/sys/user/blessing`, {type: 4, course_id: getParam('id')}).then(res => {
let {code, data: {today_browsed_courses}} = res.data;
......@@ -822,6 +868,11 @@ class Detail extends Component {
) : null
}
</div>
{
this.state.isShowUserGift &&
<UserGift close={this.close} history={this.props.history}/>
}
</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