Commit bc983c3e by xuzhenghua

pull

parent 7bae7588
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js"); importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");
importScripts( importScripts(
"/precache-manifest.96b7cacc736890250848cd957cbdf9ec.js" "/precache-manifest.731286b89f3341429e322e379cab4d51.js"
); );
workbox.clientsClaim(); workbox.clientsClaim();
......
...@@ -3,7 +3,7 @@ import './index.scss' ...@@ -3,7 +3,7 @@ import './index.scss'
const VList = (props) => { const VList = (props) => {
return ( return (
<li className='v-list-base-item' onClick={props.handleClick.bind(this, props.id)}> <li className='v-list-base-item' onClick={props.handleClick.bind(this, props.id, props.item)}>
<div className="content"> <div className="content">
<div className="cover"> <div className="cover">
{props.status} {props.status}
......
...@@ -4,7 +4,7 @@ import {CopyToClipboard} from 'react-copy-to-clipboard'; ...@@ -4,7 +4,7 @@ import {CopyToClipboard} from 'react-copy-to-clipboard';
import AceEditor from 'react-ace'; import AceEditor from 'react-ace';
import { Toast } from "antd-mobile" import { Toast } from "antd-mobile"
import {HeaderBar} from '@/common'; import {HeaderBar} from '@/common';
import { browser, http, getParam } from '@/utils'; import { browser, http, getParam, wxShare } from '@/utils';
import './index.scss'; import './index.scss';
import 'ace-builds/src-noconflict/mode-python'; import 'ace-builds/src-noconflict/mode-python';
import 'ace-builds/src-noconflict/theme-dracula'; import 'ace-builds/src-noconflict/theme-dracula';
...@@ -17,7 +17,8 @@ class PythonClass extends Component { ...@@ -17,7 +17,8 @@ class PythonClass extends Component {
isWechat: browser.isWeixin, isWechat: browser.isWeixin,
isShare: true, isShare: true,
type: '1', // 1:课后习题,2:课堂习题 type: '1', // 1:课后习题,2:课堂习题
entryMode: 0, // 0:扫码页,1:落地页,2:直接进入 entryMode: 0, // 0:扫码页,1:落地页
isGuide: false, // 是否展示引导
isExecute: false, isExecute: false,
isCopy: false, isCopy: false,
command: '', command: '',
...@@ -33,19 +34,19 @@ class PythonClass extends Component { ...@@ -33,19 +34,19 @@ class PythonClass extends Component {
initCommand = () => { initCommand = () => {
this.setState({ this.setState({
command: `${API.m}/pythonShare?id=${getParam('id')}&type=${getParam('type')}&ques=${getParam('ques')}&from=python` command: `${API.m}/pythonShare?id=${getParam('id')}&type=${getParam('type')}&ques=${getParam('ques')}&origin=python`
}) })
} }
initPageStatus = () => { initPageStatus = () => {
if(getParam('from') === 'barcode') { if(getParam('origin') === 'barcode') {
this.setState({ this.setState({
entryMode: 0 entryMode: 0
}); });
} }
if(getParam('from') === 'python') { if(getParam('origin') === 'python') {
this.setState({ this.setState({
entryMode: 2 entryMode: 1
}); });
} }
if(getParam('type') === '1') { if(getParam('type') === '1') {
...@@ -80,13 +81,38 @@ class PythonClass extends Component { ...@@ -80,13 +81,38 @@ class PythonClass extends Component {
}) })
} }
handleToSend = () => { handleToSend = (params) => {
const { history } = this.props; const { history } = this.props;
const { isShare, entryMode } = this.state;
if(browser.isWeixin) { if(browser.isWeixin) {
history.push(`/pythonShare?id=${getParam('id')}&type=${getParam('type')}&ques=${getParam('ques')}&origin=python`);
this.setState({ this.setState({
entryMode: 1 isGuide: true
});
let title = '';
let labelName = this.formatTitle(params);
if(entryMode !== 0 && !isShare) {
title = `我在${params.course_name}${labelName}遇到了困难`;
}
if(entryMode !== 0 && isShare) {
title = `我已在【${params.course_name}】上运行了行代码了${params.code_lines}`
}
wxShare({
title,
desc: labelName,
link: encodeURI(location.href),
imgUrl: params.course_img,
}); });
history.push(`/pythonShare?id=${getParam('id')}&type=${getParam('type')}&ques=${getParam('ques')}&from=python`); }
}
formatTitle = (params) => {
const { type } = this.state;
if(type === '1') {
return `练习-${params.ques_name}`;
}
if(type === '2') {
return `课堂-${params.video_name}`;
} }
} }
...@@ -105,12 +131,12 @@ class PythonClass extends Component { ...@@ -105,12 +131,12 @@ class PythonClass extends Component {
handleToHide = () => { handleToHide = () => {
this.setState({ this.setState({
entryMode: 2 isGuide: false
}); });
} }
render() { render() {
const { isWechat, isShare, isExecute, type, entryMode, command, isCopy, data } = this.state; const { isWechat, isShare, isExecute, entryMode, command, isCopy, isGuide, data } = this.state;
return ( return (
<> <>
<HeaderBar <HeaderBar
...@@ -121,12 +147,13 @@ class PythonClass extends Component { ...@@ -121,12 +147,13 @@ class PythonClass extends Component {
<PythonContent <PythonContent
isWechat={isWechat} isWechat={isWechat}
isShare={isShare} isShare={isShare}
type={type}
isExecute={isExecute} isExecute={isExecute}
entryMode={entryMode} entryMode={entryMode}
isGuide={isGuide}
isCopy={isCopy} isCopy={isCopy}
command={command} command={command}
data={data} data={data}
labelName={this.formatTitle(data)}
handleToExecute={this.handleToExecute} handleToExecute={this.handleToExecute}
handleToSend={this.handleToSend} handleToSend={this.handleToSend}
copyToSuccess={this.copyToSuccess} copyToSuccess={this.copyToSuccess}
...@@ -158,48 +185,21 @@ function PythonContent(props) { ...@@ -158,48 +185,21 @@ function PythonContent(props) {
isWechat, isWechat,
isShare, isShare,
isExecute, isExecute,
type,
entryMode, entryMode,
isCopy, isCopy,
command, command,
data: { head_img, nickname, code_lines, code, result, ques_name, course_name, course_id, video_name }, labelName,
isGuide,
data: { head_img, nickname, code_lines, code, result, course_name, course_id },
handleToSend, handleToSend,
copyToSuccess, copyToSuccess,
handleToExecute, handleToExecute,
handleToHide handleToHide
} = props; } = props;
let labelName = '';
if(type === '1') {
labelName = `练习-${ques_name}`;
}
if(type === '2') {
labelName = `课堂-${video_name}`;
}
return ( return (
<div className="python-container"> <div className="python-container">
{/* 微信 */}
{
// (entryMode === 0 && isWechat) &&
// <div className="python-header">
// <p className="python-wechat__title">请点击右上角分享</p>
// <i className="iconfont iconyindao"></i>
// </div>
}
{/* 非微信 */}
{ {
// (entryMode === 0 && !isWechat) && isGuide &&
// <div className="python-header">
// <p className="python-wechat__title">
// {isShare? '快分享给好友吧' : '快发给好友求助吧'}
// </p>
// </div>
}
{
(entryMode === 1 && isWechat) &&
<div className="python-popup" onClick={handleToHide}> <div className="python-popup" onClick={handleToHide}>
<div className="python-header"> <div className="python-header">
<p className="python-wechat__title">请点击右上角分享</p> <p className="python-wechat__title">请点击右上角分享</p>
...@@ -209,9 +209,7 @@ function PythonContent(props) { ...@@ -209,9 +209,7 @@ function PythonContent(props) {
} }
<div className="python-content"> <div className="python-content">
<div className="python-user"> <div className="python-user">
<div className="python-user__portrait"> <i className="python-user__portrait" style={{backgroundImage: `url(${head_img})`}}></i>
<img src={head_img} alt=""/>
</div>
<h2 className="python-user__id">{nickname}</h2> <h2 className="python-user__id">{nickname}</h2>
{/* 分享 */} {/* 分享 */}
...@@ -223,7 +221,7 @@ function PythonContent(props) { ...@@ -223,7 +221,7 @@ function PythonContent(props) {
</p> </p>
} }
{ {
(entryMode !== 0 && isShare) && (entryMode === 1 && isShare) &&
<p className="python-user__desc"> <p className="python-user__desc">
<span>{course_name}</span>完成了<br /> <span>{course_name}</span>完成了<br />
...@@ -241,7 +239,7 @@ function PythonContent(props) { ...@@ -241,7 +239,7 @@ function PythonContent(props) {
</p> </p>
} }
{ {
(entryMode !== 0 && !isShare) && (entryMode === 1 && !isShare) &&
<p className="python-user__desc"> <p className="python-user__desc">
<span>{course_name}</span>的<br /> <span>{course_name}</span>的<br />
...@@ -250,20 +248,22 @@ function PythonContent(props) { ...@@ -250,20 +248,22 @@ function PythonContent(props) {
} }
</div> </div>
<h4 className="python-code__title"> <h4 className="python-code__title">
{entryMode !== 0 && isShare && !isWechat? `这是Ta的第${code_lines}行代码` : '运行结果'} {entryMode === 1 && isShare? `这是Ta的第${code_lines}行代码` : '运行结果'}
</h4> </h4>
<div className="python-code__content"> <div className="python-code__content">
<SelfAceEditor code={entryMode !== 0 && isShare && !isWechat? code : result} /> <SelfAceEditor code={entryMode === 1 && isShare? code : result} />
</div> </div>
<h4 className="python-code__title">{entryMode !== 0 && isShare && !isWechat? '运行结果' : '代码'}</h4> <h4 className="python-code__title">
{entryMode === 1 && isShare? '运行结果' : '代码'}
</h4>
<div className="python-code__content"> <div className="python-code__content">
{ {
entryMode !== 0 && isShare && !isWechat entryMode === 1 && isShare
? <SelfAceEditor code={isExecute? result : ''} /> ? <SelfAceEditor code={isExecute? result : ''} />
: <SelfAceEditor code={code} /> : <SelfAceEditor code={code} />
} }
{ {
(entryMode !== 0 && isShare && !isWechat && !isExecute) && (entryMode === 1 && isShare && !isExecute) &&
<button className="python-button python-button__execute" onClick={handleToExecute}>运行看看</button> <button className="python-button python-button__execute" onClick={handleToExecute}>运行看看</button>
} }
</div> </div>
...@@ -294,7 +294,7 @@ function PythonContent(props) { ...@@ -294,7 +294,7 @@ function PythonContent(props) {
} }
{ {
entryMode !== 0 && entryMode === 1 &&
<Link className="python-button python-button__study" to={`/python?id=${course_id}`}>我也要学Python</Link> <Link className="python-button python-button__study" to={`/python?id=${course_id}`}>我也要学Python</Link>
} }
</div> </div>
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
border-radius: 50%; border-radius: 50%;
box-sizing: border-box; box-sizing: border-box;
background-color: #fff; background-color: #fff;
background-size: cover;
img { img {
display: block; display: block;
......
...@@ -76,8 +76,14 @@ class MyCourses extends Component { ...@@ -76,8 +76,14 @@ class MyCourses extends Component {
isLoading: true isLoading: true
} }
handleClick = id => { handleClick = (id, item) => {
this.props.history.push(`/play/video?id=${id}`) const {history} = this.props
const {mode, course_id} = item
if(mode && mode == 6){
history.push(`/python?id=${course_id}`)
return
}
history.push(`/play/video?id=${id}`)
} }
addCourseClick = () => { addCourseClick = () => {
this.props.history.push('/classify') this.props.history.push('/classify')
...@@ -164,6 +170,7 @@ class MyCourses extends Component { ...@@ -164,6 +170,7 @@ class MyCourses extends Component {
info={Info} info={Info}
status={status} status={status}
courseExpire={courseExpire} courseExpire={courseExpire}
item={item}
id={item['v_course_id']} id={item['v_course_id']}
/> />
) )
......
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