Commit 2dba5b4d by zhanghaozhe

领取页

parent f9e31271
......@@ -281,7 +281,8 @@ module.exports = function(webpackEnv) {
'react-native': 'react-native-web',
'@': path.resolve(__dirname, '../src'),
'@common': path.resolve(__dirname, '../src/common'),
'@components': path.resolve(__dirname, '../src/components')
'@components': path.resolve(__dirname, '../src/components'),
'@assets': path.resolve(__dirname, '../src/assets'),
},
plugins: [
// Adds support for installing with Plug'n'Play, leading to faster installs and adding
......
......@@ -1027,17 +1027,17 @@
}
},
"@babel/runtime": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.3.1.tgz",
"integrity": "sha512-7jGW8ppV0ant637pIqAcFfQDDH1orEPGJb8aXfUozuCU3QqX7rX4DA8iwrbPrR1hcH0FTTHz47yQnk+bl5xHQA==",
"version": "7.7.7",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.7.tgz",
"integrity": "sha512-uCnC2JEVAu8AKB5do1WRIsvrdJ0flYx/A/9f/6chdacnEZ7LmavjdsDXr5ksYBegxtuTPR5Va9/+13QF/kFkCA==",
"requires": {
"regenerator-runtime": "^0.12.0"
"regenerator-runtime": "^0.13.2"
},
"dependencies": {
"regenerator-runtime": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz",
"integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg=="
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz",
"integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw=="
}
}
},
......@@ -2847,6 +2847,14 @@
"@babel/plugin-transform-typescript": "^7.1.0"
}
},
"@babel/runtime": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.3.1.tgz",
"integrity": "sha512-7jGW8ppV0ant637pIqAcFfQDDH1orEPGJb8aXfUozuCU3QqX7rX4DA8iwrbPrR1hcH0FTTHz47yQnk+bl5xHQA==",
"requires": {
"regenerator-runtime": "^0.12.0"
}
},
"babel-loader": {
"version": "8.0.5",
"resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.5.tgz",
......@@ -2871,6 +2879,11 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
},
"regenerator-runtime": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz",
"integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg=="
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
......@@ -3081,9 +3094,9 @@
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg="
},
"base64-js": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw=="
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
},
"base64id": {
"version": "1.0.0",
......
......@@ -5,6 +5,7 @@
"dependencies": {
"@babel/core": "7.2.2",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/runtime": "^7.7.7",
"@loadable/component": "^5.10.1",
"@svgr/webpack": "4.1.0",
"antd-mobile": "^2.3.1",
......@@ -41,6 +42,7 @@
"jest-pnp-resolver": "1.0.2",
"jest-resolve": "23.6.0",
"jest-watch-typeahead": "^0.2.1",
"js-base64": "^2.5.1",
"js-cookie": "^2.2.0",
"less": "^3.9.0",
"less-loader": "^4.1.0",
......
import React, { Component } from 'react'
import { browser, getParam, http } from "@/utils"
import { Toast } from "antd-mobile"
import { withRouter } from 'react-router-dom'
import './assistance.scss'
import { Base64 } from "js-base64"
import { connect } from 'react-redux'
function showToast(text) {
Toast.info(text, 2, null, false)
}
@connect(({user}) => ({
user
}))
class GiveCourseAssistance extends Component {
state = {
allCourse: [],
activeName: '',
activeUrl: '',
isAwards: '',
count: '',
assistItems: [],
name: '',
courseImg: '',
code: getParam('magic_word'),
getBtnStatus: '1',
disabled: false,
successOneStatus: false,
errorStatus: false
}
componentDidMount() {
this.giveDetail()
this.assistantScroll()
let baseCode = decodeURIComponent(Base64.decode(this.state.code)).split(',')
this.setState({
getBtnStatus: this.props.user.data.uid === baseCode[0] ? '2' : '1'
})
}
giveDetail = () => {
http.get(`${API["base-api"]}/assistance/detail`)
.then(res => {
const {data, msg, errno} = res.data
if (errno === 200) {
this.setState({
allCourse: data.course_info,
activeName: data.active_info.activity_name,
activeUrl: data.active_info.activity_url,
isAwards: data.is_awards
})
} else {
showToast(msg)
}
})
}
assistantScroll = () => {
http.get(`${API["base-api"]}/assistance/active_detail?code=${getParam('magic_word')}`)
.then(res => {
const {data, msg, errno} = res.data
if (errno === 0) {
this.setState({
count: data.assistant_count,
assistItems: data.assistants,
name: data.invitation_user_nickname,
courseImg: data.course_image_name
})
} else {
showToast(msg)
}
})
}
inviteFriends = () => {
const {history, user} = this.props
if (browser.isWeixin) {
if (user.hasError) {
history.push('/passport')
return
}
this.setState({
disabled: true
})
http.post(`${API["base-api"]}/assistance/assistant`, {
code: this.state.code,
})
.then(res => {
const {errno, msg} = res.data
let success = errno == 200
this.setState({
successOneStatus: success,
errorStatus: !success,
disabled: false
})
!success && showToast(msg)
})
} else {
history.push('/wxerr')
}
}
render() {
const {
isAwards,
courseImg,
activeName,
name,
getBtnStatus,
disabled
} = this.state
const {history} = this.props
return (
<div>
<div id='assistance'>
{/*<div className="barrage-wrapper">
<!--headItems-->
<ul className="barrage-list">
<vue-seamless data="headItems" class-option="classOption" class="warp">
<li v-for="(item, index) in headItems">
<div className="person-left">
<img className="avatar" src="item.head_img" alt=""/>
<span className="name">{item.nickname}</span>
</div>
<div className="title">{item.word}</div>
</li>
</vue-seamless>
</ul>
</div>*/}
<div className="bg-image" style={{backgroundImage: `url(${courseImg})`}}>
{
isAwards == 1 && <button className="ranklist-btn" type="button" onClick={() => {
history.push(`/active/givecourse?activename=${activeName}`)
}}>大奖排行榜>></button>
}
</div>
<div className="christ-getwrap">
{
getBtnStatus === '1' &&
<div className="title">
<span className="active">@{name}</span> 赠送您一门课
</div>
}
<div className="btn-get-wrap">
{
getBtnStatus === 1
?
<button type="button" className="btn-get" disabled={disabled} click="btnGet">
免费领取
</button>
:
<button type="button" className="btn-get" onClick={this.inviteFriends}>
继续邀请好友
</button>
}
</div>
<p className="person-tolearn">领取的课程可前往七月在线APP或官网学习</p>
</div>
</div>
)
}
}
export default GiveCourseAssistance
export default withRouter(GiveCourseAssistance)
import React from 'react'
import WxErrImage from '@assets/image/wx_error.png'
import './wxerr.scss'
const WxErr = () => {
return (
<div className={'wxerr'}>
<img src={WxErrImage} alt=''/>
<p className="openLink" style={{
fontSize: `16px`,
marginTop: `40px`
}}>请在微信客户端打开链接</p>
</div>
)
}
export default WxErr
.wxerr{
margin-top: 40px;
display: flex;
flex-flow: column;
align-items: center;
.openLink{
font-size: 16px;
margin-top:40px;
}
}
......@@ -254,18 +254,19 @@ export default [
// 赠一得一
{
path: '/active/givecourses',
exact: true,
path: '/active/givecourse',
component: loadable(() => import(/* activity-give-courses */'@components/activity/give-courses/index'))
},
{
path: '/active/assistance',
exact: true,
component: loadable(() => import(/* activity-give-courses-assistance */'@components/activity/give-courses/assistance/index'))
},
{
path: '/active/to',
exact: true,
component: loadable(() => import(/* activity-give-courses-assistance */'@components/activity/give-courses/share-content/index'))
component: loadable(() => import(/* activity-give-courses-share */'@components/activity/give-courses/share-content/index'))
},
{
path: '/wxerr',
component: loadable(() => import(/* wx-err */ '@components/wxerr/index'))
}
]
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