houseList.vue 12 KB

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