index2.uvue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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 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-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. 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.testDistance = 2066869;
  89. this.SumDuration = this.testDuration;
  90. this.SumDistance = this.testDistance;
  91. return;
  92. }
  93. uni.request({
  94. url: apiGetStatistics,
  95. header: {
  96. "Content-Type": "application/x-www-form-urlencoded",
  97. },
  98. method: "POST",
  99. data: {
  100. actIdArrStr: this.actIdArrStr
  101. },
  102. success: (res) => {
  103. // console.log("getStatistics", res)
  104. const data = res.data.data;
  105. this.SumDuration = data.SumDuration;
  106. this.SumDistance = data.SumDistance;
  107. },
  108. fail: (err) => {
  109. console.log("getStatistics err", err)
  110. },
  111. });
  112. },
  113. getUploadPic() {
  114. uni.request({
  115. url: apiGetUploadPic,
  116. header: {
  117. "Content-Type": "application/x-www-form-urlencoded",
  118. },
  119. method: "POST",
  120. data: {
  121. actIdArrStr: this.actIdArrStr
  122. },
  123. success: (res) => {
  124. // console.log("getUploadPic", res);
  125. const data = res.data.data;
  126. const newCount = data.List.length;
  127. console.log("获取到的图片数量:", newCount);
  128. if (newCount > 0) {
  129. if (this.pageAutoChange == 1) {
  130. this.pageType = 2;
  131. }
  132. /* this.picList.length = 0; // 清空数组
  133. for (let i = 0; i < newCount; i++) {
  134. let picUrl = data.Domain + data.List[i];
  135. // console.log("picUrl: " + picUrl);
  136. this.picList.push(picUrl);
  137. }
  138. if (this.picCount > 0) {
  139. this.picCurIndex = this.picCount - 1;
  140. console.log("重定位 index", this.picCurIndex);
  141. } */
  142. } else {
  143. if (this.pageAutoChange == 1) {
  144. if (this.picCount == 0)
  145. this.pageType = 1;
  146. else
  147. this.pageType = 2;
  148. }
  149. }
  150. if (newCount > this.picCount) { // 有新图片
  151. console.log("有 " + (newCount - this.picCount) + " 张新图片");
  152. // 将新增的图片追加到图片队列
  153. for (let i = this.picCount; i < newCount; i++) {
  154. let picUrl = data.Domain + data.List[i];
  155. console.log("[" + i + "] picUrl: " + picUrl);
  156. this.picList.push(picUrl);
  157. }
  158. if (this.picCount > 0) {
  159. this.picCurIndex = this.picCount;
  160. console.log("重定位 index", this.picCurIndex);
  161. }
  162. this.picCount = newCount;
  163. }
  164. if (this.picCount == 0) {
  165. // console.log('this.picCount == 0');
  166. setTimeout(this.getUploadPic, 1000);
  167. }
  168. else if (this.picCount == 1) {
  169. // console.log('this.picCount == 1');
  170. // swiper在只有1张图片的情况下不会触发 @change事件,需要在这里再次获取图片数据
  171. setTimeout(this.getUploadPic, this.picInterval);
  172. }
  173. // console.log("picList", this.picList);
  174. },
  175. fail: (err) => {
  176. console.log("getUploadPic err", err);
  177. setTimeout(this.getUploadPic, 3000);
  178. },
  179. });
  180. },
  181. //当前轮播索引
  182. swiperChange(e) {
  183. console.log("pic index: " + e.detail.current);
  184. const curIndex = e.detail.current;
  185. // 播放完最后一张图片后重新获取图片数据
  186. if (curIndex == this.picCount - 1) {
  187. console.log("播放完毕,重新获取图片数据...");
  188. // this.picCurIndex = curIndex;
  189. this.getUploadPic();
  190. }
  191. },
  192. //点击轮播
  193. swiperClick(e) {
  194. console.log('点击轮播', e);
  195. },
  196. animationfinish() {
  197. console.log('animationfinish');
  198. }
  199. }
  200. }
  201. </script>
  202. <style>
  203. .body {
  204. /* width: 100%; */
  205. /* height: 100vh; */
  206. width: 1920px;
  207. height: 1080px;
  208. display: flex;
  209. flex-direction: column;
  210. align-items: center;
  211. justify-content: center;
  212. }
  213. .content {
  214. width: 100%;
  215. height: 100%;
  216. flex-direction: row;
  217. align-items: flex-start;
  218. /* justify-content: flex-start; */
  219. }
  220. .bg-led01 {
  221. background-image: url("/static/led/led01-2.webp");
  222. background-repeat: no-repeat;
  223. background-size: contain;
  224. }
  225. .bg-led02 {
  226. background-image: url("/static/led/led02-2.webp");
  227. background-repeat: no-repeat;
  228. background-size: contain;
  229. }
  230. .pic-container {
  231. width: 1270px;
  232. height: 850px;
  233. margin-left: 80px;
  234. margin-top: 80px;
  235. background: url("/static/led/pic_border.png");
  236. background-repeat: no-repeat;
  237. background-size: contain;
  238. }
  239. .swiper {
  240. height: 852px;
  241. mask-image: url('/static/led/pic_mask.png');
  242. mask-size: 1268px;
  243. mask-repeat: no-repeat;
  244. }
  245. .pic {
  246. margin: 3px;
  247. width: 1270px;
  248. height: 840px;
  249. }
  250. .pic-bg {
  251. position: absolute;
  252. margin: -10px;
  253. width: 1290px;
  254. height: 860px;
  255. filter: blur(15px);
  256. }
  257. .distance-container-1 {
  258. align-items: center;
  259. justify-content: space-around;
  260. width: 988px;
  261. height: 416px;
  262. margin-left: 843px;
  263. margin-top: 600px;
  264. }
  265. .total-time-1 {
  266. font-family: 'Arial Black';
  267. font-size: 50px;
  268. color: #ffffff;
  269. margin-left: 390px;
  270. line-height: 90px;
  271. margin-top: 6px;
  272. }
  273. .total-distance-1 {
  274. font-family: 'Arial';
  275. font-size: 330px;
  276. transform: scaleX(0.72);
  277. color: #ffffff;
  278. line-height: 300px;
  279. }
  280. .distance-container-2 {
  281. align-items: center;
  282. justify-content: space-around;
  283. width: 695px;
  284. height: 296px;
  285. margin-left: -253px;
  286. margin-top: 736px;
  287. background: url("/static/led/distance_bg.png") no-repeat;
  288. background-size: cover;
  289. }
  290. .total-time-2 {
  291. font-family: 'Arial Black';
  292. font-size: 36px;
  293. color: #ffffff;
  294. margin-left: 250px;
  295. line-height: 50px;
  296. }
  297. .total-distance-2 {
  298. font-family: 'Arial';
  299. font-size: 200px;
  300. transform: scaleX(0.8);
  301. color: #ffffff;
  302. line-height: 180px;
  303. }
  304. .run {
  305. width: 468px;
  306. height: 468px;
  307. margin-left: -840px;
  308. margin-top: 130px;
  309. }
  310. .mascot {
  311. height: 468px;
  312. margin-left: -490px;
  313. margin-top: 286px;
  314. }
  315. .lpzg {
  316. width: 468px;
  317. margin-left: -1510px;
  318. margin-top: 832px;
  319. }
  320. </style>