Sfoglia il codice sorgente

更新了每天的剩余数据

soft5566 2 anni fa
parent
commit
92b7fd6595
4 ha cambiato i file con 126 aggiunte e 31 eliminazioni
  1. 10 0
      pages/index/css/index.css
  2. 96 19
      pages/index/index.vue
  3. 0 11
      pages/order_room/order_room.vue
  4. 20 1
      utils/common.js

+ 10 - 0
pages/index/css/index.css

@@ -295,6 +295,16 @@
 	font-weight: 500;
 }
 
+.room-num {
+	position: absolute;
+	/* margin-left: 605rpx; */
+	margin-top: 58rpx;
+	margin-left: 580rpx;
+	color: rgba(166, 166, 166, 1.0);
+	font-size: 22rpx;
+	font-weight: 500;
+}
+
 .room-button {
 	position: absolute;
 	margin-left: 579rpx;

+ 96 - 19
pages/index/index.vue

@@ -75,7 +75,6 @@
 			<!-- 房型列表 -->
 			<view class="room-kuang">
 				<view class="room-xinxi" v-for="(item, index) in roomType" :key="index">
-					<!-- <image v-if="item.h_type.indexOf('标准') !== -1" class="room-image" src="../../static/index/std.jpg" @click="inputDialogToggle(item.id)"></image> -->
 					<image v-if="item.h_type.indexOf('标准') !== -1" class="room-image" src="../../static/index/std.jpg" @click="inputDialogToggle(item.h_type)">
 					</image>
 					<image v-else-if="item.h_type.indexOf('高级') !== -1" class="room-image" src="../../static/index/adv1.jpg"
@@ -92,8 +91,8 @@
 						<image src="../../static/index/index_nosmoking.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
 						<image src="../../static/index/index_lock.svg" style="width: 30rpx;height: 30rpx;margin-left: 10rpx;"></image>
 					</view>
-					<!-- <view class="before-price"><strike>¥{{item.price}}</strike></view> -->
 					<view class="room-price">¥{{ item.price }}</view>
+					<view class="room-num">今剩{{ item.s_yum }}间</view>
 					<view class="room-button" :class="{'room-button2': item.s_yum == 0}">
 						<text v-if="item.s_yum == 0">已满</text>
 						<text v-else @click="navigateToOrderRoom(item.s_yum, item.id, item.h_type, item.price)">订</text>
@@ -229,7 +228,11 @@
 				dai_type: [], // 办理入住判断条件
 				dai_panduan: [], // 办理入住判断条件赋值
 				order_txt: '', //订房事故时信息
-				cardNumber: ''
+				cardNumber: '',
+				dates: [],
+				biaozhun_min: 1000,
+				gaoji_min: 1000,
+				haohua_min: 1000
 			}
 		},
 		onLoad(options) {
@@ -358,23 +361,45 @@
 		},
 		onShow() {
 			// 获取房型
-			this.getRoomType()
+			this.getRoomType('')
 		},
 		methods: {
 			// 房型接口
-			getRoomType() {
+			getRoomType(param) {
 				let that = this
+				let d = ''
 				that.roomType = []
-				// ?startDate=" + that.startDate.substring(0, 10) + "&endDate=" + that.endDate.substring(0, 10)
-				var arrDate = this.$utils.getDateComponents(new Date(), 'date');
+				if (param == '') {
+					var arrDate = this.$utils.getDateComponents(new Date(), 'date');
+					d = arrDate.date
+				} else
+					d = param
 				that.$myRequest({
-					url: '/hotelReservation/zhotel/appday_list.action?date=' + arrDate.date,
+					url: '/hotelReservation/zhotel/appday_list.action?date=' + d,
 				}).then(res => {
 					// console.log(res.data);
 					if (res.data.code === 200) {
 						let data = res.data.data;
 						data.forEach(item => {
-							that.roomType.push(item)
+							let it = {
+								date: item.date,
+								h_type: item.h_type,
+								id: item.id,
+								price: item.price,
+								y_num: item.y_num,
+								z_num: item.z_num,
+								s_yum: item.s_yum
+							}
+							if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
+								that.biaozhun_min = item.s_yum
+							}
+							if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
+								that.gaoji_min = item.s_yum
+							}
+							if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
+								that.haohua_min = item.s_yum
+							}
+							that.roomType.push(it)
 						});
 					} else {
 						uni.showToast({
@@ -562,7 +587,7 @@
 							}
 						})
 					}
-					console.log(this.xuzhu_panduan)
+					// console.log(this.xuzhu_panduan)
 					if (this.xuzhu_panduan.length > 1) {
 						uni.navigateTo({
 							url: "/pages/my_orderlist/my_orderlist?Inv=3"
@@ -586,17 +611,69 @@
 				this.$refs.popup_picker.open()
 			},
 			change(e) {
+				var that = this;
 				var before = e.range.before;
 				var after = e.range.after;
-				this.info.selected = [{
-						date: before,
-						info: '到店'
-					},
-					{
-						date: after,
-						info: '离店'
-					}
-				];
+
+				if (before !== '' && after === '')
+					this.getRoomType(before);
+
+				this.dates = this.$utils.generateDates(before, after);
+				if (this.dates.length !== 0) {
+					let temp = this.roomType;
+					this.info.selected = []
+					this.dates.forEach((date) => {
+						that.$myRequest({
+							url: '/hotelReservation/zhotel/appday_list.action?date=' + date,
+						}).then(res => {
+							// console.log(res.data);
+							if (res.data.code === 200) {
+								var min = 1000;
+								let data = res.data.data;
+								data.forEach(item => {
+									if (item.h_type.indexOf('标准') !== -1 && item.s_yum < that.biaozhun_min) {
+										temp.forEach((it) => {
+											if (it.h_type.indexOf('标准') !== -1)
+												it.s_yum = item.s_yum
+										})
+									}
+									if (item.h_type.indexOf('高级') !== -1 && item.s_yum < that.gaoji_min) {
+										temp.forEach((it) => {
+											if (it.h_type.indexOf('高级') !== -1)
+												it.s_yum = item.s_yum
+										})
+									}
+									if (item.h_type.indexOf('豪华') !== -1 && item.s_yum < that.haohua_min) {
+										temp.forEach((it) => {
+											if (it.h_type.indexOf('豪华') !== -1)
+												it.s_yum = item.s_yum
+										})
+									}
+									if (min > item.s_yum)
+										min = item.s_yum
+								});
+								this.info.selected.push({
+									date: date,
+									info: min.toString()
+								})
+							}
+						});
+					});
+					setTimeout(() => {
+						this.roomType = []
+						this.roomType = temp;
+					}, 2000)
+				} else {
+					this.info.selected = [{
+							date: before,
+							info: '到店'
+						},
+						{
+							date: after,
+							info: '离店'
+						}
+					];
+				}
 				if (before !== '' && after === '') {
 					this.startWeek = '周' + e.lunar.ncWeek.substring(2, 3)
 				} else if (before !== '' && after !== '') {

+ 0 - 11
pages/order_room/order_room.vue

@@ -282,17 +282,6 @@
 						that.msgType = 'warn'
 						that.order_txt = data.message
 						that.$refs.popup_order.open()
-
-						uni.showModal({
-							title: '提示',
-							content: '您需要重新授权!',
-							showCancel: false,
-							success(res) {
-								if (res.confirm) {
-									accredit()
-								}
-							}
-						})
 					}
 				});
 			},

+ 20 - 1
utils/common.js

@@ -136,7 +136,7 @@ const utils = {
 		result.setDate(result.getDate() + days);
 		return result;
 	},
-	
+
 	// 检测是否为空
 	isEmpty(value) {
 		if (value === null || value === undefined) {
@@ -162,6 +162,25 @@ const utils = {
 	// 解析URL中的参数
 	getUrlKey(name) {
 		return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
+	},
+
+	generateDates(startDate, endDate) {
+		const dates = [];
+		var current = new Date(startDate);
+		var end = new Date(endDate);
+
+		if ((new Date(end).getTime()) < (new Date(current).getTime())) {
+			var temp = current;
+			current = end;
+			end = temp;
+		}
+		while (current < end) {
+			const formattedDate = current.toISOString().slice(0, 10);
+			dates.push(formattedDate);
+			current.setDate(current.getDate() + 1);
+		}
+
+		return dates;
 	}
 }