Browse Source

包月以及地图图标移动点击

zaijin 3 years ago
parent
commit
537f5c9c3c

+ 22 - 0
pages.json

@@ -98,6 +98,28 @@
             }
             
         }
+        ,{
+            "path" : "pages/handleMonthly/handleMonthly",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "办理包月",
+                "enablePullDownRefresh": false,
+                "navigationBarBackgroundColor": "#008CFF",
+                "navigationBarTextStyle": "white"
+            }
+            
+        }
+        ,{
+            "path" : "pages/center/monthly/monthly",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "我的包月",
+                "enablePullDownRefresh": false,
+                "navigationBarBackgroundColor": "#008CFF",
+                "navigationBarTextStyle": "white"
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

+ 1 - 1
pages/center/index.vue

@@ -32,7 +32,7 @@
 				<u-cell-item title="充值" @click="openPage('pages/myCars/myCars')">
 					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="chongzhi"></u-icon>
 				</u-cell-item>
-				<u-cell-item title="包月" @click="openPage('pages/center/order/order')">
+				<u-cell-item title="包月" @click="openPage('pages/center/monthly/monthly')">
 					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="baoyue"></u-icon>
 				</u-cell-item>
 				<u-cell-item title="提现" @click="openPage('pages/center/order/order')">

+ 14 - 0
pages/center/monthly/monthly.scss

@@ -0,0 +1,14 @@
+.monthly {
+	background-color: #F6F6FF;
+	padding: 37rpx 40rpx;
+	height: calc(100vh - 88rpx);
+	.monthly-list {
+		.monthly-list-item {
+			width: 100%;
+			background-color: #fff;
+			border-radius: 15rpx;
+			padding: 26rpx 39rpx;
+			margin-bottom: 20rpx;
+		}
+	}
+}

+ 62 - 0
pages/center/monthly/monthly.vue

@@ -0,0 +1,62 @@
+<template>
+	<!-- 包月 -->
+	<view class="monthly">
+		<view class="monthly-list">
+			<view class="monthly-list-item" v-for="(item, index) in monthlyList" :key="index">
+				<view class="monthly-list-item-top">
+					<view class="mlit-left">
+						<view>{{item.name}}</view>
+						<view>{{item.parking}}</view>
+					</view>
+					<view class="mlit-right">汽油车</view>
+				</view>
+				<view class="monthly-list-item-bottom">
+					<view>包期:{{item.dateRange}}</view>
+					<view>剩余天数:{{item.balance}}天</view>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				monthlyList: [
+					{
+						id: 1,
+						name: '贵A37W45',
+						parking: '甜蜜小镇D18组团停车场',
+						dateRange: '2021.04.21-2021.05.20',
+						balance: '20',
+						carType: 1
+					},
+					{
+						id: 2,
+						name: '贵A37W45',
+						parking: '甜蜜小镇D18组团停车场',
+						dateRange: '2021.04.21-2021.05.20',
+						balance: '20',
+						carType: 3
+					},
+					{
+						id: 3,
+						name: '贵A37W45',
+						parking: '甜蜜小镇D18组团停车场',
+						dateRange: '2021.04.21-2021.05.20',
+						balance: '20',
+						carType: 1
+					}
+				]
+			}
+		},
+		methods: {
+			
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+@import './monthly.scss';
+</style>

+ 72 - 0
pages/handleMonthly/handleMonthly.scss

@@ -0,0 +1,72 @@
+.handle-monthly {
+	padding: 40rpx;
+	.handle-monthly-item {
+		display: flex;
+		flex-direction: row;
+		border-bottom: solid 1rpx #CECECE;
+		height: 96rpx;
+		line-height: 96rpx;
+		>view {
+			&:first-child {
+				width: 22%;
+				color: #757575;
+				font-size: 36rpx;
+				font-weight: 400;
+				text-align: justify;
+				text-align-last: justify;
+				margin-right: 8%;
+			}
+			&:last-child {
+				width: 70%;
+				color: #404040;
+				font-size: 36rpx;
+				font-weight: 400;
+			}
+		}
+		.choose-license {
+			display: flex;
+			justify-content: space-between;
+		}
+		.handle-monthly-money {
+			color: #F97219!important;
+		}
+		.handle-monthly-time-long {
+			display: flex;
+			flex-direction: row;
+			align-items: center;
+			button {
+				margin: 0;
+				padding: 0;
+				width: 46rpx;
+				height: 46rpx;
+				line-height: 40rpx;
+				border: solid 1px #008CFF;
+				color: #008CFF;
+				text-align: center;
+			}
+			view {
+				padding: 0 61rpx;
+			}
+		}
+	}
+	.handle-monthly-explain {
+		font-size: 24rpx;
+		line-height: 40rpx;
+		color: #3A3A3A;
+		font-weight: 400;
+	}
+	.handle-monthly-confirm-button {
+		width: calc(100% - 60rpx);
+		margin: 52rpx auto;
+		button {
+			width: 100%;
+			height: 100rpx;
+			line-height: 100rpx;
+			background-color: #008CFF;
+			color: #fff;
+			font-size: 28rpx;
+			font-weight: 500;
+			border-radius: 10rpx;
+		}
+	}
+}

+ 127 - 0
pages/handleMonthly/handleMonthly.vue

@@ -0,0 +1,127 @@
+<template>
+	<view class="handle-monthly">
+		<view class="handle-monthly-item">
+			<view>车牌选择</view>
+			<view class="choose-license" @click="isShowCarLicense = true">
+				<view>{{form.carLicense.label}}</view>
+				<u-icon name="arrow-down" color="#7B7B7B" size="30"></u-icon>
+			</view>
+		</view>
+		<u-select v-model="isShowCarLicense" :list="carLicenseList" @confirm="carLicenseListConfirm"></u-select>
+		<view class="handle-monthly-item">
+			<view>车辆信息</view>
+			<view>汽油车</view>
+		</view>
+		<view class="handle-monthly-item">
+			<view>包月金额</view>
+			<view class="handle-monthly-money">200元</view>
+		</view>
+		<view class="handle-monthly-item">
+			<view>包月时长</view>
+			<view class="handle-monthly-time-long">
+				<button @click="reduceMonthNum()">-</button>
+				<view>{{form.month}}个月</view>
+				<button @click="addMonthNum()">+</button>
+			</view>
+		</view>
+		<view class="handle-monthly-item">
+			<view>包期</view>
+			<view>{{form.dateRange}}</view>
+		</view>
+		<view class="handle-monthly-explain">
+			<view>包月说明</view>
+			<view>1、停车不足30分钟,免费;</view>
+			<view>2、停车 超过20分钟,按2元/小时收费;</view>
+			<view>3、月卡会员在有效期内停车免费</view>
+		</view>
+		<view class="handle-monthly-confirm-button">
+			<button type="default">确认包月</button>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				carLicenseList: [
+					{
+						value: 1, label: '贵AWE45T'
+					},
+					{
+						value: 2, label: '贵AWE45F'
+					},
+				],
+				isShowCarLicense: false,
+				form: {
+					carLicense: {
+						value: 2,
+						label: '贵AWE45F'
+					},
+					month: 1,
+					dateRange: this.getMonthRange(new Date(), 1)
+				}
+			}
+		},
+		onLoad () {
+		},
+		methods: {
+			/**
+			  * 获取几个月的日期范围
+			  * {date} Date 起始日期,往后推一天
+			  * {monthNum} Number  往后月数 
+			  * */
+			getMonthRange (date, monthNum) {
+				let Date1 = new Date(date)
+				Date1 = Date1.valueOf() + 24 * 60 * 60 * 1000
+				Date1 = new Date(Date1)
+				const year = Date1.getFullYear()
+				const month = Date1.getMonth()
+				const day = Date1.getDate()
+				let days = new Date(year, month, 0)
+				days = days.getDate() //获取当前日期中的月的天数
+				let year2 = year;
+				let month2 = parseInt(month) + parseInt(monthNum)
+				if (month2 >12) {
+					year2 = parseInt(year2) + parseInt((parseInt(month2) / 12 == 0 ? 1 : parseInt(month2) / 12))
+					month2 = parseInt(month2) % 12;
+				}
+				const day2 = day;
+				let days2 = new Date(year2, month2, 0)
+				days2 = days2.getDate()
+				if (day2 > days2) {
+					day2 = days2
+				}
+				if (month2 < 10) {
+					month2 = '0' + month2;
+				}
+				const t1 = year + '.' + (month > 9 ? month : '0' + month) + '.' + (day > 9 ? day : '0' + day)
+				const t2 = year2 + '.' + month2 + '.' + day2
+				return t1 + '-' + t2
+			},
+			/**
+			 * 月操作 减1
+			  * */
+			reduceMonthNum () {
+				if (this.form.month > 1) {
+					this.form.month -= 1
+					this.form.dateRange = this.getMonthRange(new Date, this.form.month)
+				}
+			},
+			/**
+			 * 月操作 加1
+			  * */
+			addMonthNum () {
+				this.form.month += 1
+				this.form.dateRange = this.getMonthRange(new Date, this.form.month)
+			},
+			carLicenseListConfirm (item) {
+				this.form.carLicense = item[0]
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+@import './handleMonthly.scss';
+</style>

+ 3 - 0
pages/parkingLists/parkingLists.scss

@@ -187,6 +187,9 @@
 	background-color: #008CFF;
 	color: #fff;
 }
+.swiper-item-button .disabled {
+	background-color: #858585!important;
+}
 .loading {
 	width: 100%;
 	height: calc(100vh - 100rpx);

+ 66 - 36
pages/parkingLists/parkingLists.vue

@@ -8,7 +8,7 @@
 			<u-icon v-if="!searchContent" class="icon" name="list" size="44" color="#ffffff"
 			placeholder-color="#B5B5B5" search-icon-color="#B3B3B3"></u-icon>
 			<u-icon v-if="searchContent" class="icon" name="close" size="36" color="#ffffff"
-			placeholder-color="#B5B5B5" search-icon-color="#B3B3B3"></u-icon>
+			placeholder-color="#B5B5B5" search-icon-color="#B3B3B3" @click="clearSearchInput"></u-icon>
 		</view>
 		<view class="parking-map">
 			<map
@@ -20,11 +20,11 @@
 				@markertap="markertap"
 				:enable-traffic="true"
 				:enable-zoom="true"
+				:scale="scale"
 				:markers="covers"></map>
 		</view>
-		
 		<!-- <u-empty src="/static/img/empty.png" icon-size="335" text="正在建设中" color="#878787" mode="search"></u-empty> -->
-		<view class="parking-current-address" v-if="searchParkingList.length === 0">
+		<view class="parking-current-address" v-if="nearParkingFlag">
 			<swiper class="swiper" :current="swiperCurrent" :indicator-dots="false" :autoplay="false" previous-margin="30rpx" next-margin="30rpx" @change="swiperChange">
 				<swiper-item v-for="(item, index) in nearParkingList" :key="index + 'n'">
 					<view class="swiper-item">
@@ -35,9 +35,9 @@
 								<text>余位</text>
 								<text class="yellow-font">{{item.spaceIdle}}</text>
 							</view>
-							<view>
+							<view v-if="item.monthAmount">
 								<text>包月费用</text>
-								<text class="yellow-font">300元</text>
+								<text class="yellow-font">{{item.monthAmount}}元</text>
 							</view>
 							<view>
 								<text>距离</text>
@@ -46,7 +46,7 @@
 						</view>
 						<view class="swiper-item-button">
 							<button type="default" @click="navigation(item.latitude, item.longitude)">导航</button>
-							<button type="default">办理包月</button>
+							<button type="default" :disabled="!item.monthAmount" :class="{'disabled': !item.monthAmount}" @click="$u.route({url: 'pages/handleMonthly/handleMonthly'})">办理包月</button>
 						</view>
 						<view @click="$u.route({url: 'pages/chargeStandard/chargeStandard'})">
 							<text>点击查看停车规则</text>
@@ -112,9 +112,10 @@
 				searchContent: '',
 				page_map:'',
 				loading: false,
-				id: 0, //使用 marker点击事件 需要填写id
+				// id: 0, //使用 marker点击事件 需要填写id
 				latitude: 26.64969,
 				longitude: 106.636453,
+				scale: 16,
 				currentPosition: {
 					latitude: 26.64969,
 					longitude: 106.636453,
@@ -133,6 +134,8 @@
 					// 	iconPath: require('./../../static/img/parking-icon.png')
 					// }
 				],
+				// 附近列表是否显示
+				nearParkingFlag: false,
 				// 轮播选中
 				swiperCurrent: 0,
 				// 附近停车列表
@@ -148,16 +151,12 @@
 			}
 		},
 		onLoad(){
-			// this.page_map = uni.createMapContext("pagemap", this);
-			// console.log('page_map',this.page_map);
-			// this.getNearRoadsl();
-			console.log('load')
+			this.getLocation()
 		},
 		onShow() {
-			console.log('show')
 			this.isShowSearchParking = false
 			this.isShowParkingDetail = false
-			this.getLocation()
+			// this.getNearRoadsl()
 		},
 		methods:{
 			/* 
@@ -165,17 +164,17 @@
 			 * 
 			 * */
 			searchInputChange (value) {
-				console.log(value)
+				// 为空时关闭搜索列表
 				if (value === '') {
-					this.isShowParkingDetail = false
 					this.isShowSearchParking = false
 				}
+				this.isShowParkingDetail = false
 				this.getNearRoadsl()
 			},
 			getLocation(){
 				let that = this;
 				console.log("请求定位")
-				// that.loading = true
+				that.loading = true
 				uni.getLocation({
 					type:"gcj02",
 					success : function (res) {
@@ -184,12 +183,14 @@
 						that.longitude = res.longitude;
 						that.currentPosition.latitude = res.latitude
 						that.currentPosition.longitude = res.longitude
-						console.log(that.currentPosition)
 						that.loading = false
 						that.getNearRoadsl()
 					},
 					fail: function(res){
-						console.log("请求错误:", res)
+						this.$refs.uToast.show({
+							title: res,
+							type: 'error',
+						})
 					}
 				})
 			},
@@ -199,38 +200,60 @@
 			navigation (lat, lon) {
 				uni.openLocation({
 					latitude: parseFloat(lat),
-					longitude:parseFloat(lon),
+					longitude: parseFloat(lon),
 					scale: 18
 				})
 			},
-			async getNearRoadsl(){
+			clearSearchInput () {
+				this.searchContent = ''
+				this.getNearRoadsl()
+			},
+			/**
+			 * lon,lat 为当前选中点的经纬度
+			 * */
+			getNearRoadsl(lon, lat){
 				// await this.getLocation();
-				console.log(this.currentPosition)
 				this.$u.api.nearRoadsl({
 					latitude: this.currentPosition.latitude,
 					longitude:this.currentPosition.longitude,
 					roadName: this.searchContent
 				})
 				.then(res=>{
-					const nearParkingList = []
-					res.data.forEach((item, index)=>{
+					const nearParkingList = [] // 附近停车场列表
+					this.covers = []
+					res.data.forEach((item, index, arr)=>{
 						if(item.latitude&&item.longitude){
 							nearParkingList.push(item)
 							let marker = {
 								latitude: item.latitude,
-								longitude:item.longitude,
-								// id: '1',
-								iconPath: require('./../../static/img/parking-icon.png')
+								longitude: item.longitude,
+								id: String(index),
+								iconPath: require('./../../static/img/parking-icon.png'),
+								width: 20,
+								height: 25
+							}
+							if (lon && lat) {
+								if (lon === item.longitude && lat === item.latitude) {
+									marker.width = 40
+									marker.height = 50
+								}
+							} else {
+								if (index === 1) {
+									marker.width = 40
+									marker.height = 50
+								}
 							}
-							this.covers.push(marker);
+							this.covers.push(marker)
 						}
 					})
 					this.nearParkingList = nearParkingList
 					this.latitude = nearParkingList[0].latitude
 					this.longitude = nearParkingList[0].longitude
+					this.nearParkingFlag = true
 					if (this.searchContent) {
 						this.searchParkingList = nearParkingList
 						this.isShowSearchParking = true
+						this.nearParkingFlag = false
 					}
 				}).catch(err=>{
 					this.$refs.uToast.show({
@@ -243,22 +266,27 @@
 			 * 点击地图上的标记点触发
 			 * */
 			markertap(e){
-				console.log(e)
-				for (let i = 0; i < this.nearParkingList.length; i++) {
-					let item = this.nearParkingList[i]
-					if (item.latitude === e.latitude && item.longitude === e.longitude) {
-						this.swiperCurrent = i
+				let lon,lat
+				this.covers.forEach((item, index) => {
+					if (e.detail.markerId === item.id) {
+						lon = item.longitude
+						lat = item.latitude
+						this.swiperCurrent = index
 					}
-				}
+				})
+				this.getNearRoadsl(lon, lat)
 			},
 			/* 
 			 *地址发生变化
 			 * 
 			 * */
 			swiperChange (item) {
-				console.log(item.detail)
-				this.latitude = this.nearParkingList[item.detail.current].latitude
-				this.longitude = this.nearParkingList[item.detail.current].longitude
+				let map = uni.createMapContext('pagemap');
+				map.moveToLocation({
+					longitude: this.nearParkingList[item.detail.current].longitude,
+					latitude: this.nearParkingList[item.detail.current].latitude
+				})
+				this.getNearRoadsl(this.nearParkingList[item.detail.current].longitude, this.nearParkingList[item.detail.current].latitude)
 			},
 			/**
 			  * 点击单个停车场看详情
@@ -270,6 +298,8 @@
 				this.isShowSearchParking = false
 				this.latitude = item.latitude
 				this.longitude = item.longitude
+				this.getNearRoadsl(item.longitude, item.latitude)
+				this.scale = 18
 			}
 		}
 	}

BIN
static/img/parking-icon.png