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