houseList.vue 14 KB

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