Browse Source

充电订单

wkyy 3 years ago
parent
commit
4d273f7e1e
2 changed files with 72 additions and 36 deletions
  1. 60 32
      pages/index/index.vue
  2. 12 4
      pages/record/index.vue

+ 60 - 32
pages/index/index.vue

@@ -50,19 +50,21 @@
 		</view>
 
 		<!-- 站点 -->
-		<view class="station" v-if="message == 'getLocation:ok'">
+		<view class="station" v-if="message == 'getLocation:ok' && chargeList.length == 0" @click="gotoUrl('pages/searchPile/stationAndPile/stationDetails?id=' + stationData.id)">
 			<view class="img-box">
 				<img src="static/img/Frame 198 (1).png" alt="">
 			</view>
 			<view class="text"> 
 				
 				<view class="station-title">
-					<text class="title-left">快充</text>
-					<text class="title-right">荆沙大道救助站充电站</text>
+					<text class="title-left" v-if="stationData.type == '1'">快充</text>
+					<text class="title-left" v-if="stationData.type == '2'">慢充</text>
+					<text class="title-left" v-if="stationData.type == '1,2'">快充&慢充</text>
+					<text class="title-right">{{stationData.name}}</text>
 				</view>
 				
 				<view class="station-price">
-					<view class="price-left">1.25</view>
+					<view class="price-left">{{stationData.costPrice}}</view>
 					<view class="price-right">
 						起 元/度
 					</view>
@@ -73,13 +75,13 @@
 					<text class="park-text">2小时免费停车</text>
 				</view>
 				<view class="count">
-					<view class="count-left">空闲10/总数10</view>
-					<view class="count-right"><text class="iconfont">&#xe615;</text>10公里</view>
+					<view class="count-left">空闲{{stationData.availableNum}}/总数{{stationData.totalNum}}</view>
+					<view class="count-right"><text class="iconfont">&#xe615;</text>{{stationData.distance}}公里</view>
 				</view>
 			</view>
 		</view>
 		<!-- 定位 -->
-		<view class="location-box" v-else>
+		<view class="location-box" v-if="message != 'getLocation:ok'">
 			<view class="location">
 				<view class="location-text">
 					<view class="text-1">
@@ -101,22 +103,30 @@
 		</view>
 
      <!-- 充电状态 -->
-	 <!-- <view class="state1 state">
+	 <view class="state1 state" v-if="chargeList.length > 0" v-for="(item,index) in chargeList" :key="item.id" @click="gotoUrl('pages/searchPile/chargeProcess/dcCharging?id=' + item.id)">
 		 <view class="state-text">
 		 	<view class="text-1">
-		 		排队中
+		 		{{item.statusText}}
 		 	</view>
-			<view class="text-2">
-				前方等待两位
+			<view v-if="item.status == '4'" class="text-2">
+				前方等待2位
+			</view>
+			<view v-if="item.status == '1'" class="text-2">
+				已充{{item.actualFee != null ? item.actualFee : '0.00'}}元
+			</view>
+			<view v-if="item.status == '2'" class="text-2" style="color: red;">
+				超出时间将收取占位费
 			</view>
 			<view class="text-3">
-				荆鹏软件园充电站/1号有序充电桩
+				{{item.stationName}}/{{item.deviceNo}}
 			</view>
 		 </view>
 	 	<view class="img-box">
-	 		<img src="static/img/等待中-缺省页.png">
+	 		<img v-if="item.status == '4'" src="static/img/等待中-缺省页.png">
+			<img v-if="item.status == '1'" src="static/img/充电中-缺省页.png">
+			<img v-if="item.status == '2'" src="static/img/已充满-缺省页.png">
 	 	</view>
-	 </view> -->
+	 </view>
 	 <!-- <view class="state2 state">
 	 		 <view class="state-text">
 	 		 	<view class="text-1" style="color: green">
@@ -191,29 +201,12 @@
 		</view>
 		<!-- 导航栏 -->
 		<view class="navigation">
