houseList.vue 16 KB

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