houseList.vue 13 KB

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