Commit b1e87b6f by zhanghaozhe

我的宝箱页面app去掉头部

parent a8644801
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
} }
} }
& li:last-child{ & li:last-child {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -173,6 +173,7 @@ ...@@ -173,6 +173,7 @@
height: 2px; height: 2px;
background: #fff; background: #fff;
border-radius: 1px; border-radius: 1px;
.progress { .progress {
position: absolute; position: absolute;
right: 0; right: 0;
...@@ -194,3 +195,29 @@ ...@@ -194,3 +195,29 @@
} }
} }
} }
.landing-treasure-rules {
width: 320px;
&.popup-container {
top: 50%;
transform: translate(-50%, -50%);
.title {
font-size: 18px;
color: #111111;
}
}
.content {
padding: 0 19px 15px;
margin-top: 22px;
color: #666666;
font-size: 14px;
li {
margin-bottom: 5px;
}
}
}
import React, { Component } from 'react'; import React, { Component } from 'react'
import { connect } from 'react-redux'; import { connect } from 'react-redux'
import { HeaderBar } from '@common'; import { HeaderBar } from '@common'
import AddressPopup from '@common/addressPopup/index'; import AddressPopup from '@common/addressPopup/index'
import BindPhone from '@common/bindPhone/index'; import BindPhone from '@common/bindPhone/index'
import ConfirmPhone from '@common/confirmPhone/index'; import ConfirmPhone from '@common/confirmPhone/index'
import CreateSuccess from './../common/createSuccess/index'; import CreateSuccess from './../common/createSuccess/index'
import TreasureTeam from './team'; import TreasureTeam from './team'
import PrizeStatus from './prize'; import PrizeStatus from './prize'
import SplitSuccess from './../common/splitSuccess/index'; import SplitSuccess from './../common/splitSuccess/index'
import { http, getParam, SendMessageToApp } from '@/utils'; import { http, getParam, SendMessageToApp, browser } from '@/utils'
import Mask from './mask'; import Mask from './mask'
import './index.scss'; import './index.scss'
@connect(({country, user}) => ({ @connect(({country, user}) => ({
country, country,
userInfo: user.data userInfo: user.data
})) }))
class MyTreasure extends Component { class MyTreasure extends Component {
popupInstance = null; popupInstance = null
constructor(props) { constructor(props) {
super(props); super(props)
this.state = { this.state = {
isEnd: false, isEnd: false,
isEmpty: false, isEmpty: false,
...@@ -37,65 +37,65 @@ class MyTreasure extends Component { ...@@ -37,65 +37,65 @@ class MyTreasure extends Component {
createInfo: {}, createInfo: {},
prizeName: '', // 当前商品的名字 prizeName: '', // 当前商品的名字
treasureTime: '', // 宝箱活动结束时间 treasureTime: '', // 宝箱活动结束时间
}; }
} }
componentDidMount() { componentDidMount() {
this.fetchMyTreasure(); this.fetchMyTreasure()
this.fetchActivityStatus(); this.fetchActivityStatus()
} }
componentWillReceiveProps(nextProp) { componentWillReceiveProps(nextProp) {
const { history } = this.props; const {history} = this.props
const { userInfo } = nextProp; const {userInfo} = nextProp
if(!userInfo.uid) { if (!userInfo.uid) {
history.push('/passport'); history.push('/passport')
} }
} }
// 页面加载时,初始化当前需要绑定手机号的奖品名字 // 页面加载时,初始化当前需要绑定手机号的奖品名字
initPrizeName = (params) => { initPrizeName = (params) => {
const key = this.fetchCurrentTeamId(params); const key = this.fetchCurrentTeamId(params)
const data = params.filter(item => item.id == key); const data = params.filter(item => item.id == key)
if(data.length > 0) { if (data.length > 0) {
this.setState({ this.setState({
prizeName: data[0]['prize_name'] prizeName: data[0]['prize_name']
}); })
} }
} }
// 页面加载时,是否需要拆宝箱 // 页面加载时,是否需要拆宝箱
judgeIsHaveId = (data) => { judgeIsHaveId = (data) => {
const id = getParam('id'); const id = getParam('id')
if(id) { if (id) {
const newData = data.filter(item => item.id == id); const newData = data.filter(item => item.id == id)
if(newData.length > 0) { if (newData.length > 0) {
const params = { const params = {
team_num: newData[0]['team_num'], team_num: newData[0]['team_num'],
owner_uid: newData[0]['captain_uid'] owner_uid: newData[0]['captain_uid']
}; }
this.toSplitTreasure(params); this.toSplitTreasure(params)
} }
} }
} }
// 获取当前需要绑定手机的队伍id,当拆到需要绑定手机号/地址的宝箱时,如果不进行绑定则无法拆下一个 // 获取当前需要绑定手机的队伍id,当拆到需要绑定手机号/地址的宝箱时,如果不进行绑定则无法拆下一个
fetchCurrentTeamId = (data = []) => { fetchCurrentTeamId = (data = []) => {
const arr = data.filter(item => item.is_open && (item.bind_phone || item.bind_address)); const arr = data.filter(item => item.is_open && (item.bind_phone || item.bind_address))
if(arr.length > 0) { if (arr.length > 0) {
return arr[0]['id']; return arr[0]['id']
}else { } else {
return ''; return ''
} }
} }
// 页面加载时,是否是从选择区号页面过来的 // 页面加载时,是否是从选择区号页面过来的
// TODO,当同时展示拆宝箱成功弹窗和绑定手机号弹窗时,选择区号返回时未展示拆宝箱成功弹窗(和产品确认,后续优化) // TODO,当同时展示拆宝箱成功弹窗和绑定手机号弹窗时,选择区号返回时未展示拆宝箱成功弹窗(和产品确认,后续优化)
isShowBindPhone = (data) => { isShowBindPhone = (data) => {
const { country } = this.props; const {country} = this.props
if(country.from) { if (country.from) {
const id = this.fetchCurrentTeamId(data); const id = this.fetchCurrentTeamId(data)
this.handleToBindPhone(id); this.handleToBindPhone(id)
} }
} }
...@@ -103,19 +103,19 @@ class MyTreasure extends Component { ...@@ -103,19 +103,19 @@ class MyTreasure extends Component {
handleToBindPhone = (id) => { handleToBindPhone = (id) => {
this.setState({ this.setState({
isPhone: true, isPhone: true,
}); })
} }
// 绑定手机号--确认 // 绑定手机号--确认
handleToConfirmPhone = (params, bindInfo) => { handleToConfirmPhone = (params, bindInfo) => {
this.handleToHideWindow('isPhone'); this.handleToHideWindow('isPhone')
this.setState({ this.setState({
confirmInfo: { confirmInfo: {
params, params,
bindInfo, bindInfo,
}, },
isConfirm: true, isConfirm: true,
}); })
} }
// 绑定手机号--成功 // 绑定手机号--成功
...@@ -123,63 +123,63 @@ class MyTreasure extends Component { ...@@ -123,63 +123,63 @@ class MyTreasure extends Component {
this.setState({ this.setState({
isPhone: false, isPhone: false,
isConfirm: false, isConfirm: false,
}); })
const{ teams, splitInfo } = this.state; const {teams, splitInfo} = this.state
const teamId = this.fetchCurrentTeamId(teams); const teamId = this.fetchCurrentTeamId(teams)
const data = teams.map(item => { const data = teams.map(item => {
if(item.id == teamId) { if (item.id == teamId) {
if(item.bind_address) { if (item.bind_address) {
this.handleToBindAddress(); this.handleToBindAddress()
} }
return Object.assign({}, item, { return Object.assign({}, item, {
bind_phone: false, bind_phone: false,
}); })
} }
return item; return item
}) })
this.setState({ this.setState({
teams: data, teams: data,
splitInfo: Object.assign({}, splitInfo, { splitInfo: Object.assign({}, splitInfo, {
bind_phone: false bind_phone: false
}) })
}); })
} }
// 拆宝箱--拆 // 拆宝箱--拆
toSplitTreasure = (params) => { toSplitTreasure = (params) => {
http.post(`${API.home}/sys/split_treasure`, params).then(res => { http.post(`${API.home}/sys/split_treasure`, params).then(res => {
const { code, data } = res.data; const {code, data} = res.data
if(code === 200) { if (code === 200) {
// 拆宝箱弹窗--成功 // 拆宝箱弹窗--成功
this.showSuccessSplit(data); this.showSuccessSplit(data)
// 更新队伍状态 // 更新队伍状态
this.successSplitTreasure(data); this.successSplitTreasure(data)
if(data.bind_phone) { if (data.bind_phone) {
setTimeout(() => { setTimeout(() => {
this.handleToBindPhone(data.id); this.handleToBindPhone(data.id)
}, 500); }, 500)
}else if(data.bind_address) { } else if (data.bind_address) {
setTimeout(() => { setTimeout(() => {
this.handleToBindAddress(data.id); this.handleToBindAddress(data.id)
}, 500); }, 500)
} }
}else if(code === 12000) { } else if (code === 12000) {
// 绑定手机号 // 绑定手机号
this.handleToBindPhone(); this.handleToBindPhone()
}else if(code === 12001) { } else if (code === 12001) {
// 绑定地址 // 绑定地址
this.handleToBindAddress(); this.handleToBindAddress()
} }
}); })
} }
// 拆宝箱--成功,更新数据 // 拆宝箱--成功,更新数据
successSplitTreasure = (params) => { successSplitTreasure = (params) => {
const { userInfo } = this.props; const {userInfo} = this.props
const { teams } = this.state; const {teams} = this.state
const data = teams.map(item => { const data = teams.map(item => {
if(item.id == params.id) { if (item.id == params.id) {
return Object.assign({}, item, { return Object.assign({}, item, {
bind_phone: params.bind_phone, bind_phone: params.bind_phone,
bind_address: params.bind_address, bind_address: params.bind_address,
...@@ -187,25 +187,25 @@ class MyTreasure extends Component { ...@@ -187,25 +187,25 @@ class MyTreasure extends Component {
prize_type: params.prize_type, prize_type: params.prize_type,
prize_data: params.prize_data, prize_data: params.prize_data,
member: item.member.map(val => { member: item.member.map(val => {
if(val.uid == userInfo.uid) { if (val.uid == userInfo.uid) {
return Object.assign({}, val, { return Object.assign({}, val, {
is_open: true, is_open: true,
prize_name: params.prize_name prize_name: params.prize_name
}); })
} }
return val; return val
}) })
}); })
}else { } else {
return item; return item
} }
}); })
this.initNoSplitInfo(data); this.initNoSplitInfo(data)
this.setState({ this.setState({
teams: data, teams: data,
splitInfo: params, splitInfo: params,
prizeName: params.prize_name prizeName: params.prize_name
}); })
} }
// 拆宝箱--成功,展示弹窗 // 拆宝箱--成功,展示弹窗
...@@ -213,15 +213,15 @@ class MyTreasure extends Component { ...@@ -213,15 +213,15 @@ class MyTreasure extends Component {
this.setState({ this.setState({
isSplit: true, isSplit: true,
splitInfo: data splitInfo: data
}); })
} }
// 绑定地址--展示 // 绑定地址--展示
handleToBindAddress = (id) => { handleToBindAddress = (id) => {
if(id) { if (id) {
const { teams } = this.state; const {teams} = this.state
const data = teams.filter(item => item.id == id); const data = teams.filter(item => item.id == id)
if(data.length > 0) { if (data.length > 0) {
this.setState({ this.setState({
prizeName: data[0]['prize_name'] prizeName: data[0]['prize_name']
}) })
...@@ -229,61 +229,61 @@ class MyTreasure extends Component { ...@@ -229,61 +229,61 @@ class MyTreasure extends Component {
} }
this.setState({ this.setState({
isAddress: true isAddress: true
}); })
} }
// 绑定地址--成功 // 绑定地址--成功
successBindAddress = () => { successBindAddress = () => {
this.setState({ this.setState({
isAddress: false, isAddress: false,
}); })
const{ teams, splitInfo } = this.state; const {teams, splitInfo} = this.state
const teamId = this.fetchCurrentTeamId(teams); const teamId = this.fetchCurrentTeamId(teams)
const data = teams.map(item => { const data = teams.map(item => {
if(item.id == teamId) { if (item.id == teamId) {
return Object.assign({}, item, { return Object.assign({}, item, {
bind_address: false, bind_address: false,
}); })
} }
return item; return item
}) })
this.setState({ this.setState({
teams: data, teams: data,
splitInfo: Object.assign({}, splitInfo, { splitInfo: Object.assign({}, splitInfo, {
bind_address: false bind_address: false
}) })
}); })
} }
// 获取我的宝箱信息 // 获取我的宝箱信息
fetchMyTreasure = () => { fetchMyTreasure = () => {
http.get(`${API.home}/sys/treasure/my`).then(res => { http.get(`${API.home}/sys/treasure/my`).then(res => {
const { code, data } = res.data; const {code, data} = res.data
if (code === 200) { if (code === 200) {
this.setState({ this.setState({
rule: data.rule rule: data.rule
}); })
if (Array.isArray(data.team) && data.team.length > 0) { if (Array.isArray(data.team) && data.team.length > 0) {
this.initNoSplitInfo(data.team); this.initNoSplitInfo(data.team)
this.judgeIsHaveId(data.team); this.judgeIsHaveId(data.team)
this.isShowBindPhone(data.team); this.isShowBindPhone(data.team)
this.initPrizeName(data.team); this.initPrizeName(data.team)
this.setState({ this.setState({
isEmpty: false, isEmpty: false,
teams: data.team, teams: data.team,
}); })
} else { } else {
this.setState({ this.setState({
isEmpty: true, isEmpty: true,
}); })
} }
} }
}); })
} }
// 统计未拆的宝箱信息 // 统计未拆的宝箱信息
initNoSplitInfo = (data = []) => { initNoSplitInfo = (data = []) => {
if(data.length > 0) { if (data.length > 0) {
this.setState({ this.setState({
ids: data.filter(item => !item.is_open && item.status === 2).map(val => { ids: data.filter(item => !item.is_open && item.status === 2).map(val => {
return { return {
...@@ -291,136 +291,136 @@ class MyTreasure extends Component { ...@@ -291,136 +291,136 @@ class MyTreasure extends Component {
owner_uid: val.captain_uid owner_uid: val.captain_uid
} }
}) })
}); })
} }
} }
// 获取宝箱活动状态 // 获取宝箱活动状态
fetchActivityStatus = () => { fetchActivityStatus = () => {
http.get(`${API.home}/activity/stage`).then(res => { http.get(`${API.home}/activity/stage`).then(res => {
const { code, data } = res.data; const {code, data} = res.data
if (code === 200) { if (code === 200) {
// treasure_stage,宝箱阶段,0-不在活动时间,1-活动时间内 // treasure_stage,宝箱阶段,0-不在活动时间,1-活动时间内
if(data.treasure_stage === 0) { if (data.treasure_stage === 0) {
this.startCountDown(); this.startCountDown()
} }
this.setState({ this.setState({
isEnd: data.treasure_stage === 0, isEnd: data.treasure_stage === 0,
treasureTime: data.treasure_stop_date treasureTime: data.treasure_stop_date
}); })
} }
}); })
} }
// 活动结束--倒计时 // 活动结束--倒计时
startCountDown = () => { startCountDown = () => {
const { history } = this.props; const {history} = this.props
let { seconds } = this.state; let {seconds} = this.state
if (this.timer) { if (this.timer) {
clearInterval(this.timer); clearInterval(this.timer)
} }
this.setState({ this.setState({
seconds: seconds-- seconds: seconds--
}); })
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.setState({ this.setState({
seconds: seconds-- seconds: seconds--
}); })
if (seconds === 0) { if (seconds === 0) {
this.setState({ this.setState({
seconds: 0 seconds: 0
}); })
clearInterval(this.timer); clearInterval(this.timer)
if(getParam('version')) { if (getParam('version')) {
history.push(`/year/yearIndex?version=${getParam('version')}`); history.push(`/year/yearIndex?version=${getParam('version')}`)
}else { } else {
history.push('/year/yearIndex'); history.push('/year/yearIndex')
} }
} }
}, 1000); }, 1000)
} }
// 邀请好友 // 邀请好友
handleToInvite = (treasure_code) => { handleToInvite = (treasure_code) => {
const { history } = this.props; const {history} = this.props
if(getParam('version')){ if (getParam('version')) {
history.push(`/activity/newyear-2019/landing?treasure_code=${treasure_code}&origin=1&version=${getParam('version')}`); history.push(`/activity/newyear-2019/landing?treasure_code=${treasure_code}&origin=1&version=${getParam('version')}`)
}else { } else {
history.push(`/activity/newyear-2019/landing?treasure_code=${treasure_code}&origin=1`); history.push(`/activity/newyear-2019/landing?treasure_code=${treasure_code}&origin=1`)
} }
} }
// 组队开宝箱 // 组队开宝箱
toOrganizeTeam = () => { toOrganizeTeam = () => {
const { history, userInfo: { uid = '' } } = this.props; const {history, userInfo: {uid = ''}} = this.props
if(uid === '') { if (uid === '') {
history.push('/passport') history.push('/passport')
}else { } else {
http.get(`${API.home}/sys/treasure/createMyTeam`).then(res => { http.get(`${API.home}/sys/treasure/createMyTeam`).then(res => {
const { code, data } = res.data; const {code, data} = res.data
if(code === 200) { if (code === 200) {
const teams = []; const teams = []
teams[0] = data; teams[0] = data
this.setState({ this.setState({
isEmpty: false, isEmpty: false,
teams, teams,
isCreate: true, isCreate: true,
createInfo: data createInfo: data
}); })
} }
}); })
} }
} }
// 奖品,代金券碎片--合成 // 奖品,代金券碎片--合成
toComposeCoupon = () => { toComposeCoupon = () => {
const { history } = this.props; const {history} = this.props
if(getParam('version')) { if (getParam('version')) {
SendMessageToApp("toCoupon") SendMessageToApp("toCoupon")
}else { } else {
history.push('/coupons/my-patch'); history.push('/coupons/my-patch')
} }
} }
// 奖品,指定课程代金券--使用 // 奖品,指定课程代金券--使用
toUseCoupon = (id) => { toUseCoupon = (id) => {
const { history } = this.props; const {history} = this.props
if(getParam('version')) { if (getParam('version')) {
SendMessageToApp("toCourse", id) SendMessageToApp("toCourse", id)
}else { } else {
history.push(`/detail?id=${id}`); history.push(`/detail?id=${id}`)
} }
} }
// 第三:奖品,通用课程代金券--使用 // 第三:奖品,通用课程代金券--使用
toCourseList = () => { toCourseList = () => {
const { history } = this.props; const {history} = this.props
if(getParam('version')) { if (getParam('version')) {
SendMessageToApp('toQualityCourse') SendMessageToApp('toQualityCourse')
}else { } else {
history.push('/classify'); history.push('/classify')
} }
} }
// 第三:奖品,现金红包--提现 // 第三:奖品,现金红包--提现
toFecthMoney = () => { toFecthMoney = () => {
const { history } = this.props; const {history} = this.props
if(getParam('version')) { if (getParam('version')) {
SendMessageToApp('toAccount') SendMessageToApp('toAccount')
}else { } else {
history.push('/scholarship'); history.push('/scholarship')
} }
} }
// 弹窗--隐藏 // 弹窗--隐藏
handleToHideWindow = (key) => { handleToHideWindow = (key) => {
const param = {}; const param = {}
param[key] = false; param[key] = false
this.setState(param); this.setState(param)
} }
render() { render() {
const { history, userInfo, country } = this.props; const {history, userInfo, country} = this.props
const { const {
isEnd, isEnd,
isEmpty, isEmpty,
...@@ -441,14 +441,14 @@ class MyTreasure extends Component { ...@@ -441,14 +441,14 @@ class MyTreasure extends Component {
prizeName, prizeName,
rule, rule,
treasureTime, treasureTime,
} = this.state; } = this.state
return ( return (
<div data-skip="treasure"> <div data-skip="treasure">
<HeaderBar title="我的宝箱" arrow={true} /> {(!browser.isAndroidApp || !browser.isIOSApp) && <HeaderBar title="我的宝箱" arrow={true}/>}
{ {
isEnd && isEnd &&
<p className="activity-end__desc"> <p className="activity-end__desc">
活动已结束<br /> 活动已结束<br/>
{seconds}s后将自动返回首页 {seconds}s后将自动返回首页
</p> </p>
} }
...@@ -526,7 +526,7 @@ class MyTreasure extends Component { ...@@ -526,7 +526,7 @@ class MyTreasure extends Component {
successBindPhone={this.successBindPhone} successBindPhone={this.successBindPhone}
desc={ desc={
<> <>
<p className="phone-treasure__desc">恭喜您获得 {prizeName}</p> <p className="phone-treasure__desc">恭喜您获得 {prizeName}</p>
<p className="phone-treasure__notice">为了您的账户安全,请于{treasureTime}前绑定手机号,过期将失效</p> <p className="phone-treasure__notice">为了您的账户安全,请于{treasureTime}前绑定手机号,过期将失效</p>
</> </>
} }
...@@ -562,8 +562,8 @@ class MyTreasure extends Component { ...@@ -562,8 +562,8 @@ class MyTreasure extends Component {
<CreateSuccess <CreateSuccess
data={createInfo} data={createInfo}
handleToInvite={() => { handleToInvite={() => {
this.handleToInvite(createInfo.treasure_code); this.handleToInvite(createInfo.treasure_code)
this.handleToHideWindow('isCreate'); this.handleToHideWindow('isCreate')
}} }}
/> />
</Mask> </Mask>
...@@ -585,4 +585,4 @@ class MyTreasure extends Component { ...@@ -585,4 +585,4 @@ class MyTreasure extends Component {
} }
} }
export default MyTreasure; export default MyTreasure
\ No newline at end of file
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