Browse Source

倒计时

twt 2 years ago
parent
commit
759e4d1c77
4 changed files with 282 additions and 58 deletions
  1. 32 17
      pages/activity/jkDetail.vue
  2. 112 20
      pages/shop/goodsDetail.vue
  3. 134 17
      pages/shop/shop.vue
  4. 4 4
      pages/user/myOrder/activityOrderDetail.vue

+ 32 - 17
pages/activity/jkDetail.vue

@@ -117,17 +117,17 @@
 						<img src="../../static/timg/icon_arrow_right.png" alt="" class="bmshopjt">
 					</view>
 					<!-- clWhere报名凭证1,2,3,4 1手机号2车牌号3姓名4单位 -->
-					<view class="bmLine" v-if="info.clWhere.indexOf(1)!=-1" >
-						<input  type="number" :adjust-position="false" @blur="inputBindBlur" @focus="inputBindFocus" v-model="mobilePhone"  class="bmlineInput" placeholder="输入手机号" placeholder-style="color:#999999">
+					<view class="bmLine" v-if="info.clWhere.indexOf(1)!=-1" @click="focusState1cl">
+					<!-- :focus="focusState1" -->	<input  type="number" :hold-keyboard="true" :adjust-position="false" @blur="inputBindBlur" @focus="inputBindFocus" v-model="mobilePhone"  class="bmlineInput" placeholder="输入手机号" placeholder-style="color:#999999">
 					</view>
 					<view class="bmLine" v-if="info.clWhere.indexOf(2)!=-1" @click="focusState2cl">
-						<input type="text" :focus="focusState2" :adjust-position="false" @blur="inputBindBlur" @focus="inputBindFocus" v-model="plateNumber"   class="bmlineInput" placeholder="输入车牌号" placeholder-style="color:#999999">
+						<input type="text" :hold-keyboard="true"  :adjust-position="false" @blur="inputBindBlur" @focus="inputBindFocus" v-model="plateNumber"   class="bmlineInput" placeholder="输入车牌号" placeholder-style="color:#999999">
 					</view>
-					<view class="bmLine" v-if="info.clWhere.indexOf(3)!=-1">
-						<input type="text" :adjust-position="false" @blur="inputBindBlur" @focus="inputBindFocus" v-model="customerName"  class="bmlineInput" placeholder="输入姓名" placeholder-style="color:#999999">
+					<view class="bmLine" v-if="info.clWhere.indexOf(3)!=-1" @click="focusState3cl">
+						<input type="text" :hold-keyboard="true" :adjust-position="false"  @blur="inputBindBlur" @focus="inputBindFocus" v-model="customerName"  class="bmlineInput" placeholder="输入姓名" placeholder-style="color:#999999">
 					</view>
-					<view class="bmLine" v-if="info.clWhere.indexOf(4)!=-1">
-						<input type="text" :adjust-position="false" @blur="inputBindBlur" @focus="inputBindFocus"  v-model="unit"  class="bmlineInput" placeholder="输入单位" placeholder-style="color:#999999">
+					<view class="bmLine" v-if="info.clWhere.indexOf(4)!=-1" @click="focusState4cl">
+					  <input type="text" :adjust-position="false" :hold-keyboard="true"   @blur="inputBindBlur" @focus="inputBindFocus"  v-model="unit"  class="bmlineInput" placeholder="输入单位" placeholder-style="color:#999999">
 					</view>
 				</view>
 				<view class="bmTtnBox">
@@ -221,9 +221,9 @@
 				shopInfo:'',
 				activityEnd:true,
 				activityNoOpen:true,
-				shengyuD:1,
-				shengyuH:12,
-				shengyuM:21,
+				shengyuD:'',
+				shengyuH:'',
+				shengyuM:'',
 				queryShopList:'',
 				collectingID:'',
 				bmShow:false,
@@ -244,7 +244,10 @@
 				 mp3Url:'',
 				 payshow:false,
 				 jpNum:1,
