Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
砖业洋__
harmony_JS_Demo_breathe
提交
04fdae81
H
harmony_JS_Demo_breathe
项目概览
砖业洋__
/
harmony_JS_Demo_breathe
通知
26
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
harmony_JS_Demo_breathe
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
04fdae81
编写于
9月 25, 2020
作者:
砖业洋__
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
step10 训练页面交替显示呼气和吸气,最后显示已完成
上级
3d39ecc3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
6 deletion
+50
-6
entry/src/main/js/default/pages/xunlian/xunlian.css
entry/src/main/js/default/pages/xunlian/xunlian.css
+8
-1
entry/src/main/js/default/pages/xunlian/xunlian.hml
entry/src/main/js/default/pages/xunlian/xunlian.hml
+4
-1
entry/src/main/js/default/pages/xunlian/xunlian.js
entry/src/main/js/default/pages/xunlian/xunlian.js
+38
-4
未找到文件。
entry/src/main/js/default/pages/xunlian/xunlian.css
浏览文件 @
04fdae81
...
...
@@ -5,7 +5,14 @@
width
:
454px
;
height
:
454px
;
}
.title
{
.txt1
{
font-size
:
38px
;
text-align
:
center
;
width
:
454px
;
height
:
40px
;
margin-bottom
:
10px
;
}
.txt2
{
font-size
:
30px
;
text-align
:
center
;
width
:
400px
;
...
...
entry/src/main/js/default/pages/xunlian/xunlian.hml
浏览文件 @
04fdae81
<div class="container">
<!-- 这里if和show和vue里面一样,show即使为false,占据的空间仍然存在,if为false占据的空间就会消失-->
<!-- 使用data里面的变量都需要插值表达式{{}}-->
<text class="title" show="{{isShow}}">
<text class="txt1">
{{breathe}}
</text>
<text class="txt2" show="{{isShow}}">
再需要坚持{{seconds}}秒
</text>
<input type="button" value="点击重新开始" class="btn" onclick="clickAction"></input>
...
...
entry/src/main/js/default/pages/xunlian/xunlian.js
浏览文件 @
04fdae81
import
router
from
'
@system.router
'
let
receivePickerValue1
=
null
;
let
receivePickerValue2
=
null
;
let
timer1
=
null
;
let
timer1
=
null
;
// 倒计时定时器
let
timer2
=
null
;
// 呼吸交替定时器
let
counter
=
null
;
// 呼吸计数器
let
sumCount
=
null
;
// 需要总次数
let
picker2Seconds
=
null
;
// 用于保存转换后得到的秒数
export
default
{
data
:
{
seconds
:
0
,
isShow
:
true
isShow
:
true
,
breathe
:
"
吸气
"
},
clickAction
()
{
// 点击重新跳转到主页面时清除定时器
clearInterval
(
timer1
);
timer1
=
null
;
clearInterval
(
timer2
);
timer2
=
null
;
router
.
replace
({
uri
:
'
pages/index/index
'
// 所有页面的uri都需要在config.json中定义
uri
:
'
pages/index/index
'
// 所有页面的uri都需要在config.json中定义
});
},
run1
()
{
run1
()
{
--
this
.
seconds
;
if
(
this
.
seconds
==
0
)
{
// 字符串判断0不能直接取反,转number不如直接==判断
clearInterval
(
timer1
);
...
...
@@ -20,6 +31,16 @@ export default {
this
.
isShow
=
false
;
}
},
run2
()
{
++
counter
;
if
(
counter
===
sumCount
)
{
clearInterval
(
timer2
);
timer2
=
null
;
this
.
breathe
=
"
已完成
"
;
}
else
{
this
.
breathe
=
this
.
breathe
===
"
呼气
"
?
"
吸气
"
:
"
呼气
"
;
}
},
onInit
()
{
console
.
log
(
"
xunlian页面的onInit()被调用
"
);
console
.
log
(
`接收到左边picker的值为:
${
this
.
data1
}
`
);
...
...
@@ -27,6 +48,18 @@ export default {
receivePickerValue1
=
this
.
data1
;
receivePickerValue2
=
this
.
data2
;
this
.
seconds
=
receivePickerValue1
*
60
;
switch
(
receivePickerValue2
)
{
case
"
较慢
"
:
picker2Seconds
=
6
;
break
;
case
"
较快
"
:
picker2Seconds
=
2
;
break
;
default
:
picker2Seconds
=
4
;
break
;
}
sumCount
=
this
.
seconds
/
picker2Seconds
;
},
onReady
()
{
console
.
log
(
"
xunlian页面的onReady()被调用
"
);
...
...
@@ -34,6 +67,7 @@ export default {
onShow
()
{
console
.
log
(
"
xunlian页面的onShow()被调用
"
);
timer1
=
setInterval
(
this
.
run1
,
1000
);
// 没有this那么run1找不到
timer2
=
setInterval
(
this
.
run2
,
picker2Seconds
*
1000
);
},
onDestroy
()
{
console
.
log
(
"
xunlian页面的onDestroy()被调用
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录