Browse Source

防止白屏控制

zhengkaixin 3 years ago
parent
commit
3cf69954a4

+ 23 - 17
pages/charge/index.vue

@@ -103,7 +103,7 @@
 			<div class="showmodel" ><p  >支付方式</p>余额支付</div>
 			<div class="showmodel" ><p  >充电时间</p>{{timelist[submitForm.hour].name}}</div>
 			
-			<p class="showmodel" style="color: red;" >充满自停模式,设备充满后会自动停止计费,剩余费用会原路返还</p>
+			<p class="showmodel" style="color: red;" v-if="submitForm.hour==0" >充满自停模式,设备充满后会自动停止计费,剩余费用会原路返还</p>
 			
 		</u-modal>
 		
@@ -236,23 +236,29 @@
 				
 				this.submitForm.deviceNo=this.detail.deviceNo;
 				API.startCharging(this.submitForm).then((res) => {
-					
-					uni.showModal({
-					    title: '提示',
-						showCancel:false,
-					    content: '启动成功',
-					    success: res=> {
-					        if (res.confirm) {
-					           //付钱  改为组件
-					           this.gotoUrl("pages/index/index");
+				
+					 this.gotoUrl("pages/index/index");
+					// uni.showModal({
+					//     title: '提示',
+					// 	showCancel:false,
+					//     content: '启动成功',
+					//     success: res=> {
+					//         if (res.confirm) {
+					//            //付钱  改为组件
+					//            this.gotoUrl("pages/index/index");
 					           
-					        } else if (res.cancel) {
-					            console.log('用户点击取消');
-					        }
-					    }
-					});
-					
-					uni.hideLoading()
+					//         } else if (res.cancel) {
+					//             console.log('用户点击取消');
+					//         }
+					//     }
+					// });
+					// uni.showToast({
+					// 	title: '启动中..'
+					// })
+					// setTimeout(()=>{
+						
+					// },3000)
+					// uni.hideLoading()
 					
 				}).catch(error => {
 					if(error=='用户账户余额不足!'){

+ 31 - 16
pages/index/index.vue

@@ -24,10 +24,10 @@
 					</view>
 				</view>
 				<view class="chargeImg">
-					<img v-if="item.status==0" src="static/img/charge0.png" alt="">
-					<img v-if="item.status==1" src="static/img/charge1.png" alt="">
-					 <img v-if="item.status==2" src="static/img/charge2.png" alt=""> 
-					 <img v-if="item.status==3" src="static/img/charge3.png" alt="">
+					<img v-if="item.status==0" src="static/img/charge-0.png" alt="">
+					<img v-if="item.status==1" src="static/img/charge-1.png" alt="">
+					 <img v-if="item.status==2" src="static/img/charge-2.png" alt=""> 
+					 <img v-if="item.status==3" src="static/img/charge-3.png" alt="">
 					 <div class="JPTIME JPTIME1"  v-if="item.status==0||item.status==3" v-text="showtime[i]"></div>
 					  
 				</view>
@@ -139,6 +139,7 @@
 				//如果是扫码 ,或者登陆进来的, 并且没有充电,就跳转到充电页面  k= null
 				//如果是在系统内部访问的,  k=1  不跳转;
 			}
+			
 			if(op.id){
 				this.id=op.id;
 			}
@@ -173,8 +174,7 @@
 						var Hour = parseInt(Math.floor(ms / (60 )));
 						var Fen = parseInt(Math.floor(ms %60 ));
 						this.showtime[i]=(Hour>9?"":"0")+Hour+":"+(Fen>9?"":"0")+Fen
-						
-						console.log(ms)				
+						 		
 					}else{
 						this.showtime[i]="00:00";
 					}
@@ -189,7 +189,7 @@
 					
 				}
 				if(item.status==1){
-					var now=new Date();
+					 
 					var second=secondsDistance(item.startTime);
 					if(second>0){
 						
@@ -281,16 +281,31 @@
 					}else{
 						uni.hideLoading()
 					}
-					if(this.list.length>0&&this.setTimeoutId==""){
-						for(var i in this.list){
-							var item=this.list[i];
-							if(item.status==0||item.status==3){
-								this.setTimeoutId=setTimeout(()=>{
-									this.setTimeoutId="";
-									this.f5()
-								},5*1000)
+					if(this.list.length>0){
+						//防止定时器重复调用
+						if(this.setTimeoutId==""){
+							for(var i in this.list){
+								var item=this.list[i];
+								
+								if(item.status==0||item.status==3){
+									this.setTimeoutId=setTimeout(()=>{
+										this.setTimeoutId="";
+										this.f5()
+									},5*1000)
+								}else if(item.status==1&&item.startTime){		
+									var second=secondsDistance(item.startTime);
+									var ms=item.estimateMinute*60-second
+									if(ms<60*10){
+										this.setTimeoutId=setTimeout(()=>{
+											this.setTimeoutId="";
+											this.f5()
+										},5*1000)
+									}
+								}
 							}
 						}
+					}else{
+						this.setTimeoutId=""
 					}
 					
 				}).catch(error => {
@@ -300,7 +315,7 @@
 				})
 			},
 			f5(bl) {
-				console.log("f5")
+				
 				if(bl){
 					uni.showLoading({
 						title: "加载中",

+ 0 - 0
static/img/charge0.png → static/img/charge-0.png


+ 0 - 0
static/img/charge1.png → static/img/charge-1.png


+ 0 - 0
static/img/charge2.png → static/img/charge-2.png


+ 0 - 0
static/img/charge3.png → static/img/charge-3.png


+ 4 - 0
vue.config.js

@@ -1,4 +1,5 @@
 const path = require('path');
+const webpack = require('webpack')
 
 const CompressionWebpackPlugin = require("compression-webpack-plugin")
 const productionGzipExtensions = ['js', 'css']
@@ -54,6 +55,9 @@ module.exports = {
 			})
 		); */
 
+			config.plugins.push(new webpack.ProgressPlugin(percentage => {
+				percentage === 1 ? console.log('编译完成:100.00%') : console.log(`编译进度:${(percentage * 100).toFixed(2)}%`)
+			}));
 		config.output.filename = `./static/js/[name].${Timestamp}.js`
 		config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`