| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- <!-- LED分辨率: 1920 * 1080 -->
- <template>
- <view class="body">
- <view v-if="pageType == 1" class="content bg-led01">
- <view class="distance-container-1">
- <view class="total-time-1">总用时: {{durationStr}}</view>
- <view class="total-distance-1">{{distanceKm}}KM</view>
- </view>
- <image class="run" mode="aspectFit" src="/static/led/run.png"></image>
- </view>
- <view v-if="pageType == 2" class="content bg-led02">
- <view class="pic-container">
- <!-- <image class="pic" mode="aspectFill" :src="imageSrc"></image> -->
- <swiper class="swiper" autoplay circular :current="picCurIndex" :interval="picInterval"
- :duration="picDuration" @change="swiperChange">
- <swiper-item v-for="(image, index) in picList" :key="index">
- <image class="pic-bg" :src="image"></image>
- <image class="pic" mode="aspectFit" :src="image"></image>
- </swiper-item>
- </swiper>
- </view>
- <view class="distance-container-2">
- <view class="total-time-2">总用时: {{durationStr}}</view>
- <view class="total-distance-2">{{distanceKm}}KM</view>
- </view>
- <image class="mascot" mode="aspectFit" src="/static/led/mascot-2.png"></image>
- <image class="lpzg" mode="aspectFit" src="/static/lpzg.png"></image>
- </view>
- </view>
- </template>
- <script>
- import tools from '../../common/tools';
- import { apiGetStatistics, apiGetUploadPic } from '../../common/api';
- export default {
- data() {
- return {
- testMode: 0, // 测试模式 0:否 1:是
- testDuration: 0,
- testDistance: 0,
- pageAutoChange: 0, // 有照片是否自动切换背景 0:否 1:是
- pageType: 1, // 1: 无照片 2: 有照片
- actIdArrStr: "",
- SumDuration: 0,
- SumDistance: 0,
- picCount: 0,
- picList: [],
- picInterval: 3000, // 自动切换时间间隔
- picDuration: 500, // 滑动动画时长
- picCurIndex: 0, // swiper当前所在滑块的 index
- intervalSta: 0,
- // imageSrc: '',
- }
- },
- computed: {
- durationStr() {
- return tools.convertSecondsToHMS(this.SumDuration);
- },
- distanceKm() {
- if (this.SumDistance < 1000000)
- return Math.round(this.SumDistance * 10 / 1000) / 10;
- else
- return Math.round(this.SumDistance / 1000);
- }
- },
- onLoad(event) { // 类型非必填,可自动推导
- // this.SumDuration = 1622;
- // this.SumDistance = 999050;
- // this.SumDistance = 999949;
- // this.SumDistance = 2066869;
- // this.imageSrc = "/static/led/pic2.jpg";
- this.testMode = event["test"] ?? 0;
- this.pageAutoChange = event["pac"] ?? 0;
- this.pageType = event["page"] ?? 1;
- this.actIdArrStr = event["act"] ?? "175,176,177,178";
- this.getUploadPic();
- this.getStatistics();
- this.intervalSta = setInterval(this.getStatistics, 1000);
- },
- onUnload() {
- console.log("onUnload");
- clearInterval(this.intervalSta);
- },
- methods: {
- getStatistics() {
- if (this.testMode == 1) {
- this.testDuration += 1;
- this.testDistance += 100;
- // this.testDistance = 2066869;
- this.SumDuration = this.testDuration;
- this.SumDistance = this.testDistance;
- return;
- }
-
- uni.request({
- url: apiGetStatistics,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- },
- method: "POST",
- data: {
- actIdArrStr: this.actIdArrStr
- },
- success: (res) => {
- // console.log("getStatistics", res)
- const data = res.data.data;
- this.SumDuration = data.SumDuration;
- this.SumDistance = data.SumDistance;
- },
- fail: (err) => {
- console.log("getStatistics err", err)
- },
- });
- },
- getUploadPic() {
- uni.request({
- url: apiGetUploadPic,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- },
- method: "POST",
- data: {
- actIdArrStr: this.actIdArrStr
- },
- success: (res) => {
- // console.log("getUploadPic", res);
- const data = res.data.data;
- const newCount = data.List.length;
- console.log("获取到的图片数量:", newCount);
- if (newCount > 0) {
- if (this.pageAutoChange == 1) {
- this.pageType = 2;
- }
- /* this.picList.length = 0; // 清空数组
- for (let i = 0; i < newCount; i++) {
- let picUrl = data.Domain + data.List[i];
- // console.log("picUrl: " + picUrl);
- this.picList.push(picUrl);
- }
- if (this.picCount > 0) {
- this.picCurIndex = this.picCount - 1;
- console.log("重定位 index", this.picCurIndex);
- } */
- } else {
- if (this.pageAutoChange == 1) {
- if (this.picCount == 0)
- this.pageType = 1;
- else
- this.pageType = 2;
- }
- }
- if (newCount > this.picCount) { // 有新图片
- console.log("有 " + (newCount - this.picCount) + " 张新图片");
- // 将新增的图片追加到图片队列
- for (let i = this.picCount; i < newCount; i++) {
- let picUrl = data.Domain + data.List[i];
- console.log("[" + i + "] picUrl: " + picUrl);
- this.picList.push(picUrl);
- }
- if (this.picCount > 0) {
- this.picCurIndex = this.picCount;
- console.log("重定位 index", this.picCurIndex);
- }
-
- this.picCount = newCount;
- }
-
- if (this.picCount == 0) {
- // console.log('this.picCount == 0');
- setTimeout(this.getUploadPic, 1000);
- }
- else if (this.picCount == 1) {
- // console.log('this.picCount == 1');
- // swiper在只有1张图片的情况下不会触发 @change事件,需要在这里再次获取图片数据
- setTimeout(this.getUploadPic, this.picInterval);
- }
- // console.log("picList", this.picList);
- },
- fail: (err) => {
- console.log("getUploadPic err", err);
- setTimeout(this.getUploadPic, 3000);
- },
- });
- },
- //当前轮播索引
- swiperChange(e) {
- console.log("pic index: " + e.detail.current);
- const curIndex = e.detail.current;
- // 播放完最后一张图片后重新获取图片数据
- if (curIndex == this.picCount - 1) {
- console.log("播放完毕,重新获取图片数据...");
- // this.picCurIndex = curIndex;
- this.getUploadPic();
- }
- },
- //点击轮播
- swiperClick(e) {
- console.log('点击轮播', e);
- },
- animationfinish() {
- console.log('animationfinish');
- }
- }
- }
- </script>
- <style>
- .body {
- /* width: 100%; */
- /* height: 100vh; */
- width: 1920px;
- height: 1080px;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .content {
- width: 100%;
- height: 100%;
- flex-direction: row;
- align-items: flex-start;
- /* justify-content: flex-start; */
- }
- .bg-led01 {
- background-image: url("/static/led/led01-2.webp");
- background-repeat: no-repeat;
- background-size: contain;
- }
- .bg-led02 {
- background-image: url("/static/led/led02-2.webp");
- background-repeat: no-repeat;
- background-size: contain;
- }
- .pic-container {
- width: 1270px;
- height: 850px;
- margin-left: 80px;
- margin-top: 80px;
- background: url("/static/led/pic_border.png");
- background-repeat: no-repeat;
- background-size: contain;
- }
- .swiper {
- height: 852px;
- mask-image: url('/static/led/pic_mask.png');
- mask-size: 1268px;
- mask-repeat: no-repeat;
- }
- .pic {
- margin: 3px;
- width: 1270px;
- height: 840px;
- }
- .pic-bg {
- position: absolute;
- margin: -10px;
- width: 1290px;
- height: 860px;
- filter: blur(15px);
- }
- .distance-container-1 {
- align-items: center;
- justify-content: space-around;
- width: 988px;
- height: 416px;
- margin-left: 843px;
- margin-top: 600px;
- }
- .total-time-1 {
- font-family: 'Arial Black';
- font-size: 50px;
- color: #ffffff;
- margin-left: 390px;
- line-height: 90px;
- margin-top: 6px;
- }
- .total-distance-1 {
- font-family: 'Arial';
- font-size: 330px;
- transform: scaleX(0.72);
- color: #ffffff;
- line-height: 300px;
- }
- .distance-container-2 {
- align-items: center;
- justify-content: space-around;
- width: 695px;
- height: 296px;
- margin-left: -253px;
- margin-top: 736px;
- background: url("/static/led/distance_bg.png") no-repeat;
- background-size: cover;
- }
- .total-time-2 {
- font-family: 'Arial Black';
- font-size: 36px;
- color: #ffffff;
- margin-left: 250px;
- line-height: 50px;
- }
- .total-distance-2 {
- font-family: 'Arial';
- font-size: 200px;
- transform: scaleX(0.8);
- color: #ffffff;
- line-height: 180px;
- }
- .run {
- width: 468px;
- height: 468px;
- margin-left: -840px;
- margin-top: 130px;
- }
- .mascot {
- height: 468px;
- margin-left: -490px;
- margin-top: 286px;
- }
- .lpzg {
- width: 468px;
- margin-left: -1510px;
- margin-top: 832px;
- }
- </style>
|