project.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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">交通便利</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. console.log(positions);
  94. const markers = []
  95. positions.forEach((p, i) => {
  96. markers.push(
  97. Object.assign({}, {
  98. id: i + 1,
  99. width: 50,
  100. height: 50,
  101. joinCluster: true, // 指定了该参数才会参与聚合
  102. }, p)
  103. )
  104. })
  105. this._mapContext.addMarkers({
  106. markers,
  107. clear: false,
  108. complete(res) {
  109. console.log('addMarkers', res)
  110. }
  111. })
  112. }
  113. },
  114. }
  115. </script>
  116. <style lang="scss">
  117. .project-detail {
  118. background: #fff;
  119. padding-bottom: 60rpx;
  120. .swiper {
  121. height: 400rpx;
  122. .image {
  123. width: 100%;
  124. height: 100%;
  125. }
  126. }
  127. .project-label {
  128. font-size: 24rpx;
  129. color: $uni-secondary-color;
  130. font-weight: 300;
  131. }
  132. .project-article {
  133. font-size: 28rpx;
  134. padding: 0 30rpx;
  135. }
  136. .project-title {
  137. padding: 40rpx 130rpx 30rpx 30rpx;
  138. position: relative;
  139. .project-name {
  140. font-size: 36rpx;
  141. font-weight: 500;
  142. }
  143. .project-label {
  144. margin-top: 6rpx;
  145. }
  146. .wx-icon {
  147. position: absolute;
  148. top: 0;
  149. right: 30rpx;
  150. transform: translateY(50%);
  151. }
  152. }
  153. .content-map {
  154. width: 100%;
  155. height: 360rpx;
  156. border-radius: 16rpx;
  157. overflow: hidden;
  158. display: flex;
  159. .map {
  160. flex: 1;
  161. height: 100%;
  162. border-radius: 16rpx;
  163. }
  164. }
  165. .project-content {
  166. padding: 0 30rpx;
  167. box-sizing: border-box;
  168. .content-title {
  169. font-size: 32rpx;
  170. font-weight: 500;
  171. margin: 30rpx 0;
  172. }
  173. .content-device {
  174. display: flex;
  175. flex-wrap: wrap;
  176. .device-item {
  177. width: 50%;
  178. display: flex;
  179. align-items: center;
  180. margin-bottom: 20rpx;
  181. .device-label {
  182. flex: 1;
  183. width: 0;
  184. color: $uni-secondary-color;
  185. font-weight: 200;
  186. margin-left: 10rpx;
  187. }
  188. .device-icon {
  189. color: $uni-base-color;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>