zhengkaixin 3 jaren geleden
bovenliggende
commit
749f490b74
3 gewijzigde bestanden met toevoegingen van 74 en 17 verwijderingen
  1. 12 0
      pages/charge/index.vue
  2. 62 17
      pages/index/index.vue
  3. BIN
      static/img/charge0.png

+ 12 - 0
pages/charge/index.vue

@@ -233,6 +233,7 @@
 					title: "加载中",
 					mask: true,
 				})
+				
 				this.submitForm.deviceNo=this.detail.deviceNo;
 				API.startCharging(this.submitForm).then((res) => {
 					
@@ -277,12 +278,23 @@
 				})
 			},
 			submit(){
+				
 				if(!this.submitForm.channelNo){
 					uni.showToast({
 						title:'请先选择充电通道'
 					})
 					return
 				}
+				var obj=this.list.find(item=>{
+					return item.channelNo==this.submitForm.channelNo
+				})
+				
+				if(!obj||obj.status!=0){
+					uni.showToast({
+						title:'当前设备不可选'
+					})
+					return
+				}
 				if(this.submitForm.hour==0&&this.user.accountBalance<5){
 					uni.showModal({
 					    title: '支付',

+ 62 - 17
pages/index/index.vue

@@ -3,7 +3,7 @@
 		<u-navbar title="充电中" :is-back="false">
 			<view class="slot-wrap">
 				<view class="navbar-left"></view>
-				<view class="navbar-right" @click="f5()" style="    color: #1d7cff;">
+				<view class="navbar-right" @click="f5(true)" style="    color: #1d7cff;">
 					<u-icon name="shuaxin" custom-prefix="custom-icon" color="#1677ff" size="40"></u-icon>刷新
 				</view>
 			</view>
@@ -24,12 +24,24 @@
 					</view>
 				</view>
 				<view class="chargeImg">
-					<img v-if="item.status==0" src="static/img/charge1.png" alt="">
+					<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==2" src="static/img/charge2.png" alt=""> 
+					 <img v-if="item.status==3" src="static/img/charge1.png" alt="">
+					 
+				</view>
+				<view class="chargeTime" v-if="item.status==3">
+					<h1>停止中...</h1>
 				</view>
-
-				<view class="chargeTime">
+				<view class="chargeTime" v-if="item.status==0">
+					<h1>启动中...</h1>
+					请在2分钟内接入电源!
+				</view>
+				<view class="chargeTime" v-if="item.status==2">
+					<h1>充电结束</h1>
+					 {{item.remark}}
+				</view>
+				<view class="chargeTime" v-if="item.status==1">
 					<p>剩余时长</p>
 					<u-line-progress active-color="#ececec"  height="48" :percent="getPercent(item).percent">
 						<div style="     
@@ -56,7 +68,7 @@
 				<view class="chargeData">
 					<view class="chargeData-item">
 						<u-icon name="jiagebaohu" custom-prefix="custom-icon" color="#1677ff" size="56"></u-icon>
-						<h2>{{item.estimateFee}}元</h2>
+						<h2>{{item.estimateFee?item.estimateFee:0}}元</h2>
 						<p>消费金额</p>
 					</view>
 					<view class="chargeData-item">
@@ -65,14 +77,14 @@
 										<view class="chargeData-power">
 											<span>0</span>
 											<u-line-progress active-color="#2979ff" :percent="item.chargingPower/9" :show-percent="false"></u-line-progress>
-											<span>{{item.chargingPower}}</span>
+											<span>{{item.chargingPower?item.chargingPower:0}}W</span>
 										</view>
 
 						<p>充电功率</p>
 					</view>
 				</view>
 				<view class="chargeBtn">
-					<view class="chargeBtn-item" @click="returnMoney(item)">终止并退款</view>
+					<view class="chargeBtn-item" v-if="item.status==1" @click="returnMoney(item)">终止并退款</view>
 					<view class="chargeBtn-item" @click="showTips(item)">费用说明</view>
 				</view>
 				
@@ -84,6 +96,7 @@
 			
 		</swiper>
 		<u-modal v-model="showmodel" title="费用说明" >
+			<p v-if="showitem.length==0">当前为免费充电桩</p>
 			<p v-for="(item,i) in showitem" class="showmodel" :key="i">{{item.minPower}}W-{{item.maxPower}}W <span>{{item.price}}元每小时</span></p>
 			
 		</u-modal>
@@ -99,6 +112,7 @@
 		data() {
 			return {
 				k:0,
+				id:"",
 				showmodel:false,
 				showitem:[],
 				percent:0,
@@ -119,6 +133,13 @@
 				//如果是扫码 ,或者登陆进来的, 并且没有充电,就跳转到充电页面  k= null
 				//如果是在系统内部访问的,  k=1  不跳转;
 			}
+			if(op.id){
+				this.id=op.id;
+			}
+			uni.showLoading({
+				title: "加载中",
+				mask: true,
+			})
 			this.init(op.phone)
 		},
 		methods: {
@@ -141,7 +162,14 @@
 					
 					}
 				}
-				
+				if(item.status==0){
+					obj.value="启动中"
+					obj.percent="50";
+				}
+				if(item.status==2){
+					obj.value="关闭中"
+					obj.percent="50";
+				}
 				//特殊情况默认值
 				if(!obj.value){
 					obj.value="00:00"
@@ -183,7 +211,7 @@
 					deviceNo:item.deviceNo,
 				};
 				API.stopCharging(data).then((res) => {
-					this.f5()
+					this.f5(true)
 				}).catch(error => {
 					
 					uni.showToast({
@@ -195,22 +223,33 @@
 				if(!phone){
 					phone=""
 				}
-				uni.showLoading({
-					title: "加载中",
-					mask: true,
-				})
+				// uni.showLoading({
+				// 	title: "加载中",
+				// 	mask: true,
+				// })
 				var data = {
 					phone:phone
 				};
 				API.findChargeData(data).then((res) => {
+					
 					this.list = res.data.chargingRecordList;
 					this.isCharge=res.data.isCharge;
 					this.isReady=true;
 					if(!this.isCharge&&this.k!=1){
-						this.gotoUrl("pages/charge/index")
+						this.gotoUrl("pages/charge/index?id="+this.id)
 					}else{
 						uni.hideLoading()
 					}
+					if(this.list.length>0){
+						for(var i in this.list){
+							var item=this.list[i];
+							if(item.status==0||item.status==3){
+								setTimeout(()=>{
+									this.f5()
+								},5*1000)
+							}
+						}
+					}
 					
 				}).catch(error => {
 					uni.showToast({
@@ -218,7 +257,13 @@
 					})
 				})
 			},
-			f5() {
+			f5(bl) {
+				if(bl){
+					uni.showLoading({
+						title: "加载中",
+						mask: true,
+					})
+				}
 				this.k=1;
 				this.init()
 			},
@@ -228,7 +273,7 @@
 
 		},onShow() {
 			if(this.isReady){
-				this.f5()
+				this.f5(true)
 			}
 		}
 	}

BIN
static/img/charge0.png