house.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <view class="house-detail">
  3. <view class="house-swiper">
  4. <swiper class="swiper" circular :indicator-dots="true">
  5. <swiper-item v-for="item in responsibility" :key="item.id">
  6. <view class="swiper-item-box">
  7. <image class="image" :src="item.url" mode="aspectFill" @click="openImage(item)">
  8. </image>
  9. <view class="open-video-icon" v-if="item.fileType === 'video'" @click="openVideo(item)">
  10. <uni-icons type="icon-bofang" custom-prefix="iconfont" color="rgba(255, 255, 255, 0.6)"
  11. size="26">
  12. </uni-icons>
  13. </view>
  14. </view>
  15. </swiper-item>
  16. </swiper>
  17. <uni-icons class="btn" @click="roomCollection" :type="detail.roomCollection ? 'heart-filled' : 'heart'"
  18. color="#ff4d4f" size="28">
  19. </uni-icons>
  20. </view>
  21. <view class="house-title">
  22. <view class="house-name">{{detail.name}}</view>
  23. <view class="tag">
  24. <text style="margin-right: 6rpx;">{{detail.area}}m²</text>
  25. <text v-for="(tag,index) in detail.tagList" :key="index"> | {{tag.name}}</text>
  26. </view>
  27. <view class="pirce">
  28. <text class="number">{{detail.price}}</text>
  29. <text class="label">/月</text>
  30. </view>
  31. <view class="project-label">距离您{{detail.distance || '-'}}km</view>
  32. <button type="default" class="wx-icon" open-type="share">
  33. <uni-icons type="weixin" open-type="share" size="38" color="#43b156">
  34. </uni-icons>
  35. </button>
  36. </view>
  37. <view class="house-label house-article">{{detail.comment}}</view>
  38. <view class="house-content">
  39. <view class="content-title">基本信息</view>
  40. <view class="information-list">
  41. <view class="information-box">
  42. <text class="information-title">所属楼宇:</text>
  43. <text class="information-text">{{detail.projectItemName}}</text>
  44. </view>
  45. <view class="information-box">
  46. <text class="information-title">所属楼层:</text>
  47. <text class="information-text">{{detail.projectItemTargetName}}</text>
  48. </view>
  49. <view class="information-box">
  50. <text class="information-title">房源类型:</text>
  51. <text class="information-text">{{$field.findTypeName('houseType',detail.roomTypeId)}}</text>
  52. </view>
  53. <view class="information-box">
  54. <text class="information-title">房间号码:</text>
  55. <text class="information-text">{{detail.roomNumber}}</text>
  56. </view>
  57. <view class="information-box">
  58. <text class="information-title">房源面积:</text>
  59. <text class="information-text">{{detail.area}}</text>
  60. </view>
  61. <view class="information-box">
  62. <text class="information-title">付款方式:</text>
  63. <text class="information-text">{{$field.findTypeName('payWay',detail.payWay)}}</text>
  64. </view>
  65. <view class="information-box" style="margin-bottom: 0;">
  66. <text class="information-title">产权证书:</text>
  67. <text class="information-text">{{detail.propertyCertificateNumber?'有':'无'}}</text>
  68. </view>
  69. <view class="information-box" style="margin-bottom: 0;">
  70. <text class="information-title">是否装修:</text>
  71. <text class="information-text">{{detail.decoration === 1 ? '已装修':'未装修'}}</text>
  72. </view>
  73. </view>
  74. <view class="content-title">房源简介</view>
  75. <view class="desc-text" v-html="detail.introduce"></view>
  76. <view class="people-tell">
  77. <avatar class="people-avatar"
  78. :user="{portrait:detail.chargePersonPortrait,name:detail.chargePersonName}"
  79. @click="$navigateTo('/pages/person/person?userId='+detail.chargePersonId)" :size="34">
  80. </avatar>
  81. <view class="people-text" @click="$navigateTo('/pages/person/person?userId=' + detail.chargePersonId)">
  82. <view class="people-name">{{detail.chargePersonName}}</view>
  83. <view class="people-organization">{{detail.organizationName||'-'}}</view>
  84. </view>
  85. <view class="people-icon" @click="tell">
  86. <uni-icons type="phone-filled" color="#fff"></uni-icons>
  87. </view>
  88. </view>
  89. <view class="content-title">地理位置</view>
  90. <view class="content-map">
  91. <map id="map" class="map" :show-location="true" :latitude="latitude" :longitude="longitude"></map>
  92. </view>
  93. <view class="content-title">配套设施</view>
  94. <view class="content-device">
  95. <view class="device-item"
  96. v-for="item in $field.findTypeNameByList('supportingFacilities',detail.supportingFacilities)"
  97. :key="item.id">
  98. <uni-icons class="device-icon" custom-prefix="iconfont" :type="item.icon" size="18"></uni-icons>
  99. <text class="device-label">{{item.name}}</text>
  100. </view>
  101. </view>
  102. <view class="content-title">
  103. <text>访客记录</text>
  104. <text class="more" @click="$navigateTo('/pages/visitor/visitor?houseId=' + houseId)">查看更多>></text>
  105. </view>
  106. <view class="visitor">
  107. <view class="visitor-item" v-for="(item,index) in visitorList" :key="index">
  108. <image class="visitor-avatar" :src="item.userPortrait" mode="aspectFill">
  109. </image>
  110. <text class="visitor-label">{{item.userName}}访问了房源</text>
  111. <uni-dateformat class="visitor-time" :date="item.date" :threshold="[60000,3600000 * 24 * 365]">
  112. </uni-dateformat>
  113. </view>
  114. </view>
  115. <view class="content-title">
  116. <text>房源评价</text>
  117. </view>
  118. <view class="evaluate">
  119. <hb-comment ref="hbComment" @add="addEvaluate" @del="del" @like="like" :deleteTip="'确认删除?'"
  120. :cmData="commentData" v-if="commentData">
  121. </hb-comment>
  122. </view>
  123. </view>
  124. <view class="hui-button-box">
  125. <view class="hui-button-view">
  126. <view class="hui-button hui-button-light"
  127. @click="$navigateTo('/pages/reservation/reservation?houseId=' + houseId+'&projectId=' + detail.projectId + '&chargePersonId=' + detail.chargePersonId)">
  128. <uni-icons class="hui-button-icon" type="calendar" color="#08979c" size="22"></uni-icons> 预约看房
  129. </view>
  130. <view class="hui-button"
  131. @click="$navigateTo('/pages/chat/chat?userId='+detail.chargePersonId+'&userName='+detail.chargePersonName)">
  132. <uni-icons class="hui-button-icon" type="chat" color="#fff" size="22"></uni-icons>
  133. 在线联系
  134. </view>
  135. </view>
  136. <uv-safe-bottom></uv-safe-bottom>
  137. </view>
  138. <uni-popup ref="popup" type="bottom" mask-background-color="rgba(0,0,0,0.8)">
  139. <video id="myVideo" v-if="videoUrl" :src="videoUrl" controls autoplay>
  140. </video>
  141. </uni-popup>
  142. </view>
  143. </template>
  144. <script>
  145. import {
  146. dayjs
  147. } from '@/uni_modules/iRainna-dayjs/js_sdk/dayjs.min';
  148. import {
  149. getHouseDetailById,
  150. insertVisitor,
  151. getVisitorByQuery,
  152. collection,
  153. disableCollection,
  154. getHouseEvaluateListByPage,
  155. insertEvaluate
  156. } from '@/request/api/house.js'
  157. import avatar from '@/components/common/avatar.vue';
  158. export default {
  159. data() {
  160. return {
  161. detail: {
  162. area: 0
  163. },
  164. houseId: 15,
  165. responsibility: [],
  166. coordinates: [],
  167. latitude: 39.90923,
  168. longitude: 116.397428,
  169. mapContext: {},
  170. visitorList: [],
  171. startTime: '',
  172. commentData: {
  173. readNumer: 0,
  174. commentSize: 0,
  175. comment: []
  176. },
  177. shareButton: false,
  178. coordinates: '',
  179. videoUrl: ''
  180. }
  181. },
  182. components: {
  183. avatar
  184. },
  185. onLoad(body) {
  186. if (body.houseId) this.houseId = body.houseId;
  187. this.coordinates = this.$store.getters.coordinates;
  188. this.startTime = new Date().getTime();
  189. },
  190. onReady() {
  191. this.mapContext = uni.createMapContext("map", this);
  192. this.init();
  193. },
  194. onUnload() {
  195. let endTime = new Date().getTime();
  196. let time = endTime - this.startTime;
  197. if (time > 10000) this.createVisitor();
  198. },
  199. onShareAppMessage(res) {
  200. return {
  201. title: this.detail.name || '',
  202. }
  203. },
  204. methods: {
  205. init() {
  206. getHouseDetailById(this.houseId + '?coordinates=' + this.coordinates).then(res => {
  207. if (res.code === 200) {
  208. this.detail = res.data;
  209. let imageBox = [],
  210. videoBox = [];
  211. if (this.detail.picture) {
  212. imageBox = JSON.parse(this.detail.picture).map(node => {
  213. node['fileType'] = 'image';
  214. return node;
  215. });
  216. }
  217. if (this.detail.video) {
  218. videoBox = JSON.parse(this.detail.video).map(node => {
  219. node['fileType'] = 'video';
  220. node['videoUrl'] = node.url;
  221. node['url'] = node.url + '?x-oss-process=video/snapshot,t_0,f_jpg'
  222. return node;
  223. });
  224. }
  225. this.responsibility = videoBox.concat(imageBox);
  226. if (this.detail.coordinates) {
  227. this.coordinates = this.detail.coordinates.split(',');
  228. this.latitude = this.coordinates[1];
  229. this.longitude = this.coordinates[0];
  230. this.addMarkers();
  231. }
  232. this.getVisitor();
  233. this.getHouseEvaluate();
  234. }
  235. })
  236. },
  237. getHouseEvaluate() {
  238. getHouseEvaluateListByPage({
  239. currPage: 1,
  240. pageSize: 100,
  241. projectItemTargetRoomId: this.houseId
  242. }).then(res => {
  243. if (res.code == 200) {
  244. this.commentData.commentSize = res.data.totalCount;
  245. this.commentData.comment = this.getTree(res.data.dataList.map(node => {
  246. return {
  247. "id": node.id, // 唯一主键
  248. "owner": true, // 是否是拥有者,为true则可以删除,管理员全部为true
  249. "hasLike": false, // 是否点赞
  250. "likeNum": 2, // 点赞数量
  251. "avatarUrl": node.userPortrait, // 评论者头像地址
  252. "nickName": node.userName, // 评论者昵称,昵称过长请在后端截断
  253. "content": node.content, // 评论内容
  254. "parentId": node.parentId, // 所属评论的唯一主键
  255. "createTime": node.date // 创建时间
  256. }
  257. }))
  258. }
  259. })
  260. },
  261. openVideo(item) {
  262. this.videoUrl = item.videoUrl;
  263. this.$refs.popup.open('center');
  264. },
  265. openImage(item) {
  266. if (item.fileType !== 'image') return;
  267. let imageList = this.responsibility.filter(node => node.fileType === 'image');
  268. let current = imageList.findIndex(node => node.id == item.id);
  269. uni.previewImage({
  270. urls: imageList.map(node => node.url),
  271. current: current,
  272. longPressActions: {
  273. success: function(data) {},
  274. fail: function(err) {}
  275. }
  276. });
  277. },
  278. getTree(data) {
  279. let result = [];
  280. let map = {};
  281. data.forEach(item => {
  282. map[item.id] = item;
  283. });
  284. data.forEach(item => {
  285. let parent = map[item.parentId];
  286. if (parent) {
  287. (parent.children || (parent.children = [])).push(item);
  288. } else {
  289. result.push(item);
  290. }
  291. });
  292. return result;
  293. },
  294. addEvaluate(data) {
  295. insertEvaluate({
  296. userId: this.$store.getters.user.userId,
  297. projectItemTargetRoomId: this.houseId,
  298. content: data.content,
  299. parentId: data.pId || 0
  300. }).then(res => {
  301. if (res.code == 200) {
  302. this.$toast('评价成功');
  303. this.getHouseEvaluate();
  304. this.$refs.hbComment.addComplete();
  305. }
  306. })
  307. },
  308. mp4Preview() {
  309. },
  310. del() {
  311. },
  312. like() {
  313. },
  314. tell() {
  315. if (!this.detail.chargePersonPhone) this.$toast('该用户暂未提供手机号');
  316. uni.makePhoneCall({
  317. phoneNumber: this.detail.chargePersonPhone
  318. });
  319. },
  320. roomCollection() {
  321. this.detail.roomCollection ? disableCollection(this.houseId).then(res => this.successCollection(res,
  322. '取消收藏')) : collection(this.houseId).then(res => this.successCollection(res, '收藏成功'));
  323. },
  324. successCollection(res, msg) {
  325. if (res.code === 200) {
  326. this.init();
  327. this.$toast(msg);
  328. }
  329. },
  330. addMarkers() {
  331. const positions = [{
  332. latitude: this.coordinates[1],
  333. longitude: this.coordinates[0],
  334. }]
  335. const markers = []
  336. positions.forEach((p, i) => {
  337. markers.push(
  338. Object.assign({}, {
  339. id: i + 1,
  340. width: 50,
  341. height: 50,
  342. joinCluster: true, // 指定了该参数才会参与聚合
  343. }, p)
  344. )
  345. })
  346. this.mapContext.addMarkers({
  347. markers,
  348. clear: false,
  349. complete(res) {}
  350. })
  351. },
  352. getVisitor() {
  353. getVisitorByQuery({
  354. currPage: 1,
  355. pageSize: 2,
  356. projectItemTargetRoomId: this.houseId
  357. }).then(res => {
  358. if (res.code === 200) {
  359. this.visitorList = res.data.dataList;
  360. }
  361. })
  362. },
  363. createVisitor() {
  364. insertVisitor({
  365. userId: this.$store.getters.user.userId,
  366. projectItemTargetRoomId: this.houseId
  367. })
  368. },
  369. share() {
  370. //根据id获取
  371. uni.createSelectorQuery().select('#shareButton').node().exec(res => {
  372. //res[0].node未获取到的指定的dom元素对象
  373. console.log("res", res[0].node)
  374. })
  375. }
  376. },
  377. }
  378. </script>
  379. <style lang="scss">
  380. .house-detail {
  381. background: #fff;
  382. padding-bottom: 160rpx;
  383. .house-swiper {
  384. position: relative;
  385. .btn {
  386. position: absolute;
  387. top: 20rpx;
  388. right: 30rpx;
  389. }
  390. }
  391. .swiper {
  392. height: 400rpx;
  393. .image,
  394. .swiper-item-box {
  395. width: 100%;
  396. height: 100%;
  397. position: relative;
  398. }
  399. .open-video-icon {
  400. position: absolute;
  401. top: 50%;
  402. left: 50%;
  403. width: 80rpx;
  404. height: 80rpx;
  405. border-radius: 80rpx;
  406. background: rgba(0, 0, 0, 0.6);
  407. display: flex;
  408. align-items: center;
  409. justify-content: center;
  410. margin-left: -40rpx;
  411. margin-top: -40rpx;
  412. padding-left: 6rpx;
  413. box-sizing: border-box;
  414. }
  415. }
  416. .house-label {
  417. font-size: 24rpx;
  418. color: $uni-secondary-color;
  419. font-weight: 300;
  420. }
  421. .house-article {
  422. font-size: 28rpx;
  423. padding: 0 30rpx;
  424. }
  425. .house-title {
  426. padding: 40rpx 130rpx 30rpx 30rpx;
  427. position: relative;
  428. .house-name {
  429. font-size: 36rpx;
  430. font-weight: 500;
  431. }
  432. .project-label {
  433. font-size: 24rpx;
  434. color: $uni-secondary-color;
  435. font-weight: 300;
  436. position: absolute;
  437. bottom: 50rpx;
  438. right: 30rpx;
  439. }
  440. .tag {
  441. font-size: 24rpx;
  442. font-weight: 300;
  443. color: $uni-secondary-color;
  444. padding: 12rpx 0;
  445. }
  446. .pirce {
  447. color: $uni-primary;
  448. .number {
  449. font-weight: 600;
  450. font-size: 48rpx;
  451. }
  452. .label {
  453. font-size: 24rpx;
  454. }
  455. }
  456. .wx-icon {
  457. position: absolute;
  458. top: 0;
  459. right: 30rpx;
  460. transform: translateY(50%);
  461. line-height: 1;
  462. background: transparent;
  463. &::after {
  464. display: none;
  465. }
  466. }
  467. }
  468. .content-map {
  469. width: 100%;
  470. height: 360rpx;
  471. border-radius: 16rpx;
  472. overflow: hidden;
  473. display: flex;
  474. .map {
  475. flex: 1;
  476. height: 100%;
  477. border-radius: 16rpx;
  478. }
  479. }
  480. .house-content {
  481. padding: 0 30rpx;
  482. box-sizing: border-box;
  483. .content-title {
  484. font-size: 32rpx;
  485. font-weight: 500;
  486. margin: 30rpx 0;
  487. display: flex;
  488. align-items: center;
  489. justify-content: space-between;
  490. .more {
  491. color: $uni-secondary-color;
  492. font-weight: 300;
  493. font-size: 24rpx;
  494. }
  495. }
  496. .people-tell {
  497. margin: 40rpx 0;
  498. height: 140rpx;
  499. border-radius: 20rpx;
  500. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  501. display: flex;
  502. align-items: center;
  503. padding: 0 30rpx;
  504. .people-avatar {
  505. width: 90rpx;
  506. height: 90rpx;
  507. border-radius: 50%;
  508. margin-right: 30rpx;
  509. overflow: hidden;
  510. }
  511. .people-text {
  512. flex: 1;
  513. width: 0;
  514. overflow: hidden;
  515. }
  516. .people-name {
  517. font-size: 16px;
  518. font-weight: 500;
  519. margin-bottom: 8rpx;
  520. }
  521. .people-organization {
  522. font-weight: 300;
  523. font-size: 24rpx;
  524. color: $uni-secondary-color;
  525. }
  526. .people-icon {
  527. width: 60rpx;
  528. height: 60rpx;
  529. border-radius: 50%;
  530. background: $uni-primary;
  531. text-align: center;
  532. line-height: 60rpx;
  533. }
  534. }
  535. .visitor {
  536. .visitor-item {
  537. margin-bottom: 20rpx;
  538. display: flex;
  539. align-items: center;
  540. font-weight: 300;
  541. .visitor-avatar {
  542. width: 80rpx;
  543. height: 80rpx;
  544. border-radius: 80rpx;
  545. }
  546. .visitor-label {
  547. flex: 1;
  548. width: 0;
  549. overflow: hidden;
  550. white-space: nowrap;
  551. text-overflow: ellipsis;
  552. margin: 0 20rpx;
  553. }
  554. .visitor-time {
  555. font-size: 24rpx;
  556. color: $uni-secondary-color;
  557. }
  558. &:last-child {
  559. margin-bottom: 0;
  560. }
  561. }
  562. }
  563. .desc-text {
  564. font-weight: 300;
  565. }
  566. .information-list {
  567. display: flex;
  568. flex-wrap: wrap;
  569. .information-box {
  570. width: 50%;
  571. display: flex;
  572. margin-bottom: 30rpx;
  573. }
  574. .information-title {
  575. color: $uni-secondary-color;
  576. font-weight: 500;
  577. }
  578. .information-text {
  579. flex: 1;
  580. width: 0;
  581. overflow: hidden;
  582. white-space: nowrap;
  583. text-overflow: ellipsis;
  584. font-weight: 300;
  585. }
  586. }
  587. .content-device {
  588. display: flex;
  589. flex-wrap: wrap;
  590. .device-item {
  591. width: 50%;
  592. display: flex;
  593. align-items: center;
  594. margin-bottom: 20rpx;
  595. .device-label {
  596. flex: 1;
  597. width: 0;
  598. color: $uni-secondary-color;
  599. font-weight: 200;
  600. margin-left: 10rpx;
  601. }
  602. .device-icon {
  603. color: $uni-base-color;
  604. }
  605. }
  606. }
  607. }
  608. .uni-popup__wrapper {
  609. width: 100%;
  610. height: 600rpx;
  611. #myVideo {
  612. width: 100%;
  613. height: 100%;
  614. }
  615. }
  616. }
  617. </style>