homeDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <div class="home-detail">
  3. <div class="container">
  4. <div class="container-box" v-if="detail.id">
  5. <div class="title">{{detail.projectName}}</div>
  6. <div class="home-detail-content">
  7. <div class="home-detail-swiper">
  8. <div class="swiper-container">
  9. <div class="swiper-wrapper">
  10. <div v-for="item in swiperList" :key="item.id" class="swiper-slide"
  11. :style="`background-image:url(${item.url})`" @click.stop="openImage(item)">
  12. <div class="open-video-icon" v-if="item.fileType === 'video'"
  13. @click.stop="openVideo(item)">
  14. <i class="iconfont huifont-bofang"></i>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="swiper-button-prev"></div>
  19. <div class="swiper-button-next"></div>
  20. </div>
  21. </div>
  22. <div class="home-detail-information">
  23. <div class="house-name">{{detail.name}}</div>
  24. <div class="tag">
  25. <span>{{detail.area}}m²</span>
  26. <span v-for="(tag,index) in detail.tagList" :key="index">{{tag.name}}</span>
  27. </div>
  28. <div class="house-price">
  29. <div>
  30. <span class="average alibaba">{{detail.price}}</span><span class="unit">元/月</span>
  31. </div>
  32. <div class="hui-button" @click="reservation">预约看房</div>
  33. </div>
  34. <div class="content-title">基本信息</div>
  35. <div class="information-list">
  36. <div class="information-box">
  37. <div class="information-title">所属楼宇:</div>
  38. <div class="information-div">{{detail.projectItemName}}</div>
  39. </div>
  40. <div class="information-box">
  41. <div class="information-title">所属楼层:</div>
  42. <div class="information-div">{{detail.projectItemTargetName}}</div>
  43. </div>
  44. <div class="information-box">
  45. <div class="information-title">房源类型:</div>
  46. <div class="information-div">{{$field.findTypeName('houseType',detail.roomTypeId)}}
  47. </div>
  48. </div>
  49. <div class="information-box">
  50. <div class="information-title">房间号码:</div>
  51. <div class="information-div">{{detail.roomNumber}}</div>
  52. </div>
  53. <div class="information-box">
  54. <div class="information-title">房源面积:</div>
  55. <div class="information-div">{{detail.area}}m²</div>
  56. </div>
  57. <div class="information-box">
  58. <div class="information-title">付款方式:</div>
  59. <div class="information-div">{{$field.findTypeName('payWay',detail.payWay)}}</div>
  60. </div>
  61. <div class="information-box">
  62. <div class="information-title">产权证书:</div>
  63. <div class="information-div">{{detail.propertyCertificateNumber?'有':'无'}}</div>
  64. </div>
  65. <div class="information-box">
  66. <div class="information-title">是否装修:</div>
  67. <div class="information-div">{{detail.decoration === 1 ? '已装修':'未装修'}}</div>
  68. </div>
  69. </div>
  70. <div class="content-title">房源简介</div>
  71. <div class="desc-text" v-html="detail.introduce"></div>
  72. </div>
  73. </div>
  74. <div class="sub-title">周边配套</div>
  75. <div class="map-container">
  76. <div id="map"></div>
  77. <div class="content-device">
  78. <div class="people-tell">
  79. <avatar class="people-avatar"
  80. :user="{portrait:detail.chargePersonPortrait,name:detail.chargePersonName}" :size="24">
  81. </avatar>
  82. <div class="people-text">
  83. <div class="people-name">{{detail.chargePersonName}}</div>
  84. <div class="people-organization">组织名称</div>
  85. </div>
  86. </div>
  87. <div class="device-list">
  88. <div class="device-item"
  89. v-for="item in $field.findTypeNameByList('supportingFacilities',detail.supportingFacilities)"
  90. :key="item.id">
  91. <i :class="'iconfont device-icon ' + item.icon"></i>
  92. <span class="device-label">{{item.name}}</span>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="skeleton-box" v-else>
  99. <el-empty :description="description">
  100. <span class="color-blue" style="cursor: pointer;" @click="login" v-if="description === '请登录后查看'">
  101. 点击登录>>
  102. </span>
  103. </el-empty>
  104. </div>
  105. </div>
  106. <house-foot></house-foot>
  107. <el-dialog :close-on-click-modal="false" title="预约看房" :visible.sync="visible" width="900px"
  108. :append-to-body="true">
  109. <reservation v-if="visible" @callback="visible = false" :houseId="detail.id" :projectId="detail.projectId"
  110. :chargePersonId="detail.chargePersonId">
  111. </reservation>
  112. </el-dialog>
  113. <el-dialog title="预览" :visible.sync="fileVisible" width="900px" :append-to-body="true">
  114. <video v-if="videoSrc && fileVisible" :src="videoSrc" width="100%" height="100%" style="background: #000;"
  115. controls>
  116. </video>
  117. </el-dialog>
  118. <image-viewer v-if="isShow" :url-list="[imageUrl]" :on-close="()=>isShow = false"></image-viewer>
  119. </div>
  120. </template>
  121. <script>
  122. // 引入插件
  123. import Swiper from 'swiper'; // 注意引入的是Swiper
  124. import 'swiper/css/swiper.min.css' // 注意这里的引入
  125. import houseFoot from "@/components/website/houseFoot.vue"
  126. import Crypto from '@/uitls/crypto'
  127. import {
  128. getToken
  129. } from '@/uitls/auth'
  130. import {
  131. getHouseDetailById
  132. } from '@/httpApi/space'
  133. import {
  134. mapGetters
  135. } from 'vuex';
  136. import reservation from '@/components/website/reservation';
  137. import imageViewer from 'element-ui/packages/image/src/image-viewer.vue';
  138. export default {
  139. data() {
  140. return {
  141. swiper: null,
  142. swiperList: [],
  143. detail: {},
  144. detailId: '',
  145. description: '无房源信息',
  146. visible: false,
  147. isShow: false,
  148. imageUrl: '',
  149. videoSrc: '',
  150. fileVisible: false
  151. };
  152. },
  153. mounted() {
  154. window.scrollTo(0, 0);
  155. this.init();
  156. },
  157. methods: {
  158. init() {
  159. if (!getToken()) return this.description = '请登录后查看';
  160. this.detailId = Crypto.AES.decrypt(decodeURIComponent(this.$route.query.id), 'bosshand');
  161. if (!this.detailId) return this.description = '无房源信息';
  162. this.getDetail();
  163. },
  164. openImage(item) {
  165. if (item.fileType === 'video') return;
  166. this.imageUrl = item.url;
  167. this.isShow = true;
  168. },
  169. openVideo(item) {
  170. this.videoSrc = item.videoUrl;
  171. this.fileVisible = true;
  172. },
  173. getDetail() {
  174. getHouseDetailById(this.detailId).then(res => {
  175. if (res.state) {
  176. this.detail = res.data;
  177. let imageBox = [],
  178. videoBox = [];
  179. if (this.detail.picture) {
  180. imageBox = JSON.parse(this.detail.picture).map(node => {
  181. node['fileType'] = 'image';
  182. return node;
  183. });
  184. }
  185. if (this.detail.video) {
  186. videoBox = JSON.parse(this.detail.video).map(node => {
  187. node['fileType'] = 'video';
  188. node['videoUrl'] = node.url;
  189. node['url'] = node.url + '?x-oss-process=video/snapshot,t_0,f_jpg'
  190. return node;
  191. });
  192. }
  193. this.swiperList = videoBox.concat(imageBox);
  194. this.getSwiper();
  195. if (this.detail.coordinates) {
  196. this.coordinates = this.detail.coordinates.split(',');
  197. this.initMap();
  198. }
  199. }
  200. })
  201. },
  202. initMap() {
  203. this.$nextTick(() => {
  204. let position = new T.LngLat(this.coordinates[0], this.coordinates[1]);
  205. let map = new T.Map('map');
  206. map.centerAndZoom(position, 18);
  207. let mark = new T.Marker(position, {
  208. z: 12
  209. });
  210. map.addOverLay(mark);
  211. })
  212. },
  213. getSwiper() {
  214. this.$nextTick(() => {
  215. this.swiper = new Swiper(".swiper-container", {
  216. loop: true,
  217. navigation: {
  218. nextEl: '.swiper-button-next',
  219. prevEl: '.swiper-button-prev',
  220. },
  221. })
  222. })
  223. },
  224. login() {
  225. this.$store.dispatch('app/changeEvent', {
  226. type: 'login'
  227. })
  228. },
  229. reservation() {
  230. this.visible = true;
  231. }
  232. },
  233. components: {
  234. houseFoot,
  235. reservation,
  236. imageViewer
  237. },
  238. computed: {
  239. ...mapGetters(['event'])
  240. },
  241. watch: {
  242. event() {
  243. let event = this.$store.getters.event;
  244. if (event.type == 'homeDetailReload') this.init();
  245. }
  246. },
  247. };
  248. </script>
  249. <style lang="scss">
  250. .home-detail {
  251. padding-top: 60px;
  252. color: #000;
  253. .login-toggle {
  254. position: fixed;
  255. top: 0;
  256. left: 0;
  257. right: 0;
  258. bottom: 0;
  259. z-index: 998;
  260. background: rgba(0, 0, 0, 0.5);
  261. display: flex;
  262. align-items: center;
  263. justify-content: center;
  264. }
  265. .title {
  266. font-size: 30px;
  267. font-weight: bolder;
  268. line-height: 30px;
  269. margin: 20px 0;
  270. }
  271. .sub-title {
  272. font-size: 24px;
  273. font-weight: bolder;
  274. line-height: 30px;
  275. margin: 20px 0;
  276. }
  277. .map-container {
  278. display: flex;
  279. margin-bottom: 30px;
  280. #map {
  281. width: 670px;
  282. height: 400px;
  283. }
  284. .content-device {
  285. width: 470px;
  286. height: 400px;
  287. margin-left: 60px;
  288. .people-tell {
  289. border-bottom: 1px solid #e7ebee;
  290. display: flex;
  291. align-items: center;
  292. padding: 15px 0;
  293. margin-bottom: 15px;
  294. .people-avatar {
  295. width: 50px;
  296. height: 50px;
  297. border-radius: 50%;
  298. margin-right: 15px;
  299. overflow: hidden;
  300. }
  301. .people-text {
  302. flex: 1;
  303. width: 0;
  304. overflow: hidden;
  305. }
  306. .people-name {
  307. font-size: 20px;
  308. font-weight: 500;
  309. }
  310. .people-organization {
  311. font-weight: 300;
  312. font-size: 14px;
  313. }
  314. }
  315. .device-list {
  316. display: flex;
  317. flex-wrap: wrap;
  318. align-content: flex-start;
  319. }
  320. .device-item {
  321. width: 50%;
  322. display: flex;
  323. align-items: center;
  324. margin-bottom: 15px;
  325. .device-label {
  326. flex: 1;
  327. width: 0;
  328. font-weight: 200;
  329. margin-left: 10px;
  330. }
  331. .device-icon {
  332. font-size: 18px;
  333. margin-right: 5px;
  334. }
  335. }
  336. }
  337. }
  338. .container {
  339. width: 1200px;
  340. margin: 0 auto;
  341. min-height: calc(100vh - 117px);
  342. }
  343. .skeleton-box {
  344. padding-top: 50px;
  345. }
  346. .home-detail-content {
  347. display: flex;
  348. }
  349. .home-detail-swiper {
  350. width: 670px;
  351. height: 480px;
  352. .swiper-container,
  353. .swiper-wrapper,
  354. .swiper-slide {
  355. width: 100%;
  356. height: 100%;
  357. }
  358. .swiper-slide {
  359. background-size: cover;
  360. background-position: center;
  361. background-repeat: no-repeat;
  362. cursor: pointer;
  363. position: relative;
  364. .open-video-icon {
  365. position: absolute;
  366. top: 50%;
  367. left: 50%;
  368. width: 40px;
  369. height: 40px;
  370. border-radius: 40px;
  371. background: rgba(0, 0, 0, 0.6);
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. margin-left: -20px;
  376. margin-top: -20px;
  377. box-sizing: border-box;
  378. .huifont-bofang {
  379. color: #fff;
  380. font-size: 20px;
  381. }
  382. }
  383. }
  384. .swiper-button-next:after,
  385. .swiper-button-prev:after {
  386. color: #eee;
  387. font-size: 16px;
  388. }
  389. .swiper-button-prev,
  390. .swiper-container-rtl .swiper-button-next {
  391. left: 0;
  392. background: rgba(0, 0, 0, 0.3);
  393. height: 70px;
  394. margin-top: -35px;
  395. }
  396. .swiper-button-next,
  397. .swiper-container-rtl .swiper-button-prev {
  398. right: 0;
  399. background: rgba(0, 0, 0, 0.3);
  400. height: 70px;
  401. margin-top: -35px;
  402. }
  403. }
  404. .home-detail-information {
  405. width: 470px;
  406. height: 480px;
  407. margin-left: 60px;
  408. .house-name {
  409. font-size: 26px;
  410. font-weight: 500;
  411. }
  412. .tag {
  413. margin: 10px 0;
  414. span {
  415. background: #eee;
  416. padding: 5px 10px;
  417. border-radius: 4px;
  418. margin: 5px 5px 5px 0;
  419. font-size: 12px;
  420. color: #7b7979;
  421. }
  422. }
  423. .content-title {
  424. font-size: 16px;
  425. font-weight: 500;
  426. }
  427. .house-price {
  428. display: flex;
  429. align-items: center;
  430. justify-content: space-between;
  431. span {
  432. color: $--color-red;
  433. }
  434. border-bottom: 1px solid #e7ebee;
  435. margin-bottom: 15px;
  436. padding-bottom: 5px;
  437. .hui-button {
  438. color: #fff;
  439. background: $--color-primary;
  440. width: 100px;
  441. height: 34px;
  442. text-align: center;
  443. line-height: 34px;
  444. border-radius: 4px;
  445. cursor: pointer;
  446. &:hover {
  447. opacity: 0.8;
  448. }
  449. }
  450. }
  451. .average {
  452. font-size: 30px;
  453. font-weight: 900;
  454. margin-right: 5px;
  455. }
  456. .desc-text {
  457. margin-top: 10px;
  458. }
  459. .information-list {
  460. display: flex;
  461. flex-wrap: wrap;
  462. margin-bottom: 10px;
  463. .information-box {
  464. width: 50%;
  465. display: flex;
  466. padding: 7px 20px 7px 0;
  467. box-sizing: border-box;
  468. }
  469. .information-title {
  470. color: #979b9e;
  471. font-weight: 500;
  472. }
  473. .information-div {
  474. flex: 1;
  475. width: 0;
  476. overflow: hidden;
  477. white-space: nowrap;
  478. font-weight: 300;
  479. }
  480. }
  481. }
  482. .footer {
  483. background: #212631;
  484. min-width: 1200px;
  485. .footer-box {
  486. width: 1200px;
  487. margin: 0 auto
  488. }
  489. .foot-information {
  490. font-weight: 400;
  491. font-size: 12px;
  492. color: #98999d;
  493. line-height: 17px;
  494. display: flex;
  495. align-items: center;
  496. padding: 20px;
  497. justify-content: center
  498. }
  499. .foot-information a {
  500. color: #98999d;
  501. margin-right: 30px
  502. }
  503. .foot-information img {
  504. width: 14px;
  505. height: 14px;
  506. margin-left: 30px;
  507. margin-right: 10px
  508. }
  509. }
  510. }
  511. </style>