index3.uvue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <!-- LED分辨率: 1920 * 1080 -->
  2. <template>
  3. <view class="body">
  4. <view v-if="pageType == 1" class="content bg-led01">
  5. <view class="distance-container-1">
  6. <view class="total-time-1">总用时: {{durationStr}}</view>
  7. <view class="total-distance-1">{{distanceKm}}KM</view>
  8. </view>
  9. <!-- <image class="run" mode="aspectFit" src="/static/led/run.png"></image> -->
  10. </view>
  11. <view v-if="pageType == 2" class="content bg-led02">
  12. <view class="pic-container">
  13. <!-- <image class="pic" mode="aspectFill" :src="imageSrc"></image> -->
  14. <swiper ref="swiper" class="swiper" :autoplay="autoplay" circular :current="swiperCurrent" :interval="picInterval"
  15. :duration="picDuration" @change="swiperChange" @animationfinish="animationfinish">
  16. <swiper-item v-for="(image, index) in swiperData" :key="index">
  17. <image class="pic-bg" :src="image"></image>
  18. <image class="pic" mode="aspectFit" :src="image"></image>
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. <view class="distance-container-2">
  23. <view class="total-time-2">总用时: {{durationStr}}</view>
  24. <view class="total-distance-2">{{distanceKm}}KM</view>
  25. </view>
  26. <image class="mascot" mode="aspectFit" src="/static/led/mascot-2.png"></image>
  27. <!-- <image class="lpzg" mode="aspectFit" src="/static/lpzg.png"></image> -->
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import tools from '../../common/tools';
  33. import { apiGetStatistics, apiGetUploadPic } from '../../common/api';
  34. export default {
  35. data() {
  36. return {
  37. testMode: 0, // 测试模式 0:否 1:是
  38. testDuration: 0,
  39. testDistance: 0,
  40. pageAutoChange: 0, // 有照片是否自动切换背景 0:否 1:是
  41. pageType: 1, // 1: 无照片 2: 有照片
  42. actIdArrStr: "",
  43. SumDuration: 0,
  44. SumDistance: 0,
  45. picCount: 0,
  46. autoplay: true,
  47. swiperData: [], // swiper控件的数据
  48. swiperCurrent: 0, // swiper当前所在滑块的 index
  49. lastSwiperCurIndex: 0, // 用于新图片加载后恢复之前的图片index
  50. picGroupSize: 90, // 图片分组 每组最大图片数量
  51. picGroupNum: 0, // 图片分组 分组数量
  52. picGroupCurIndex: 0,// 图片分组 当前播放的分组序号
  53. picSwiperIndex: 0, // 图片分组 当前播放的分组内的图片序号
  54. picList: [], // 图片列表 存放从服务器获取的所有图片
  55. picInterval: 3000, // 自动切换时间间隔
  56. picDuration: 500, // 滑动动画时长
  57. intervalSta: 0,
  58. intervalGrpSw: 0,
  59. // imageSrc: '',
  60. }
  61. },
  62. computed: {
  63. durationStr() {
  64. return tools.convertSecondsToHMS(this.SumDuration);
  65. },
  66. distanceKm() {
  67. if (this.SumDistance < 1000000)
  68. return Math.round(this.SumDistance * 10 / 1000) / 10;
  69. else
  70. return Math.round(this.SumDistance / 1000);
  71. }
  72. },
  73. onLoad(event) { // 类型非必填,可自动推导
  74. // this.SumDuration = 1622;
  75. // this.SumDistance = 999050;
  76. // this.SumDistance = 999949;
  77. // this.SumDistance = 2066869;
  78. // this.imageSrc = "/static/led/pic2.jpg";
  79. this.swiperData = this.picList[0];
  80. this.testMode = event["test"] ?? 0;
  81. this.pageAutoChange = event["pac"] ?? 0;
  82. this.pageType = event["page"] ?? 1;
  83. this.actIdArrStr = event["act"] ?? "175,176,177,178";
  84. this.getUploadPic();
  85. this.getStatistics();
  86. this.handleGroupSwitch();
  87. this.intervalSta = setInterval(this.getStatistics, 1000);
  88. // this.intervalGrpSw = setInterval(this.handleGroupSwitch, 1000);
  89. },
  90. onUnload() {
  91. console.log("onUnload");
  92. clearInterval(this.intervalSta);
  93. // clearInterval(this.intervalGrpSw);
  94. },
  95. methods: {
  96. handleGroupSwitch() {
  97. // console.log("[handleGroupSwitch] pic group: " + this.picGroupCurIndex + " / pic index: " + this.picSwiperIndex);
  98. if (this.swiperData == undefined) {
  99. setTimeout(this.handleGroupSwitch, 1000);
  100. return;
  101. }
  102. // 当前组已播完
  103. if (this.picSwiperIndex == this.swiperData.length - 1) {
  104. this.picSwiperIndex = 0;
  105. this.autoplay = false;
  106. setTimeout(() => {
  107. // 播放下一组图片
  108. if (this.picGroupCurIndex < this.picGroupNum - 1) {
  109. this.picGroupCurIndex++;
  110. // this.swiperData = this.picList[this.picGroupCurIndex];
  111. this.setSwiperData(this.picList[this.picGroupCurIndex]);
  112. this.swiperCurrent = 0;
  113. console.log("播放下一组图片 picGroupCurIndex = " + this.picGroupCurIndex);
  114. }
  115. // 所有图片组都播放完后,重新获取图片数据
  116. else {
  117. console.log("播放完毕,重新获取图片数据... picGroupCurIndex: " , this.picGroupCurIndex);
  118. this.lastSwiperCurIndex = this.picSwiperIndex;
  119. this.getUploadPic();
  120. }
  121. this.autoplay = true;
  122. setTimeout(this.handleGroupSwitch, 1000);
  123. }, this.picInterval - 100); // 时间-100ms,防止swiper滑动到下一个图片
  124. }
  125. else {
  126. setTimeout(this.handleGroupSwitch, 1000);
  127. }
  128. },
  129. setSwiperData(res) {
  130. // console.log("[setSwiperData] res:", res);
  131. if (res == undefined) {
  132. return;
  133. }
  134. this.swiperData = [];
  135. for (let n=0; n<res.length; n++) {
  136. this.swiperData.push(res[n]);
  137. // console.log("[setSwiperData] swiperData.push", res[n]);
  138. }
  139. },
  140. getStatistics() {
  141. if (this.testMode == 1) {
  142. this.testDuration += 1;
  143. this.testDistance += 100;
  144. // this.testDistance = 999949;
  145. this.SumDuration = this.testDuration;
  146. this.SumDistance = this.testDistance;
  147. return;
  148. }
  149. uni.request({
  150. url: apiGetStatistics,
  151. header: {
  152. "Content-Type": "application/x-www-form-urlencoded",
  153. },
  154. method: "POST",
  155. data: {
  156. actIdArrStr: this.actIdArrStr
  157. },
  158. success: (res) => {
  159. // console.log("getStatistics", res)
  160. const data = res.data.data;
  161. this.SumDuration = data.SumDuration;
  162. this.SumDistance = data.SumDistance;
  163. },
  164. fail: (err) => {
  165. console.log("getStatistics err", err)
  166. },
  167. });
  168. },
  169. getUploadPic() {
  170. uni.request({
  171. url: apiGetUploadPic,
  172. header: {
  173. "Content-Type": "application/x-www-form-urlencoded",
  174. },
  175. method: "POST",
  176. data: {
  177. actIdArrStr: this.actIdArrStr
  178. },
  179. success: (res) => {
  180. // console.log("getUploadPic", res);
  181. const data = res.data.data;
  182. const newCount = data.List.length;
  183. console.log("获取到的图片数量:", newCount);
  184. if (newCount > 0) {
  185. if (this.pageAutoChange == 1) {
  186. this.pageType = 2;
  187. }
  188. } else {
  189. if (this.pageAutoChange == 1) {
  190. if (this.picCount == 0)
  191. this.pageType = 1;
  192. else
  193. this.pageType = 2;
  194. }
  195. }
  196. if (newCount > this.picCount) { // 有新图片
  197. console.log("有 " + (newCount - this.picCount) + " 张新图片");
  198. // 将新增的图片追加到图片队列
  199. for (let i = this.picCount; i < newCount; i++) {
  200. let picUrl = data.Domain + data.List[i];
  201. if (this.picList.length == 0) {
  202. this.picGroupNum = 1;
  203. this.picList[this.picGroupNum-1] = new Array();
  204. console.log("新增图片分组: " + this.picGroupNum);
  205. }
  206. if (this.picList[this.picGroupNum-1].length >= this.picGroupSize) {
  207. this.picGroupNum++;
  208. this.picList[this.picGroupNum-1] = new Array();
  209. console.log("新增图片分组: " + this.picGroupNum);
  210. }
  211. this.picList[this.picGroupNum-1].push(picUrl);
  212. // console.log("picList[" + (this.picGroupNum-1) + "][" + (this.picList[this.picGroupNum-1].length-1) + "]: " + picUrl);
  213. // console.log("--> picList", this.picList[this.picGroupNum-1]);
  214. // for (let j=0; j<15; j++) {
  215. // this.picList[this.picGroupNum-1].push(picUrl);
  216. // }
  217. }
  218. // console.log("*** picList 总数量", this.picList.length);
  219. // if (this.picCount > 0) {
  220. // // this.swiperCurrent = this.picCount;
  221. // this.swiperCurrent = this.lastSwiperCurIndex;
  222. // console.log("重定位 picGroupCurIndex", this.picGroupCurIndex);
  223. // console.log("重定位 index", this.swiperCurrent);
  224. // }
  225. this.picCount = newCount;
  226. this.autoplay = false;
  227. // this.swiperData = this.picList[this.picGroupCurIndex];
  228. this.setSwiperData(this.picList[this.picGroupCurIndex]);
  229. this.swiperCurrent = this.lastSwiperCurIndex;
  230. this.picSwiperIndex = this.lastSwiperCurIndex;
  231. this.autoplay = true;
  232. console.log("重定位 picGroupCurIndex", this.picGroupCurIndex);
  233. console.log("重定位 index", this.swiperCurrent);
  234. }
  235. else { // 没有新图片
  236. // 从第1组重新开始播放图片
  237. console.log("没有新图片,从第1组重新开始播放图片");
  238. this.autoplay = false;
  239. this.picGroupCurIndex = 0;
  240. this.swiperCurrent = 0;
  241. this.picSwiperIndex = 0;
  242. // this.swiperData = this.picList[this.picGroupCurIndex];
  243. this.setSwiperData(this.picList[this.picGroupCurIndex]);
  244. this.autoplay = true;
  245. // console.log("picList", this.picList);
  246. // console.log("swiperData", this.swiperData);
  247. }
  248. if (this.picCount == 0) {
  249. // console.log('this.picCount == 0');
  250. setTimeout(this.getUploadPic, 1000);
  251. }
  252. else if (this.picCount == 1) {
  253. // console.log('this.picCount == 1');
  254. // swiper在只有1张图片的情况下不会触发 @change事件,需要在这里再次获取图片数据
  255. setTimeout(this.getUploadPic, this.picInterval);
  256. }
  257. // console.log("picList", this.picList);
  258. },
  259. fail: (err) => {
  260. console.log("getUploadPic err", err);
  261. setTimeout(this.getUploadPic, 3000);
  262. },
  263. });
  264. },
  265. //当前轮播索引
  266. swiperChange(e) {
  267. console.log("pic group: " + this.picGroupCurIndex + " / pic index: " + e.detail.current);
  268. // console.log("picGroupNum: " + this.picGroupNum);
  269. const curIndex = e.detail.current;
  270. this.picSwiperIndex = curIndex;
  271. // // 当前组已播完
  272. if (curIndex == this.swiperData.length - 1) {
  273. this.autoplay = false;
  274. // setTimeout(() => {
  275. // // 播放下一组图片
  276. // if (this.picGroupCurIndex < this.picGroupNum - 1) {
  277. // this.picGroupCurIndex++;
  278. // // this.swiperData = this.picList[this.picGroupCurIndex];
  279. // // this.swiperCurrent = 0;
  280. // this.setSwiperData(this.picList[this.picGroupCurIndex]);
  281. // console.log("播放下一组图片 picGroupCurIndex = " + this.picGroupCurIndex);
  282. // }
  283. // // 所有图片组都播放完后,重新获取图片数据
  284. // else {
  285. // console.log("播放完毕,重新获取图片数据..." , this.picGroupCurIndex);
  286. // this.lastSwiperCurIndex = curIndex;
  287. // this.getUploadPic();
  288. // }
  289. // }, this.picInterval - 100); // 时间-100ms,防止swiper滑动到下一个图片
  290. }
  291. },
  292. //点击轮播
  293. swiperClick(e) {
  294. console.log('点击轮播', e);
  295. },
  296. animationfinish(e) {
  297. // console.log('animationfinish');
  298. // console.log("pic group: " + this.picGroupCurIndex + " / pic index: " + e.detail.current);
  299. // const curIndex = e.detail.current;
  300. // // 当前组已播完
  301. // if (curIndex == this.swiperData.length - 1) {
  302. // // setTimeout(() => {
  303. // // 播放下一组图片
  304. // if (this.picGroupCurIndex < this.picGroupNum - 1) {
  305. // this.picGroupCurIndex++;
  306. // this.swiperCurrent = 0;
  307. // // this.swiperData = this.picList[this.picGroupCurIndex];
  308. // this.setSwiperData(this.picList[this.picGroupCurIndex]);
  309. // console.log("播放下一组图片 picGroupCurIndex = " + this.picGroupCurIndex);
  310. // // console.log("picList", this.picList);
  311. // // console.log("swiperData", this.swiperData);
  312. // }
  313. // // 所有图片组都播放完后,重新获取图片数据
  314. // else {
  315. // console.log("播放完毕,重新获取图片数据..." , this.picGroupCurIndex);
  316. // this.lastSwiperCurIndex = curIndex;
  317. // this.getUploadPic();
  318. // }
  319. // // }, this.picInterval - 1000); // 时间-100ms,防止swiper滑动到下一个图片
  320. // }
  321. }
  322. }
  323. }
  324. </script>
  325. <style>
  326. .body {
  327. /* width: 100%; */
  328. /* height: 100vh; */
  329. width: 1920px;
  330. height: 1080px;
  331. display: flex;
  332. flex-direction: column;
  333. align-items: center;
  334. justify-content: center;
  335. }
  336. .content {
  337. width: 100%;
  338. height: 100%;
  339. flex-direction: row;
  340. align-items: flex-start;
  341. /* justify-content: flex-start; */
  342. }
  343. .bg-led01 {
  344. background-image: url("/static/led/led01-3.webp");
  345. background-repeat: no-repeat;
  346. background-size: contain;
  347. }
  348. .bg-led02 {
  349. background-image: url("/static/led/led02-3.webp");
  350. background-repeat: no-repeat;
  351. background-size: contain;
  352. }
  353. .pic-container {
  354. width: 1220px;
  355. height: 810px;
  356. margin-left: 100px;
  357. margin-top: 100px;
  358. background: url("/static/led/pic_border-3.png");
  359. background-repeat: no-repeat;
  360. background-size: contain;
  361. }
  362. .swiper {
  363. height: 812px;
  364. mask-image: url('/static/led/pic_mask-3.png');
  365. mask-size: 1218px;
  366. mask-repeat: no-repeat;
  367. }
  368. .pic {
  369. margin: 3px;
  370. width: 1218px;
  371. height: 810px;
  372. }
  373. .pic-bg {
  374. position: absolute;
  375. margin: -10px;
  376. width: 1240px;
  377. height: 830px;
  378. filter: blur(15px);
  379. }
  380. .distance-container-1 {
  381. align-items: center;
  382. justify-content: space-around;
  383. width: 1130px;
  384. height: 476px;
  385. margin-left: 175px;
  386. margin-top: 165px;
  387. }
  388. .total-time-1 {
  389. font-family: 'Arial Black';
  390. font-size: 50px;
  391. color: #ffffff;
  392. margin-left: 390px;
  393. line-height: 90px;
  394. margin-top: 0px;
  395. }
  396. .total-distance-1 {
  397. font-family: 'Arial';
  398. font-size: 330px;
  399. transform: scaleX(0.8);
  400. color: #ffffff;
  401. line-height: 300px;
  402. }
  403. .distance-container-2 {
  404. align-items: center;
  405. justify-content: space-around;
  406. width: 660px;
  407. height: 280px;
  408. margin-left: -163px;
  409. margin-top: 366px;
  410. background: url("/static/led/distance_bg.png") no-repeat;
  411. background-size: cover;
  412. }
  413. .total-time-2 {
  414. font-family: 'Arial Black';
  415. font-size: 36px;
  416. transform: scaleX(0.9);
  417. color: #ffffff;
  418. margin-left: 320px;
  419. line-height: 50px;
  420. }
  421. .total-distance-2 {
  422. font-family: 'Arial';
  423. font-size: 200px;
  424. transform: scaleX(0.78);
  425. color: #ffffff;
  426. line-height: 180px;
  427. }
  428. .run {
  429. width: 468px;
  430. height: 468px;
  431. margin-left: -840px;
  432. margin-top: 130px;
  433. }
  434. .mascot {
  435. height: 358px;
  436. margin-left: -525px;
  437. margin-top: 80px;
  438. }
  439. .lpzg {
  440. width: 468px;
  441. margin-left: -1510px;
  442. margin-top: 832px;
  443. }
  444. </style>