瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

583 lines
12 KiB

11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <template>
  2. <view class="page">
  3. <navbar :title="isEdit ? '编辑租房' : '发布租房'" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="form">
  5. <view class="help-issue">
  6. <text>租房标题</text>
  7. <text style="color: #BD3624;">*</text>
  8. </view>
  9. <view class="form-sheet-cell">
  10. <input type="text" class="title-input" v-model="form.title"/>
  11. </view>
  12. <uv-cell
  13. title="租房地点"
  14. rightIconStyle="fontSize: 30rpx;"
  15. :value="form.address || '请选择租房地点'"
  16. @click="selectAddr"
  17. isLink
  18. ></uv-cell>
  19. <uv-cell
  20. title="朝向"
  21. rightIconStyle="fontSize: 30rpx;"
  22. :value="form.face || '请选择朝向'"
  23. @click="openPicker('face')"
  24. isLink
  25. ></uv-cell>
  26. <uv-cell
  27. title="装修"
  28. rightIconStyle="fontSize: 30rpx;"
  29. :value="form.decoration || '请选择装修'"
  30. @click="openPicker('decoration')"
  31. isLink
  32. ></uv-cell>
  33. <!-- <uv-cell
  34. title="楼层"
  35. rightIconStyle="fontSize: 30rpx;"
  36. value="请选择楼层"
  37. isLink
  38. ></uv-cell> -->
  39. <!-- <view class="form-sheet-cell">
  40. <view class="label">
  41. 租房地点
  42. </view>
  43. <view class="price">
  44. <input placeholder="请输入租房地点" v-model="form.address" />
  45. </view>
  46. </view> -->
  47. <view class="form-sheet-cell">
  48. <view class="label">
  49. 楼层
  50. </view>
  51. <view class="price">
  52. <input placeholder="请输入楼层(1楼)" v-model="form.floor" />
  53. </view>
  54. </view>
  55. <view class="form-sheet-cell">
  56. <view class="label">
  57. 户型
  58. </view>
  59. <view class="price">
  60. <input placeholder="请输入户型(三室一厅)" v-model="form.home" />
  61. </view>
  62. </view>
  63. <view class="form-sheet-cell">
  64. <view class="label">
  65. 付款方式
  66. </view>
  67. <view class="price">
  68. <input placeholder="请输入付款方式(押一付三)" v-model="form.payment" />
  69. </view>
  70. </view>
  71. <view class="form-sheet-cell">
  72. <view class="label">
  73. 租金/
  74. </view>
  75. <view class="price">
  76. <input placeholder="请输入租金" type="text" v-model="form.money" />
  77. </view>
  78. </view>
  79. <view class="form-sheet-cell">
  80. <view class="label">
  81. 面积
  82. </view>
  83. <view class="price">
  84. <input placeholder="请输入面积(平方米)" type="number" v-model="form.crm" />
  85. </view>
  86. </view>
  87. <view class="form-sheet-cell">
  88. <view class="label">
  89. 看房
  90. </view>
  91. <uv-radio-group v-model="form.showings">
  92. <view class="price">
  93. <uv-radio
  94. :customStyle="{margin: '8px'}"
  95. iconSize="30rpx"
  96. size="40rpx"
  97. labelSize="26rpx"
  98. :label="t.name"
  99. v-for="(t, i) in showingsRadio"
  100. :key="i"
  101. :name="t.name">
  102. </uv-radio>
  103. </view>
  104. </uv-radio-group>
  105. </view>
  106. <view class="form-sheet-cell">
  107. <view class="label">
  108. 电梯
  109. </view>
  110. <uv-radio-group v-model="form.lift">
  111. <view class="price">
  112. <uv-radio
  113. :customStyle="{margin: '8px'}"
  114. iconSize="30rpx"
  115. size="40rpx"
  116. labelSize="26rpx"
  117. :label="t.name"
  118. :name="t.name"
  119. v-for="(t, i) in liftRadio"
  120. :key="i">
  121. </uv-radio>
  122. </view>
  123. </uv-radio-group>
  124. </view>
  125. <view class="form-sheet-cell">
  126. <view class="label">
  127. 交付
  128. </view>
  129. <uv-radio-group v-model="form.deliver">
  130. <view class="price">
  131. <uv-radio
  132. :customStyle="{margin: '8px'}"
  133. iconSize="30rpx"
  134. size="40rpx"
  135. labelSize="26rpx"
  136. :label="t.name"
  137. :name="t.name"
  138. v-for="(t, i) in deliverRadio"
  139. :key="i">
  140. </uv-radio>
  141. </view>
  142. </uv-radio-group>
  143. </view>
  144. <view class="form-sheet-cell">
  145. <view class="label">
  146. 联系电话
  147. </view>
  148. <input placeholder="请输入联系电话" v-model="form.phone" />
  149. </view>
  150. <view class="form-sheet-cell">
  151. <view class="label">
  152. 备注
  153. </view>
  154. <input placeholder="请输入备注" v-model="form.titleSub" />
  155. </view>
  156. <view class="images box">
  157. <view class="">
  158. 精选照片
  159. </view>
  160. <uv-upload
  161. :fileList="fileList"
  162. :maxCount="imageMax"
  163. multiple
  164. width="150rpx"
  165. height="150rpx"
  166. @delete="deleteImage"
  167. @afterRead="afterRead"
  168. :previewFullImage="true"></uv-upload>
  169. </view>
  170. <view class="category">
  171. <view class="title">
  172. 选择地区
  173. </view>
  174. <view class="tagList">
  175. <view
  176. :class="{act : t.id == form.addId}"
  177. @click="form.addId = t.id"
  178. v-for="(t, i) in cityList"
  179. :key="i">
  180. {{ t.name }}
  181. </view>
  182. </view>
  183. </view>
  184. <!-- <view class="">
  185. <uv-textarea
  186. v-model="form.content"
  187. count
  188. :maxlength="300"
  189. autoHeight
  190. placeholder="请输入详细介绍"></uv-textarea>
  191. </view> -->
  192. <uv-picker
  193. ref="picker"
  194. :columns="columns"
  195. @confirm="pickerConfirm"></uv-picker>
  196. <view class="uni-color-btn"
  197. @click="submit">
  198. {{ isEdit ? '保存修改' : '发布' }}
  199. </view>
  200. <!-- 编辑模式下显示删除按钮 -->
  201. <view v-if="isEdit" class="delete-btn"
  202. @click="deleteRenting">
  203. 删除租房
  204. </view>
  205. </view>
  206. </view>
  207. </template>
  208. <script>
  209. import Position from '@/utils/position.js'
  210. import { mapState } from 'vuex'
  211. export default {
  212. data() {
  213. return {
  214. rentingId: '', // 租房ID,用于编辑模式
  215. isEdit: false, // 是否为编辑模式
  216. form : {
  217. addId : '',//地区id
  218. address : '',//地址
  219. crm : '',//面积
  220. showings : '随时可看',//看房
  221. face : '',
  222. lift : '有',
  223. deliver : '整租',
  224. floor : '',
  225. decoration : '',
  226. title: '', // 租房标题
  227. home: '', // 户型
  228. payment: '', // 付款方式
  229. money: '', // 租金
  230. phone: '', // 联系电话
  231. titleSub: '', // 备注
  232. latitude: '', // 纬度
  233. longitude: '', // 经度
  234. },
  235. showingsRadio : [//看房
  236. {
  237. name : '随时可看',
  238. },
  239. {
  240. name : '电话预约',
  241. },
  242. ],
  243. liftRadio : [
  244. {
  245. name : '有',
  246. },
  247. {
  248. name : '无',
  249. },
  250. ],
  251. deliverRadio : [
  252. {
  253. name : '整租',
  254. },
  255. {
  256. name : '合租',
  257. },
  258. ],
  259. fileList : [],
  260. imageMax : 9,
  261. picker : {
  262. face : [
  263. '朝东',
  264. '朝南',
  265. '朝西',
  266. '朝北',
  267. ],
  268. decoration : [
  269. '精装',
  270. '毛胚',
  271. ],
  272. },
  273. pickerKey : '',
  274. }
  275. },
  276. onLoad(options) {
  277. // 检查是否是编辑模式
  278. if (options.id) {
  279. this.rentingId = options.id
  280. this.isEdit = true
  281. this.getRentingDetail()
  282. } else {
  283. // 新增模式,设置默认地区
  284. if (this.cityList && this.cityList.length > 0) {
  285. this.form.addId = this.cityList[0].id
  286. }
  287. }
  288. },
  289. computed : {
  290. columns(){
  291. return [this.picker[this.pickerKey]]
  292. },
  293. ...mapState(['cityList', 'category']),
  294. },
  295. watch: {
  296. // 监听cityList变化,用于处理异步加载的城市数据
  297. cityList: {
  298. handler(newVal) {
  299. if (newVal && newVal.length > 0 && !this.isEdit && !this.form.addId) {
  300. this.form.addId = newVal[0].id
  301. }
  302. },
  303. immediate: true
  304. }
  305. },
  306. methods: {
  307. // 获取租房详情数据
  308. getRentingDetail() {
  309. this.$api('getRentDetail', { id: this.rentingId }, res => {
  310. if (res.code == 200) {
  311. const data = res.result
  312. // 回显基本信息
  313. this.form = {
  314. ...this.form,
  315. title: data.title || '',
  316. address: data.address || '',
  317. face: data.face || '',
  318. decoration: data.decoration || '',
  319. floor: data.floor || '',
  320. home: data.home || '',
  321. payment: data.payment || '',
  322. money: data.money || '',
  323. crm: data.crm || '',
  324. showings: data.showings || '随时可看',
  325. lift: data.lift || '有',
  326. deliver: data.deliver || '整租',
  327. phone: data.phone || '',
  328. titleSub: data.titleSub || '',
  329. addId: data.addId || (this.cityList.length > 0 ? this.cityList[0].id : ''),
  330. latitude: data.latitude || '',
  331. longitude: data.longitude || '',
  332. }
  333. // 回显图片
  334. if (data.image) {
  335. const images = data.image.split(',').filter(img => img.trim())
  336. this.fileList = images.map(url => ({ url: url.trim() }))
  337. }
  338. } else {
  339. uni.showToast({
  340. title: res.msg || '获取租房信息失败',
  341. icon: 'none'
  342. })
  343. }
  344. })
  345. },
  346. openPicker(key){
  347. this.pickerKey = key
  348. this.$refs.picker.open()
  349. },
  350. pickerConfirm(e){
  351. this.form[this.pickerKey] = e.value[0]
  352. },
  353. deleteImage(e){
  354. this.fileList.splice(e.index, 1)
  355. },
  356. afterRead(e){
  357. let self = this
  358. e.file.forEach(file => {
  359. self.$Oss.ossUpload(file.url).then(url => {
  360. self.fileList.push({
  361. url
  362. })
  363. })
  364. })
  365. },
  366. //地图上选择地址
  367. selectAddr() {
  368. Position.selectAddress(this.form.latitude || 0, this.form.longitude || 0, res => {
  369. //经纬度信息
  370. this.form.latitude = res.latitude
  371. this.form.longitude = res.longitude
  372. if (res.name) {
  373. return this.form.address = res.name
  374. }
  375. this.form.address = ''
  376. })
  377. },
  378. // 提交
  379. submit(){
  380. if (this.$utils.verificationAll(this.form, {
  381. title: '请输入标题',
  382. address : '请选择租房地点',
  383. face : '请选择朝向',
  384. decoration : '请选择装修',
  385. floor : '请输入楼层',
  386. home : '请输入户型',
  387. payment : '请输入付款方式',
  388. money : '请输入租金',
  389. crm : '请输入面积',
  390. showings : '请选择看房',
  391. lift : '请选择电梯',
  392. deliver : '请选择交付方式',
  393. phone: '请输入联系电话',
  394. })) {
  395. return
  396. }
  397. if(this.fileList.length == 0){
  398. return uni.showToast({
  399. title: '请上传精选照片',
  400. icon : 'none'
  401. })
  402. }
  403. // 处理图片数据
  404. this.form.image = this.fileList.map(n => n.url).join(',')
  405. // 根据是否是编辑模式调用不同的API
  406. const apiName = this.isEdit ? 'editMyRent' : 'publishRent'
  407. const params = this.isEdit ? { ...this.form, id: this.rentingId } : this.form
  408. this.$api(apiName, params, res => {
  409. if(res.code == 200){
  410. uni.showToast({
  411. title: this.isEdit ? '修改成功!' : '发布成功!',
  412. icon: 'none'
  413. })
  414. setTimeout(() => {
  415. uni.navigateBack()
  416. }, 1000)
  417. } else {
  418. uni.showToast({
  419. title: res.msg || (this.isEdit ? '修改失败' : '发布失败'),
  420. icon: 'none'
  421. })
  422. }
  423. })
  424. },
  425. // 删除租房
  426. deleteRenting() {
  427. uni.showModal({
  428. title: '确认删除',
  429. content: '确定要删除这个租房信息吗?删除后无法恢复。',
  430. confirmColor: '#ff4757',
  431. success: (res) => {
  432. if (res.confirm) {
  433. this.$api('deleteMyRent', { id: this.rentingId }, res => {
  434. if (res.code == 200) {
  435. uni.showToast({
  436. title: '删除成功!',
  437. icon: 'none'
  438. })
  439. setTimeout(() => {
  440. uni.navigateBack()
  441. }, 1000)
  442. } else {
  443. uni.showToast({
  444. title: res.msg || '删除失败',
  445. icon: 'none'
  446. })
  447. }
  448. })
  449. }
  450. }
  451. })
  452. },
  453. }
  454. }
  455. </script>
  456. <style scoped lang="scss">
  457. .page{
  458. background-color: #fff;
  459. min-height: 100vh;
  460. box-sizing: border-box;
  461. color: #333333;
  462. font-size: 28rpx;
  463. /deep/ text{
  464. font-size: 28rpx !important;
  465. }
  466. .form{
  467. padding: 30rpx;
  468. .help-issue {
  469. margin: 20rpx;
  470. }
  471. .title-input{
  472. border: 1px solid $uni-color;
  473. width: 100%;
  474. border-radius: 10rpx;
  475. padding: 10rpx 20rpx;
  476. box-sizing: border-box;
  477. height: 65rpx;
  478. }
  479. .form-sheet-cell{
  480. display: flex;
  481. background-color: #fff;
  482. padding: 20rpx 30rpx;
  483. align-items: center;
  484. .label{
  485. width: 160rpx;
  486. }
  487. .price{
  488. display: flex;
  489. // text-align: center;
  490. input{
  491. width: 450rpx;
  492. // border: 1px solid $uni-color;
  493. margin: 0 10rpx;
  494. }
  495. }
  496. .right-icon{
  497. margin-left: auto;
  498. }
  499. }
  500. .images{
  501. padding: 30rpx;
  502. view{
  503. padding-bottom: 20rpx;
  504. }
  505. }
  506. }
  507. .delete-btn {
  508. background: #ff4757;
  509. color: white;
  510. text-align: center;
  511. padding: 20rpx;
  512. margin: 30rpx;
  513. border-radius: 40rpx;
  514. font-size: 28rpx;
  515. font-weight: bold;
  516. &:active {
  517. background: #ff3742;
  518. }
  519. }
  520. .category{
  521. padding: 20rpx;
  522. .title{
  523. // font-weight: 900;
  524. // font-size: 30rpx;
  525. }
  526. .tagList{
  527. display: flex;
  528. flex-wrap: wrap;
  529. padding: 10rpx 0;
  530. view{
  531. background: rgba($uni-color, 0.1);
  532. padding: 10rpx 20rpx;
  533. margin: 10rpx;
  534. border-radius: 10rpx;
  535. font-size: 26rpx;
  536. }
  537. .act{
  538. color: #fff;
  539. background: $uni-color;
  540. }
  541. }
  542. }
  543. }
  544. </style>