houseList.vue 11 KB

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