+				 focusState1:false,
 				 focusState2:false,
+				 focusState3:false,
+				 focusState4:false,
 			}
 		},
 		onLoad(opt) {
@@ -295,9 +298,18 @@
 			this.bgmMusic.stop()
 		},
 		methods: {
+			focusState1cl(){
+				this.focusState1=true;
+			},
 			focusState2cl(){
 				this.focusState2=true;
 			},
+			focusState3cl(){
+				this.focusState3=true;
+			},
+			focusState4cl(){
+				this.focusState4=true;
+			},
 			inputBindFocus(e){
 				//console.log( e.detail.height);
 				this.jpHeight=e.detail.height+ "px";
@@ -762,17 +774,19 @@
 		top: 0;
 		left: 0;
 		z-index: 11;
+		/* display: flex;
+		align-items: center; */
 	}
 	.bmTtnBox{
 		width: 750rpx;
 		height: 120rpx;
 		background: #FFFFFF;
 		box-shadow: 0px -2px 10rpx 0px rgba(153,153,153,0.2000);
-		position: absolute;
+		/* position: absolute;
 		left: 0;
-		bottom: 0;
-		padding-bottom: constant(safe-area-inset-bottom);
-		padding-bottom: env(safe-area-inset-bottom);
+		bottom: 0; */
+		/* padding-bottom: constant(safe-area-inset-bottom);
+		padding-bottom: env(safe-area-inset-bottom); */
 	}
 	.bmBtn{
 		width: 690rpx;
@@ -785,6 +799,7 @@
 		font-size: 30rpx;
 		margin-top: 23rpx;
 		margin-left: 30rpx;
+		margin-top: 20rpx;
 	}
 	.bmshopjt{
 		width: 12rpx;
@@ -834,9 +849,9 @@
 	.baomingCont{
 		position: absolute;
 		width: 750rpx;
-		height:850rpx;
-		padding-bottom: constant(safe-area-inset-bottom);
-		padding-bottom: env(safe-area-inset-bottom);
+		/* height:850rpx; */
+		/* padding-bottom: constant(safe-area-inset-bottom);
+		padding-bottom: env(safe-area-inset-bottom); */
 		left: 0;
 		bottom: 0;
 		background: #ffffff;

+ 112 - 20
pages/shop/goodsDetail.vue

@@ -105,23 +105,34 @@
 		 <rich-text :nodes="info.details" style="background: #fff;"></rich-text>
 	</view>
 	<view style="height: 120rpx;padding-bottom: env(safe-area-inset-bottom)"></view>
-	
-	<view class="bottomBox">
-		<view class="bottomImgBox" @click="goINdex">
-			<image src="../../static/timg/home.png" mode="" class="bottomImg"></image>
-			<view class="bottomTxt">首页</view>
+	<view class="bottomHz">
+		<view class="timeTbox" v-if="!activityEnd">
+		  <view class="timeK">{{shengyuD}}</view>
+		  <view class="timeviewTxt" > 天</view>
+		  <view class="timeK">{{shengyuH}}</view>
+		  <view class="timeviewTxt"> 时</view>
+		  <view class="timeK">{{shengyuM}}</view>
+		  <view class="timeviewTxt" > 分 &nbsp;&nbsp; 后结束抢购</view>
+		</view>
+		<view class="timeTbox" v-if="activityEnd"></view>
+		<view class="bottomBox">
+			<view class="bottomImgBox" @click="goINdex">
+				<image src="../../static/timg/home.png" mode="" class="bottomImg"></image>
+				<view class="bottomTxt">首页</view>
+			</view>
+			<!-- <view class="bottomImgBox" style="margin-left: 20rpx;" @click="sharewx">
+				<image src="../../static/timg/share.png" mode="" class="bottomImg"></image>
+				<view class="bottomTxt">分享</view>
+			</view> -->
+			<button open-type="share" class="bottomImgBox shareBtn" >
+				<image src="../../static/timg/share.png" mode="" class="bottomImg"></image>
+				<view class="bottomTxt">分享</view>
+			</button>
+			<view class="bottomBtn" @click="ljbuy">立即购买</view>
+			
 		</view>
-		<!-- <view class="bottomImgBox" style="margin-left: 20rpx;" @click="sharewx">
-			<image src="../../static/timg/share.png" mode="" class="bottomImg"></image>
-			<view class="bottomTxt">分享</view>
-		</view> -->
-		<button open-type="share" class="bottomImgBox shareBtn" >
-			<image src="../../static/timg/share.png" mode="" class="bottomImg"></image>
-			<view class="bottomTxt">分享</view>
-		</button>
-		<view class="bottomBtn" @click="ljbuy">立即购买</view>
-		
 	</view>
+
 	
 	<!-- 立即购买 -->
 	<view class="buyBox" v-if="buyShow" @click="buyShow=false">
@@ -171,6 +182,7 @@
 					</view>
 				</view>
 			</view>
+			
 			<view class="buybtnBox">
 				<view class="buyBtn" @click="goBuy">立即购买</view>
 			</view>
@@ -215,6 +227,10 @@
 				ext:'',
 				categoryIds:'',
 				thenShow:false,
+				activityEnd:true,
+				shengyuD:1,
+				shengyuH:12,
+				shengyuM:21,
 			}
 		},
 		onLoad(opt) {
@@ -269,9 +285,44 @@
 						this.shopInfo='';
 						this.$store.commit('mutationsckshopInfo', '')
 						this.szShop()
+						if(this.info.goodsDownTime){
+							this.activityEnd=false;
+							this.clock()
+						}
 						
 				 })
 			},