-			<!-- 	<view class="nav-items">
-				<view class="nav-icon iconfont ">
-	                         &#xe610;
-				</view>
-				<view class="nav-text">主页</view>
-			</view>
-			<view class="nav-items">
-				<view class="nav-icon iconfont">&#xe622;</view>
-				<view class="nav-text">找桩</view>
-			</view>
-			<view class="nav-items">
-				<view class="nav-icon iconfont">&#xe627;</view>
-				<view class="nav-text">我的</view>
-			</view> -->
-		<!-- 登录提示 -->
 			<view class="login-prompt" v-if="!userId">
 				登录显示更多会员服务
 				<text class="button" @click="toLogin">登录/注册</text>
 			</view>
-			<Tabbar :current="0"></Tabbar>
 		</view>
-		
-
+		<Tabbar :current="0"></Tabbar>
 	</view>
 </template>
 
@@ -221,6 +214,7 @@
 	import * as API from '@/apis/index.js'
 	import * as newsApi from '@/apis/news.js'
 	import * as WxJsApi from '@/utils/wxJsApi.js'
+	import * as siteApi from '@/apis/site.js';
 	import MapLoader from '@/utils/AMap'
 	import Tabbar from '@/components/Tabbar.vue'
 
@@ -230,6 +224,8 @@
 		},
 		data() {
 			return {
+				stationData: {},
+				chargeList: [],
 				activityList: [],
 				userId: '',
 				newsList: [],
@@ -270,8 +266,28 @@
 			this.getPoint();
 			this.getNewsList();
 			this.getActivityInfoList();
+			this.getFindChargeData();
 		},
 		methods: {
+			getFindChargeData() {
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				
+				API.findChargeData({
+					pageIndex: 1,
+					pageSize: 10
+				}).then((res) => {
+					uni.hideLoading()					
+					this.chargeList = res.data.chargingRecordList;
+				}).catch(error => {
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			},
 			toSearchPile() {
 				uni.navigateTo({
 					url: '/pages/searchPile/searchPile'
@@ -372,6 +388,18 @@
 						uni.showToast({
 							title: res
 						})
+					} else {
+						siteApi.searchStationData({
+							longitude: this.longitude,
+							latitude: this.latitude
+						}).then((response) => {		
+							this.stationData = response.data.data[0];
+						}).catch(error => {
+							uni.showToast({
+								title: error,
+								icon: "none"
+							})
+						})
 					}
 				}).catch(error => {
 					uni.showToast({

+ 12 - 4
pages/record/index.vue

@@ -47,7 +47,8 @@
 				},
 				show: false,
 				month: '',
-				dateMonth: '',
+				startDate: '',
+				endDate: '',
 				chargeList: []
 			}
 		},
@@ -56,22 +57,28 @@
 			this.month = date.getMonth() + 1;
 			
 			var year = date.getFullYear();
+			var day = new Date(year, this.month, 0).getDate();
 			var monthN = this.month;
 			if(monthN >= 1 && monthN <= 9) {
 				monthN = "0" + monthN;
 			}
-			this.dateMonth = year + '-' + monthN;
+			
+			this.startDate = year + '-' + monthN + '-' + '01';
+			this.endDate = year + '-' + monthN + '-' + day;
 					
 			this.getChargeList();
 		},
 		methods: {
 			confirmTime(params) {
-				this.dateMonth = params.year + '-' + params.month;
 				if(params.month.slice(0,1) == '0') {
 					this.month = params.month.slice(1);
 				} else {
 					this.month = params.month;
 				}
+				
+				this.startDate = params.year + '-' + params.month + '-' + '01';
+				var day = new Date(params.year, params.month, 0).getDate();
+				this.endDate = params.year + '-' + params.month + '-' + day;
 				this.getChargeList();
 				this.show = false;
 			},
@@ -86,7 +93,8 @@
 				API.chargingRecordData({
 					pageIndex: 1,
 					pageSize: 100,
-					// month: this.dateMonth,
+					startDate: this.startDate,
+					endDate: this.endDate
 				}).then((res) => {
 					uni.hideLoading();