Commit bc983c3e by xuzhenghua

pull

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