houseList.vue 15 KB

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