瀏覽代碼

Merge branch 'master' of http://47.92.161.104:10080/zkx/JP-ChargeTeam51

zhengkaixin 3 年之前
父節點
當前提交
cdeb41203e

+ 1 - 1
App.vue

@@ -37,7 +37,7 @@
 	  background-color: #F2F4F4;  
 	  margin: 0;
 	  padding: 0;
-	}
+	} ygff
 	// 后退图标
 	.back{
 		display: inline-block;

+ 15 - 0
apis/index.js

@@ -2,6 +2,21 @@ import request from '../utils/request.js';
 import requestWhite from '../utils/requestWhite.js';
 import Qs from 'qs';
 
+export function scanCode(res) {
+	// res="jp_team51_charge_id:A_11111"
+	var str1 = res.slice(0,19);
+	var str2 = res.slice(20,21);
+	var id = res.slice(22);
+	
+	if(str == 'jp_team51_charge_id') {
+		if(str == 'A') {
+			uni.navigateTo({
+				url: '/pages/searchPile/stationAndPile/stationDetails?id=' + id
+			})
+		}
+	}
+}
+
 export function activityInfoList(data) {
 	return requestWhite({
 		method: 'post',

+ 5 - 1
apis/site.js

@@ -1,7 +1,11 @@
 import request from '../utils/request.js';
 import Qs from 'qs';
 export function geChargingStationData(data){
-	
+	return request({
+		method: 'post',
+		data: data,
+		url: '/mobile/chargingStation/chargingStationData'
+	})
 }
 export function getPileDetails(data){
 	var p = new Promise(function(resolve,rejct){

+ 68 - 17
components/Chargermap.vue

@@ -68,11 +68,12 @@
 						longitude:112.279274,
 						latitude:30.303273,
 					}
-				]
+				],
 			};
 		},
 		methods:{
-			getLocation () {
+			getLocation1() {
+//			  console.log('getLocation');
 			  const self = this;
 			  AMap.plugin('AMap.Geolocation', function () {
 				var geolocation = new AMap.Geolocation({
@@ -88,26 +89,30 @@
 				 
 				function onComplete (data) {
 				  // data是具体的定位信息
+				  self.$emit('location',data);
 				  console.log('定位成功信息:', data.addressComponent.city);
 				  self.city = data.addressComponent.city;
 				}
 				 
 				function onError (data) {
 				  // 定位出错
-				  console.log('定位失败错误:', data);
+//				  console.log('定位失败错误:', data);
 				  // 调用IP定位
-				  self.getLngLatLocation();
+				  let ret = { position:{longitude: 112.28468,latitude: 30.307094}};
+				  self.$emit('location',ret);
+				  //self.getLngLatLocation();
 				}
 			  });
 			}, 
 			// 通过IP获取当前位置
 			getLngLatLocation () {
+				const self = this;
 			  AMap.plugin('AMap.CitySearch', function () {
 				var citySearch = new AMap.CitySearch();
 				citySearch.getLocalCity(function (status, result) {
 				  if (status === 'complete' && result.info === 'OK') {
 					// 查询成功,result即为当前所在城市信息
-					console.log('通过ip获取当前城市:', result);
+					//console.log('通过ip获取当前城市:', result);
 					// 逆向地理编码
 					AMap.plugin('AMap.Geocoder', function () {
 					  var geocoder = new AMap.Geocoder({
@@ -118,8 +123,9 @@
 					  var lnglat = result.rectangle.split(';')[0].split(',');
 					  geocoder.getAddress(lnglat, function (status, data) {
 						if (status === 'complete' && data.info === 'OK') {
-						  // result为对应的地理位置详细信息
-						  console.log(data);
+						  // result为对应的地理位置详细信息	
+						   //self.$emit('location',data);
+							console.log('location'+JSON.stringify(data));
 						}
 					  });
 					});
@@ -127,12 +133,57 @@
 				});
 			  });
 			}, 
+			searchBtn(startLngLat,endLst){
+				var _this = this;
+				
+				AMap.plugin('AMap.Driving', function() {
+				  var driving = new AMap.Driving({
+					// 驾车路线规划策略,AMap.DrivingPolicy.LEAST_TIME是最快捷模式
+					policy: AMap.DrivingPolicy.LEAST_TIME
+				  })
+				  
+				 //var startLngLat = [_this.longitude, _this.latitude]
+				 //var endLngLat = [116.427281, 39.903719]
+				 console.log('searchBtn'+JSON.stringify(endLst))
+				 for(let i=0;i< endLst.length;i++)
+				 {
+					 let item = endLst[i];
+					 let endLngLat = [item.longitude,item.latitude]
+					  driving.search(startLngLat, endLngLat, function (status, result) {
+							//console.log(result)
+							//console.log(result.routes[0].time)//秒
+							//console.log(result.routes[0].distance)//米
+							//uni.showToast({
+							//	title:result.routes[0].time+"秒,"+result.routes[0].distance+"米"
+							//})
+							 endLst[i].distance = result.routes[0].distance/1000.0;
+							 endLst[i].time = result.routes[0].time/60.0;
+					  })
+					  
+					  //var startLngLat2 = [_this.longitude, _this.latitude]
+					  //var endLngLat2 = [_this.longitude2, _this.latitude2]
+					
+					 /* 
+					  driving.search(startLngLat2, endLngLat2, function (status, result) {
+												console.log(result)
+												console.log(result.routes[0].time)//秒
+												console.log(result.routes[0].distance)//米
+												uni.showToast({
+													title:result.routes[0].time+"秒,"+result.routes[0].distance+"米"
+												})
+					  })*/
+				}
+				console.log('search---'+JSON.stringify(startLngLat))
+				console.log('search+++'+JSON.stringify(endLst))
+				}) 
+			},
 			updateCharger(pos){
 //				console.log('更新充电桩1'+JSON.stringify(pos)) 
 //				console.log('更新充电桩2'+JSON.stringify(this.chargerList[0].info)) 
-				let index = this.chargerList.findIndex(item => item.info.latitude === pos.latitude && item.info.longitude === pos.longitude);
+//				let index = this.chargerList.findIndex(item => item.info.latitude === pos.latitude && item.info.longitude === pos.longitude);
 				//let index = this.chargerList.findIndex(item => (Math.abs(item.info.longitude-pos.longitude)<0.000001 && Math.abs(item.info.longitude - pos.latitude)<0.000001));
-				
+				let index = this.chargerList.findIndex(item => item.info.id === pos.id);
+					console.log('更新充电桩['+ index + ']'+JSON.stringify(pos)) 
 				if(index>=0){
 					let station_icon2 = "width: 100px;height: 36px;line-height: 20px;border-radius: 50px;background-color: rgba(0, 185, 98, 100);text-align: center;display: flex;";
 					let corner2=" width: 0;height: 0;position: absolute;top: 36px;left: 0;right: 0;margin: auto;border-bottom: 6px solid transparent;border-left: 6px solid transparent;border-right: 6px solid transparent;border-top: 8px solid #00b962 ;";
@@ -150,8 +201,8 @@
 					content+="</div>";
 					content+="</div>";
 					
- 					console.log('找到充电桩[]'+content)
-					//let content = "<div  style='height: 40px;width: 100px;display: flex;flex-direction: row;   flex-wrap: wrap; background-color: #00B962!important;border-radius: 20px;'>		    <div><img src='"+this.chargerSelectedIcon+"' style='idth: 40px;height: 40px'></div><div style='display: flex;flex-direction:column;color:#FFFFFF;'><div style='margin-left:10px'>¥"+ pos.price +"</div><div style='margin-left:10px'>空闲"+pos.idleNum + "</div> </div></div>";
+// 					console.log('找到充电桩[]'+content)
+					//content = "<div  style='height: 40px;width: 100px;display: flex;flex-direction: row;   flex-wrap: wrap; background-color: #00B962!important;border-radius: 20px;'>		    <div><img src='"+this.chargerSelectedIcon+"' style='idth: 40px;height: 40px'></div><div style='display: flex;flex-direction:column;color:#FFFFFF;'><div style='margin-left:10px'>¥"+ pos.price +"</div><div style='margin-left:10px'>空闲"+pos.idleNum + "</div> </div></div>";
 					this.chargerList[index].info.selected = true;
 					this.chargerList[index].marker.setContent(content);						
 				} 
@@ -308,7 +359,7 @@
 			},
 			
 			init(){
-				console.log('init')
+//				console.log('init')
 				var _this = this;
 //				this.personIcon = require("@/static/img/charger_selected.png")
 				// this.chargerIcon = require("@/static/img/charger.png");
@@ -325,10 +376,10 @@
 						zoom: 14
 					});
 					 
-					var clickHandler = function(e) {
-						console.log('您在[ '+e.lnglat.getLng()+','+e.lnglat.getLat()+' ]的位置点击了地图!');
-					};
-					_this.mapcharger.on('click', clickHandler); 
+					//var clickHandler = function(e) {
+					//	console.log('您在[ '+e.lnglat.getLng()+','+e.lnglat.getLat()+' ]的位置点击了地图!');
+					//};
+					//_this.mapcharger.on('click', clickHandler); 
 					_this.$emit('onload')
 					var mapMovestart = function(){
 						console.log('movestart')
@@ -339,7 +390,7 @@
 					var mapMoveend = function(){
 						let pos = _this.logMapInfo();
 						_this.$emit('onMoveEnd',pos);
-						console.log('mapMoveend')
+//						console.log('mapMoveend')
 					}
 					_this.mapcharger.on('movestart', mapMovestart);
 					_this.mapcharger.on('mapmove', mapMove);

+ 7 - 0
pages.json

@@ -57,6 +57,13 @@
 				//"navigationStyle": "custom" // 隐藏系统导航栏
 			}
 		},
+		{
+			"name": "个人资料",
+			"path": "pages/user/data",
+			"style": {
+				//"navigationStyle": "custom" // 隐藏系统导航栏
+			}
+		},
 		{
 			"name": "车量管理",
 			"path": "pages/user/car/index",

+ 260 - 125
pages/index/index.vue

@@ -10,7 +10,7 @@
 		<!-- 选项列表 -->
 		<view class="option-list">
 
-			<view class="list-item" @click="scanCode">
+			<view class="list-item" @click="getScanCode">
 				<view class="icon iconfont" style="background-color:#59d96e;">
 					&#xe61a;
 				</view>
@@ -54,21 +54,21 @@
 			<view class="img-box">
 				<img src="/static/img/Frame 198 (1).png" alt="">
 			</view>
-			<view class="text"> -->
-				<!-- 站点头部 -->
-				<!-- <view class="station-title">
+			<view class="text"> 
+				
+				<view class="station-title">
 					<text class="title-left">快充</text>
 					<text class="title-right">荆沙大道救助站充电站</text>
-				</view> -->
-				<!-- 价格 -->
-				<!-- <view class="station-price">
+				</view>
+				
+				<view class="station-price">
 					<view class="price-left">1.25</view>
 					<view class="price-right">
 						起 元/度
 					</view>
-				</view> -->
-				<!-- park -->
-				<!-- <view class="park">
+				</view>
+				
+				<view class="park">
 					<text class="park-p">p</text>
 					<text class="park-text">2小时免费停车</text>
 				</view>
@@ -94,82 +94,134 @@
 				</view>
 				<view class="img-box">
 					<img src="/static/img/暂无网络信号-缺省页 1.png">
-		  </view>
+				</view>
+			</view>
+
+
 		</view>
-		
-	</view>
+
+     <!-- 充电状态 -->
+	 <!-- <view class="state1 state">
+		 <view class="state-text">
+		 	<view class="text-1">
+		 		排队中
+		 	</view>
+			<view class="text-2">
+				前方等待两位
+			</view>
+			<view class="text-3">
+				荆鹏软件园充电站/1号有序充电桩
+			</view>
+		 </view>
+	 	<view class="img-box">
+	 		<img src="/static/img/等待中-缺省页.png">
+	 	</view>
+	 </view> -->
+	 <!-- <view class="state2 state">
+	 		 <view class="state-text">
+	 		 	<view class="text-1" style="color: green">
+	 		 		充电中
+	 		 	</view>
+	 			<view class="text-2">
+	 				前方等待两位
+	 			</view>
+	 			<view class="text-3">
+	 				荆鹏软件园充电站/1号有序充电桩
+	 			</view>
+	 		 </view>
+	 	<view class="img-box">
+	 		<img src="/static/img/充电中-缺省页.png">
+	 	</view>
+	 </view> -->
+	 <!-- <view class="state3 state">
+	 		 <view class="state-text">
+	 		 	<view class="text-1" style="color: red;">
+	 		 		已充满
+	 		 	</view>
+	 			<view class="text-2" style="color: red;">
+	 				超出时间将收取占位费
+	 			</view>
+	 			<view class="text-3">
+	 				荆鹏软件园充电站/1号有序充电桩
+	 			</view>
+	 		 </view>
+	 	<view class="img-box">
+	 		<img src="/static/img/已充满-缺省页.png">
+	 	</view>
+	 </view> -->
+
 		<!-- 充值活动 -->
 		<view class=" top-up">
-					<view class="top-up-title"><text class="line"></text>充值活动</view>
-					<view class="img-box">
-						<view class="img-1" @click="rechargeActivity">
-							<img src="/static/img/瓷片区1.png" alt="">
-							<view class="img-text">
-								充100送20
-								<view class="img-text2">即充即赠 立享优惠</view>
-							</view>
-						</view>
-						<view class="img-1">
-							<img src="/static/img/瓷片区2.png" alt="">
-							<view class="img-text" style="color: #FF7C00;">
-								邀请有礼
-								<view class="img-text2 color">最高可得500元</view>
-							</view>
-						</view>
+			<view class="top-up-title"><text class="line"></text>充值活动</view>
+			<view class="img-box">
+				<view class="img-1" @click="rechargeActivity">
+					<img src="/static/img/瓷片区1.png" alt="">
+					<view class="img-text">
+						充100送20
+						<view class="img-text2">即充即赠 立享优惠</view>
 					</view>
 				</view>
-				<!-- 新闻 -->
-				<view class="news-title">
-					<view class="news-title-left">
-						<view class="line" style="margin-top:4px;"></view>新闻公告
+				<view class="img-1">
+					<img src="/static/img/瓷片区2.png" alt="">
+					<view class="img-text" style="color: #FF7C00;">
+						邀请有礼
+						<view class="img-text2 color">最高可得500元</view>
 					</view>
+				</view>
+			</view>
+		</view>
+		<!-- 新闻 -->
+		<view class="news-title">
+			<view class="news-title-left">
+				<view class="line" style="margin-top:4px;"></view>新闻公告
+			</view>
 
-					<view class="more" @click="toNewsNotice">更多<view class="more-icon iconfont"> &#xe600;</view>
-					</view>
+			<view class="more" @click="toNewsNotice">更多<view class="more-icon iconfont"> &#xe600;</view>
+			</view>
 
 
+		</view>
+		<view class="news">
+
+			<view class="news-content" @click="gotoUrl('pages/article/articleDetails?id=')">
+				<view class="content-text">
+					日印计划联手开发低成本充电桩 推动新兴市场电动车发展
+					<view class="news-time">05-01 09:00</view>
 				</view>
-				<view class="news">
-
-					<view class="news-content" @click="gotoUrl('pages/article/articleDetails?id=')">
-						<view class="content-text">
-							日印计划联手开发低成本充电桩 推动新兴市场电动车发展
-							<view class="news-time">05-01 09:00</view>
-						</view>
-						<view class="content-img">
-							<img src="/static/img/11091323191.jpg" alt="">
-						</view>
-					</view>
-					<view class="news-content">
-						<view class="content-text">
-							我国新能源汽车市场腾飞在即,充换电何时能够不再“拖后腿”?
-							<view class="news-time">05-01 09:00</view>
-						</view>
-						<view class="content-img">
-							<img src="/static/img/103613441.jpg" alt="">
-						</view>
-					</view>
+				<view class="content-img">
+					<img src="/static/img/11091323191.jpg" alt="">
+				</view>
+			</view>
+			<view class="news-content">
+				<view class="content-text">
+					我国新能源汽车市场腾飞在即,充换电何时能够不再“拖后腿”?
+					<view class="news-time">05-01 09:00</view>
+				</view>
+				<view class="content-img">
+					<img src="/static/img/103613441.jpg" alt="">
+				</view>
+			</view>
 
-					<view class="news-content">
-						<view class="content-text">
-							新疆建成首个充电桩实验室
-							<view class="news-time">05-01 09:00</view>
-						</view>
-						<view class="content-img">
-							<img src="/static/img/180023631.jpg" alt="">
-						</view>
-					</view>
+			<view class="news-content">
+				<view class="content-text">
+					新疆建成首个充电桩实验室
+					<view class="news-time">05-01 09:00</view>
 				</view>
-				<view class="bottom" v-if="newsList.length == recordsTotal">
-					<view class="bot">
-						<view class="bot-line"></view>
-						<view class="bot-text">已经到底了</view>
-						<view class="bot-line"></view>
-					</view>
+				<view class="content-img">
+					<img src="/static/img/180023631.jpg" alt="">
 				</view>
-				<!-- 导航栏 -->
-				<view class="navigation">
-					<!-- 	<view class="nav-items">
+			</view>
+		</view>
+		<view class="bottom" v-if="newsList.length == recordsTotal">
+			<view class="bot">
+				<view class="bot-line"></view>
+				<view class="bot-text">已经到底了</view>
+				<view class="bot-line"></view>
+			</view>
+		</view>
+		<!-- 导航栏 -->
+		<view class="navigation">
+			<!-- 	<view class="nav-items">
 				<view class="nav-icon iconfont ">
 	                         &#xe610;
 				</view>
@@ -183,15 +235,16 @@
 				<view class="nav-icon iconfont">&#xe627;</view>
 				<view class="nav-text">我的</view>
 			</view> -->
+		<!-- 登录提示 -->
 			<view class="login-prompt" v-if="userId.length == 0">
 				登录显示更多会员服务
 				<text class="button" @click="toLogin">登录/注册</text>
 			</view>
-					<Tabbar :current="0"></Tabbar>
-				</view>
-				<!-- 登录提示 -->
-				
-			</view>
+			<Tabbar :current="0"></Tabbar>
+		</view>
+		
+
+	</view>
 </template>
 
 <script>
@@ -200,7 +253,7 @@
 	import * as WxJsApi from '@/utils/wxJsApi.js'
 	import MapLoader from '@/utils/AMap'
 	import Tabbar from '@/components/Tabbar.vue'
-	
+
 	export default {
 		components: {
 			Tabbar
@@ -209,7 +262,6 @@
 			return {
 				activityList: [],
 				userId: '',
-				nickname: '',
 				newsList: [],
 				pageIndex: 1,
 				recordsTotal: 0,
@@ -219,21 +271,21 @@
 			}
 		},
 		onReachBottom() {
-			if (this.newsList.length < this.recordsTotal) {			
+			if (this.newsList.length < this.recordsTotal) {
 				this.myLoadmore();
 			}
 		},
 		onReady() {
-			if(this.carhelp.getPersonInfo().id != null) {
+			if (this.carhelp.getPersonInfo().id != null) {
 				this.userId = this.carhelp.getPersonInfo().id;
 			}
-			
-			WxJsApi.getWxConfig(['getLocation','addEventListener','scanQRCode']).then((res)=>{
+
+			WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
 				// console.log(res)
 			}).catch(error => {
-					// console.log(res)
+				console.log(res)
 			})
-			
+
 			this.getPoint();
 			this.getNewsList();
 			this.getActivityInfoList();
@@ -250,12 +302,21 @@
 				})
 			},
 			//微信扫二维码
-			scanCode() {
-				if(this.userId != '') {
+			getScanCode() {
+				if (this.userId != '') {
 					WxJsApi.scanQRCode(1).then(res => {
+						if(res) {
+							Api.scanCode(res).then((response) => {
 						
+							}).catch(error => {
+								uni.showToast({
+									title: error,
+									icon: "none"
+								})
+							})
+						}
 					}).catch(error => {
-						
+
 					})
 				} else {
 					uni.redirectTo({
@@ -264,7 +325,7 @@
 				}
 			},
 			fastRecharge() {
-				if(this.userId != '') {
+				if (this.userId != '') {
 					this.gotoUrl('pages/user/finance/recharge?id=' + this.userId)
 				} else {
 					uni.redirectTo({
@@ -273,7 +334,7 @@
 				}
 			},
 			chargingRecord() {
-				if(this.userId != '') {
+				if (this.userId != '') {
 					this.gotoUrl('pages/user/finance/rechargeList?id=' + this.userId)
 				} else {
 					uni.redirectTo({
@@ -282,7 +343,7 @@
 				}
 			},
 			rechargeActivity() {
-				if(this.userId != '') {
+				if (this.userId != '') {
 					this.gotoUrl('pages/user/finance/recharge?id=' + this.userId)
 				} else {
 					uni.redirectTo({
@@ -291,23 +352,23 @@
 				}
 			},
 			getActivityInfoList() {
-				
+
 			},
 			getPoint() {
 				WxJsApi.getLocation().then((res) => {
 					this.latitude = parseFloat(res.latitude);
 					this.longitude = parseFloat(res.longitude);
 					this.message = res.errMsg;
-					
-					if(res.errMsg != 'getLocation:ok') {
+
+					if (res.errMsg != 'getLocation:ok') {
 						uni.showToast({
-							title:JSON.stringify(res)
+							title: JSON.stringify(res)
 						})
-					}				
+					}
 				}).catch(error => {
 					uni.showToast({
-						title:JSON.stringify(error)
-					})					
+						title: JSON.stringify(error)
+					})
 				})
 			},
 			getNewsList(bl) {
@@ -320,7 +381,23 @@
 					this.pageIndex = 1;
 				}
 				
-				uni.hideLoading();
+				newsApi.newsInfoList({
+					pageIndex: 1,
+					pageSize: 10
+				}).then((res) => {
+					uni.hideLoading()
+					
+					this.newsList = [
+						...this.newsList,
+						...res.data.data
+					];
+					this.recordsTotal = res.data.recordsTotal		
+				}).catch(error => {
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
 			},
 			myLoadmore() {
 				this.pageIndex += 1;
@@ -498,7 +575,7 @@
 
 			// 数量
 			.count {
-				margin-top: 8px;
+				margin-top: 12px !important;
 				width: 96%;
 				display: flex;
 				justify-content: space-between;
@@ -510,7 +587,7 @@
 	//定位
 
 	.location {
-		width: 343px;
+
 		background-color: #ffffff;
 		height: 120px;
 		display: flex;
@@ -558,6 +635,47 @@
 		}
 	}
 
+	.state{
+		// width: 343px;
+		width: 91.4%;
+		background-color: #ffffff;
+		height: 120px;
+		display: flex;
+		margin: 70px auto 0;
+		border-radius: 8px;
+		border: #F2F4F4 1px;
+		.state-text{
+			width: 61.8%;
+			padding: 24px 0 0 28px;
+			.text-1 {
+				height: 16px;
+				line-height: 16px;
+				color: blueviolet;
+				font-size: 16px;
+				text-align: left;
+			}
+			.text-2 {
+				height: 17px;
+				line-height: 17px;
+				color: #101010;
+				text-align: left;
+				margin-top: 12px;
+			}
+			
+			.text-3 {
+				font-size: 12px;
+				text-align: center;
+				margin-top: 6px;
+				color: #999999;
+			}
+			
+		}
+		.img-box {
+			width: 120px;
+			height: 120px;
+			float: right;
+		}
+	}
 	//充值
 	.top-up {
 		margin-left: 16px;
@@ -736,7 +854,7 @@
 		}
 	}
 
-	
+
 
 	img {
 		width: 100%;
@@ -961,6 +1079,21 @@
 			float: right;
 		}
 	}
+	// 状态
+	.state{
+		width: 91.4%;
+		background-color: #ffffff;
+		height: 120px;
+		display: flex;
+		margin: 70px auto 0;
+		border-radius: 8px;
+		border: #F2F4F4 1px;
+		.img-box {
+			width: 120px;
+			height: 120px;
+			float: right;
+		}
+	}
 
 	//充值
 	.top-up {
@@ -1137,28 +1270,30 @@
 			font-size: 14px;
 		}
 	}
-// 登录提示
-.login-prompt{
-	width: 91.4%;
-	height: 40px;
-	line-height: 40px;
-	border-radius: 50px;
-	text-align: left;
-	padding-left: 16px;
-	padding-right: 4px;
-	background-color: rgba(0, 0, 0, 0.6);
-	position: fixed;
-	bottom: 75px;
-	color: #ffffff;
-	.button{
-		width: 88px;
-		height: 32px;
-		line-height: 32px;
+
+	// 登录提示
+	.login-prompt {
+		width: 91.4%;
+		height: 40px;
+		line-height: 40px;
 		border-radius: 50px;
-		background-color: rgba(0, 185, 98, 100);
-		text-align: center;
-		float: right;
-		margin-top: 4px;
+		text-align: left;
+		padding-left: 16px;
+		padding-right: 4px;
+		background-color: rgba(0, 0, 0, 0.6);
+		position: fixed;
+		bottom: 75px;
+		color: #ffffff;
+
+		.button {
+			width: 88px;
+			height: 32px;
+			line-height: 32px;
+			border-radius: 50px;
+			background-color: rgba(0, 185, 98, 100);
+			text-align: center;
+			float: right;
+			margin-top: 4px;
+		}
 	}
-}
 </style>

+ 303 - 100
pages/searchPile/searchPile.vue

@@ -131,7 +131,7 @@
 			</view>
 			<view v-show="!viewMode" >
 				 
-				<view v-for="(item,index) in stations" :key="item.id" class="charing-slow" >
+				<view v-for="(item,index) in stationslist" :key="item.id" class="charing-slow" >
 					<text :class="item.type == '快充' ? 'fast-charge':'trickle-charge'">{{item.type}}</text> <text class="station-items">{{item.name}}</text>
 					<view class="address">
 						{{item.position}}
@@ -151,7 +151,7 @@
 							<text style="color:#009143;">空闲{{item.idleNum}}</text>/总数{{item.total}}
 						</view>
 						<view class="distance">
-							<text class="iconfont distance-font">&#xe615;</text>{{item.distance}}公里 {{item.time}}分钟
+							<text class="iconfont distance-font">&#xe615;</text>{{item.distance.toFixed(2)}}公里 {{item.time.toFixed(0)}}分钟
 						</view>
 					</view>
 				</view>
@@ -163,17 +163,17 @@
 			</view>
 			<view v-show="viewMode" >					
 				<view>
-					<Chargermap  @onMoveEnd="moveEnd" ref="amap" @onload="mapdown" @clickMap="clickMap"></Chargermap>
+					<Chargermap @location="location"  @onMoveEnd="moveEnd" ref="amap" @onload="mapdown" @clickMap="clickMap"></Chargermap>
 				</view>
 				 
-				<view v-if="stations.length>0" class="chargerCard" style="border-radius: 20rpx;" > 
+				<view v-if="stationsmap.length>0" class="chargerCard" style="border-radius: 20rpx;" > 
 					<swiper :current="currentIndex" @change="swiperChange" @transition="swiperTransition" style="height: 100%;">
-					 	<swiper-item v-for="(item,index) in stations" :key="index" style="height: 100%;">							 
+					 	<swiper-item v-for="(item,index) in stationsmap" :key="item.id" style="height: 100%;">							 
 							
 							<view class="swiper-item" style="height: 100%; background-color: #ffffff;">
 								<view class="card_item" style="font-size: 35rpx;padding-top: 5rpx;">
 									<view style="display: flex;flex-direction: row;">
-										<view class="round2" style="margin-right: 5rpx;">
+										<view :class="item.type == '快充'? 'fast-charge':'trickle-charge'" >
 											{{item.type}}
 										</view>
 										<view>
@@ -218,10 +218,10 @@
 									<view class="round">
 										<text class="iconfont distance-font">&#xe615;</text>
 										<view  style="margin-right: 10rpx;">
-											{{item.distance}}公里											
+											{{item.distance.toFixed(2)}}公里											
 										</view>
 										<view  style="margin-right: 10rpx;">
-											{{item.time}}分钟
+											{{item.time.toFixed(0)}}分钟
 										</view>
 									</view>
 								</view>
@@ -242,7 +242,9 @@ import * as api from '@/apis/site.js';
 import Chargermap from '@/components/Chargermap.vue';
 import DoubleSlider from '@/components/double-slider/DoubleSlider.vue';
 import Tabbar from '@/components/Tabbar.vue';
-
+import * as WxJsApi from '@/utils/wxJsApi.js'
+import MapLoader from '@/utils/AMap'
+//import * as navigation from '@/pages/navigation/index.vue'
 let _self;
 export default {
 	components: {
@@ -260,8 +262,8 @@ export default {
 			mapopen: false,
 			isReady: false,
 			id: '',
-			longitude: 112.28468,
-			latitude: 30.307094,
+			longitude: 112.28308,
+			latitude: 30.312084,
 			//			longitude: '',
 			//			latitude: '',
 			nearbyStationInfo: {
@@ -277,13 +279,15 @@ export default {
 				save_preference: false,
 				obc_power: { minValue: 0, maxValue: 500 }
 			},
-			stations:[
+			stationsmap:[
 /*				{name:'荆鹏软件园充电站',position:'湖北省荆州市沙市区江津东路附155号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'慢充'},
 				{name:'荆鹏软件园充电站2',position:'湖北省荆州市沙市区江津东路附156号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'快充'},
 				{name:'荆鹏软件园充电站3',position:'湖北省荆州市沙市区江津东路附157号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'慢充'},
 				{name:'荆鹏大道求助站充电站',position:'湖北省荆州市沙市区江津东路附158号',price:1.2,idle:10,total:10,distance:0.1,time:1,type:'快充'},
 	*/			
 			],
+			timer:null,
+			stationslist:[],
 			info: {
 				miles_type: [
 					{ distance: 1, text: '1公里' },
@@ -311,44 +315,27 @@ export default {
 			if (op.latitude != null) this.latitude = op.latitude;
 			if (op.id != null) this.id = op.id;
 		}
+		
 	},
 	onReady() {
+		 
+		 WxJsApi.getWxConfig(['getLocation','addEventListener']).then((res)=>{
+		 
+		 	// this.message=JSON.stringify(res)
+		 	// uni.showToast({
+		 	// 	title:JSON.stringify(res)
+		 	// })
+		 	console.log(res)
+		  
+		 }).catch(error => {
+		 		console.log(res)
+		 })
+		 
+		this.getPoint();
 		//		console.log('longitude2  '+this.longitude)
 		//		console.log('latitude2  '+this.latitude)
-		this.getNearbyStationInfo();
-		this.isReady = true;
 		this.$refs.amap.init();
-		 
-		//let state = {};
-		uni.getSystemInfo({
-			success: (res) => {
-				// #ifndef MP
-				let navbarH = 0
-				// #endif
-				// #ifdef MP
-				let navbarH = uni.upx2px(90)
-				// #endif
-				/*state.status_width = res.windowWidth;
-				console.log('window width'+state.status_width);*/
-				
-				let scrollH = res.windowHeight;// - uni.upx2px(88) - navbarH
-				console.log('布局结果'+ JSON.stringify(res));
-				console.log('scrollH'+scrollH)
-				//#ifdef MP-WEIXIN
-				const {
-					statusBarHeight,
-					windowWidth,
-				} = uni.getSystemInfoSync();
-				console.log('height ' + statusBarHeight);
-				//this.status_height = uni.getStatusbarHeight();
-				let res1 =  uni.getMenuButtonBoundingClientRect()
-				console.log('layout selectHeight '+JSON.stringify(res1))
-				//state.selectHeight = (res1.top-res.statusBarHeight)*2+ res1.height;
-				//#endif
-				//console.log('status height'+state.status_height)
-				_self.$refs.amap.setMyStyle("height:"+(scrollH-88-50)+ "px;width:100%;");
-			}
-		})
+		
 //		this.$refs.amap.setMyStyle("height:1500rpx;width:100%;");
 //	this.$refs.amap.setMyStyle("height:calc(100%-176rpx);width:100%;");
 				
@@ -356,11 +343,218 @@ export default {
 		//		console.log('latitude3  '+this.latitude)
 	},
 	onShow() {
+		
+		console.log('onShow')
 		if (this.isReady) {
-			this.getNearbyStationInfo();
+			 
 		}
 	},
+	onHide(){
+		this.end();
+	},
 	methods: {
+		getPoint() {
+		
+			
+			WxJsApi.getLocation().then((res) => {
+				
+				var latitude = parseFloat(res.latitude);
+				var longitude = parseFloat(res.longitude);
+				let data = {position:{latitude:latitude,longitude:longitude}};
+				this.location(data);
+				//this.latitude2 = latitude;
+				//this.longitude2 = longitude;
+				/*uni.showToast({
+					title:JSON.stringify(res)
+				})*/
+				//this.message=JSON.stringify(res)
+			}).catch(error => {
+				uni.showToast({
+					title:JSON.stringify(error)
+				})					
+			})
+		},
+		start() {
+			let self = this;
+		  // 将定时器名字赋值到变量中
+		  this.timer = setInterval(() => {
+			//console.log("开始---");
+			
+			self.$refs.amap.getLocation1();
+			//self.$refs.amap.getLocation ();
+		  }, 10000);
+		},
+		end() {
+		  clearInterval(this.timer);
+		  this.timer = null // 这里最好清除一下,回归默认值
+		  // 众所周知,定时器返回一个随机整数,用于表示定时器的编号,后面通过名字可以取消这个定时器的执行。
+		  console.log(this.timer);
+		},
+		location(e){
+			if(e.position){
+				if(e.position.latitude && e.position.longitude)
+				if(this.latitude != e.position.latitude || 
+					this.longitude != e.position.longitude)
+					{
+						this.longitude = e.position.longitude;
+						this.latitude = e.position.latitude;
+						
+						let data = {latitude:this.latitude,longtitude:this.longitude,findType:"1"};
+						this.getChargingStationData(data);
+						console.log('获取定位'+JSON.stringify(e));
+						
+					}
+			}
+		},
+		getChargingStationData(pos){
+ 
+			if(pos == null)
+				return ;			
+//			console.log('getChargingStationData'+JSON.stringify(pos))
+			let data1 = { pageIndex:0,pageSize:20};
+			if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('直流快充')>=0)
+				data1.type = "1";
+			else if(this.info.obc_type[this.preference.obc_type_index].text.indexOf('交流慢充')>=0)
+				data1.type = "2";
+			if(pos.longtitude != null)
+				data1.longitude = pos.longtitude.toString();
+			if(pos.latitude != null)
+				data1.latitude = pos.latitude.toString(); 
+			if(this.info.miles_type[this.preference.miles_index].distance!=null)
+				data1.radius = this.info.miles_type[this.preference.miles_index].distance.toString();
+			data1.online = "0";//在线	
+			if(pos.findType != null)
+				data1.findType = pos.findType;
+			else
+				data1.findType = "0";
+			
+			if(this.preference.obc_power.minValue!=null)
+				data1.powerStart = this.preference.obc_power.minValue.toString();
+			if(this.preference.obc_power.maxValue!=null)
+				data1.powerEnd = this.preference.obc_power.maxValue.toString();
+			
+//			console.log('data1'+JSON.stringify(data1))
+			api.geChargingStationData(data1).then(function(res){
+				if(!res.result || !res.data || !res.data.data)
+					return;
+				let items = res.data.data;
+				
+
+				if(data1.findType == "0")
+				{
+//					console.log('res1'+JSON.stringify(res));
+					_self.stationsmap = [];
+					for(let i = 0;i<items.length;i++)
+					{
+						let obj = {
+									name:'',
+									position:'',
+									price:1.2,
+									idleNum:10,
+									total:10,									
+									type: data1.type == "2" ? '慢充':'快充',
+									id: i,									
+									distance:0.9,
+									time:9,
+									park: '以实际费用为准',
+//									longitude: 112.28541 + i * 0.001,
+//									latitude: 30.308354 + i * 0.01
+									};
+						if(items[i].name!=null)
+							obj.name = items[i].name;
+						if(items[i].address!=null)
+							obj.position = items[i].address;
+						if(items[i].coostPrice!=null)
+							obj.price = items[i].coostPrice;
+						if(items[i].availableNum!=null)
+							obj.idleNum = items[i].availableNum;
+						if(items[i].totalNum!=null)
+							obj.total = items[i].totalNum;
+						if(items[i].longitude!=null)
+							obj.longitude = items[i].longitude;
+						if(items[i].latitude!=null)
+							obj.latitude = items[i].latitude;
+						if(items[i].distance!=null)
+							obj.distance = items[i].distance;
+						if(items[i].time != null){
+							obj.time = items[i].time;
+						}
+						if(items[i].park != null)
+							obj.park = items[i].park;
+						/*
+						let obj = {name:items[i].name,
+									position:items[i].address,
+									price:items[i].coostPrice,									
+									idleNum:items[i].availableNum,
+									total:items[i].totalNum,
+									distance:0.1,
+									time:1,
+									type:'慢充',
+									id: items[i].id,
+									park: i%2 == 0? '以实际费用为准':'2小时免费停车',
+									longitude: items[i].longitude,
+									latitude: items[i].latitude
+									};*/
+						_self.stationsmap.push(obj);						
+					}
+					_self.$refs.amap.searchBtn([_self.longitude, _self.latitude],_self.stationsmap)
+ 					_self.$refs.amap.setChargerList(_self.stationsmap);
+				}else if(data1.findType == "1")
+				{
+					_self.stationslist = [];
+//					console.log('res2'+JSON.stringify(res));
+					for(let i = 0;i<items.length;i++)
+					{
+						
+						let obj = {
+								name:'',
+								position:'',
+								price:1.2,
+								idleNum:10,
+								total:10,									
+								type: data1.type == "2" ? '慢充':'快充',
+								id: i,									
+								distance:0.9,
+								time:9,
+								park: '以实际费用为准',
+	//									longitude: 112.28541 + i * 0.001,
+	//									latitude: 30.308354 + i * 0.01
+								};
+							if(items[i].name!=null)
+								obj.name = items[i].name;
+							if(items[i].address!=null)
+								obj.position = items[i].address;
+							if(items[i].coostPrice!=null)
+								obj.price = items[i].coostPrice;
+							if(items[i].availableNum!=null)
+								obj.idleNum = items[i].availableNum;
+							if(items[i].totalNum!=null)
+								obj.total = items[i].totalNum;
+							if(items[i].longitude!=null)
+								obj.longitude = items[i].longitude;
+							if(items[i].latitude!=null)
+								obj.latitude = items[i].latitude;
+							if(items[i].distance!=null)
+								obj.distance = items[i].distance;
+							if(items[i].time != null){
+								obj.time = items[i].time;
+							}
+							if(items[i].park != null)
+								obj.park = items[i].park;
+									//arr.push(obj);
+							_self.stationslist.push(obj);
+					}
+					_self.$refs.amap.searchBtn([_self.longitude, _self.latitude],_self.stationslist)
+					
+					console.log('stations'+JSON.stringify(_self.stationslist))
+					 
+				}
+			},function(err){
+				console.log('err'+JSON.stringify(err))
+			}
+			)
+			
+		},		
 		charge(item){
 			 console.log('扫码充电')
 			//#ifdef MP-WEIXIN
@@ -380,9 +574,11 @@ export default {
 			 	url:'stationAndPile/chargingPileDetails'
 			 })
 			
-		},
+		},		
 		moveEnd(e){
-			console.log('moveEnd'+JSON.stringify(e))
+			console.log('moveEnd'+JSON.stringify(e))			
+			let data = {latitude:e.center.lat,longtitude:e.center.lng};
+			this.getChargingStationData(data);
 		},
 		clickTabItem (index) {
 			
@@ -390,19 +586,23 @@ export default {
 		},
 		swiperChange (e) {
 			this.currentIndex = e.detail.current
-			let station = this.stations[this.currentIndex];
+			let station = this.stationsmap[this.currentIndex];
 			
 			let posCenter= {longitude: station.longitude,latitude: station.latitude};
-			console.log('currentIndex'+JSON.stringify(this.currentIndex))
-			console.log('currentIndex'+JSON.stringify(posCenter))
-			console.log('station'+JSON.stringify(station))
-			this.$refs.amap.setCenter(posCenter);
+//			console.log('currentIndex'+JSON.stringify(this.currentIndex))
+//			console.log('currentIndex'+JSON.stringify(posCenter))
+//			console.log('station'+JSON.stringify(station))
+			let bounds = this.$refs.amap.logMapInfo();
+			/*if( (posCenter.latitude<bounds.bounds.northeast.lat && posCenter.latitude>bounds.bounds.sourthwest.lat)
+			&&  (posCenter.longitude<bounds.bounds.northeast.lng && posCenter.longitude>bounds.bounds.sourthwest.lng)
+			){
+				console.log('bounds'+JSON.stringify(bounds));
+				
+			}else{			
+				this.$refs.amap.setCenter(posCenter);				
+			}*/
 			this.$refs.amap.updateCharger(station);
-			 //console.log('currentIndex'+e.detail.current)
-			/*if(e.detail.current>= 2) {
-			this.scrollIntoView = 'index' + (e.detail.current-2)
-			}
-			*/
+			  
 		},
 		swiperTransition (e) {
 			// console.log(e)
@@ -462,6 +662,8 @@ export default {
 		close() {
 			console.log('偏好设置' + JSON.stringify(this.preference));
 			this.show = false;
+			let data = {latitude:this.latitude,longtitude:this.longitude};
+			this.getChargingStationData(data);
 			// console.log('close');
 		},
 		// 获取当前位置
@@ -477,7 +679,7 @@ export default {
 							//obj.obj.price = 2.25;
 							//obj.obj.idleNum = 12;
 							_self.$refs.amap.updateCharger(obj.obj);
-							let index = _self.stations.findIndex(item => item.id == obj.obj.id);
+							let index = _self.stationsmap.findIndex(item => item.id == obj.obj.id);
 							_self.currentIndex = index;
 							console.log('find Index'+index);
 						}
@@ -493,7 +695,41 @@ export default {
 			//console.log('this'+JSON.stringify(this))
 //			console.log('longitude1  ' + this.longitude);
 //			console.log('latitude1  ' + this.latitude);
-
+			//this.start();
+			//this.$refs.amap.getLocation1();
+			this.getNearbyStationInfo();
+			this.isReady = true;
+			//this.$refs.amap.getLocation ();
+			//let state = {};
+			uni.getSystemInfo({
+				success: (res) => {
+					// #ifndef MP
+					let navbarH = 0
+					// #endif
+					// #ifdef MP
+					let navbarH = uni.upx2px(90)
+					// #endif
+					/*state.status_width = res.windowWidth;
+					console.log('window width'+state.status_width);*/
+					
+					let scrollH = res.windowHeight;// - uni.upx2px(88) - navbarH
+	//				console.log('布局结果'+ JSON.stringify(res));
+	//				console.log('scrollH'+scrollH)
+					//#ifdef MP-WEIXIN
+					const {
+						statusBarHeight,
+						windowWidth,
+					} = uni.getSystemInfoSync();
+	//				console.log('height ' + statusBarHeight);
+					//this.status_height = uni.getStatusbarHeight();
+					let res1 =  uni.getMenuButtonBoundingClientRect()
+	//				console.log('layout selectHeight '+JSON.stringify(res1))
+					//state.selectHeight = (res1.top-res.statusBarHeight)*2+ res1.height;
+					//#endif
+					//console.log('status height'+state.status_height)
+					_self.$refs.amap.setMyStyle("height:"+(scrollH-88-50)+ "px;width:100%;");
+				}
+			})
 			var obj = {
 				longitude: _self.longitude,
 				latitude: _self.latitude
@@ -504,31 +740,7 @@ export default {
 				longitude: this.nearbyStationInfo.longitude,
 				latitude: this.nearbyStationInfo.latitude
 			};*/
-			let arr = [];
-			for (let i = 0; i < 10; i++) {
-				let obj = {name:'荆鹏软件园充电站'+i.toString(),
-							position:'湖北省荆州市沙市区江津东路附155号',
-							price:1.2,idleNum:10,total:10,distance:0.1,
-							time:1,
-							type:'慢充',
-							id: i,
-							park: i%2 == 0? '以实际费用为准':'2小时免费停车',
-							longitude: 112.28541 + i * 0.001,
-							latitude: 30.308354 + i * 0.01
-							};
-				if(i%2 == 0){
-					obj.longitude = 112.28571 ;
-					obj.latitude = 30.307539;
-				}else{
-					obj.type = '快充';
-				}
-				
-				//arr.push(obj);
-				this.stations.push(obj);
-			}
-			console.log('stations'+JSON.stringify(this.stations))
-
-			this.$refs.amap.setChargerList(this.stations);
+			
 			//this.$refs.amap.setPerson(obj);
 			//this.$refs.amap.setSite(obj2);
 		},
@@ -547,22 +759,13 @@ export default {
 		},
 
 		getNearbyStationInfo() {
-			var obj = {
-				longitude: this.longitude,
-				latitude: this.latitude,
-				id: this.id
-			};
+			
+			let data1 = {latitude:this.latitude,longtitude:this.longitude,findType:"1"};
+			this.getChargingStationData(data1);
+			let data2 = {latitude:this.latitude,longtitude:this.longitude,findType:"0"};
+			this.getChargingStationData(data2);
 
-			//this.$refs.common.showLoading();
-			/*
-					API.nearbyStationInfo(obj).then((res) => {
-						this.nearbyStationInfo=res.data;
-						
-						this.$refs.common.showLoading(false);
-					}).catch(error => {
-						this.$refs.common.showLoading(false,error);
-						
-					})*/
+			 
 		}
 	}
 };

+ 6 - 0
pages/user/data.vue

@@ -22,11 +22,17 @@
 	export default {
 		data() {
 			return {
+				userId: '',
 				form: {
 					name: '',
 				},
 			}
 		},
+		onReady() {
+			if(this.carhelp.getPersonInfo() != null) {
+				this.userId = this.carhelp.getPersonInfo().id;
+			}
+		},
 		methods: {
 		}
 	}

+ 5 - 0
pages/user/finance/recharge.vue

@@ -47,6 +47,7 @@
 	export default {
 		data() {
 			return {
+				userId: '',
 				detail:{},
 				moneyActiveClass: 1,
 				moneyList: [
@@ -70,6 +71,10 @@
 			}
 		},
 		onReady() {
+			if(this.carhelp.getPersonInfo() != null) {
+				this.userId = this.carhelp.getPersonInfo().id;
+			}
+			
 			this.init();
 		},
 		methods: {

+ 5 - 0
pages/user/finance/rechargeList.vue

@@ -31,6 +31,7 @@
 	export default {
 		data() {
 			return {
+				userId: '',
 				params: {
 					year: true,
 					month: true,
@@ -48,6 +49,10 @@
 			}
 		},
 		onReady() {
+			if(this.carhelp.getPersonInfo() != null) {
+				this.userId = this.carhelp.getPersonInfo().id;
+			}
+			
 			var date = new Date();
 			this.date.year = date.getFullYear();
 			this.date.month = date.getMonth() + 1;

+ 77 - 20
pages/user/index.vue

@@ -1,11 +1,19 @@
 <template>
 	<view>
-		<view class="userHead">
+		<view class="userHead" v-if="userId != ''" @click="toData">
+			<view class="userHead-img">
+				<u-avatar :src="headImg" size="96"></u-avatar>
+			</view>
+			<view class="userHead-text">
+				<h3>{{userPhone}}</h3>
+			</view>
+		</view>
+		<view class="userHead" v-else>
 			<view class="userHead-img">
 				<u-avatar src="../../assets/img/head.png" size="96"></u-avatar>
 			</view>
 			<view class="userHead-text">
-				<h3>177****8888</h3>
+				<h3>点击登录/注册</h3>
 			</view>
 		</view>
 		<view class="userData">
@@ -79,6 +87,8 @@
 		data() {
 			return {
 				userId: '',
+				headImg: '',
+				userPhone: '',
 				show: false,
 				title: '联系客服',
 				content: '0716-8123456',
@@ -89,35 +99,82 @@
 			}
 		},
 		onReady() {
-			if(this.carhelp.getPersonInfo().id != null) {
+			if(this.carhelp.getPersonInfo() != null) {
 				this.userId = this.carhelp.getPersonInfo().id;
+				this.headImg = this.carhelp.getPersonInfo().headImg;
+				
+				var phone = this.carhelp.getPersonInfo().phone;
+				var phone1 = phone.slice(0,3);
+				var phone2 = phone.slice(-4);
+				this.userPhone = phone1 + '****' + phone2;
 			}
 		},
 		methods: {
-			toBalance() {
-				uni.navigateTo({
-					url: '/pages/user/finance/balance'
-				})
+			toData() {			
+				if(this.userId != '') {
+					uni.navigateTo({
+						url: '/pages/user/data'
+					})
+				} else {
+					uni.redirectTo({
+						url: '/pages/login/login'
+					})
+				}
 			},
-			toRecharge() {
-				uni.navigateTo({
-					url: '/pages/user/finance/recharge'
-				})
+			toBalance() {			
+				if(this.userId != '') {
+					uni.navigateTo({
+						url: '/pages/user/finance/balance'
+					})
+				} else {
+					uni.redirectTo({
+						url: '/pages/login/login'
+					})
+				}
+			},
+			toRecharge() {	
+				if(this.userId != '') {
+					uni.navigateTo({
+						url: '/pages/user/finance/recharge'
+					})
+				} else {
+					uni.redirectTo({
+						url: '/pages/login/login'
+					})
+				}
 			},
 			carManage() {
-				uni.navigateTo({
-					url: '/pages/user/car/index'
-				})
+				if(this.userId != '') {
+					uni.navigateTo({
+						url: '/pages/user/car/index'
+					})
+				} else {
+					uni.redirectTo({
+						url: '/pages/login/login'
+					})
+				}
 			},
 			feedback() {
-				uni.navigateTo({
-					url: '/pages/user/message'
-				})
+				if(this.userId != '') {
+					uni.navigateTo({
+						url: '/pages/user/message'
+					})
+				} else {
+					uni.redirectTo({
+						url: '/pages/login/login'
+					})
+				}		
 			},
 			setUp() {
-				uni.navigateTo({
-					url: '/pages/user/setting'
-				})
+				if(this.userId != '') {
+					uni.navigateTo({
+						url: '/pages/user/setting'
+					})
+				} else {
+					uni.redirectTo({
+						url: '/pages/login/login'
+					})
+				}
 			},
 			openModal() {
 				this.show = true;

+ 109 - 7
pages/user/phone.vue

@@ -4,33 +4,135 @@
 		<view class="login-form">
 			<view class="login-form-item">
 				<view class="input">
-					<u-input v-model="tel" type="number" placeholder="请输入手机号" placeholder-style="font-size:16px;color:#ccc;"/>
+					<u-input v-model="form.telephone" type="number" placeholder="请输入手机号" placeholder-style="font-size:16px;color:#ccc;"/>
 				</view>
 			</view>
 			<view class="login-form-item">
 				<view class="input">
-					<view class="code">获取验证码</view>
-					<u-input v-model="tel" type="number" placeholder="请输入验证码" placeholder-style="font-size:16px;color:#ccc;"/>
+					<view class="code" @click="getCode">{{codeTips}}</view>
+					<u-input v-model="form.verifyCode" type="number" placeholder="请输入验证码" placeholder-style="font-size:16px;color:#ccc;"/>
 				</view>
 			</view>
 		</view>
 		
 		<u-button class="login-btn" type="success" shape="circle" @click="sure">确定修改</u-button>
+		
+		<u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start" change-text="已发送(XS)">
+		</u-verification-code>
 	</view>
 </template>
 
 <script>
+	import {
+		checkPhone
+	} from '@/utils'
+	
 	export default {
 		data() {
 			return {
-				tel:'',
+				form: {
+					telephone: '',
+					verifyCode: '',
+				},
+				isSendMsgIng: false,
+				sendMsgSecond: 60,
+				codeTips: '',
 			}
 		},
 		methods: {
+			codeChange(text) {
+				this.codeTips = text;
+			},
+			start() {
+				if (!this.isSendMsgIng) {
+					uni.showLoading({
+						title: "加载中",
+						mask: true,
+					})
+					loginApi.getVerifyCode(this.form.telephone).then((response) => {
+						uni.hideLoading();
+						this.carhelp.set("getvcodetime", new Date().getTime());
+			
+						if (!"") {
+							//倒计时
+							uni.showToast({
+								title: "发送成功"
+							})
+						} else {
+							uni.showToast({
+								title: "您的验证码已经发送[5分钟有效],请勿重复点击"
+							})
+						}
+					}).catch(error => {
+						uni.showToast({
+							title: error,
+							icon: "none"
+						})
+					})
+				}
+			},
+			//倒计时
+			end() {
+				this.sendMsgSecond = 60;
+				this.isSendMsgIng = false;
+			},
+			// 获取验证码
+			getCode() {
+				if (this.$refs.uCode.canGetCode) {} else {
+					uni.showToast({
+						title: '倒计时结束后再发送',
+						icon: "none"
+					})
+					return
+				}
+			
+				var checkPhoneResult = checkPhone(this.form.telephone);
+			
+				if (checkPhoneResult !== true) {
+					uni.showToast({
+						title: checkPhoneResult,
+					})
+					return;
+				}
+				this.$refs.uCode.start();
+			},
 			sure() {
-				uni.redirectTo({
-					url: '/pages/login/login'
-				})
+				var checkPhoneResult = checkPhone(this.form.telephone);
+				
+				if(!this.form.telephone || checkPhoneResult != true) {
+					uni.showToast({
+						title: checkPhoneResult,
+						icon: "none"
+					})
+					return;
+				}
+				if(!this.form.verifyCode) {
+					uni.showToast({
+						title: "请输入验证码",
+						icon: "none"
+					})
+					return
+				}
+				
+				// uni.showLoading({
+				// 	title: "加载中",
+				// 	mask: true,
+				// })		
+				// loginApi.validateCode({
+				// 	verifyCode: this.form.verifyCode,
+				// 	telephone: this.form.telephone,
+				// }).then((response) => {
+				// 	uni.hideLoading();
+					
+					uni.redirectTo({
+						url: '/pages/login/login'
+					})
+				// }).catch(error => {
+				// 	uni.showToast({
+				// 		title: error,
+				// 		icon: "none"
+				// 	})
+				// })
 			}
 		}
 	}

+ 13 - 1
pages/user/setting.vue

@@ -2,7 +2,7 @@
 	<view>
 		<u-navbar title="设置"></u-navbar>
 		<u-cell-group>
-			<u-cell-item title="修改手机号" value="155****1111" @click="gotoUrl('pages/user/phone')"></u-cell-item>
+			<u-cell-item title="修改手机号" v-model="userPhone" @click="gotoUrl('pages/user/phone')"></u-cell-item>
 			<u-cell-item title="注销账号" value="注销后无法恢复,请谨慎操作" :value-style="valueStyle" @click="gotoUrl('pages/user/logout')"></u-cell-item>
 		</u-cell-group>
 		<view class="logout-btn" @click="signOut">
@@ -15,11 +15,23 @@
 	export default {
 		data() {
 			return {
+				userId: '',
+				userPhone: '',
 				valueStyle: {
 					color:'#ff3300',
 				}
 			}
 		},
+		onReady() {
+			if(this.carhelp.getPersonInfo() != null) {
+				this.userId = this.carhelp.getPersonInfo().id;
+				
+				var phone = this.carhelp.getPersonInfo().phone;
+				var phone1 = phone.slice(0,3);
+				var phone2 = phone.slice(-4);
+				this.userPhone = phone1 + '****' + phone2;
+			}
+		},
 		methods: {
 			signOut() {
 				uni.redirectTo({

二進制
static/img/充电中-缺省页.png


二進制
static/img/已充满-缺省页.png


二進制
static/img/等待中-缺省页.png


+ 1 - 1
utils/AMap.js

@@ -5,7 +5,7 @@ export default function MapLoader() {
 		if (window.AMap) {
 			resolve(window.AMap)
 		} else {
-			console.log("map")
+//			console.log("map")
 			var script = document.createElement('script')
 			script.type = 'text/javascript'
 			script.async = true