3 Commits 9e17333fa3 ... b75a2c3f6b

Author SHA1 Message Date
  lifanzai b75a2c3f6b Merge branch 'master' of http://git.ringzle.com:3000/htcwl/hotelHomestayWx 9 months ago
  lifanzai 077970261a 3 9 months ago
  lifanzai 358c24fcbd 1 9 months ago
2 changed files with 108 additions and 43 deletions
  1. 96 40
      pages/my/houseList.vue
  2. 12 3
      pages/my/roomType.vue

+ 96 - 40
pages/my/houseList.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="page" :style="{'height':(h-th)+'px','padding-top':mt+'px'}">
-			<c-nav-bar title="房间列表" :showIcon="false" :titleStyle="titleStyle"></c-nav-bar>
+			<c-nav-bar title="房型信息" :showIcon="false" :titleStyle="titleStyle"></c-nav-bar>
 		<view class="body">
 			<!-- 房型信息 -->
 			
@@ -22,27 +22,24 @@
 					<text style="font-size: 30rpx; " >是否上架</text>
 				</view>
 				<view style="margin-right: 30rpx;">
-					<u-switch v-model="checked" size="50" @change="change(status)" active-color="#07C160" ></u-switch>
+					<u-switch v-model="checked" size="50" active-color="#07C160"> </u-switch>
 				</view>
 			</view>
 			<!-- 图片上传
 			 -->
 			 <view class="uploadPic">
 			 	<view style=" margin-left: 30rpx;">
-					<text style="font-size: 32rpx; font-weight: 700; ">封面图片(0/1)</text>
-			 		
+					<text style="font-size: 32rpx; font-weight: 700; ">封面图片(0/1)</text>		 		
 			 	</view>
 				<view style="margin-top: 20rpx; margin-left: 30rpx; color: #777; font-size: 24rpx;">
 					<text>仅能上传1张,需展示房间内容</text>
 				</view>
 				<view class="pic">
 					<!-- 图片 -->
-					<view v-show="false" >
-						<u-upload :action="action" :file-list="fileList" >
-							<!-- <img src="https://img.51miz.com/Element/00/77/24/47/cd39208d_E772447_a1d65d72.png" style="width: 190rpx; height: 120rpx;" /> -->
-						</u-upload>
+					<u-upload>
 						
-					</view>
+							<img  src="https://img.51miz.com/Element/00/77/24/47/cd39208d_E772447_a1d65d72.png" style="width: 190rpx; height: 120rpx;" />			
+					</u-upload>
 				</view>
 				
 			 </view>
@@ -149,34 +146,29 @@
 			 	 <view class="HouseListTitleInfo" >
 			 	 	<text style="font-size: 32rpx; font-weight: 700;">房间列表</text>
 					<text style="font-size: 24rpx; color: #777;">共8个房间</text>
-			 	 </view>
+			 	</view>
 				 <!-- 房间号 -->
-				 <view class="priceBoxWeek">
+				 <view class="priceBoxWeek" v-for="(room,index) in form.roomFloor" :key="index">
 				 	<view class="weekendBox" style="display: flex; justify-content: space-between;">						
 						<view style="display: flex;">
-							<text> 楼层:</text><input style="width: 50rpx;" v-model="form.roomFloor[0].floor" type="text" />
+							<text style="font-size: 30rpx;"> 楼层:</text><input style="width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx;" v-model="room.floor" type="text" />
 						</view>
 						<view style="display: flex;">
-								<text > 房间号:</text><input style="width: 50rpx;"  v-model="form.roomFloor[0].roomNumber" type="text" />
+								<text style="font-size: 30rpx;" > 房间号:</text><input style="width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx;"  v-model="room.roomNumber" type="text" />
 						</view>
 						
-				 		<view style="display: flex; margin-top: 10rpx;">
+				 		<view style="display: flex; margin-top: 10rpx;" @click="delRoom(index)">
 							<u-icon name="trash"></u-icon>
 				 		</view>
 				 	</view>
 				 </view>
-				 
-				
-			 </view>
-			 
-			 <!-- 添加按钮 -->
-			 <view class="submit">
+			 </view>		 
+			<view class="submit" @click="addRoom">
 			 	<u-icon name="plus-circle" color=" #1372FF"></u-icon>
 				<text style="color: #1372FF; font-size: 30rpx;">添加房间</text>
-			 </view>
-			 
+			 </view>					 
 			 <!-- 确定添加按钮 -->
-			 <view class="addSubmit" @click="addNewRoom">
+			<view class="addSubmit" @click="addNewRoom">
 				 
 			 	<text style="line-height: 96rpx; margin-left:310rpx; font-size: 32rpx; color: #fff;">确定</text>
 			 </view>
