lifanzai vor 10 Monaten
Ursprung
Commit
914a106827
3 geänderte Dateien mit 108 neuen und 40 gelöschten Zeilen
  1. 1 1
      pages.json
  2. 105 37
      pages/my/houseList.vue
  3. 2 2
      pages/my/roomType.vue

+ 1 - 1
pages.json

@@ -22,7 +22,7 @@
 				"navigationStyle": "custom"
 			}
 		},
-		//登录
+		// 登录
 		{
 			"path": "pages/login/index",
 			"style": {

+ 105 - 37
pages/my/houseList.vue

@@ -41,7 +41,7 @@
 					<!-- 图片 -->
 					<u-upload :fileList="fileList" multiple :maxCount="1" :maxSize="1 * 1024 * 1024"
 						@afterRead="afterRead" @oversize="overSize" width="120" height="120">
-						
+
 					</u-upload>
 				</view>
 
@@ -63,6 +63,8 @@
 						</view>
 					</view>
 				</view>
+				<!-- 平日价格 -->
+				
 
 				<!-- 每日价格 -->
 				<view class="priceBoxWeek">
@@ -156,44 +158,45 @@
 				<view class="HouseListTitleInfo">
 					<text style="font-size: 32rpx; font-weight: 700;">房间列表</text>
 					<text style="font-size: 24rpx; color: #777;">共8个房间</text>
-			 	</view>
-				 <!-- 房间号 -->
-				 <view class="priceBoxWeek" v-for="(room,index) in form.roomFloor" :key="index">
-				 	<view class="weekendBox" style="display: flex; justify-content: space-between;">						
+				</view>
+				<!-- 房间号 -->
+				<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 style="font-size: 30rpx;"> 楼层:</text><input style="width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx;" v-model="room.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 style="font-size: 30rpx;" > 房间号:</text><input style="width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx;"  v-model="room.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;" @click="delRoom(index)">
+
+						<view style="display: flex; margin-top: 10rpx;" @click="delRoom(index)">
 							<u-icon name="trash"></u-icon>
-				 		</view>
-				 	</view>
-				 </view>
-			 </view>		 
+						</view>
+					</view>
+				</view>
+			</view>
 			<view class="submit" @click="addRoom">
-			 	<u-icon name="plus-circle" color=" #1372FF"></u-icon>
+				<u-icon name="plus-circle" color=" #1372FF"></u-icon>
 				<text style="color: #1372FF; font-size: 30rpx;">添加房间</text>
-			 </view>					 
-			 <!-- 确定添加按钮 -->
-			<view class="addSubmit" @click="addNewRoom">
-				 
-			 	<text style="line-height: 96rpx; margin-left:310rpx; font-size: 32rpx; color: #fff;">确定</text>
-			 </view>
-		</view>
-			
 			</view>
-
 			<!-- 确定添加按钮 -->
 			<view class="addSubmit" @click="addNewRoom">
-
 				<text style="line-height: 96rpx; margin-left:310rpx; font-size: 32rpx; color: #fff;">确定</text>
 			</view>
 		</view>
+		<!-- 确定添加按钮 -->
+		<view class="addSubmit" @click="addNewRoom">
+
+			<text style="line-height: 96rpx; margin-left:310rpx; font-size: 32rpx; color: #fff;">确定</text>
+		</view>
+		</view>
 
 	</view>
+
 </template>
 
 <script>
@@ -227,13 +230,14 @@
 			}
 
 		},
-		onLoad({
-			id
-		}) {
-			this.form.homestayId = id
-			console.log(this.form.homestayId)
-
-		},
+		onLoad({id,houseBaseId}){
+				this.form.homestayId=id
+				// console.log(houseBaseId)
+				this.id=houseBaseId
+				// console.log(this.id)
+				this.getTypeInfo()
+				
+			},
 		methods: {
 			// 删除图片
 			deletePic(event) {
@@ -241,9 +245,9 @@
 			},
 			// 新增图片
 			async afterRead(event) {
-					const result = await this.uploadFilePromise(event.file[0].url);
-					//图片路径
-					console.log(result)
+				const result = await this.uploadFilePromise(event.file[0].url);
+				//图片路径
+				console.log(result)
 			},
 			// 图片大小超出最大允许大小
 			overSize(e) {
@@ -254,7 +258,7 @@
 				console.log(url)
 				return new Promise((resolve, reject) => {
 					let a = uni.uploadFile({
-						url: 'https://i.ringzle.com/island-cloud-server/oss/file/upload', 
+						url: 'https://i.ringzle.com/island-cloud-server/oss/file/upload',
 						filePath: url,
 						name: 'file',
 						header: {
@@ -271,6 +275,68 @@
 					});
 				})
 			},
+			// 添加&编辑房屋
+						addNewRoom(){
+								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.form=res.data.data				
+								}
+							})
+								
+							}else{
+								return
+							}
+						}
 		}
 
 	}
@@ -352,7 +418,7 @@
 		// margin-top: 20rpx;
 		// width: 190rpx;
 		// height: 120rpx;
-		margin:20rpx 30rpx;
+		margin: 20rpx 30rpx;
 		padding-bottom: 20rpx;
 	}
 
@@ -464,10 +530,12 @@
 		background-color: #1372FF;
 		border-radius: 48rpx;
 	}
-	.uploadPicPic{
+
+	.uploadPicPic {
 		position: relative;
 		top: -96rpx;
 	}
+
 	.u-upload__deletable[data-v-69e2a36e] {
 		width: 0 !important;
 	}

+ 2 - 2
pages/my/roomType.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="page" :style="{'height':(h-th)+'px','padding-top':mt+'px'}">
-			<c-nav-bar title="房型列表" :showIcon="true" :titleStyle="titleStyle"></c-nav-bar>
+			<c-nav-bar title="房型列表" :showIcon="false" :titleStyle="titleStyle"></c-nav-bar>
 			<!-- 房型数量 -->
 			<view class="typeNum">
 					<text style="font-size: 24rpx; color: #777;">共{{roomType.length}}个房型</text>
@@ -29,7 +29,7 @@
 	export default {
 		data(){
 			return {
-				homestayId:uni.getStorageSync('homestayId'),
+				homestayId:this.$store.state.moduleHouse.homestayId,
 				roomType:[]
 			}
 		},