Commit 618d120f by FE

add execute fn

parent b64c2ec8
...@@ -13,6 +13,7 @@ class PythonClass extends Component { ...@@ -13,6 +13,7 @@ class PythonClass extends Component {
isWechat: browser.isWeixin, isWechat: browser.isWeixin,
isShare: true, isShare: true,
entryMode: 1, // 0:扫码页,1:落地页,2:直接进入 entryMode: 1, // 0:扫码页,1:落地页,2:直接进入
isExecute: false,
isCopy: false, isCopy: false,
command: 'http://m.julyedu.com/python?from=python' command: 'http://m.julyedu.com/python?from=python'
} }
...@@ -35,7 +36,7 @@ class PythonClass extends Component { ...@@ -35,7 +36,7 @@ class PythonClass extends Component {
} }
handleFetchInfo = () => { handleFetchInfo = () => {
const id = getParam(id) || 17; const id = getParam('id') || 10;
http.get(`${API.home}/web/python/share/help/${id}`).then(res => { http.get(`${API.home}/web/python/share/help/${id}`).then(res => {
console.log(res); console.log(res);
}) })
...@@ -47,12 +48,8 @@ class PythonClass extends Component { ...@@ -47,12 +48,8 @@ class PythonClass extends Component {
this.setState({ this.setState({
entryMode: 1 entryMode: 1
}); });
history.push('/python?from=python'); history.push(`/python?id=${getParam('id')}&from=python`);
}else {
} }
console.log(this.props);
} }
copyToSuccess = () => { copyToSuccess = () => {
...@@ -62,8 +59,14 @@ class PythonClass extends Component { ...@@ -62,8 +59,14 @@ class PythonClass extends Component {
}); });
} }
handleToExecute = () => {
this.setState({
isExecute: true
});
}
render() { render() {
const { isWechat, isShare, entryMode, command, isCopy } = this.state; const { isWechat, isShare, isExecute, entryMode, command, isCopy } = this.state;
return ( return (
<> <>
<HeaderBar <HeaderBar
...@@ -71,12 +74,15 @@ class PythonClass extends Component { ...@@ -71,12 +74,15 @@ class PythonClass extends Component {
arrow={true} arrow={true}
home={true} home={true}
/> />
{entryMode}
<PythonContent <PythonContent
isWechat={isWechat} isWechat={isWechat}
isShare={isShare} isShare={isShare}
isExecute={isExecute}
entryMode={entryMode} entryMode={entryMode}
isCopy={isCopy} isCopy={isCopy}
command={command} command={command}
handleToExecute={this.handleToExecute}
handleToSend={this.handleToSend} handleToSend={this.handleToSend}
copyToSuccess={this.copyToSuccess} copyToSuccess={this.copyToSuccess}
/> />
...@@ -86,7 +92,7 @@ class PythonClass extends Component { ...@@ -86,7 +92,7 @@ class PythonClass extends Component {
} }
function PythonContent(props) { function PythonContent(props) {
const { isWechat, isShare, entryMode, isCopy, command, handleToSend, copyToSuccess } = props; const { isWechat, isShare, isExecute, entryMode, isCopy, command, handleToSend, copyToSuccess, handleToExecute } = props;
return ( return (
<div className="python-container"> <div className="python-container">
...@@ -168,10 +174,17 @@ function PythonContent(props) { ...@@ -168,10 +174,17 @@ function PythonContent(props) {
</div> </div>
<h4 className="python-code__title">代码</h4> <h4 className="python-code__title">代码</h4>
<div className="python-code__content"> <div className="python-code__content">
code
{ {
(entryMode !== 1 && isShare) && entryMode === 0 &&
<button className="python-button python-button__execute">运行看看</button> <p>code</p>
}
{
entryMode !== 0 &&
<p>{isExecute? 'code' : ''}</p>
}
{
(entryMode !== 0 && isShare && !isExecute) &&
<button className="python-button python-button__execute" onClick={handleToExecute}>运行看看</button>
} }
</div> </div>
</div> </div>
......
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