houseList1.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="page" :style="{'height':(h)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="房间列表" :showIcon="true"></c-nav-bar>
  4. <view class="body">
  5. <!-- 房型信息 -->
  6. <view class="typeInfo">
  7. <view class="titleInfo">
  8. <text style="font-size: 32rpx; font-weight: 700;">房型信息</text>
  9. </view>
  10. <view class="cellBox">
  11. <text style="font-size: 30rpx; margin-right: 30rpx;">房型名称</text>
  12. <input v-model="form.name" type="text" placeholder="请输入房型"
  13. style="width: 210rpx;height: 42rpx; font-size: 30rpx;flex:1" />
  14. </view>
  15. <view class="bigRoom">
  16. <text style="font-size: 30rpx;color: black; margin-right: 90rpx;">简称</text>
  17. <input v-model="form.shortName" type="text" placeholder="请输入简称"
  18. style="width: 210rpx;height: 42rpx; font-size: 30rpx;flex:1" />
  19. </view>
  20. </view>
  21. <view class="shelves">
  22. <view style="margin-left: 30rpx;">
  23. <text style="font-size: 30rpx; ">是否上架</text>
  24. </view>
  25. <view style="margin-right: 30rpx;">
  26. <u-switch v-model="checked" size="50" active-color="#07C160"> </u-switch>
  27. </view>
  28. </view>
  29. <!-- 图片上传
  30. -->
  31. <view class="uploadPic">
  32. <view style=" margin-left: 30rpx;">
  33. <text style="font-size: 32rpx; font-weight: 700; ">封面图片({{fileList.length}}/1)</text>
  34. </view>
  35. <view style="margin-top: 20rpx; margin-left: 30rpx; color: #777; font-size: 24rpx;">
  36. <text>仅能上传1张,需展示房间内容</text>
  37. </view>
  38. <view class="pic">
  39. <!-- 图片 -->
  40. <u-upload :fileList="fileList" multiple :maxCount="1" :maxSize="1 * 1024 * 1024"
  41. @afterRead="afterRead" @oversize="overSize" width="120" height="120" @delete="deletePic">
  42. </u-upload>
  43. </view>
  44. </view>
  45. <!-- 价格信息 -->
  46. <view class="priceInfo">
  47. <!-- 标题 -->
  48. <view class="titleInfo">
  49. <text style="font-size: 32rpx; font-weight: 700; margin-left: 10rpx;">价格信息</text>
  50. </view>
  51. <!-- 周末周日区分 -->
  52. <view class="week">
  53. <view class="weekend">
  54. <view>
  55. <text style="font-size: 30rpx; ">区分平日周末</text>
  56. </view>
  57. <view>
  58. <u-switch v-model="weekedChecked" size="50" active-color="#07C160"></u-switch>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 平日价格 -->
  63. <view class="priceBoxWeek" v-if="!weekedChecked">
  64. <view class="weekendBox">
  65. <view>
  66. <text style="font-size: 30rpx; margin-right: 90rpx; ">固定房价</text>
  67. </view>
  68. <view style="display: flex; align-items: center; height: 50rpx;">
  69. <text style="font-size: 30rpx;">¥</text>
  70. <u--input type='text' border="none" v-model="form.price" placeholder="请输入价格"
  71. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 每日价格 -->
  76. <view class="priceBoxWeek" v-if="weekedChecked">
  77. <view class="weekendBox">
  78. <view>
  79. <text style="font-size: 30rpx; margin-right: 90rpx; ">周一</text>
  80. </view>
  81. <view style="display: flex; align-items: center;">
  82. <text style="font-size: 30rpx;">¥</text>
  83. <u--input type='text' border="none" v-model="form.mondayPrice" placeholder="请输入价格"
  84. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="priceBoxWeek" v-if="weekedChecked">
  89. <view class="weekendBox">
  90. <view>
  91. <text style="font-size: 30rpx; margin-right: 90rpx; ">周二</text>
  92. </view>
  93. <view style="display: flex; align-items: center;">
  94. <text style="font-size: 30rpx;">¥</text>
  95. <u--input type='text' border="none" v-model="form.tuesdayPrice" placeholder="请输入价格"
  96. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="priceBoxWeek" v-if="weekedChecked">
  101. <view class="weekendBox">
  102. <view>
  103. <text style="font-size: 30rpx; margin-right: 90rpx; ">周三</text>
  104. </view>
  105. <view style="display: flex; align-items: center;">
  106. <text style="font-size: 30rpx;">¥</text>
  107. <u--input type='text' border="none" v-model="form.wednesdayPrice" placeholder="请输入价格"
  108. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="priceBoxWeek" v-if="weekedChecked">
  113. <view class="weekendBox">
  114. <view>
  115. <text style="font-size: 30rpx; margin-right: 90rpx; ">周四</text>
  116. </view>
  117. <view style="display: flex; align-items: center;">
  118. <text style="font-size: 30rpx;">¥</text>
  119. <u--input type='text' border="none" v-model="form.thursdayPrice" placeholder="请输入价格"
  120. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  121. </view>
  122. </view>
  123. </view>
  124. <view class="priceBoxWeek" v-if="weekedChecked">
  125. <view class="weekendBox">
  126. <view>
  127. <text style="font-size: 30rpx; margin-right: 90rpx; ">周五</text>
  128. </view>
  129. <view style="display: flex; align-items: center;">
  130. <text style="font-size: 30rpx;">¥</text>
  131. <u--input type='text' border="none" v-model="form.fridayPrice" placeholder="请输入价格"
  132. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="priceBoxWeek" v-if="weekedChecked">
  137. <view class="weekendBox">
  138. <view>
  139. <text style="font-size: 30rpx; margin-right: 90rpx; ">周六</text>
  140. </view>
  141. <view style="display: flex; align-items: center;">
  142. <text style="font-size: 30rpx;">¥</text>
  143. <u--input type='text' border="none" v-model="form.saturdayPrice" placeholder="请输入价格"
  144. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  145. </view>
  146. </view>
  147. </view>
  148. <view class="priceBoxWeek" v-if="weekedChecked">
  149. <view class="weekendBox" style=" border-bottom: 1rpx solid #fff;">
  150. <view style="margin-top: 10rpx;">
  151. <text style="font-size: 30rpx; margin-right: 90rpx; ">周日</text>
  152. </view>
  153. <view style="display: flex; margin-top: 10rpx; align-items: center;">
  154. <text style="font-size: 30rpx;">¥</text>
  155. <u--input type='text' border="none" v-model="form.sundayPrice" placeholder="请输入价格"
  156. style="width: 210rpx;height: 42rpx; font-size: 30rpx;"></u--input>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. <!-- 房间列表 -->
  162. <view class="everyHouseList" style="padding-top: 20rpx;">
  163. <view class="HouseListTitleInfo">
  164. <text style="font-size: 32rpx; font-weight: 700;">房间列表</text>
  165. <text style="font-size: 24rpx; color: #777;">共{{form.roomFloor.length}}个房间</text>
  166. </view>
  167. <!-- 房间号 -->
  168. <view class="priceBoxWeek" v-for="(room,index) in form.roomFloor" :key="index">
  169. <view class="weekendBox" style="display: flex; justify-content: space-between; align-items: center">
  170. <view style="display: flex; align-items: center;height:54rpx ">
  171. <view style="font-size: 30rpx;"> 楼层:</view>
  172. <u--input type='text' border="none" v-model="room.floor"
  173. style="width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx; height: 50rpx;"></u--input>
  174. </view>
  175. <view style="display: flex; align-items: center;">
  176. <view style="font-size: 30rpx;"> 房间号:</view>
  177. <u--input type='text' border="none" v-model="room.roomNumber"
  178. style="width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx; height: 50rpx;"></u--input>
  179. </view>
  180. <view style="display: flex; margin-top: 10rpx;" @click="delRoom(index)">
  181. <u-icon name="trash"></u-icon>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. <view class="submit" @click="addRoom">
  187. <u-icon name="plus-circle" color=" #1372FF"></u-icon>
  188. <text style="color: #1372FF; font-size: 30rpx;">添加房间</text>
  189. </view>
  190. </view>
  191. <!-- 新增按钮 -->
  192. <view class="btn-btn" @click="addNewRoom()">
  193. <view class="btn">
  194. 确定
  195. </view>
  196. </view>
  197. </view>
  198. </view>
  199. </template>
  200. <script>
  201. export default {
  202. data() {
  203. return {
  204. checked: false,
  205. weekedChecked: false,
  206. action: '', //图片服务器地址
  207. fileList: [],
  208. form: {
  209. price: '',
  210. homestayId: '',
  211. mondayPrice: '',
  212. tuesdayPrice: '',
  213. wednesdayPrice: '',
  214. thursdayPrice: '',
  215. fridayPrice: '',
  216. saturdayPrice: '',
  217. sundayPrice: '',
  218. name: '',
  219. shortName: '',
  220. isPutaway: '',
  221. roomFloor: [{
  222. floor: '',
  223. roomNumber: ''
  224. }]
  225. },
  226. }
  227. },
  228. onLoad({
  229. id,
  230. houseBaseId
  231. }) {
  232. this.form.homestayId = id
  233. // console.log(houseBaseId)
  234. this.id = houseBaseId
  235. // console.log(this.id)
  236. this.getTypeInfo()
  237. },
  238. methods: {
  239. // 删除图片
  240. deletePic(event) {
  241. this.fileList.splice(event.index, 1)
  242. },
  243. // 新增图片
  244. async afterRead(event) {
  245. const result = await this.uploadFilePromise(event.file[0].url);
  246. //图片路径
  247. console.log(result)
  248. },
  249. // 图片大小超出最大允许大小
  250. overSize(e) {
  251. uni.$u.toast('上传图片大小不能超过10MB!')
  252. },
  253. //上传图片
  254. uploadFilePromise(url) {
  255. console.log(url)
  256. return new Promise((resolve, reject) => {
  257. let a = uni.uploadFile({
  258. url: 'https://i.ringzle.com/island-cloud-server/oss/file/upload',
  259. filePath: url,
  260. name: 'file',
  261. header: {
  262. token: wx.getStorageSync('access_token')
  263. },
  264. success: (res) => {
  265. console.log(res)
  266. let data = JSON.parse(res.data) //最终传给的是字符串,这里需要转换格式
  267. this.fileList.push({
  268. url: data.data.url
  269. })
  270. resolve(data.data.url)
  271. }
  272. });
  273. })
  274. },
  275. // 添加&编辑房屋
  276. addNewRoom() {
  277. // console.log(this.form)
  278. if (!this.id) {
  279. if (this.checked === true) {
  280. this.form.isPutaway = 1
  281. } else {
  282. this.form.isPutaway = 0
  283. }
  284. this.$api.post('/merchant/hotel/mine/addHouseBase', this.form).then(res => {
  285. // console.log(res)
  286. if (res.data.code === 0) {
  287. this.$showToast('修改成功');
  288. setTimeout(() => {
  289. uni.reLaunch({
  290. url: '/pages/my/roomType'
  291. })
  292. }, 1500)
  293. }
  294. })
  295. console.log('这是')
  296. } else {
  297. // console.log('这是修改')
  298. // if(this.)
  299. if (this.checked === true) {
  300. this.form.isPutaway = 1
  301. } else {
  302. this.form.isPutaway = 0
  303. }
  304. this.$api.put('/merchant/hotel/mine/updHouseBase', this.form).then(res => {
  305. // console.log('修改成功')
  306. if (res.data.code === 0) {
  307. this.$showToast('修改成功')
  308. setTimeout(() => {
  309. uni.reLaunch({
  310. url: '/pages/my/roomType'
  311. })
  312. }, 1500)
  313. }
  314. })
  315. }
  316. },
  317. // 添加房间
  318. addRoom() {
  319. const newRoom = {
  320. floor: '',
  321. roomNumber: ''
  322. }
  323. this.form.roomFloor.push(newRoom)
  324. },
  325. // 删除房间
  326. delRoom(index) {
  327. this.form.roomFloor.splice(index, 1)
  328. },
  329. // 获取当前房型信息
  330. getTypeInfo() {
  331. if (this.id) {
  332. this.$api.get(`/merchant/hotel/mine/getHouseBaseInfo/${this.id}`).then((res) => {
  333. // console.log(res)
  334. if (res.data.code === 0) {
  335. this.form = res.data.data
  336. this.fileList.push({
  337. url: res.data.data.cover
  338. })
  339. if (this.form.isPutaway == 1) {
  340. this.checked = true
  341. } else {
  342. this.checked = false
  343. }
  344. }
  345. })
  346. } else {
  347. return
  348. }
  349. }
  350. }
  351. }
  352. </script>
  353. <style lang="scss">
  354. .btn-btn {
  355. width: 100%;
  356. height: 136rpx;
  357. background-color: #fff;
  358. position: fixed;
  359. bottom: 0;
  360. padding: 30rpx 0 0;
  361. // margin: 0 auto;
  362. z-index: 999999;
  363. // margin-top: 30rpx;
  364. // margin-left: 30rpx;
  365. }
  366. .btn {
  367. margin: 0 auto;
  368. width: 690rpx;
  369. height: 96rpx;
  370. background-color: #1372FF;
  371. color: #fff;
  372. display: flex;
  373. justify-content: center;
  374. align-items: center;
  375. font-size: 34rpx;
  376. border-radius: 48rpx;
  377. }
  378. .uicon-close {
  379. font-size: 30rpx !important;
  380. top: 8rpx !important;
  381. }
  382. .page {
  383. background: #F3F4F4;
  384. padding-bottom: 260rpx;
  385. box-sizing: border-box;
  386. overflow-y: auto;
  387. overflow-x: auto;
  388. }
  389. .body {
  390. padding-top: 20rpx;
  391. padding-left: 30rpx;
  392. padding-right: 30rpx;
  393. }
  394. .typeInfo {
  395. background-color: #fff;
  396. width: 100%;
  397. // height: 145px;
  398. border-radius: 5px;
  399. padding-top: 15px;
  400. padding-left: 7px;
  401. padding-right: 15px;
  402. box-sizing: border-box;
  403. }
  404. .titleInfo {
  405. // margin-top: 30rpx;
  406. margin-left: 20rpx;
  407. margin-bottom: 40rpx;
  408. }
  409. .cellBox {
  410. margin-left: 20rpx;
  411. display: flex;
  412. padding-bottom: 40rpx;
  413. border-bottom: 1rpx solid #E1E1E1;
  414. }
  415. .bigRoom {
  416. margin-left: 20rpx;
  417. width: 100%;
  418. height: 102rpx;
  419. display: flex;
  420. // justify-content: center;
  421. align-items: center;
  422. }
  423. .shelves {
  424. width: 695rpx;
  425. height: 102rpx;
  426. background-color: #fff;
  427. margin-top: 20rpx;
  428. border-radius: 10rpx;
  429. display: flex;
  430. justify-content: space-between;
  431. align-items: center;
  432. // padding-left: 30rpx;
  433. // padding-right: 30rpx;
  434. }
  435. .uploadPic {
  436. padding-top: 28rpx;
  437. width: 690rpx;
  438. // height: 293rpx;
  439. background-color: #fff;
  440. border-radius: 10rpx;
  441. margin-top: 20rpx;
  442. }
  443. .pic {
  444. // margin-left: 30rpx;
  445. // margin-top: 20rpx;
  446. // width: 190rpx;
  447. // height: 120rpx;
  448. margin: 20rpx 30rpx;
  449. padding-bottom: 20rpx;
  450. }
  451. // .custom-upload-button{
  452. // width: 190rpx;
  453. // height: 120rpx;
  454. // }
  455. .priceInfo {
  456. width: 690rpx;
  457. // height: 908rpx;
  458. background-color: #fff;
  459. border-radius: 10rpx;
  460. margin-top: 20rpx;
  461. padding-top: 30rpx;
  462. }
  463. .week {
  464. padding-left: 30rpx;
  465. padding-right: 30rpx;
  466. margin-bottom: 20rpx;
  467. }
  468. .weekend {
  469. display: flex;
  470. justify-content: space-between;
  471. border-bottom: 1rpx solid #E1E1E1;
  472. padding-bottom: 30rpx;
  473. }
  474. .everyDay {
  475. padding-left: 30rpx;
  476. padding-right: 30rpx;
  477. width: 100%;
  478. // background-color: pink;
  479. height: 102rpx;
  480. display: flex;
  481. align-items: center;
  482. }
  483. .days {
  484. display: flex;
  485. align-items: center;
  486. border-bottom: 1rpx solid #E1E1E1;
  487. padding-bottom: 30rpx;
  488. }
  489. .priceBoxWeek {
  490. display: flex;
  491. align-items: center;
  492. padding-left: 30rpx;
  493. padding-right: 30rpx;
  494. }
  495. .weekendBox {
  496. width: 630rpx;
  497. display: flex;
  498. align-items: center;
  499. // margin-right: 90rpx;
  500. // justify-content: space-between;
  501. border-bottom: 1rpx solid #E1E1E1;
  502. height: 102rpx;
  503. overflow: hidden;
  504. box-sizing: border-box;
  505. }
  506. .everyHouseList {
  507. // padding-right: 30rpx;
  508. width: 690rpx;
  509. // height: 908rpx;
  510. background-color: #fff;
  511. border-radius: 10rpx;
  512. margin-top: 20rpx;
  513. // padding-top: 30rpx;
  514. }
  515. .HouseListTitleInfo {
  516. margin-right: 30rpx;
  517. margin-left: 20rpx;
  518. margin-bottom: 40rpx;
  519. display: flex;
  520. justify-content: space-between;
  521. }
  522. .submit {
  523. margin-top: 20rpx;
  524. border-radius: 10rpx;
  525. width: 690rpx;
  526. height: 102rpx;
  527. background-color: #fff;
  528. display: flex;
  529. justify-content: center;
  530. align-items: center;
  531. }
  532. .addSubmit {
  533. width: 100%;
  534. position: fixed;
  535. /* 固定定位 */
  536. bottom: 20rpx;
  537. /* 底部对齐 */
  538. left: 0;
  539. /* 可选:左对齐 */
  540. // width: 690rpx;
  541. /* 可选:宽度为 100% */
  542. height: 96rpx;
  543. margin-left: 30rpx;
  544. // padding-top: 20rpx;
  545. margin-top: 30rpx;
  546. background-color: #1372FF;
  547. border-radius: 48rpx;
  548. }
  549. .uploadPicPic {
  550. position: relative;
  551. top: -96rpx;
  552. }
  553. .u-upload__deletable[data-v-69e2a36e] {
  554. width: 0 !important;
  555. }
  556. </style>