houseList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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. <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;">
  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;">
  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;">
  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;">
  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;">
  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;">
  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;">
  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">
  163. <view class="weekendBox"
  164. style="display: flex; justify-content: space-between; align-items: center">
  165. <view style="display: flex; align-items: center;height:54rpx ">
  166. <view style="font-size: 30rpx;"> 楼层:</view>
  167. <input style="width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx; height: 50rpx;"
  168. v-model="room.floor" />
  169. </view>
  170. <view style="display: flex; align-items: center;">
  171. <view style="font-size: 30rpx;"> 房间号:</view><input
  172. style=" width: 70rpx; margin-bottom: 5rpx; font-size: 28rpx; height: 50rpx;"
  173. v-model="room.roomNumber" />
  174. </view>
  175. <view style="display: flex; margin-top: 10rpx;" @click="delRoom(index)">
  176. <u-icon name="trash"></u-icon>
  177. </view>
  178. </view>
  179. </view>
  180. </view>
  181. <view class="submit" @click="addRoom">
  182. <u-icon name="plus-circle" color=" #1372FF"></u-icon>
  183. <text style="color: #1372FF; font-size: 30rpx;">添加房间</text>
  184. </view>
  185. <!-- 新增按钮 -->
  186. <!-- <view class="btn-btn" @click="addNewRoom()">
  187. <view class="btn">
  188. 确定
  189. </view>
  190. </view> -->
  191. </view>
  192. <!-- 新增按钮 -->
  193. <!-- <view class="btn-btn" @click="addNewRoom()">
  194. <view class="btn">
  195. 确定
  196. </view>
  197. </view> -->
  198. </view>
  199. </view>
  200. </template>
  201. <script>
  202. export default {
  203. data() {
  204. return {
  205. checked: false,
  206. weekedChecked: false,
  207. action: '', //图片服务器地址
  208. fileList: [],
  209. form: {
  210. price: '',
  211. homestayId: '',
  212. mondayPrice: '',
  213. tuesdayPrice: '',
  214. wednesdayPrice: '',
  215. thursdayPrice: '',
  216. fridayPrice: '',
  217. saturdayPrice: '',
  218. sundayPrice: '',
  219. name: '',
  220. shortName: '',
  221. isPutaway: '',
  222. roomFloor: [{
  223. floor: '',
  224. roomNumber: ''
  225. }]
  226. },
  227. }
  228. },
  229. onLoad({
  230. id,
  231. houseBaseId
  232. }) {
  233. this.form.homestayId = id
  234. // console.log(houseBaseId)
  235. this.id = houseBaseId
  236. // console.log(this.id)
  237. this.getTypeInfo()
  238. },
  239. methods: {
  240. // 删除图片
  241. deletePic(event) {
  242. this.fileList.splice(event.index, 1)
  243. },
  244. // 新增图片
  245. async afterRead(event) {
  246. const result = await this.uploadFilePromise(event.file[0].url);
  247. //图片路径
  248. console.log(result)
  249. },
  250. // 图片大小超出最大允许大小
  251. overSize(e) {
  252. uni.$u.toast('上传图片大小不能超过10MB!')
  253. },
  254. //上传图片
  255. uploadFilePromise(url) {
  256. console.log(url)
  257. return new Promise((resolve, reject) => {
  258. let a = uni.uploadFile({
  259. url: 'https://i.ringzle.com/island-cloud-server/oss/file/upload',
  260. filePath: url,
  261. name: 'file',
  262. header: {
  263. token: wx.getStorageSync('access_token')
  264. },
  265. success: (res) => {
  266. console.log(res)
  267. let data = JSON.parse(res.data) //最终传给的是字符串,这里需要转换格式
  268. this.fileList.push({
  269. url: data.data.url
  270. })
  271. resolve(data.data.url)
  272. }
  273. });
  274. })
  275. },
  276. // 添加&编辑房屋
  277. addNewRoom() {
  278. // console.log(this.form)
  279. if (!this.id) {
  280. if (this.checked === true) {
  281. this.form.isPutaway = 1
  282. } else {
  283. this.form.isPutaway = 0
  284. }
  285. this.$api.post('/merchant/hotel/mine/addHouseBase', this.form).then(res => {
  286. // console.log(res)
  287. if (res.data.code === 0) {
  288. this.$showToast('修改成功');
  289. setTimeout(() => {
  290. uni.reLaunch({
  291. url: '/pages/my/roomType'
  292. })
  293. }, 1500)
  294. }
  295. })
  296. console.log('这是')
  297. } else {
  298. // console.log('这是修改')
  299. // if(this.)
  300. if (this.checked === true) {
  301. this.form.isPutaway = 1
  302. } else {
  303. this.form.isPutaway = 0
  304. }
  305. this.$api.put('/merchant/hotel/mine/updHouseBase', this.form).then(res => {
  306. // console.log('修改成功')
  307. if (res.data.code === 0) {
  308. this.$showToast('修改成功')
  309. setTimeout(() => {
  310. uni.reLaunch({
  311. url: '/pages/my/roomType'
  312. })
  313. }, 1500)
  314. }
  315. })
  316. }
  317. },
  318. // 添加房间
  319. addRoom() {
  320. const newRoom = {
  321. floor: '',
  322. roomNumber: ''
  323. }
  324. this.form.roomFloor.push(newRoom)
  325. },
  326. // 删除房间
  327. delRoom(index) {
  328. this.form.roomFloor.splice(index, 1)
  329. },
  330. // 获取当前房型信息
  331. getTypeInfo() {
  332. if (this.id) {
  333. this.$api.get(`/merchant/hotel/mine/getHouseBaseInfo/${this.id}`).then((res) => {
  334. // console.log(res)
  335. if (res.data.code === 0) {
  336. this.form = res.data.data
  337. this.fileList.push({
  338. url: res.data.data.cover
  339. })
  340. if (this.form.isPutaway == 1) {
  341. this.checked = true
  342. } else {
  343. this.checked = false
  344. }
  345. }
  346. })
  347. } else {
  348. return
  349. }
  350. }
  351. }
  352. }
  353. </script>
  354. <style lang="scss">
  355. .btn-btn {
  356. width: 100%;
  357. height: 136rpx;
  358. background-color: #fff;
  359. position: fixed;
  360. bottom: 0;
  361. padding: 30rpx 0 0;
  362. // margin: 0 auto;
  363. z-index: 999999;
  364. // margin-top: 30rpx;
  365. // margin-left: 30rpx;
  366. }
  367. .btn {
  368. margin: 0 auto;
  369. width: 690rpx;
  370. height: 96rpx;
  371. background-color: #1372FF;
  372. color: #fff;
  373. display: flex;
  374. justify-content: center;
  375. align-items: center;
  376. font-size: 34rpx;
  377. border-radius: 48rpx;
  378. }
  379. .uicon-close {
  380. font-size: 30rpx !important;
  381. top: 8rpx !important;
  382. }
  383. .page {
  384. background: #F3F4F4;
  385. padding-bottom: 260rpx;
  386. box-sizing: border-box;
  387. overflow-y: auto;
  388. overflow-x: auto;
  389. }
  390. .body {
  391. padding-top: 20rpx;
  392. padding-left: 30rpx;
  393. padding-right: 30rpx;
  394. }
  395. .typeInfo {
  396. background-color: #fff;
  397. width: 100%;
  398. // height: 145px;
  399. border-radius: 5px;
  400. padding-top: 15px;
  401. padding-left: 7px;
  402. padding-right: 15px;
  403. box-sizing: border-box;
  404. }
  405. .titleInfo {
  406. // margin-top: 30rpx;
  407. margin-left: 20rpx;
  408. margin-bottom: 40rpx;
  409. }
  410. .cellBox {
  411. margin-left: 20rpx;
  412. display: flex;
  413. padding-bottom: 40rpx;
  414. border-bottom: 1rpx solid #E1E1E1;
  415. }
  416. .bigRoom {
  417. margin-left: 20rpx;
  418. width: 100%;
  419. height: 102rpx;
  420. display: flex;
  421. // justify-content: center;
  422. align-items: center;
  423. }
  424. .shelves {
  425. width: 695rpx;
  426. height: 102rpx;
  427. background-color: #fff;
  428. margin-top: 20rpx;
  429. border-radius: 10rpx;
  430. display: flex;
  431. justify-content: space-between;
  432. align-items: center;
  433. // padding-left: 30rpx;
  434. // padding-right: 30rpx;
  435. }
  436. .uploadPic {
  437. padding-top: 28rpx;
  438. width: 690rpx;
  439. // height: 293rpx;
  440. background-color: #fff;
  441. border-radius: 10rpx;
  442. margin-top: 20rpx;
  443. }
  444. .pic {
  445. // margin-left: 30rpx;
  446. // margin-top: 20rpx;
  447. // width: 190rpx;
  448. // height: 120rpx;
  449. margin: 20rpx 30rpx;
  450. padding-bottom: 20rpx;
  451. }
  452. // .custom-upload-button{
  453. // width: 190rpx;
  454. // height: 120rpx;
  455. // }
  456. .priceInfo {
  457. width: 690rpx;
  458. // height: 908rpx;
  459. background-color: #fff;
  460. border-radius: 10rpx;
  461. margin-top: 20rpx;
  462. padding-top: 30rpx;
  463. }
  464. .week {
  465. padding-left: 30rpx;
  466. padding-right: 30rpx;
  467. margin-bottom: 20rpx;
  468. }
  469. .weekend {
  470. display: flex;
  471. justify-content: space-between;
  472. border-bottom: 1rpx solid #E1E1E1;
  473. padding-bottom: 30rpx;
  474. }
  475. .everyDay {
  476. padding-left: 30rpx;
  477. padding-right: 30rpx;
  478. width: 100%;
  479. // background-color: pink;
  480. height: 102rpx;
  481. display: flex;
  482. align-items: center;
  483. }
  484. .days {
  485. display: flex;
  486. align-items: center;
  487. border-bottom: 1rpx solid #E1E1E1;
  488. padding-bottom: 30rpx;
  489. }
  490. .priceBoxWeek {
  491. display: flex;
  492. align-items: center;
  493. padding-left: 30rpx;
  494. padding-right: 30rpx;
  495. }
  496. .weekendBox {
  497. width: 630rpx;
  498. display: flex;
  499. align-items: center;
  500. // margin-right: 90rpx;
  501. // justify-content: space-between;
  502. border-bottom: 1rpx solid #E1E1E1;
  503. height: 102rpx;
  504. overflow: hidden;
  505. box-sizing: border-box;
  506. }
  507. .everyHouseList {
  508. // padding-right: 30rpx;
  509. width: 690rpx;
  510. // height: 908rpx;
  511. background-color: #fff;
  512. border-radius: 10rpx;
  513. margin-top: 20rpx;
  514. // padding-top: 30rpx;
  515. }
  516. .HouseListTitleInfo {
  517. margin-right: 30rpx;
  518. margin-left: 20rpx;
  519. margin-bottom: 40rpx;
  520. display: flex;
  521. justify-content: space-between;
  522. }
  523. .submit {
  524. margin-top: 20rpx;
  525. border-radius: 10rpx;
  526. width: 690rpx;
  527. height: 102rpx;
  528. background-color: #fff;
  529. display: flex;
  530. justify-content: center;
  531. align-items: center;
  532. }
  533. .addSubmit {
  534. width: 100%;
  535. position: fixed;
  536. /* 固定定位 */
  537. bottom: 20rpx;
  538. /* 底部对齐 */
  539. left: 0;
  540. /* 可选:左对齐 */
  541. // width: 690rpx;
  542. /* 可选:宽度为 100% */
  543. height: 96rpx;
  544. margin-left: 30rpx;
  545. // padding-top: 20rpx;
  546. margin-top: 30rpx;
  547. background-color: #1372FF;
  548. border-radius: 48rpx;
  549. }
  550. .uploadPicPic {
  551. position: relative;
  552. top: -96rpx;
  553. }
  554. .u-upload__deletable[data-v-69e2a36e] {
  555. width: 0 !important;
  556. }
  557. </style>