project.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="project-detail">
  3. <swiper class="swiper" circular :indicator-dots="true">
  4. <swiper-item v-for="item in responsibility" :key="item.id">
  5. <image class="image" :src="item.url" mode="aspectFill">
  6. </image>
  7. </swiper-item>
  8. </swiper>
  9. <view class="project-title">
  10. <view class="project-name">{{detail.name}}</view>
  11. <view class="project-label">距离您2km</view>
  12. <button type="default" class="wx-icon" open-type="share">
  13. <uni-icons type="weixin" open-type="share" size="38" color="#43b156">
  14. </uni-icons>
  15. </button>
  16. </view>
  17. <view class="project-label project-article">{{detail.comment}}</view>
  18. <view class="project-content">
  19. <view class="content-title">地理位置</view>
  20. <view class="content-map">
  21. <map id="map" class="map" :show-location="true" :latitude="latitude" :longitude="longitude"></map>
  22. </view>
  23. <view class="content-title">配套设施</view>
  24. <view class="content-device">
  25. <view class="device-item"
  26. v-for="item in $field.findTypeNameByList('supportingFacilities',detail.supportingFacilities)"
  27. :key="item.id">
  28. <uni-icons class="device-icon" custom-prefix="iconfont" :type="item.icon" size="18"></uni-icons>
  29. <text class="device-label">{{item.name}}</text>
  30. </view>
  31. </view>
  32. <view class="content-title">房源列表</view>
  33. <view class="house-list">
  34. <house-items v-for="(item,index) in list" :house="item" :key="item.id"></house-items>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. getOpenHouseListByPage
  42. } from '@/request/api/house.js'
  43. import {
  44. getProjectDetailById
  45. } from '@/request/api/project.js'
  46. import houseItems from "@/components/house/houseItems.vue";
  47. export default {
  48. data() {
  49. return {
  50. list: [],
  51. detail: {},
  52. responsibility: [],
  53. coordinates: [],
  54. latitude: 39.90923,
  55. longitude: 116.397428,
  56. projectId: ''
  57. }
  58. },
  59. onLoad(body) {
  60. this.projectId = body.projectId;
  61. this.init();
  62. },
  63. onReady() {
  64. this._mapContext = uni.createMapContext("map", this);
  65. },
  66. components: {
  67. houseItems
  68. },
  69. methods: {
  70. init() {
  71. getProjectDetailById(this.projectId).then(res => {
  72. if (res.code === 200) {
  73. this.detail = res.data;
  74. if (this.detail.picture) this.responsibility = JSON.parse(this.detail.picture);
  75. if (this.detail.coordinates) {
  76. this.coordinates = this.detail.coordinates.split(',');
  77. this.latitude = this.coordinates[1];
  78. this.longitude = this.coordinates[0];
  79. this.addMarkers();
  80. }
  81. }
  82. })
  83. getOpenHouseListByPage({
  84. currPage: 1,
  85. pageSize: 100,
  86. projectId: parseInt(this.projectId)
  87. }).then(res => {
  88. if (res.code === 200) {
  89. this.list = this.list.concat(res.data.dataList); //追加新数据
  90. }
  91. })
  92. },
  93. addMarkers() {
  94. const positions = [{
  95. latitude: this.coordinates[1],
  96. longitude: this.coordinates[0],
  97. }]
  98. const markers = []
  99. positions.forEach((p, i) => {
  100. markers.push(
  101. Object.assign({}, {
  102. id: i + 1,
  103. width: 50,
  104. height: 50,
  105. joinCluster: true, // 指定了该参数才会参与聚合
  106. }, p)
  107. )
  108. })
  109. this._mapContext.addMarkers({
  110. markers,
  111. clear: false,
  112. complete(res) {}
  113. })
  114. }
  115. },
  116. }
  117. </script>
  118. <style lang="scss">
  119. .project-detail {
  120. background: #fff;
  121. padding-bottom: 60rpx;
  122. .swiper {
  123. height: 400rpx;
  124. .image {
  125. width: 100%;
  126. height: 100%;
  127. }
  128. }
  129. .project-label {
  130. font-size: 24rpx;
  131. color: $uni-secondary-color;
  132. font-weight: 300;
  133. }
  134. .project-article {
  135. font-size: 28rpx;
  136. padding: 0 30rpx;
  137. }
  138. .project-title {
  139. padding: 40rpx 130rpx 30rpx 30rpx;
  140. position: relative;
  141. .project-name {
  142. font-size: 36rpx;
  143. font-weight: 500;
  144. }
  145. .project-label {
  146. margin-top: 6rpx;
  147. }
  148. .wx-icon {
  149. position: absolute;
  150. top: 0;
  151. right: 30rpx;
  152. transform: translateY(50%);
  153. line-height: 1;
  154. background: transparent;
  155. &::after {
  156. display: none;
  157. }
  158. }
  159. }
  160. .content-map {
  161. width: 100%;
  162. height: 360rpx;
  163. border-radius: 16rpx;
  164. overflow: hidden;
  165. display: flex;
  166. .map {
  167. flex: 1;
  168. height: 100%;
  169. border-radius: 16rpx;
  170. }
  171. }
  172. .project-content {
  173. padding: 0 30rpx;
  174. box-sizing: border-box;
  175. .content-title {
  176. font-size: 32rpx;
  177. font-weight: 500;
  178. margin: 30rpx 0;
  179. }
  180. .content-device {
  181. display: flex;
  182. flex-wrap: wrap;
  183. .device-item {
  184. width: 50%;
  185. display: flex;
  186. align-items: center;
  187. margin-bottom: 20rpx;
  188. .device-label {
  189. flex: 1;
  190. width: 0;
  191. color: $uni-secondary-color;
  192. font-weight: 200;
  193. margin-left: 10rpx;
  194. }
  195. .device-icon {
  196. color: $uni-base-color;
  197. }
  198. }
  199. }
  200. }
  201. }
  202. </style>