mainpage.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <div class="content">
  3. <div class="top" :style="{backgroundColor:bgColor}">
  4. <span class="watchState">{{watchText}}</span>
  5. <div class="toprow">
  6. <div class="lt">
  7. <div class="activeLevel">
  8. <div v-if="activeState">
  9. <s>%</s>
  10. <em>{{activeLevel}}</em>
  11. </div>
  12. <div v-else>
  13. <s class="noValue">--</s>
  14. </div>
  15. </div>
  16. <span>{{activeLevelText}}</span>
  17. </div>
  18. <div class="md">
  19. <div class="headContainer">
  20. <img src="../static/images/main/testhead.png"/>
  21. </div>
  22. <span class="username">
  23. <em>{{username}}</em>
  24. <img src="../static/images/main/male.png" height="60" width="60" v-if="sex == 1"/>
  25. <img src="../static/images/main/female.png" height="60" width="60" v-if="sex == 2"/>
  26. </span>
  27. </div>
  28. <div class="rt">
  29. <div class="heartJump">
  30. <div v-if="activeState">
  31. <img src="../static/images/main/heart.png" height="74" width="86"/>
  32. <em :class="[
  33. {'normalJump':activeLevel > 30 && activeLevel <= 90},
  34. {'fastJump':activeLevel > 90},
  35. {'slowJump':activeLevel < 30},
  36. ]">{{heartRate}}</em>
  37. </div>
  38. <div v-else>
  39. <s class="noValue">--</s>
  40. </div>
  41. </div>
  42. <span>瞬时心率</span>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="info">
  47. <ul>
  48. <li><em>{{height}}</em><span>身高cm</span></li>
  49. <li><em>{{age}}</em><span>年龄</span></li>
  50. <li><em>{{weight}}</em><span>体重kg</span></li>
  51. <li><em>{{peaceHeart}}</em><span>静息心率</span></li>
  52. </ul>
  53. </div>
  54. <div class="row">
  55. <div class="rowCenter" v-if="!watchState" @click="connectWatch">
  56. <img src="../static/images/main/chain.png"/>
  57. <em>心率带未连接</em>
  58. <button>点击连接</button>
  59. </div>
  60. </div>
  61. <div class="middle">
  62. <ul>
  63. <li>
  64. <div class="center">
  65. <em>{{cal}}</em>
  66. <img src="../static/images/main/normal.png"/>
  67. <span>卡路里</span>
  68. </div>
  69. </li>
  70. <li>
  71. <div class="center">
  72. <em>{{sportCal}}</em>
  73. <img src="../static/images/main/redfire.png"/>
  74. <span>运动卡路里</span>
  75. </div>
  76. </li>
  77. <li>
  78. <div class="center">
  79. <em>{{ck}}</em>
  80. <img src="../static/images/main/ck.png" class="ck"/>
  81. <span>CK</span>
  82. </div>
  83. </li>
  84. </ul>
  85. </div>
  86. <div class="bottom">
  87. <h5>5分钟心率趋势图</h5>
  88. <span>最大心率 : {{heartMax}} 平均心率 : {{heartAverage}}</span>
  89. <Line-example
  90. :width="screenWidth"
  91. :height="screenHeight"
  92. :dataLabels="dataLabels"
  93. :datadatasets="dataDatasets"
  94. />
  95. <em v-if="activeState" :class="[
  96. {'normalJump':activeLevel > 30 && activeLevel <= 90},
  97. {'fastJump':activeLevel > 90},
  98. {'slowJump':activeLevel < 30},
  99. ]">{{heartRate}}</em>
  100. </div>
  101. <mu-dialog title="" width="600" max-width="80%" :esc-press-close="false"
  102. :overlay-close="false" :open.sync="openAlert">
  103. <p v-if="!watchs">
  104. 没有任何设备
  105. </p>
  106. <div class="watchList" v-else>
  107. <p>请选择设备</p>
  108. <ul>
  109. <li v-for="w in watchs" @click="choiceWatch">{{w.name}} <em>信号:{{w.level}}</em></li>
  110. </ul>
  111. </div>
  112. <br>
  113. <mu-button slot="actions" flat color="primary" @click="closeAlertDialog" v-if="watchListState">取消
  114. </mu-button>
  115. <mu-button slot="actions" flat color="primary" @click="searchWatch" v-else>搜索</mu-button>
  116. </mu-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import LineExample from '../components/LineExample'
  121. export default {
  122. data() {
  123. return {
  124. dataLabels: [],
  125. dataDatasets: [],
  126. watchText: '',
  127. watchState: false,//false
  128. bgColor: '#028FE1',
  129. activeLevel: 0,
  130. activeLevelText: '激活放松',
  131. heartRate: 0,
  132. activeState: false,//false
  133. openAlert: false,//false
  134. alertState: false,//false
  135. watchListState: false,//false
  136. username: '王胜寒',
  137. sex: 1,
  138. height: 148,
  139. age: 8,
  140. weight: 38,
  141. peaceHeart: 100,
  142. heartMax: 0,
  143. heartAverage: 0,
  144. cal: 0,
  145. sportCal: 0,
  146. ck: 0,
  147. screenWidth: document.body.clientWidth,
  148. screenHeight: parseInt(document.documentElement.clientHeight / 5),
  149. watchs: [],
  150. }
  151. },
  152. mounted() {
  153. this.getBodyInfo();
  154. this.activeLevel = 0;
  155. this.watchs = [
  156. // {name: 'CL831-0022750', id: 1, rssi: -90, level: '强'},
  157. // {name: 'CL831-0022767', id: 2, rssi: -30, level: '弱'},
  158. ]
  159. },
  160. watch: {
  161. activeLevel(val) {
  162. let that = this;
  163. switch (true) {
  164. case parseInt(val) < 39 :
  165. that.bgColor = '#028FE1';
  166. that.activeLevelText = '激活放松';
  167. break;
  168. case parseInt(val) < 54 && parseInt(val) >= 39 :
  169. that.bgColor = '#6D29FA';
  170. that.activeLevelText = '动态热身';
  171. break;
  172. case parseInt(val) < 69 && parseInt(val) >= 54 :
  173. that.bgColor = '#0AB105';
  174. that.activeLevelText = '脂肪燃烧';
  175. break;
  176. case parseInt(val) < 79 && parseInt(val) >= 69 :
  177. that.bgColor = '#B9CB01';
  178. that.activeLevelText = '糖分消耗';
  179. break;
  180. case parseInt(val) < 89 && parseInt(val) >= 79 :
  181. that.bgColor = '#EA8813';
  182. that.activeLevelText = '心肺训练';
  183. break;
  184. case parseInt(val) >= 90 :
  185. that.bgColor = '#D11122';
  186. that.activeLevelText = '峰值锻炼';
  187. break;
  188. }
  189. }
  190. },
  191. methods: {
  192. connectWatch() {
  193. // 打开蓝牙适配器
  194. this.Toast('蓝牙适配器打开成功!');
  195. let that = this;
  196. plus.bluetooth.openBluetoothAdapter({
  197. success: function (e) {
  198. that.Toast('蓝牙适配器打开成功!');
  199. that.openAlert = true;
  200. return e
  201. },
  202. fail: function (e) {
  203. that.Toast('打开失败! 请确认蓝牙开关已开启');
  204. }
  205. });
  206. },
  207. closeAlertDialog() {
  208. this.openAlert = false;
  209. },
  210. searchWatch() {
  211. // test
  212. this.watchs = [
  213. {name: 'CL831-0022750', id: 1, rssi: -90, level: '强'},
  214. {name: 'CL831-0022767', id: 2, rssi: -30, level: '弱'},
  215. ];
  216. this.watchListState = true;
  217. },
  218. choiceWatch() {
  219. },
  220. // 获取基础身体数据
  221. getBodyInfo() {
  222. }
  223. },
  224. components: {
  225. LineExample
  226. }
  227. }
  228. </script>
  229. <style scoped>
  230. .top {
  231. width: 100%;
  232. overflow: hidden;
  233. display: block;
  234. margin: 0 auto;
  235. }
  236. .top .watchState {
  237. width: 100%;
  238. overflow: hidden;
  239. display: block;
  240. margin: 0 auto;
  241. height: 20px;
  242. line-height: 20px;
  243. color: #fff;
  244. text-align: center;
  245. margin-top: 10px;
  246. margin-bottom: 10px;
  247. }
  248. .toprow {
  249. width: 100%;
  250. overflow: hidden;
  251. display: block;
  252. margin: 0 auto;
  253. }
  254. .toprow .lt {
  255. width: 30%;
  256. float: left;
  257. overflow: hidden;
  258. }
  259. .toprow .md {
  260. width: 40%;
  261. float: left;
  262. overflow: hidden;
  263. }
  264. .toprow .rt {
  265. width: 30%;
  266. float: right;
  267. overflow: hidden;
  268. }
  269. .toprow .lt .activeLevel {
  270. width: 100%;
  271. overflow: hidden;
  272. display: block;
  273. margin: 0 auto;
  274. margin-top: 10px;
  275. color: #fff;
  276. }
  277. .activeLevel div {
  278. width: 86px;
  279. overflow: hidden;
  280. display: block;
  281. margin: 0 auto;
  282. }
  283. .activeLevel s {
  284. float: right;
  285. font-size: 20px;
  286. }
  287. .activeLevel em {
  288. font-size: 40px;
  289. text-align: right;
  290. font-weight: bold;
  291. float: right;
  292. }
  293. .toprow .lt span {
  294. width: 80px;
  295. height: 20px;
  296. overflow: hidden;
  297. display: block;
  298. margin: 0 auto;
  299. color: #fff;
  300. border: 1px solid #fff;
  301. border-radius: 250px;
  302. text-align: center;
  303. line-height: 20px;
  304. font-size: 12px;
  305. }
  306. .toprow .md .headContainer {
  307. width: 70%;
  308. height: 70%;
  309. border: 3px solid rgba(255, 255, 255, 0.71);
  310. border-radius: 250px;
  311. overflow: hidden;
  312. display: block;
  313. margin: 0 auto;
  314. }
  315. .headContainer img {
  316. width: 100%;
  317. height: 100%;
  318. overflow: hidden;
  319. display: block;
  320. margin: 0 auto;
  321. }
  322. .activeLevel .noValue {
  323. width: 100%;
  324. overflow: hidden;
  325. display: block;
  326. margin: 0 auto;
  327. font-weight: bold;
  328. font-size: 40px;
  329. text-align: center;
  330. float: none;
  331. }
  332. .username {
  333. width: 100%;
  334. height: 30px;
  335. overflow: hidden;
  336. display: block;
  337. margin: 0 auto;
  338. font-size: 14px;
  339. color: #fff;
  340. margin-top: 10px;
  341. }
  342. .username em {
  343. width: 100%;
  344. overflow: hidden;
  345. display: block;
  346. margin: 0 auto;
  347. text-align: center;
  348. }
  349. .username img {
  350. position: relative;
  351. bottom: 20px;
  352. float: right;
  353. width: 15px;
  354. height: 15px;
  355. right: 15%;
  356. }
  357. .heartJump {
  358. width: 90%;
  359. overflow: hidden;
  360. float: left;
  361. margin: 0 auto;
  362. margin-top: 10px;
  363. color: #fff;
  364. }
  365. .heartJump div {
  366. width: 86px;
  367. overflow: hidden;
  368. display: block;
  369. margin: 0 auto;
  370. }
  371. .heartJump img {
  372. width: 16px;
  373. height: 14px;
  374. float: right;
  375. }
  376. .heartJump em {
  377. font-size: 40px;
  378. text-align: right;
  379. font-weight: bold;
  380. float: right;
  381. }
  382. .heartJump .noValue {
  383. width: 100%;
  384. overflow: hidden;
  385. display: block;
  386. margin: 0 auto;
  387. font-weight: bold;
  388. font-size: 40px;
  389. text-align: center;
  390. float: none;
  391. }
  392. .toprow .rt span {
  393. width: 80px;
  394. height: 20px;
  395. overflow: hidden;
  396. float: left;
  397. color: #fff;
  398. border: 1px solid #fff;
  399. border-radius: 250px;
  400. text-align: center;
  401. line-height: 20px;
  402. font-size: 12px;
  403. }
  404. .info {
  405. width: 100%;
  406. overflow: hidden;
  407. display: block;
  408. margin: 0 auto;
  409. }
  410. .info ul {
  411. width: 100%;
  412. overflow: hidden;
  413. display: block;
  414. margin: 0 auto;
  415. margin-top: 10px;
  416. margin-bottom: 10px;
  417. }
  418. .info li {
  419. width: 25%;
  420. border-left: 1px solid #fff;
  421. border-right: 1px solid #fff;
  422. float: left;
  423. text-align: center;
  424. }
  425. .info li:nth-child(2) {
  426. border-color: #E2E2E2;
  427. }
  428. .info li:nth-child(3) {
  429. border-color: #E2E2E2;
  430. border-left: 0;
  431. }
  432. .info li em {
  433. width: 100%;
  434. overflow: hidden;
  435. display: block;
  436. margin: 0 auto;
  437. color: #363636;
  438. font-size: 20px;
  439. text-align: center;
  440. }
  441. .info li span {
  442. width: 100%;
  443. overflow: hidden;
  444. display: block;
  445. margin: 0 auto;
  446. color: #C4C4C4;
  447. font-size: 12px;
  448. text-align: center;
  449. }
  450. .row {
  451. width: 100%;
  452. overflow: hidden;
  453. display: block;
  454. margin: 0 auto;
  455. background: #EFEFEF;
  456. padding-top: 10px;
  457. padding-bottom: 10px;
  458. }
  459. .row .rowCenter {
  460. width: 208px;
  461. overflow: hidden;
  462. display: block;
  463. margin: 0 auto;
  464. line-height: 30px;
  465. }
  466. .rowCenter img {
  467. width: 11px;
  468. height: 11px;
  469. float: left;
  470. margin-top: 10px;
  471. margin-right: 5px;
  472. }
  473. .rowCenter em {
  474. font-size: 14px;
  475. color: #FF4040;
  476. margin-right: 15px;
  477. }
  478. .rowCenter button {
  479. width: 92px;
  480. height: 27px;
  481. text-align: center;
  482. line-height: 27px;
  483. color: black;
  484. background: #FFDE93;
  485. border-radius: 6px;
  486. border: none;
  487. outline: none;
  488. }
  489. .middle {
  490. width: 100%;
  491. overflow: hidden;
  492. display: block;
  493. margin: 0 auto;
  494. border-bottom: 10px solid #EFEFEF;
  495. }
  496. .middle ul {
  497. width: 100%;
  498. overflow: hidden;
  499. display: block;
  500. margin: 0 auto;
  501. padding-top: 10px;
  502. padding-bottom: 10px;
  503. }
  504. .middle li {
  505. width: 33%;
  506. float: left;
  507. border-left: 1px solid #fff;
  508. border-right: 1px solid #fff;
  509. }
  510. .middle li .center {
  511. width: 72px;
  512. overflow: hidden;
  513. display: block;
  514. margin: 0 auto;
  515. }
  516. .middle li:nth-child(2) {
  517. border-color: #E2E2E2;
  518. }
  519. .middle li img {
  520. width: 15px;
  521. float: right;
  522. margin-top: 4px;
  523. margin-right: 5px;
  524. }
  525. .middle li em {
  526. float: right;
  527. text-align: right;
  528. color: #000;
  529. font-weight: bold;
  530. font-size: 22px;
  531. }
  532. .middle li span {
  533. width: 100%;
  534. overflow: hidden;
  535. display: block;
  536. margin: 0 auto;
  537. text-align: right;
  538. color: #9A9A9A;
  539. font-size: 12px;
  540. }
  541. .middle .ck {
  542. width: 19px;
  543. height: 19px;
  544. margin-top: 6px;
  545. }
  546. .bottom {
  547. width: 100%;
  548. overflow: hidden;
  549. display: block;
  550. margin: 0 auto;
  551. }
  552. .bottom h5 {
  553. width: 100%;
  554. overflow: hidden;
  555. display: block;
  556. margin: 0 auto;
  557. color: #363636;
  558. font-size: 16px;
  559. text-align: center;
  560. font-weight: normal;
  561. margin-top: 14px;
  562. }
  563. .bottom span {
  564. width: 100%;
  565. overflow: hidden;
  566. display: block;
  567. margin: 0 auto;
  568. text-align: center;
  569. font-size: 12px;
  570. color: #9A9A9A;
  571. }
  572. .bottom em {
  573. position: relative;
  574. bottom: 160px;
  575. right: 20px;
  576. float: right;
  577. color: #FF4040;
  578. background: #fff;
  579. }
  580. .slowJump {
  581. animation: mymove 3s infinite;
  582. -webkit-animation: mymove 3s infinite; /*Safari and Chrome*/
  583. animation-direction: alternate; /*轮流反向播放动画。*/
  584. animation-timing-function: ease-in-out; /*动画的速度曲线*/
  585. /* Safari 和 Chrome */
  586. -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
  587. -webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
  588. }
  589. .normalJump {
  590. animation: mymove 2s infinite;
  591. -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
  592. animation-direction: alternate; /*轮流反向播放动画。*/
  593. animation-timing-function: ease-in-out; /*动画的速度曲线*/
  594. /* Safari 和 Chrome */
  595. -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
  596. -webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
  597. }
  598. .fastJump {
  599. animation: mymove 1s infinite;
  600. -webkit-animation: mymove 1s infinite; /*Safari and Chrome*/
  601. animation-direction: alternate; /*轮流反向播放动画。*/
  602. animation-timing-function: ease-in-out; /*动画的速度曲线*/
  603. /* Safari 和 Chrome */
  604. -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
  605. -webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
  606. }
  607. @keyframes mymove {
  608. 0% {
  609. transform: scale(1); /*开始为原始大小*/
  610. }
  611. 25% {
  612. transform: scale(1.1); /*放大1.1倍*/
  613. }
  614. 50% {
  615. transform: scale(1);
  616. }
  617. 75% {
  618. transform: scale(1.1);
  619. }
  620. }
  621. @-webkit-keyframes mymove /*Safari and Chrome*/
  622. {
  623. 0% {
  624. transform: scale(1); /*开始为原始大小*/
  625. }
  626. 25% {
  627. transform: scale(1.1); /*放大1.1倍*/
  628. }
  629. 50% {
  630. transform: scale(1);
  631. }
  632. 75% {
  633. transform: scale(1.1);
  634. }
  635. }
  636. /deep/ .mu-dialog {
  637. background-color: rgba(0, 0, 0, 0.75);
  638. color: #fff;
  639. border-radius: 20px;
  640. background-size: 100%;
  641. background-origin: content-box;
  642. filter: blur(0.5px);
  643. }
  644. /deep/ .mu-dialog p {
  645. color: #fff;
  646. text-align: center;
  647. }
  648. /deep/ .mu-dialog .mu-primary-text-color {
  649. margin: 0 auto;
  650. border-radius: 9px;
  651. background-color: rgba(255, 255, 255, 0.1);
  652. color: #fff;
  653. }
  654. .watchList {
  655. width: 100%;
  656. overflow: hidden;
  657. display: block;
  658. margin: 0 auto;
  659. min-height: 100px;
  660. overflow-y: scroll;
  661. }
  662. .watchList li {
  663. width: 100%;
  664. padding-left: 5%;
  665. padding-right: 5%;
  666. padding-top: 5px;
  667. padding-bottom: 5px;
  668. overflow: hidden;
  669. display: block;
  670. margin: 0 auto;
  671. background-color: rgba(255, 255, 255, 0.29);
  672. color: #fff;
  673. border-radius: 9px;
  674. font-size: 12px;
  675. margin-bottom: 5px;
  676. }
  677. .watchList li em {
  678. float: right;
  679. text-align: right;
  680. }
  681. </style>