project.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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">距离您{{detail.distance || '-'}}km</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. coordinatesstr: ''
  58. }
  59. },
  60. onLoad(body) {
  61. this.projectId = body.projectId;
  62. this.coordinatesstr = this.$store.getters.coordinates;
  63. this.init();
  64. },
  65. onReady() {
  66. this._mapContext = uni.createMapContext("map", this);
  67. },
  68. components: {
  69. houseItems
  70. },
  71. methods: {
  72. init() {
  73. console.log(this.coordinatesstr);
  74. getProjectDetailById(this.projectId + '?coordinates=' + this.coordinatesstr).then(res => {
  75. if (res.code === 200) {
  76. this.detail = res.data;
  77. if (this.detail.picture) this.responsibility = JSON.parse(this.detail.picture);
  78. if (this.detail.coordinates) {
  79. this.coordinates = this.detail.coordinates.split(',');
  80. this.latitude = this.coordinates[1];
  81. this.longitude = this.coordinates[0];
  82. this.addMarkers();
  83. }
  84. }
  85. })
  86. getOpenHouseListByPage({
  87. currPage: 1,
  88. pageSize: 100,
  89. projectId: parseInt(this.projectId)
  90. }).then(res => {
  91. if (res.code === 200) {
  92. this.list = this.list.concat(res.data.dataList); //追加新数据
  93. }
  94. })
  95. },
  96. addMarkers() {
  97. const positions = [{
  98. latitude: this.coordinates[1],
  99. longitude: this.coordinates[0],
  100. }]
  101. const markers = []
  102. positions.forEach((p, i) => {
  103. markers.push(
  104. Object.assign({}, {
  105. id: i + 1,
  106. width: 50,
  107. height: 50,
  108. joinCluster: true, // 指定了该参数才会参与聚合
  109. }, p)
  110. )
  111. })
  112. this._mapContext.addMarkers({
  113. markers,
  114. clear: false,
  115. complete(res) {}
  116. })
  117. }
  118. },
  119. }
  120. </script>
  121. <style lang="scss">
  122. .project-detail {
  123. background: #fff;
  124. padding-bottom: 60rpx;
  125. .swiper {
  126. height: 400rpx;
  127. .image {
  128. width: 100%;
  129. height: 100%;
  130. }
  131. }
  132. .project-label {
  133. font-size: 24rpx;
  134. color: $uni-secondary-color;
  135. font-weight: 300;
  136. }
  137. .project-article {
  138. font-size: 28rpx;
  139. padding: 0 30rpx;
  140. }
  141. .project-title {
  142. padding: 40rpx 130rpx 30rpx 30rpx;
  143. position: relative;
  144. .project-name {
  145. font-size: 36rpx;
  146. font-weight: 500;
  147. }
  148. .project-label {
  149. margin-top: 6rpx;
  150. }
  151. .wx-icon {
  152. position: absolute;
  153. top: 0;
  154. right: 30rpx;
  155. transform: translateY(50%);
  156. line-height: 1;
  157. background: transparent;
  158. &::after {
  159. display: none;
  160. }
  161. }
  162. }
  163. .content-map {
  164. width: 100%;
  165. height: 360rpx;
  166. border-radius: 16rpx;
  167. overflow: hidden;
  168. display: flex;
  169. .map {
  170. flex: 1;
  171. height: 100%;
  172. border-radius: 16rpx;
  173. }
  174. }
  175. .project-content {
  176. padding: 0 30rpx;
  177. box-sizing: border-box;
  178. .content-title {
  179. font-size: 32rpx;
  180. font-weight: 500;
  181. margin: 30rpx 0;
  182. }
  183. .content-device {
  184. display: flex;
  185. flex-wrap: wrap;
  186. .device-item {
  187. width: 50%;
  188. display: flex;
  189. align-items: center;
  190. margin-bottom: 20rpx;
  191. .device-label {
  192. flex: 1;
  193. width: 0;
  194. color: $uni-secondary-color;
  195. font-weight: 200;
  196. margin-left: 10rpx;
  197. }
  198. .device-icon {
  199. color: $uni-base-color;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. </style>