lifanzai 9 months ago
parent
commit
358c24fcbd
3 changed files with 73 additions and 24 deletions
  1. 2 2
      http/baseApi.js
  2. 59 19
      pages/my/houseList.vue
  3. 12 3
      pages/my/roomType.vue

+ 2 - 2
http/baseApi.js

@@ -1,11 +1,11 @@
 // const BaseApi = 'http://192.168.2.190:8080' //汪瑶
 // const BaseApi = 'http://192.168.2.205:8080' //汪辉
-const BaseApi = 'http://192.168.2.19:8080' //李勇
+// const BaseApi = 'http://192.168.2.19:8080' //李勇
 // const BaseApi = 'http://192.168.3.13:8080' //徐涛
 // const BaseApi = 'http://192.168.2.39:8080' //肖添伟
 // const BaseApi = 'http://192.168.3.6:8080' //朱壮波
 
-// const BaseApi = 'https://i.ringzle.com/island-cloud-server' //测试服务器
+const BaseApi = 'https://i.ringzle.com/island-cloud-server' //测试服务器
 
 export {
 	BaseApi

+ 59 - 19
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,7 +22,7 @@
 					<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>
 			<!-- 图片上传
@@ -37,9 +37,9 @@
 				</view>
 				<view class="pic">
 					<!-- 图片 -->
+							<img @click="handelUpload" ref="pic-upload" src="https://img.51miz.com/Element/00/77/24/47/cd39208d_E772447_a1d65d72.png" style="width: 190rpx; height: 120rpx;" />
 					<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>
 						
 					</view>
@@ -151,16 +151,16 @@
 					<text style="font-size: 24rpx; color: #777;">共8个房间</text>
 			 	 </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> 楼层:</text><input style="width: 70rpx;" 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 > 房间号:</text><input style="width: 70rpx;"  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>
@@ -170,7 +170,7 @@
 			 </view>
 			 
 			 <!-- 添加按钮 -->
-			 <view class="submit">
+			 <view class="submit" @click="addRoom">
 			 	<u-icon name="plus-circle" color=" #1372FF"></u-icon>
 				<text style="color: #1372FF; font-size: 30rpx;">添加房间</text>
 			 </view>
@@ -189,7 +189,7 @@
 	export default{
 		data(){
 			return{
-				checked:false,
+				
 				weekedChecked:false,
 				action: '',//图片服务器地址
 							fileList: [
@@ -197,8 +197,12 @@
 									url: '',
 								}
 							],
+							id:'',
+							// roomTypeInfo:{},
 				
+					checked:true,
 				form:{
+					isPutAway:1,
 					homestayId:'',
 					mondayPrice:'',
 					tuesdayPrice:'',
@@ -220,25 +224,61 @@
 			}
 			
 		},
-		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()
 			
 		},
 		methods:{
 			// change(status) {
 			// 				console.log(status);
 			// 			},
+			// 添加&编辑房屋
 			addNewRoom(){
-				this.$api.post('/merchant/hotel/mine/addHouseBase',this.form).then(res=>{
-					console.log(res)
+			
+				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('这是修改')
+					this.$api.put('/merchant/hotel/mine/updHouseBase',this.form).then(res=>{
+						console.log('修改成功')
+					})
+					
+				}
+			},
+			// 添加房间
+			addRoom(){
+				const newRoom = {floor:'',roomNumber:''}
+				this.form.roomFloor.push(newRoom)
+			},
+			// 删除房间
+			delRoom(index){
+				this.form.roomFloor.splice(index,1)
+			},
+			handelUpload(){
+				 this.$refs['pic-upload'].click() 
+			},
+			// 获取当前房型信息
+			getTypeInfo(){
+				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
+						// console.log(this.roomTypeInfo)
 					}
 				})
 			}

+ 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)
 			}
 		}
 	}