Rank_old.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div class="content">
  3. <Headside></Headside>
  4. <div class="sumTitle">
  5. <div class="lt">
  6. <img src="../assets/imgs/rank/fire.svg" alt="">
  7. <h5>卡路里排名</h5>
  8. </div>
  9. <div class="rt">
  10. <img src="../assets/imgs/rank/ck.svg" alt="">
  11. <h5>CK排名</h5>
  12. </div>
  13. <div class="md">
  14. <span>本次训练排名</span>
  15. </div>
  16. </div>
  17. <div class="listContainer">
  18. <div class="lt">
  19. <ul>
  20. <div class="ltTitle">
  21. <span>排名</span>
  22. <span>成员</span>
  23. <span>卡路里</span>
  24. </div>
  25. <li v-for="(s,i) in students.CalSort" v-if="i <= 7"
  26. :class="[{ 'box animate__animated animate__flipInX': Listate[i].state }]">
  27. <div class="gary">
  28. <em>{{ i + 1 }}</em>
  29. <div class="head">
  30. <img :src="s.Head" alt="" v-if="s.Head" :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  31. <img src="../static/img/people/flyhead.png" alt="" v-if="!s.Head"
  32. :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  33. </div>
  34. <span class="names">{{ s.Name }}</span>
  35. <span class="glory">
  36. <img src="../assets/imgs/rank/cr.png" v-if="i == 0" alt="">
  37. <img src="../assets/imgs/rank/mr.png" v-if="i == 1" alt="">
  38. <img src="../assets/imgs/rank/pb.png" v-if="i == 2" alt="">
  39. </span>
  40. <span class="score">
  41. {{ s.Cle|fmtInt }}
  42. <!-- {{ s.Ck|fmtFloat }}-->
  43. </span>
  44. </div>
  45. </li>
  46. </ul>
  47. </div>
  48. <div class="rt">
  49. <ul>
  50. <div class="ltTitle">
  51. <span>排名</span>
  52. <span>成员</span>
  53. <span>CK</span>
  54. </div>
  55. <li v-for="(s,i) in students.CkSort" v-if="i <= 7"
  56. :class="[{ 'box animate__animated animate__flipInX': Listate[i].state }]">
  57. <div class="gary">
  58. <em>{{ i + 1 }}</em>
  59. <div class="head">
  60. <img :src="s.Head" alt="" v-if="s.Head" :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  61. <img src="../static/img/people/flyhead.png" alt="" v-if="!s.Head"
  62. :class="[{'boy':s.Sex == 1},{'girl':s.Sex == 2}]">
  63. </div>
  64. <span class="names">{{ s.Name }}</span>
  65. <span class="glory">
  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. <img src="../assets/imgs/rank/pb.png" v-if="i == 2" alt="">
  69. </span>
  70. <span class="score">
  71. {{ s.Ck|fmtFloat }}
  72. </span>
  73. </div>
  74. </li>
  75. </ul>
  76. </div>
  77. </div>
  78. <div class="icons">
  79. <img src="../assets/imgs/rank/icons.svg" alt="">
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import Headside from '@/components/Headside'
  85. import {ClassUserRank} from "@/api/getApiRes";
  86. let qs = require('qs');
  87. export default {
  88. data() {
  89. return {
  90. eqSn: '30:9C:23:0C:8B:1E',
  91. pageStyle: RandomBg(),
  92. trueDate: true,//真实数据 true false
  93. autoJump: true,//开启自动跳走
  94. students: {
  95. CkSort: [],
  96. CalSort: [],
  97. },
  98. rankTimer: null,
  99. totalTime: '',
  100. Listate: [
  101. {state: false},
  102. {state: false},
  103. {state: false},
  104. {state: false},
  105. {state: false},
  106. {state: false},
  107. {state: false},
  108. {state: false},
  109. ],
  110. }
  111. },
  112. mounted() {
  113. this.init();
  114. this.cardPlay();
  115. },
  116. watch: {
  117. '$route': function (val) {
  118. if (val.path == '/rank') {
  119. if (this.trueDate) {
  120. this.init();
  121. } else {
  122. // this.rankTimer = setInterval(() => {
  123. this.students.CkSort = fakeNews(5);
  124. this.students.CalSort = fakeNews(5);
  125. // }, 5000);
  126. }
  127. } else {
  128. clearInterval(this.autoJump);
  129. clearInterval(this.rankTimer);
  130. }
  131. }
  132. },
  133. beforeDestroy() {
  134. clearInterval(this.rankTimer);
  135. this.rankTimer = null;
  136. },
  137. methods: {
  138. init() {
  139. this.getClassUserRank();
  140. },
  141. getClassUserRank() {
  142. let that = this;
  143. let param = {
  144. eqSn: localStorage.eqSn
  145. };
  146. let postdata = qs.stringify(param);
  147. ClassUserRank(postdata).then(res => {
  148. let json = res;
  149. console.log(json);
  150. if (json.Code == 0) {
  151. let totalTime = 40;
  152. let Studenlength = 0;
  153. if (json.Rs) {
  154. Studenlength = json.Rs.length;
  155. }
  156. // 根据人数多少显示停留时间
  157. if (Studenlength > 3) {
  158. totalTime = 60
  159. } else {
  160. totalTime = 40
  161. }
  162. this.jumpWait(totalTime);
  163. let CkSort = json.Rs;
  164. let CalSort = deepClone(json.Rs);
  165. let Rs = json.Rs;
  166. if (Rs != '') {
  167. // 排序
  168. that.students.CkSort = CkSort.sort(function (a, b) {
  169. return b.Ck - a.Ck;
  170. });
  171. that.students.CalSort = CalSort.sort(function (a, b) {
  172. return b.Cle - a.Cle;
  173. });
  174. }
  175. } else {
  176. this.students.CkSort = [];
  177. this.students.CalSort = [];
  178. if (json.Code == '999') {
  179. // that.$router.push({path: '/'});
  180. } else {
  181. // 已出错
  182. that.$message.error(json.Memo);
  183. }
  184. }
  185. })
  186. },
  187. jumpWait(totalTime) {
  188. // 倒计时60秒自动关闭
  189. let that = this;
  190. clearInterval(clock);
  191. let clock = window.setInterval(() => {
  192. totalTime--;
  193. that.totalTime = totalTime;
  194. if (parseInt(totalTime) <= 0) {
  195. // 前往等待页面
  196. that.$router.push({path: '/'}); //todo 调试时关闭跳走
  197. // 计时器回收
  198. clearInterval(clock);
  199. }
  200. }, 1000)
  201. },
  202. cardPlay() {
  203. let that = this;
  204. // 重置一下状态
  205. that.Listate.map(function (t) {
  206. t.state = false;
  207. })
  208. let timeScope = 400;
  209. let timeLong;
  210. let row;
  211. for (let i = 0; i < 8; i++) {
  212. timeLong = parseInt(i * timeScope);
  213. that.timer = setTimeout(() => { //设置延迟执行
  214. that.Listate[i].state = true;
  215. }, timeLong)
  216. }
  217. },
  218. },
  219. filters: {
  220. fmtNum(val) {
  221. if (val == 0) {
  222. return '--'
  223. } else {
  224. if (parseInt(val) < 0) return 0;
  225. if (parseInt(val) > 0) return val
  226. }
  227. },
  228. fmtFloat(val) {
  229. if (val == 0) {
  230. return '0.0'
  231. } else {
  232. return parseFloat(val).toFixed(1);
  233. }
  234. },
  235. fmtInt(val) {
  236. if (val == 0) {
  237. return '0'
  238. } else {
  239. return parseInt(val);
  240. }
  241. },
  242. },
  243. components: {
  244. Headside
  245. }
  246. }
  247. </script>
  248. <style lang="scss" scoped>
  249. @mixin bg {
  250. height: 100%;
  251. background-color: #333;
  252. background-repeat: no-repeat;
  253. background-position: top center;
  254. background-size: 100% 100%;
  255. }
  256. @mixin cube {
  257. width: 100%;
  258. overflow: hidden;
  259. display: block;
  260. margin: 0 auto;
  261. }
  262. .content {
  263. background: url("../../src/assets/imgs/rank/Training.png");
  264. @include bg;
  265. .sumTitle {
  266. @include cube;
  267. width: 80%;
  268. height: 0.75rem;
  269. margin-top: 0.7rem;
  270. overflow: visible;
  271. h5 {
  272. float: left;
  273. width: 80%;
  274. margin: 0;
  275. text-align: center;
  276. color: #fff;
  277. font-size: 0.5rem;
  278. font-weight: bold;
  279. }
  280. .lt {
  281. width: 50%;
  282. height: 0.75rem;
  283. float: left;
  284. background: url("../../src/assets/imgs/rank/redTitel.png");
  285. background-repeat: no-repeat;
  286. background-position: top center;
  287. background-size: 100%;
  288. border-radius: 250rem;
  289. img {
  290. width: 0.51rem;
  291. float: left;
  292. }
  293. }
  294. .rt {
  295. width: 50%;
  296. height: 0.75rem;
  297. float: right;
  298. background: url("../../src/assets/imgs/rank/redTitel.png");
  299. background-repeat: no-repeat;
  300. background-position: top center;
  301. background-size: 100%;
  302. border-radius: 250rem;
  303. img {
  304. width: 0.8rem;
  305. float: right;
  306. }
  307. h5 {
  308. float: right;
  309. }
  310. }
  311. .md {
  312. position: relative;
  313. width: 3rem;
  314. height: 0.9rem;
  315. margin: 0 auto;
  316. bottom: 0.1rem;
  317. background: url("../../src/assets/imgs/rank/titleBg.png");
  318. background-repeat: no-repeat;
  319. background-position: top center;
  320. background-size: 100% 100%;
  321. line-height: 0.7rem;
  322. span {
  323. @include cube;
  324. position: relative;
  325. bottom: 0.65rem;
  326. color: #fff;
  327. text-align: center;
  328. font-size: 0.35rem;
  329. font-weight: bold;
  330. }
  331. }
  332. }
  333. }
  334. .listContainer {
  335. @include cube;
  336. width: 80%;
  337. padding-top: 0.5rem;
  338. .lt {
  339. width: 47%;
  340. float: left;
  341. }
  342. .rt {
  343. width: 47%;
  344. float: right;
  345. .ltTitle span {
  346. margin-right: 0.3rem;
  347. }
  348. }
  349. .ltTitle {
  350. @include cube;
  351. span {
  352. float: left;
  353. color: #fff;
  354. font-size: 0.25rem;
  355. &:nth-child(1) {
  356. margin-right: 1.3rem;
  357. }
  358. &:last-child {
  359. float: right;
  360. }
  361. }
  362. }
  363. ul {
  364. @include cube;
  365. li {
  366. @include cube;
  367. height: 0.7rem;
  368. padding-top: 0.2rem;
  369. .gary {
  370. @include cube;
  371. height: 0.6rem;
  372. margin-bottom: 0.3rem;
  373. background: url("../assets/imgs/rank/row.png");
  374. background-repeat: no-repeat;
  375. background-position: top center;
  376. background-size: 100% 100%;
  377. overflow: visible;
  378. border: 1px solid rgba(255, 255, 255, 0.1);
  379. border-radius: 250px;
  380. border-left: 0;
  381. border-top-left-radius: 0;
  382. border-bottom-left-radius: 0;
  383. }
  384. em {
  385. width: 0.6rem;
  386. height: 0.6rem;
  387. float: left;
  388. background: url("../assets/imgs/rank/rowTitle.png");
  389. background-repeat: no-repeat;
  390. background-position: top center;
  391. background-size: 100% 100%;
  392. text-align: left;
  393. text-indent: 0.1rem;
  394. font-size: 0.3rem;
  395. font-weight: bold;
  396. text-decoration: none;
  397. font-style: normal;
  398. color: white;
  399. line-height: 0.6rem;
  400. }
  401. .head {
  402. position: relative;
  403. bottom: 0.5rem;
  404. float: left;
  405. margin-left: 0.3rem;
  406. img {
  407. width: 0.65rem;
  408. border-radius: 250rem;
  409. &.girl {
  410. border: 1px solid #EA26EA;
  411. }
  412. &.boy {
  413. border: 1px solid #39B6FF;
  414. }
  415. }
  416. }
  417. .names {
  418. float: left;
  419. color: white;
  420. font-size: 0.3rem;
  421. line-height: 0.6rem;
  422. margin-left: 0.4rem;
  423. }
  424. .glory {
  425. float: left;
  426. margin-left: 0.4rem;
  427. img {
  428. float: right;
  429. width: 0.6rem;
  430. margin-left: 0.2rem;
  431. margin-top: 0.1rem;
  432. }
  433. }
  434. .score {
  435. float: right;
  436. color: #FFE61F;
  437. font-size: 0.3rem;
  438. line-height: 0.6rem;
  439. font-family: Arial;
  440. font-weight: bold;
  441. font-style: italic;
  442. text-align: center;
  443. padding-right: 0.2rem;
  444. }
  445. }
  446. }
  447. }
  448. .icons {
  449. @include cube;
  450. position: absolute;
  451. bottom: 0.2rem;
  452. img {
  453. @include cube;
  454. width: 40%;
  455. }
  456. }
  457. </style>