@@ -189,16 +181,18 @@
 	export default{
 		data(){
 			return{
-				checked:false,
+				
 				weekedChecked:false,
-				action: '',//图片服务器地址
+				action: 'https://i.ringzle.com/island-cloud-server',//图片服务器地址
 							fileList: [
 								{
 									url: '',
 								}
 							],
-				
+							id:'',//houseBaseId				
+					checked:true,
 				form:{
+					isPutAway:'',
 					homestayId:'',
 					mondayPrice:'',
 					tuesdayPrice:'',
@@ -220,27 +214,82 @@
 			}
 			
 		},
-		onLoad({id}){
+		onLoad({id,houseBaseId}){
 			this.form.homestayId=id
-			console.log(this.form.homestayId)
+			// console.log(houseBaseId)
+			this.id=houseBaseId
+			// console.log(this.id)
+			this.getTypeInfo()
+			
+		},
+		computed:{
 			
 		},
 		methods:{
-			// change(status) {
-			// 				console.log(status);
-			// 			},
+			change(status) {
+							console.log(status);
+						},
+			// 添加&编辑房屋
 			addNewRoom(){
-				this.$api.post('/merchant/hotel/mine/addHouseBase',this.form).then(res=>{
-					console.log(res)
+					if(this.checked===true){
+						this.form.isPutAway=1
+					}else{
+						this.form.isPutAway=0
+					}
+					// console.log(this.form)
+				if(!this.id){
+					this.$api.post('/merchant/hotel/mine/addHouseBase',this.form).then(res=>{
+						// console.log(res)
+						if(res.data.code===0){
+							this.$showToast('添加成功');
+							setTimeout(()=>{
+								uni.reLaunch({
+									url:'/pages/my/roomType'
+								})
+							},1500)
+						}
+					})
+					console.log('这是')
+				}else{
+					// console.log('这是修改')
+					// if(this.)
+					this.$api.put('/merchant/hotel/mine/updHouseBase',this.form).then(res=>{
+						// console.log('修改成功')
+						if(res.data.code===0){
+							this.$showToast('添加成功')
+							setTimeout(()=>{
+								uni.reLaunch({
+									url:'/pages/my/roomType'
+								})
+							},1500)
+						}
+					})
+					
+				}
+			},
+			// 添加房间
+			addRoom(){
+				const newRoom = {floor:'',roomNumber:''}
+				this.form.roomFloor.push(newRoom)
+			},
+			// 删除房间
+			delRoom(index){
+				this.form.roomFloor.splice(index,1)
+			},
+		
+			// 获取当前房型信息
+			getTypeInfo(){
+				if(this.id){
+				this.$api.get(`/merchant/hotel/mine/getHouseBaseInfo/${this.id}`).then((res)=>{
+					// console.log(res)
 					if(res.data.code===0){
-						this.$showToast('添加成功');
-						setTimeout(()=>{
-							uni.reLaunch({
-								url:'/pages/my/roomType'
-							})
-						},1500)
+						this.form=res.data.data				
 					}
 				})
+					
+				}else{
+					return
+				}
 			}
 		}
 		
@@ -314,7 +363,7 @@
 		margin-top: 20rpx;
 		width: 190rpx;
 		height: 120rpx;
-		background-color: pink;
+		// background-color: pink;
 	}
 	// .custom-upload-button{
 	// 	width: 190rpx;
@@ -410,4 +459,11 @@
 		    background-color: #1372FF;
 			border-radius: 48rpx;
 	}
+	.uploadPicPic{
+		position: relative;
+		top: -96rpx;
+	}
+	.u-upload__deletable[data-v-69e2a36e] {
+		width: 0 !important;
+	}
 </style>

+ 12 - 3
pages/my/roomType.vue

@@ -3,10 +3,10 @@
 			<c-nav-bar title="房型列表" :showIcon="false" :titleStyle="titleStyle"></c-nav-bar>
 			<!-- 房型数量 -->
 			<view class="typeNum">
-					<text style="font-size: 24rpx; color: #777;">共3个房型</text>
+					<text style="font-size: 24rpx; color: #777;">共{{roomType.length}}个房型</text>
 			</view>
 			<!-- 房型选择 -->
-			<view class="type" v-for="item in roomType" :key="item.houseBaseId">
+			<view class="type" v-for="item in roomType" :key="item.houseBaseId" @click="goEditTypeInfo(item.houseBaseId)">
 				<view class="top">
 					<text style="font-size: 30rpx; color: #333;" >{{item.name}}</text>
 					<u-icon name="arrow-right"></u-icon>
@@ -14,7 +14,6 @@
 				<view class="under">
 					<text style="font-size: 24rpx; color: #777;">大床房</text>
 					<text style="font-size: 24rpx; color: #777;">{{item.roomCount}}间</text>
-					
 				</view>
 				
 			</view>
@@ -41,11 +40,14 @@
 		methods:{
 			// 获取房型列表信息
 			getHomestayId(){
+			
+				
 				this.$api.get(`/merchant/hotel/mine/getHouseBaseList/${this.homestayId}`,{
 					homestayId:this.homestayId
 				}).then((res)=>{
 					// console.log(res)
 					this.roomType=res.data.data
+					
 					// let roomSymbleName=this.roomType.name
 					// console.log(roomSymbleName)
 					// console.log(this.roomType)
@@ -56,6 +58,13 @@
 				uni.navigateTo({
 					url:`/pages/my/houseList?id=${this.homestayId}`
 				})
+			},
+			// 修改房型信息
+			goEditTypeInfo(houseBaseId){
+				uni.navigateTo({
+					url:`/pages/my/houseList?houseBaseId=${houseBaseId}`
+				})
+				console.log(houseBaseId)
 			}
 		}
 	}