project.vue 4.6 KB

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