Commit dc40a45f by FE

poster

parent e1acf99d
import React, {Component} from 'react' import React, {Component} from 'react';
import './index.scss' import './index.scss';
import {HeaderBar} from '../../common' import {HeaderBar} from '@/common';
import {http, api, getParam} from '@/utils' import {http, getParam} from '@/utils';
import QRCode from 'qrcode' import QRCode from 'qrcode';
import { Toast} from 'antd-mobile' import { Toast} from 'antd-mobile';
class SharePoster extends Component { class SharePoster extends Component {
constructor(props) { constructor(props) {
...@@ -23,7 +21,7 @@ class SharePoster extends Component { ...@@ -23,7 +21,7 @@ class SharePoster extends Component {
} }
componentDidMount() { componentDidMount() {
this.getCodeWe() this.getCodeWe();
http.get(`${API.home}/m/dist/posters/${getParam('courseId')}/${getParam('uid')}`).then((res) => { http.get(`${API.home}/m/dist/posters/${getParam('courseId')}/${getParam('uid')}`).then((res) => {
if (res.data.code === 200) { if (res.data.code === 200) {
this.setState({ this.setState({
...@@ -221,56 +219,73 @@ class SharePoster extends Component { ...@@ -221,56 +219,73 @@ class SharePoster extends Component {
squareClick = (index) => { squareClick = (index) => {
this.setState({ this.setState({
smallactive: index smallactive: index
}) });
this.initCanvas(this.state.bgImage, index); this.initCanvas(this.state.bgImage, index);
} }
render() { render() {
const { distPrice={}, smallListImg=[], smallactive } = this.state;
return ( return (
<div className='share-poster'> <div className='share-poster'>
<HeaderBar title='生成专属海报' arrow={true} cart={false}></HeaderBar> <HeaderBar
title='生成专属海报'
arrow={true}
cart={false}
/>
<div className="total-container"> <div className="total-container">
<div className='placard-img-container' id='imgWrapper'> <div className='placard-img-container' id='imgWrapper'>
<img src={this.state.billSrc.src} alt=""/> <img src={this.state.billSrc.src} alt="" />
</div> </div>
<img src={this.state.codeSrc} alt="" id='qrcode' className='placard-code'/> <img
<canvas id='canvas' width='450' height='800' src={this.state.codeSrc}
className={this.state.billSrc === '' ? '' : 'hide'}></canvas> alt=""
id='qrcode'
className='placard-code'
/>
<canvas
id='canvas'
width='450'
height='800'
className={this.state.billSrc === '' ? '' : 'hide'}
/>
</div> </div>
<div className='placard-desc'> <div className='placard-desc'>
<span className='placard-sharetxt'> <span className='placard-sharetxt'>
长按保存海报分享给好友,每有一人通过您的分享购买该课程,您可以 长按保存海报分享给好友,每有一人通过您的分享购买该课程,您可以
{ {
this.state.distPrice.count_type === 0 && distPrice.count_type === 0 &&
<span className='placard-price'>获得{this.state.distPrice.first_level_tip}元的佣金奖励。</span> <span className='placard-price'>
获得{distPrice.first_level_tip}元的佣金奖励。
</span>
} }
{ {
this.state.distPrice.count_type === 1 && distPrice.count_type === 1 &&
<span <span className='placard-price'>
className='placard-price'>获得成交金额的{this.state.distPrice.first_level_scale}%作为佣金奖励。</span> 获得成交金额的{distPrice.first_level_scale}%作为佣金奖励。
</span>
} }
</span> </span>
</div> </div>
<div className='placard-swiper'> <div className='placard-swiper'>
<ul className='placard-list'> <ul className='placard-list'>
{ {
this.state.smallListImg && this.state.smallListImg.length > 0 && this.state.smallListImg.map((item, index) => { smallListImg.length > 0 && smallListImg.map((item, index) => {
return ( return (
<li onClick={this.squareClick.bind(this, index)} key={index} <li
className={this.state.smallactive === index ? 'active' : ''}> onClick={this.squareClick.bind(this, index)}
<img src={item.square} alt=""/> key={index}
className={smallactive === index ? 'active' : ''}
>
<img src={item.square} alt="" />
</li> </li>
) );
}) })
} }
</ul> </ul>
</div> </div>
</div> </div>
) );
} }
} }
export default SharePoster export default SharePoster;
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