Rank.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <template>
  2. <div class="content" :class="[{'bg1': pages == 1}, {'bg2': pages == 2}]">
  3. <Headside></Headside>
  4. <!-- 训练排名 -->
  5. <div class="pageXlpm" v-show="pages == 1">
  6. <div class="sumTitle">
  7. <div class="lt">
  8. <img src="../assets/imgs/rank/fire.svg" alt="">
  9. <h5>卡路里排名</h5>
  10. </div>
  11. <div class="rt">
  12. <img src="../assets/imgs/rank/ck.svg" alt="">
  13. <h5>CK排名</h5>
  14. </div>
  15. <div class="md">
  16. <span>本次训练排名</span>
  17. </div>
  18. </div>
  19. <div class="listContainer">
  20. <div class="lt">
  21. <ul>
  22. <div class="ltTitle">
  23. <span>排名</span>
  24. <span>成员</span>
  25. <span>卡路里</span>
  26. </div>
  27. <li v-for="(s,i) in students.CalSort.slice(0, maxShowNum)" v-if="i <= maxShowNum-1" v-show="Listate[i].state"
  28. :class="[{ 'box animate__animated animate__flipInX': Listate[i].state }]">
  29. <div class="gary">
  30. <em>{{ i + 1 }}</em>
  31. <div class="head">
  32. <img :src="s.Head" alt="" v-if="s.Head" :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  33. <img src="../static/img/people/flyhead.png" alt="" v-if="!s.Head"
  34. :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  35. </div>
  36. <span class="names">{{ s.Name }}</span>
  37. <span class="glory">
  38. <img src="../assets/imgs/rank/pb.png" v-if="s.IsBreaking == 1" alt="">
  39. <!-- <img src="../assets/imgs/rank/cr.png" v-if="i == 0" alt="">
  40. <img src="../assets/imgs/rank/mr.png" v-if="i == 1" alt=""> -->
  41. </span>
  42. <span class="score">{{ s.Cle|fmtInt }}</span>
  43. </div>
  44. </li>
  45. </ul>
  46. </div>
  47. <div class="rt">
  48. <ul>
  49. <div class="ltTitle">
  50. <span>排名</span>
  51. <span>成员</span>
  52. <span>CK</span>
  53. </div>
  54. <li v-for="(s,i) in students.CkSort.slice(0, maxShowNum)" v-if="i <= maxShowNum-1" v-show="Listate[i].state"
  55. :class="[{ 'box animate__animated animate__flipInX': Listate[i].state }]">
  56. <div class="gary">
  57. <em>{{ i + 1 }}</em>
  58. <div class="head">
  59. <img :src="s.Head" alt="" v-if="s.Head" :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  60. <img src="../static/img/people/flyhead.png" alt="" v-if="!s.Head"
  61. :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  62. </div>
  63. <span class="names">{{ s.Name }}</span>
  64. <span class="glory">
  65. <img src="../assets/imgs/rank/pb.png" v-if="s.IsBreaking == 1" alt="">
  66. <!-- <img src="../assets/imgs/rank/cr.png" v-if="i == 0" alt="">
  67. <img src="../assets/imgs/rank/mr.png" v-if="i == 1" alt=""> -->
  68. </span>
  69. <span class="score">{{ s.Ck|fmtFloat }}</span>
  70. </div>
  71. </li>
  72. </ul>
  73. </div>
  74. </div>
  75. <div class="icons">
  76. <img src="../assets/imgs/rank/icons2.svg" alt="">
  77. </div>
  78. </div>
  79. <!-- 运动强度排名 -->
  80. <div class="pageYdqdpm" v-show="pages == 2">
  81. <div class="title">
  82. <span>运动强度排名</span>
  83. </div>
  84. <eiRank :students="students" :Listate="Listate"></eiRank>
  85. </div>
  86. <div v-show="totalTime > 0" class="countdown">{{totalTime}}</div>
  87. </div>
  88. </template>
  89. <script>
  90. import Headside from '@/components/Headside'
  91. import {ClassUserRank} from "@/api/getApiRes";
  92. import eiRank from '@/components/eiRank'
  93. let qs = require('qs');
  94. export default {
  95. data() {
  96. return {
  97. pages: 1,
  98. eqSn: '30:9C:23:0C:8B:1E',
  99. pageStyle: RandomBg(),
  100. trueDate: true,//真实数据 true false
  101. autoJump: true,//开启自动跳走
  102. students: {
  103. CkSort: [],
  104. CalSort: [],
  105. EiSort: [],
  106. Ei0Sort: [], //0-39% 激活放松
  107. Ei1Sort: [], //40-54% 动态热身
  108. Ei2Sort: [], //55-69% 脂肪燃烧
  109. Ei3Sort: [], //70-79% 糖分消耗
  110. Ei4Sort: [], //80-89% 心肺训练
  111. Ei5Sort: [], //90-100% 峰值锻炼
  112. },
  113. rsCount: 0, //获取到的记录数
  114. fakeCount: 0, //记录不足,需要填充的记录数
  115. maxShowNum: 8, //页面最大显示记录数
  116. rankTimer: null,
  117. totalTime: '',
  118. Listate: [
  119. {state: false},
  120. {state: false},
  121. {state: false},
  122. {state: false},
  123. {state: false},
  124. {state: false},
  125. {state: false},
  126. {state: false},
  127. ],
  128. }
  129. },
  130. mounted() {
  131. this.init();
  132. },
  133. watch: {
  134. '$route': function (val) {
  135. if (val.path == '/rank') {
  136. if (this.trueDate) {
  137. this.init();
  138. } else {
  139. // this.rankTimer = setInterval(() => {
  140. this.students.CkSort = fakeNews(5);
  141. this.students.CalSort = fakeNews(5);
  142. // }, 5000);
  143. }
  144. } else {
  145. clearInterval(this.autoJump);
  146. clearInterval(this.rankTimer);
  147. }
  148. }
  149. },
  150. beforeDestroy() {
  151. clearInterval(this.rankTimer);
  152. this.rankTimer = null;
  153. },
  154. methods: {
  155. init() {
  156. this.getClassUserRank();
  157. this.cardPlay();
  158. this.pages = 1;
  159. // N秒后翻页
  160. this.rankTimer = setTimeout(() => {
  161. if (this.pages == 1) {
  162. this.pages = 2;
  163. }
  164. else {
  165. this.pages = 1;
  166. }
  167. this.cardPlay();
  168. }, 30000);
  169. },
  170. getClassUserRank() {
  171. let that = this;
  172. let param = {
  173. eqSn: localStorage.eqSn
  174. };
  175. let postdata = qs.stringify(param);
  176. ClassUserRank(postdata).then(res => {
  177. let json = res;
  178. // console.log(json);
  179. if (json.Code == 0) {
  180. let totalTime = 120;
  181. let Studenlength = 0;
  182. if (json.Rs) {
  183. Studenlength = json.Rs.length;
  184. }
  185. // 根据人数多少显示停留时间
  186. if (Studenlength > 3) {
  187. totalTime = 120
  188. } else {
  189. totalTime = 110
  190. }
  191. this.jumpWait(totalTime);
  192. let CkSort = json.Rs;
  193. let CalSort = deepClone(json.Rs);
  194. let EiSort = deepClone(json.Rs);
  195. this.computeAcMap(EiSort);
  196. let Rs = json.Rs;
  197. if (Rs != '') {
  198. // 排序
  199. that.students.CkSort = CkSort.sort(function (a, b) {
  200. return b.Ck - a.Ck;
  201. });
  202. that.students.CalSort = CalSort.sort(function (a, b) {
  203. return b.Cle - a.Cle;
  204. });
  205. that.students.EiSort = EiSort.sort(function (a, b) {
  206. return b.EI - a.EI;
  207. });
  208. }
  209. } else {
  210. this.students.CkSort = [];
  211. this.students.CalSort = [];
  212. this.students.EiSort = [];
  213. if (json.Code == '999') {
  214. // that.$router.push({path: '/'});
  215. } else {
  216. // 已出错
  217. that.$message.error(json.Memo);
  218. }
  219. }
  220. })
  221. },
  222. computeAcMap(Rs) {
  223. let that = this;
  224. let sumAcMap = 0;
  225. let Ei0Sort = []; //0-39% 激活放松
  226. let Ei1Sort = []; //40-54% 动态热身
  227. let Ei2Sort = []; //55-69% 脂肪燃烧
  228. let Ei3Sort = []; //70-79% 糖分消耗
  229. let Ei4Sort = []; //80-89% 心肺训练
  230. let Ei5Sort = []; //90-100% 峰值锻炼
  231. Rs.map(function (item, t) {
  232. sumAcMap = 0;
  233. for (var key in item.EiCalcBean.acMap) {
  234. // console.log("key = " + key);
  235. // console.log("value = " + item.EiCalcBean.acMap[key]);
  236. sumAcMap += parseFloat(item.EiCalcBean.acMap[key]);
  237. };
  238. // console.log("sumAcMap = " + sumAcMap);
  239. item.ei0Per = that.fmtEiPerValue(item.EiCalcBean.acMap[39] / sumAcMap);
  240. item.ei1Per = that.fmtEiPerValue(item.EiCalcBean.acMap[54] / sumAcMap);
  241. item.ei2Per = that.fmtEiPerValue(item.EiCalcBean.acMap[69] / sumAcMap);
  242. item.ei3Per = that.fmtEiPerValue(item.EiCalcBean.acMap[79] / sumAcMap);
  243. item.ei4Per = that.fmtEiPerValue(item.EiCalcBean.acMap[89] / sumAcMap);
  244. item.ei5Per = that.fmtEiPerValue(item.EiCalcBean.acMap[100] / sumAcMap);
  245. Ei0Sort.push(item);
  246. });
  247. // console.log(JSON.stringify(Ei0Sort));
  248. Ei1Sort = deepClone(Ei0Sort);
  249. Ei2Sort = deepClone(Ei0Sort);
  250. Ei3Sort = deepClone(Ei0Sort);
  251. Ei4Sort = deepClone(Ei0Sort);
  252. Ei5Sort = deepClone(Ei0Sort);
  253. that.students.Ei0Sort = Ei0Sort.sort(function (a, b) {
  254. return b.ei0Per - a.ei0Per;
  255. });
  256. that.students.Ei1Sort = Ei1Sort.sort(function (a, b) {
  257. return b.ei1Per - a.ei1Per;
  258. });
  259. that.students.Ei2Sort = Ei2Sort.sort(function (a, b) {
  260. return b.ei2Per - a.ei2Per;
  261. });
  262. that.students.Ei3Sort = Ei3Sort.sort(function (a, b) {
  263. return b.ei3Per - a.ei3Per;
  264. });
  265. that.students.Ei4Sort = Ei4Sort.sort(function (a, b) {
  266. return b.ei4Per - a.ei4Per;
  267. });
  268. that.students.Ei5Sort = Ei5Sort.sort(function (a, b) {
  269. return b.ei5Per - a.ei5Per;
  270. });
  271. },
  272. fmtEiPerValue(val) {
  273. let fmtval = (val*100).toFixed(0);
  274. // console.log("val: " + val);
  275. // console.log("fmtval: " + fmtval);
  276. return fmtval
  277. },
  278. jumpWait(totalTime) {
  279. // 倒计时60秒自动关闭
  280. let that = this;
  281. clearInterval(clock);
  282. let clock = window.setInterval(() => {
  283. that.totalTime = totalTime;
  284. if (parseInt(totalTime) <= 0) {
  285. // 前往等待页面
  286. that.$router.push({path: '/'});
  287. // 计时器回收
  288. clearInterval(clock);
  289. }
  290. totalTime--;
  291. }, 1000)
  292. },
  293. cardPlay() {
  294. let that = this;
  295. // 重置一下状态
  296. that.Listate.map(function (t) {
  297. t.state = false;
  298. })
  299. let timeScope = 100; //400
  300. let timeLong;
  301. that.timer = setTimeout(() => { //设置延迟执行
  302. for (let i = 0; i < 8; i++) {
  303. timeLong = parseInt(i * timeScope);
  304. that.timer = setTimeout(() => { //设置延迟执行
  305. that.Listate[i].state = true;
  306. }, timeLong)
  307. }
  308. }, 60);
  309. },
  310. },
  311. filters: {
  312. fmtNum(val) {
  313. if (val == 0) {
  314. return '--'
  315. } else {
  316. if (parseInt(val) < 0) return 0;
  317. if (parseInt(val) > 0) return val
  318. }
  319. },
  320. fmtFloat(val) {
  321. if (val == 0) {
  322. return '0.0'
  323. } else {
  324. return parseFloat(val).toFixed(1);
  325. }
  326. },
  327. fmtInt(val) {
  328. if (val == 0) {
  329. return '0'
  330. } else {
  331. return parseInt(val);
  332. }
  333. },
  334. },
  335. components: {
  336. Headside, eiRank
  337. }
  338. }
  339. </script>
  340. <style lang="scss" scoped>
  341. $font-color: white;
  342. $yellow: #FFEB50;
  343. @mixin bg {
  344. height: 100%;
  345. background-color: #333;
  346. background-repeat: no-repeat;
  347. background-position: top center;
  348. background-size: 100% 100%;
  349. }
  350. @mixin cube {
  351. width: 100%;
  352. overflow: hidden;
  353. display: block;
  354. margin: 0 auto;
  355. }
  356. .bg1 {
  357. background: url("../../src/assets/imgs/rank/Training.png");
  358. @include bg;
  359. }
  360. .bg2 {
  361. background: url("../../src/assets/imgs/rank/bg_ydqdpm.png");
  362. @include bg;
  363. }
  364. .content {
  365. .pageXlpm {
  366. .sumTitle {
  367. @include cube;
  368. width: 80%;
  369. height: 0.75rem;
  370. margin-top: 0.7rem;
  371. overflow: visible;
  372. h5 {
  373. float: left;
  374. width: 80%;
  375. margin: 0;
  376. text-align: center;
  377. color: #fff;
  378. font-size: 0.5rem;
  379. font-weight: bold;
  380. line-height: 0.65rem;
  381. }
  382. .lt {
  383. width: 50%;
  384. height: 0.75rem;
  385. float: left;
  386. background: url("../../src/assets/imgs/rank/redTitel.png");
  387. background-repeat: no-repeat;
  388. background-position: top center;
  389. background-size: 100%;
  390. border-radius: 250rem;
  391. img {
  392. width: 0.51rem;
  393. float: left;
  394. }
  395. }
  396. .rt {
  397. width: 50%;
  398. height: 0.75rem;
  399. float: right;
  400. background: url("../../src/assets/imgs/rank/redTitel.png");
  401. background-repeat: no-repeat;
  402. background-position: top center;
  403. background-size: 100%;
  404. border-radius: 250rem;
  405. img {
  406. width: 0.8rem;
  407. float: right;
  408. }
  409. h5 {
  410. float: right;
  411. }
  412. }
  413. .md {
  414. position: relative;
  415. width: 3rem;
  416. height: 0.9rem;
  417. margin: 0 auto;
  418. bottom: 0.12rem;
  419. background: url("../../src/assets/imgs/rank/titleBg.png");
  420. background-repeat: no-repeat;
  421. background-position: top center;
  422. background-size: 100% 100%;
  423. line-height: 0.7rem;
  424. span {
  425. @include cube;
  426. position: relative;
  427. bottom: 0.65rem;
  428. color: #fff;
  429. text-align: center;
  430. font-size: 0.35rem;
  431. font-weight: bold;
  432. }
  433. }
  434. }
  435. .listContainer {
  436. @include cube;
  437. width: 80%;
  438. padding-top: 0.5rem;
  439. .lt {
  440. width: 47%;
  441. float: left;
  442. }
  443. .rt {
  444. width: 47%;
  445. float: right;
  446. .ltTitle span {
  447. margin-right: 0.3rem;
  448. }
  449. }
  450. .ltTitle {
  451. @include cube;
  452. span {
  453. float: left;
  454. color: #fff;
  455. font-size: 0.25rem;
  456. &:nth-child(1) {
  457. margin-right: 1.5rem;
  458. }
  459. &:last-child {
  460. float: right;
  461. margin-right: 0.2rem;
  462. }
  463. }
  464. }
  465. ul {
  466. @include cube;
  467. li {
  468. @include cube;
  469. height: 0.7rem;
  470. padding-top: 0.2rem;
  471. .gary {
  472. @include cube;
  473. height: 0.6rem;
  474. margin-bottom: 0.3rem;
  475. background: url("../assets/imgs/rank/row.png");
  476. background-repeat: no-repeat;
  477. background-position: top center;
  478. background-size: 100% 100%;
  479. overflow: visible;
  480. border: 1px solid rgba(255, 255, 255, 0.1);
  481. border-radius: 250px;
  482. border-left: 0;
  483. border-top-left-radius: 0;
  484. border-bottom-left-radius: 0;
  485. }
  486. em {
  487. width: 0.6rem;
  488. height: 0.6rem;
  489. float: left;
  490. background: url("../assets/imgs/rank/rowTitle.png");
  491. background-repeat: no-repeat;
  492. background-position: top center;
  493. background-size: 100% 100%;
  494. text-align: left;
  495. text-indent: 0.1rem;
  496. font-size: 0.3rem;
  497. font-weight: bold;
  498. text-decoration: none;
  499. font-style: normal;
  500. color: white;
  501. line-height: 0.6rem;
  502. }
  503. .head {
  504. position: relative;
  505. bottom: 0.5rem;
  506. float: left;
  507. margin-left: 0.3rem;
  508. img {
  509. width: 0.65rem;
  510. height: 0.65rem;
  511. border-radius: 250rem;
  512. &.girl {
  513. border: 1px solid #EA26EA;
  514. }
  515. &.boy {
  516. border: 1px solid #39B6FF;
  517. }
  518. }
  519. }
  520. .names {
  521. float: left;
  522. color: white;
  523. font-size: 0.3rem;
  524. line-height: 0.6rem;
  525. margin-left: 0.4rem;
  526. min-width: 1rem;
  527. text-align: left;
  528. }
  529. .glory {
  530. float: left;
  531. margin-left: 0.4rem;
  532. img {
  533. float: right;
  534. width: 0.6rem;
  535. margin-left: 0.2rem;
  536. margin-top: 0.1rem;
  537. }
  538. }
  539. .score {
  540. float: right;
  541. color: #FFE61F;
  542. font-size: 0.3rem;
  543. line-height: 0.6rem;
  544. font-family: Arial;
  545. font-weight: bold;
  546. font-style: italic;
  547. text-align: center;
  548. padding-right: 0.2rem;
  549. }
  550. }
  551. }
  552. }
  553. }
  554. .pageYdqdpm {
  555. .title {
  556. // position: relative;
  557. width: 3.6rem;
  558. height: 0.75rem;
  559. margin: 0 auto;
  560. margin-top: 0.03rem;
  561. bottom: 0.1rem;
  562. background: url("../../src/assets/imgs/rank/titleBg2.png");
  563. background-repeat: no-repeat;
  564. background-position: top center;
  565. background-size: 100% 100%;
  566. line-height: 0.7rem;
  567. span {
  568. @include cube;
  569. // position: relative;
  570. bottom: 0.65rem;
  571. color: #fff;
  572. text-align: center;
  573. font-size: 0.35rem;
  574. font-weight: bold;
  575. }
  576. }
  577. }
  578. }
  579. .icons {
  580. @include cube;
  581. position: absolute;
  582. bottom: 0.2rem;
  583. img {
  584. @include cube;
  585. // width: 40%;
  586. width: 18%;
  587. }
  588. }
  589. .countdown {
  590. width: 1rem;
  591. position: absolute;
  592. font-size: 0.25rem;
  593. color: white;
  594. right: 0rem;
  595. bottom: 0.2rem;
  596. }
  597. </style>