Ver Fonte

月卡倒计时

wkyy há 2 anos atrás
pai
commit
ceae5cd753
1 ficheiros alterados com 32 adições e 17 exclusões
  1. 32 17
      pages/index/index.vue

+ 32 - 17
pages/index/index.vue

@@ -180,7 +180,7 @@
 		</view>
 
 		<!-- 充值活动 -->
-		<view class=" top-up" v-if="activityList.length > 0">
+		<view class=" top-up" v-if="activityList.length > 0 && description == '0:0:0'">
 			<view class="top-up-title oldTextjp" oldstyle="font-size:20px;"><text class="line"></text>最新活动</view>
 			<view class="img-box">
 				<view class="img-1" v-for="(item,index) in activityList" :key="item.id"
@@ -190,20 +190,21 @@
 			</view>
 		</view>
 		<!-- 最新活动 -->
-		<view class=" top-up" v-if="activityList.length > 0 && false">
+		<view class=" top-up" v-if="description != '0:0:0'">
 			<view class="top-up-title oldTextjp" oldstyle="font-size:20px;"><text class="line"></text>最新活动</view>
 			<view class="img-box2">
-				<view class="left-image">
+				<view class="left-image" @click="gotoUrl('pages/monthlyCardActivity/monthlyCardBuy')">
 					<p>充电免服务费包月卡</p>
 					<view class="time-activities">
 						限时活动 <text class="time">{{description}}</text>
 					</view>
 				</view>
-				<view class="right-image" v-if="activityList.length > 0">
+				<view class="right-image">
 			
-					<img class="margin-bottom" v-for="(item,index) in activityList" :key="item.id" 
-						@click="rechargeActivity(index)" :src="item.picUrl" alt="">
-					<!-- <img class="margin-top" src="../../assets/img/topup3.png" alt=""> -->
+					<!-- <img class="margin-bottom" v-for="(item,index) in activityList" :key="item.id" 
+						@click="rechargeActivity(index)" :src="item.picUrl" alt=""> -->
+					<img class="margin-bottom" src="../../assets/img/topup2.png" alt="" @click="rechargeActivity(0)">
+					<img class="margin-bottom" src="../../assets/img/topup3.png" alt="" @click="rechargeActivity(1)">
 				</view>
 
 			</view>
@@ -298,7 +299,7 @@
 				value: '长辈模式',
 				elderStatus: false,
 				fontMode: '',
-				description: ''
+				description: '0:0:0'
 			}
 		},
 		onLoad(op) {
@@ -370,14 +371,27 @@
 		},
 		methods: {
 			getDescriptionTime() {
-				var data = new Date().getMonth();
-				console.log(data)
-				var dataTime2=new Date('2022-07-25 16:20:00').getTime()
-				var c=hourDistanceArr(new Date(),new Date(dataTime2+2*60*60*1000))
-				this.description= c[0]+':'+c[1]+':'+c[2];
-				// setTimeout(()=>{
-				// 	this.getDescriptionTime();
-				// },1000)
+				var date = '2022-08-07 23:59:59';
+				var dateMonth1 = new Date().getMonth()+1;
+				var dateDay1 = new Date().getDate();
+				var dateMonth2 =  parseInt(date.slice(5,7));
+				var dateDay2 =  parseInt(date.slice(8,10));
+				if(dateMonth1 < dateMonth2) {
+					var days = new Date(new Date().getFullYear(), dateMonth1, 0).getDate();
+					dateDay2 = dateDay2 + days;
+					console.log(dateDay2)
+				}
+				
+				if(dateDay1 < dateDay2-2) {
+					this.description = dateDay2 - dateDay1 + '天'
+				} else {
+					var dateTime2=new Date(date).getTime()
+					var c=hourDistanceArr(new Date(),new Date(dateTime2))
+					this.description = c[0]+':'+c[1]+':'+c[2];
+					setTimeout(()=>{
+						this.getDescriptionTime();
+					},1000)
+				}
 			},
 			getUserInfo() {
 				uni.showLoading({
@@ -665,7 +679,6 @@
 					
 					} else if (mod.clickUrl.indexOf('http') == 0) {
 						window.location = mod.clickUrl+uurl;
-					
 					} else if (mod.clickUrl.indexOf('#/') == 0) {
 						if (mod.clickUrl.indexOf("?") == -1) {
 							mod.clickUrl += '?';
@@ -1141,6 +1154,8 @@
 					margin-top: 4px;
 					.time{
 						margin-left: 4px;
+						color: #fa3534;
+						font-weight: bold;
 					}
 				}
 		}