Commit 618d120f by FE

add execute fn

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