index.uvue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <!-- LED分辨率: 1920 * 1440 -->
  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.gif"></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 class="swiper" autoplay circular :current="picCurIndex" :interval="picInterval"
  15. :duration="picDuration" @change="swiperChange">
  16. <swiper-item v-for="(image, index) in picList" :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.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. picList: [],
  47. picInterval: 3000, // 自动切换时间间隔
  48. picDuration: 500, // 滑动动画时长
  49. picCurIndex: 0, // swiper当前所在滑块的 index
  50. intervalSta: 0,
  51. // imageSrc: '',
  52. }
  53. },
  54. computed: {
  55. durationStr() {
  56. return tools.convertSecondsToHMS(this.SumDuration);
  57. },
  58. distanceKm() {
  59. if (this.SumDistance < 1000000)
  60. return Math.round(this.SumDistance * 10 / 1000) / 10;
  61. else
  62. return Math.round(this.SumDistance / 1000);
  63. }
  64. },
  65. onLoad(event) { // 类型非必填,可自动推导
  66. // this.SumDuration = 1622;
  67. // this.SumDistance = 999050;
  68. // this.SumDistance = 999949;
  69. // this.SumDistance = 2066869;
  70. // this.imageSrc = "/static/led/pic2.jpg";
  71. this.testMode = event["test"] ?? 0;
  72. this.pageAutoChange = event["pac"] ?? 0;
  73. this.pageType = event["page"] ?? 1;
  74. this.actIdArrStr = event["act"] ?? "175,176,177,178";
  75. this.getUploadPic();
  76. this.getStatistics();
  77. this.intervalSta = setInterval(this.getStatistics, 1000);
  78. },
  79. onUnload() {
  80. console.log("onUnload");
  81. clearInterval(this.intervalSta);
  82. },
  83. methods: {
  84. getStatistics() {
  85. if (this.testMode == 1) {
  86. this.testDuration += 1;
  87. this.testDistance += 100;
  88. this.SumDuration = this.testDuration;
  89. this.SumDistance = this.testDistance;
  90. return;
  91. }
  92. uni.request({
  93. url: apiGetStatistics,
  94. header: {
  95. "Content-Type": "application/x-www-form-urlencoded",
  96. },
  97. method: "POST",
  98. data: {
  99. actIdArrStr: this.actIdArrStr
  100. },
  101. success: (res) => {
  102. // console.log("getStatistics", res)
  103. const data = res.data.data;
  104. this.SumDuration = data.SumDuration;
  105. this.SumDistance = data.SumDistance;
  106. },
  107. fail: (err) => {
  108. console.log("getStatistics err", err)
  109. },
  110. });
  111. },
  112. getUploadPic() {
  113. uni.request({
  114. url: apiGetUploadPic,
  115. header: {
  116. "Content-Type": "application/x-www-form-urlencoded",
  117. },
  118. method: "POST",
  119. data: {
  120. actIdArrStr: this.actIdArrStr
  121. },
  122. success: (res) => {
  123. // console.log("getUploadPic", res);
  124. const data = res.data.data;
  125. const newCount = data.List.length;
  126. console.log("获取到的图片数量:", newCount);
  127. if (newCount > 0) {
  128. if (this.pageAutoChange == 1) {
  129. this.pageType = 2;
  130. }
  131. /* this.picList.length = 0; // 清空数组
  132. for (let i = 0; i < newCount; i++) {
  133. let picUrl = data.Domain + data.List[i];
  134. // console.log("picUrl: " + picUrl);
  135. this.picList.push(picUrl);
  136. }
  137. if (this.picCount > 0) {
  138. this.picCurIndex = this.picCount - 1;
  139. console.log("重定位 index", this.picCurIndex);
  140. } */
  141. } else {
  142. if (this.pageAutoChange == 1) {
  143. if (this.picCount == 0)
  144. this.pageType = 1;
  145. else
  146. this.pageType = 2;
  147. }
  148. }
  149. if (newCount > this.picCount) { // 有新图片
  150. console.log("有 " + (newCount - this.picCount) + " 张新图片");
  151. // 将新增的图片追加到图片队列
  152. for (let i = this.picCount; i < newCount; i++) {
  153. let picUrl = data.Domain + data.List[i];
  154. console.log("[" + i + "] picUrl: " + picUrl);
  155. this.picList.push(picUrl);
  156. }
  157. if (this.picCount > 0) {
  158. this.picCurIndex = this.picCount;
  159. console.log("重定位 index", this.picCurIndex);
  160. }
  161. this.picCount = newCount;
  162. }
  163. if (this.picCount == 0) {
  164. // console.log('this.picCount == 0');
  165. setTimeout(this.getUploadPic, 1000);
  166. }
  167. else if (this.picCount == 1) {
  168. // console.log('this.picCount == 1');
  169. // swiper在只有1张图片的情况下不会触发 @change事件,需要在这里再次获取图片数据
  170. setTimeout(this.getUploadPic, this.picInterval);
  171. }
  172. // console.log("picList", this.picList);
  173. },
  174. fail: (err) => {
  175. console.log("getUploadPic err", err);
  176. setTimeout(this.getUploadPic, 3000);
  177. },
  178. });
  179. },
  180. //当前轮播索引
  181. swiperChange(e) {
  182. console.log("pic index: " + e.detail.current);
  183. const curIndex = e.detail.current;
  184. // 播放完最后一张图片后重新获取图片数据
  185. if (curIndex == this.picCount - 1) {
  186. console.log("播放完毕,重新获取图片数据...");
  187. // this.picCurIndex = curIndex;
  188. this.getUploadPic();
  189. }
  190. },
  191. //点击轮播
  192. swiperClick(e) {
  193. console.log('点击轮播', e);
  194. },
  195. animationfinish() {
  196. console.log('animationfinish');
  197. }
  198. }
  199. }
  200. </script>
  201. <style>
  202. .body {
  203. /* width: 100%; */
  204. /* height: 100vh; */
  205. width: 1920px;
  206. height: 1440px;
  207. display: flex;
  208. flex-direction: column;
  209. align-items: center;
  210. justify-content: center;
  211. }
  212. .content {
  213. width: 100%;
  214. height: 100%;
  215. flex-direction: row;
  216. align-items: flex-start;
  217. /* justify-content: flex-start; */
  218. }
  219. .bg-led01 {
  220. background-image: url("/static/led/led01.webp");
  221. background-repeat: no-repeat;
  222. background-size: contain;
  223. }
  224. .bg-led02 {
  225. background-image: url("/static/led/led02.webp");
  226. background-repeat: no-repeat;
  227. background-size: contain;
  228. }
  229. .pic-container {
  230. width: 1300px;
  231. height: 850px;
  232. margin-left: 76px;
  233. margin-top: 303px;
  234. background: url("/static/led/pic_border.png");
  235. background-repeat: no-repeat;
  236. background-size: contain;
  237. }
  238. .swiper {
  239. height: 852px;
  240. mask-image: url('/static/led/pic_mask.png');
  241. mask-size: 1298px;
  242. mask-repeat: no-repeat;
  243. }
  244. .pic {
  245. margin: 3px;
  246. width: 1300px;
  247. height: 840px;
  248. }
  249. .pic-bg {
  250. position: absolute;
  251. margin: -10px;
  252. width: 1320px;
  253. height: 860px;
  254. filter: blur(15px);
  255. }
  256. .distance-container-1 {
  257. align-items: center;
  258. justify-content: space-around;
  259. width: 1070px;
  260. height: 450px;
  261. margin-left: 766px;
  262. margin-top: 850px;
  263. }
  264. .total-time-1 {
  265. font-family: 'Arial Black';
  266. font-size: 50px;
  267. color: #ffffff;
  268. margin-left: 390px;
  269. line-height: 100px;
  270. margin-top: 6px;
  271. }
  272. .total-distance-1 {
  273. font-family: 'Arial';
  274. font-size: 330px;
  275. transform: scaleX(0.8);
  276. color: #ffffff;
  277. line-height: 330px;
  278. }
  279. .distance-container-2 {
  280. align-items: center;
  281. justify-content: space-around;
  282. width: 695px;
  283. height: 296px;
  284. margin-left: -253px;
  285. margin-top: 946px;
  286. background: url("/static/led/distance_bg.png") no-repeat;
  287. background-size: cover;
  288. }
  289. .total-time-2 {
  290. font-family: 'Arial Black';
  291. font-size: 36px;
  292. color: #ffffff;
  293. margin-left: 250px;
  294. line-height: 50px;
  295. }
  296. .total-distance-2 {
  297. font-family: 'Arial';
  298. font-size: 200px;
  299. transform: scaleX(0.8);
  300. color: #ffffff;
  301. line-height: 180px;
  302. }
  303. .run {
  304. width: 520px;
  305. height: 520px;
  306. margin-left: -880px;
  307. margin-top: 356px;
  308. }
  309. .mascot {
  310. height: 468px;
  311. margin-left: -495px;
  312. margin-top: 486px;
  313. }
  314. .lpzg {
  315. width: 468px;
  316. margin-left: -1540px;
  317. margin-top: 1072px;
  318. }
  319. </style>