+			clock(){
+				let _this = this
+				let today = new Date() // 当前时间
+				let h = today.getHours()
+				let m = today.getMinutes()
+				let s = today.getSeconds()
+				let stopTime = new Date(_this.info.goodsDownTime.replace(/-/g, '/')) // 结束时间
+				if (Number(new Date(_this.info.goodsDownTime).getTime()) < Number(new Date().getTime())) {
+				  this.activityEnd = true
+				  return
+				}
+							
+				let stopH = stopTime.getHours()
+				let stopM = stopTime.getMinutes()
+				let stopS = stopTime.getSeconds()
+				let shenyu = stopTime.getTime() - today.getTime() // 倒计时毫秒数
+				let shengyuD = parseInt(shenyu / (60 * 60 * 24 * 1000)) // 转换为天
+				let D = parseInt(shenyu) - parseInt(shengyuD * 60 * 60 * 24 * 1000)// 除去天的毫秒数
+				let shengyuH = parseInt(D / (60 * 60 * 1000)) // 除去天的毫秒数转换成小时
+				let H = D - shengyuH * 60 * 60 * 1000 // 除去天、小时的毫秒数
+				let shengyuM = parseInt(H / (60 * 1000)) // 除去天的毫秒数转换成分钟
+				let M = H - shengyuM * 60 * 1000// 除去天、小时、分的毫秒数
+				let S = parseInt((shenyu - shengyuD * 60 * 60 * 24 * 1000 - shengyuH * 60 * 60 * 1000 - shengyuM * 60 * 1000) / 1000)// 除去天、小时、分的毫秒数转化为秒
+							
+				this.daojishi = '报名倒计时:' + shengyuD + '天' + shengyuH + '小时' + shengyuM + '分' + S + '秒'
+				// setTimeout("clock()",500);
+				this.shengyuM=shengyuM;
+				this.shengyuD=shengyuD;
+				this.shengyuH=shengyuH;
+				setTimeout(_this.clock, 500)
+			},
 			ljbuy(){
 				if(!this.userInfo){
 					this.authorizShow=true
@@ -401,7 +452,49 @@
 </script>
 
 <style scoped lang="less">
-
+.timeTbox{
+		width: 750rpx;
+		height: 60rpx;
+		background:#FFF5F0;
+		border-radius: 24rpx 24rpx 0px 0px;
+		border: 1px solid #EFE1D5;
+		display: flex;
+		justify-content: center;
+		font-size: 24rpx;
+		font-family: PingFangSC-Regular, PingFang SC;
+		font-weight: 400;
+		color: #764D49;
+	
+	}
+	.timeviewTxt{
+			line-height: 41rpx;
+			padding-top: 10rpx;
+	}
+	.timeDivTxt{
+		line-height: 60rpx;
+		padding: 0 10rpx;
+	}
+	.timeK{
+		height: 41rpx;
+		line-height: 41rpx;
+		color: #FFFFFF;
+		width: 41rpx;
+		text-align: center;
+		background: #F03B3B;
+		border-radius: 6rpx;
+		margin-top: 9rpx;
+		margin-left: 15rpx;
+		margin-right: 15rpx;
+	}
+	.bottomHz{
+		width: 750rpx;
+		height: 180rpx;
+		position: fixed;left: 0;
+		bottom: 0;
+		padding-bottom: env(safe-area-inset-bottom);
+		background: #FFFFFF;
+		border-radius: 24rpx 24rpx 0px 0px;
+	}
 .box{
 	background: #F4F5F7;
 	min-height: 100vh;
@@ -592,16 +685,15 @@
 		text-decoration:line-through;
 	}
 	
-	
+
 .bottomBox{
 	width: 750px;
 	height: 120rpx;
 	background: #FFFFFF;
 	box-shadow: 0px -2px 10px 0px rgba(153,153,153,0.2000);
-	position: fixed;left: 0;
-	bottom: 0;
+	
 	display: flex;
-	padding-bottom: env(safe-area-inset-bottom);
+	
 }
 .bottomTxt{
 	color: #666666;font-size: 22rpx;

+ 134 - 17
pages/shop/shop.vue

@@ -56,21 +56,32 @@
 	   				</view>
 	   				<view class="hotGoodsLineRIght">
 	   					<view class="goodsName">{{item.name}}</view>
-	   				    <view class="Sold" >
-							<view v-if="item.showLabel&&item.showLabel.indexOf('3')!=-1">
-								已售 {{item.saleQty}}
-							</view>
+						<view class="timeTbox" v-if="item.goodsDownTime">
+						  <view class="timeK" style="margin-left: 0;">{{item.shengyuD}}</view>
+						  <view class="timeviewTxt" > 天</view>
+						  <view class="timeK">{{item.shengyuH}}</view>
+						  <view class="timeviewTxt"> 时</view>
+						  <view class="timeK">{{item.shengyuM}}</view>
+						  <view class="timeviewTxt" > 分 &nbsp;&nbsp; 后结束抢购</view>
 						</view>
-	   					<view class="goodsPrice">
-	   						<view class="goodsPrice1">{{item.saleLabel}}</view>
-	   						<view class="goodsPrice2">¥</view>
-	   						<view class="goodsPrice3">{{item.salePrice?item.salePrice:item.scribingPrice}}
-							 <span v-if="item.categoryIds=='7B97D114-C419-42B2-9C1E-0B4CA284CDA0'">万</span>
-							</view>
-	   						<view class="goodsPrice4" v-if="item.showLabel&&item.scribingPrice">
-								<span v-if="item.showLabel.indexOf('1')!=-1">¥{{item.scribingPrice}}</span>
-							</view>
-	   					</view>
+	   				   <view class="hotGoodsLineRIghtBottom">
+	   				   	<view class="goodsPrice">
+	   				   		<view class="goodsPrice1">{{item.saleLabel}}</view>
+	   				   		<view class="goodsPrice2">¥</view>
+	   				   		<view class="goodsPrice3">{{item.salePrice?item.salePrice:item.scribingPrice}}
+	   				   		 <span v-if="item.categoryIds=='7B97D114-C419-42B2-9C1E-0B4CA284CDA0'">万</span>
+	   				   		</view>
+	   				   		<view class="goodsPrice4" v-if="item.showLabel&&item.scribingPrice">
+	   				   			<span v-if="item.showLabel.indexOf('1')!=-1">¥{{item.scribingPrice}}</span>
+	   				   		</view>
+	   				   	</view>
+	   				   	<view class="Sold" >
+	   				   		<view v-if="item.showLabel&&item.showLabel.indexOf('3')!=-1">
+	   				   			已售 {{item.saleQty}}
+	   				   		</view>
+	   				   	</view>
+	   				   </view>
+	   					
 	   				</view>
 	   			</view>
 				<nodata v-if="list.length==0"></nodata>
@@ -330,6 +341,7 @@
 			
 			getlistOpenGoodsPage(){
 				uni.showLoading({ title: '加载中'});
+				var that=this;
 				this.$http('openMall/listOpenGoodsPage', {
 				   page:this.page,
 				   limit:this.limit,
@@ -340,12 +352,81 @@
 				    unionId:this.ext.unionId
 				 },'GET').then(res => {
 					 uni.hideLoading();
+						
+						res.data.Items.forEach(item=>{
+							if(item.goodsDownTime){
+								item.shengyuM=''
+								item.shengyuD=''
+								item.shengyuH=''
+								//console.log(item)
+								//that.clock(item)
+								let _this = this
+								let today = new Date() // 当前时间
+								let h = today.getHours()
+								let m = today.getMinutes()
+								let s = today.getSeconds()
+								let stopTime = new Date(item.goodsDownTime.replace(/-/g, '/')) // 结束时间
+								if (Number(new Date(item.goodsDownTime).getTime()) < Number(new Date().getTime())) {
+								  this.activityEnd = true
+								  return
+								}
+											
+								let stopH = stopTime.getHours()
+								let stopM = stopTime.getMinutes()
+								let stopS = stopTime.getSeconds()
+								let shenyu = stopTime.getTime() - today.getTime() // 倒计时毫秒数
+								let shengyuD = parseInt(shenyu / (60 * 60 * 24 * 1000)) // 转换为天
+								let D = parseInt(shenyu) - parseInt(shengyuD * 60 * 60 * 24 * 1000)// 除去天的毫秒数
+								let shengyuH = parseInt(D / (60 * 60 * 1000)) // 除去天的毫秒数转换成小时
+								let H = D - shengyuH * 60 * 60 * 1000 // 除去天、小时的毫秒数
+								let shengyuM = parseInt(H / (60 * 1000)) // 除去天的毫秒数转换成分钟
+								let M = H - shengyuM * 60 * 1000// 除去天、小时、分的毫秒数
+								let S = parseInt((shenyu - shengyuD * 60 * 60 * 24 * 1000 - shengyuH * 60 * 60 * 1000 - shengyuM * 60 * 1000) / 1000)// 除去天、小时、分的毫秒数转化为秒
+								item.shengyuM=shengyuM;
+								item.shengyuD=shengyuD;
+								item.shengyuH=shengyuH;
+							}
+						})
 						var data=res.data.Items;
-						this.list=this.list.concat(data)
+						this.list=this.list.concat(data);
+						console.log(this.list)
 				 })
-			}
+			},
+			clock(item){
+				console.log(item)
+				if(!item){
+					return false;
+				}
+				let _this = this
+				let today = new Date() // 当前时间
+				let h = today.getHours()
+				let m = today.getMinutes()
+				let s = today.getSeconds()
+				let stopTime = new Date(item.goodsDownTime.replace(/-/g, '/')) // 结束时间
+				if (Number(new Date(item.goodsDownTime).getTime()) < Number(new Date().getTime())) {
+				  this.activityEnd = true
+				  return
+				}
+							
+				let stopH = stopTime.getHours()
+				let stopM = stopTime.getMinutes()
+				let stopS = stopTime.getSeconds()
+				let shenyu = stopTime.getTime() - today.getTime() // 倒计时毫秒数
+				let shengyuD = parseInt(shenyu / (60 * 60 * 24 * 1000)) // 转换为天
+				let D = parseInt(shenyu) - parseInt(shengyuD * 60 * 60 * 24 * 1000)// 除去天的毫秒数
+				let shengyuH = parseInt(D / (60 * 60 * 1000)) // 除去天的毫秒数转换成小时
+				let H = D - shengyuH * 60 * 60 * 1000 // 除去天、小时的毫秒数
+				let shengyuM = parseInt(H / (60 * 1000)) // 除去天的毫秒数转换成分钟
+				let M = H - shengyuM * 60 * 1000// 除去天、小时、分的毫秒数
+				let S = parseInt((shenyu - shengyuD * 60 * 60 * 24 * 1000 - shengyuH * 60 * 60 * 1000 - shengyuM * 60 * 1000) / 1000)// 除去天、小时、分的毫秒数转化为秒
+				this.shengyuM=shengyuM;
+				this.shengyuD=shengyuD;
+				this.shengyuH=shengyuH;
+				setTimeout(_this.clock, 500)
+			},
 			
 		},
+		
 		onReachBottom(){
 			this.page++;
 			this.getlistOpenGoodsPage()
@@ -363,6 +444,42 @@
 </script>
 
 <style scoped lang="less">
+	.timeTbox{
+			
+			height: 60rpx;
+			display: flex;
+			
+			font-size: 24rpx;
+			font-family: PingFangSC-Regular, PingFang SC;
+			font-weight: 400;
+			color: #764D49;
+		
+		}
+		.timeviewTxt{
+				line-height: 41rpx;
+				padding-top: 10rpx;
+		}
+		.timeDivTxt{
+			line-height: 60rpx;
+			padding: 0 10rpx;
+		}
+		.timeK{
+			height: 41rpx;
+			line-height: 41rpx;
+			color: #FFFFFF;
+			width: 41rpx;
+			text-align: center;
+			background: #F03B3B;
+			border-radius: 6rpx;
+			margin-top: 9rpx;
+			margin-left: 15rpx;
+			margin-right: 15rpx;
+		}
+.hotGoodsLineRIghtBottom{
+	display: flex;
+	justify-content: space-between;
+	    width: 470rpx;
+}
 .topbox{
 	position: fixed;
 	width: 750rpx;
@@ -531,7 +648,7 @@ z-index: 11;
 		font-weight: 400;
 		color: #999999;
 		font-size: 24rpx;
-		padding-top: 8rpx;
+		padding-top: 20rpx;
 		line-height: 30rpx;
 		height: 30rpx;
 	}

+ 4 - 4
pages/user/myOrder/activityOrderDetail.vue

@@ -109,20 +109,20 @@
 		<!-- 订单信息 -->
 		<view class="information">
 			<view class="detailedTitle">订单信息</view>
-			<view class="informationLine">
+			<view class="informationLine" v-if="orderData.data.plateNumber">
 				<view class="informationTxt">车牌号:</view>
 				<view class="informationNum">{{orderData.data.plateNumber}}</view>
 			</view>
 			
-			<view class="informationLine">
+			<view class="informationLine" v-if="orderData.data.customerName">
 				<view class="informationTxt">联系人:</view>
 				<view class="informationNum">{{orderData.data.customerName}}</view>
 			</view>
-			<view class="informationLine">
+			<view class="informationLine" v-if="orderData.data.mobilePhone">
 				<view class="informationTxt">手机号:</view>
 				<view class="informationNum">{{orderData.data.mobilePhone}}</view>
 			</view>
-			<view class="informationLine">
+			<view class="informationLine" v-if="orderData.data.unit">
 				<view class="informationTxt">单位:</view>
 				<view class="informationNum">{{orderData.data.unit}}</view>
 			</view>