index.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
  5. var qqmapsdk
  6. const page = require('../../utils/page.js');
  7. import fetch from '../../utils/http'
  8. const $api = require('../../config/api.js').$api;
  9. Page({
  10. onShow() {
  11. wx.setNavigationBarTitle({
  12. title: '楼盘详情'
  13. })
  14. },
  15. onLoad: function(options) {
  16. const id = page.getCurrentPageOptions().id
  17. const _that = this
  18. //调用wx.getSystemInfo接口,然后动态绑定组件高度
  19. wx.getSystemInfo({
  20. success: function(res) {
  21. _that.setData({
  22. height: (res.windowWidth - 40) * 0.45
  23. })
  24. }
  25. })
  26. qqmapsdk = new QQMapWX({
  27. key: 'KJCBZ-G2MKX-DB443-Z4CBR-7E6K2-GJF5D'
  28. })
  29. fetch({
  30. url: $api.visit.url.replace(':id', id),
  31. method: $api.visit.method,
  32. data: {
  33. customerId: app.globalData.UserInfo.customerId,
  34. customerName: app.globalData.UserInfo.name,
  35. avatar: app.globalData.UserInfo.avatar,
  36. visitType: 'building',
  37. visitContent: id
  38. }
  39. }).then(() => {
  40. fetch({
  41. url: $api.collection.getByUser.url.replace(':openid', app.globalData.UserInfo.openid),
  42. method: $api.collection.getByUser.method,
  43. data: {
  44. pageNum: 1,
  45. pageSize: 100
  46. }
  47. }).then((collects) => {
  48. _that.setData({
  49. Collects: collects.data.records
  50. })
  51. fetch({
  52. url: $api.building.detail.url.replace(':id', id),
  53. method: $api.building.detail.method,
  54. }).then((data) => {
  55. const dicts = app.globalData.Dict
  56. const apart = data.data.buildingApartment.filter(x => x.apartmentType === 'apart').map(x => {
  57. return {
  58. ...x,
  59. imgUrl: (x.buildingImgList[0] || {}).url,
  60. marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
  61. }
  62. })
  63. const photo = data.data.buildingApartment.filter(x => x.apartmentType === 'photo').map(x => {
  64. return {
  65. ...x,
  66. imgUrl: (x.buildingImgList[0] || {}).url,
  67. marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
  68. }
  69. })
  70. let propertyType = ''
  71. data.data.propertyType.split(',').map(x => {
  72. const f = dicts.filter(d => d.id == x)
  73. if (f.length > 0) {
  74. propertyType += (propertyType === '' ? '' : ',') + f[0].name
  75. }
  76. })
  77. _that.setData({
  78. EstateDetail: {
  79. ...data.data,
  80. latitude: data.data.coordinate.split(',')[0] - 0,
  81. longitude: data.data.coordinate.split(',')[1] - 0,
  82. markers: [{
  83. id: data.data.buildingId,
  84. latitude: data.data.coordinate.split(',')[0] - 0,
  85. longitude: data.data.coordinate.split(',')[1] - 0,
  86. }],
  87. openingDate: data.data.openingDate.split(' ')[0],
  88. propertyType: propertyType,
  89. buildingApartment: apart,
  90. IsCollect: (_that.data.Collects.filter(x => x.buildingId == data.data.buildingId).length > 0 ? true : false),
  91. Photos: photo || []
  92. }
  93. })
  94. })
  95. })
  96. })
  97. },
  98. data: {
  99. height: 0,
  100. UserInfo: app.globalData.UserInfo,
  101. ScreenBottomHeight: app.globalData.ScreenBottomHeight,
  102. EstateDetail: {},
  103. Collects: [],
  104. ShowMaxSwiper: false,
  105. CurrentImgList: [],
  106. CurrentIndex: 0
  107. },
  108. CloseMaxSwiper() { // 关闭大图
  109. this.setData({
  110. ShowMaxSwiper: false,
  111. CurrentIndex: 0
  112. })
  113. },
  114. CheckMaxImg(e) { // 查看大图
  115. // console.log(e.target.dataset)
  116. this.setData({
  117. CurrentImgList: this.data.EstateDetail[e.target.dataset.type][e.target.dataset.index].buildingImgList,
  118. ShowMaxSwiper: true
  119. })
  120. },
  121. MakeAnAppointment() { // 预约看房
  122. wx.navigateTo({
  123. url: '/pages/AppointmentTime/index?id=' + this.data.EstateDetail.buildingId + '&name=' + this.data.EstateDetail.buildingName
  124. })
  125. },
  126. MakeCollect() {
  127. const _that = this
  128. fetch({
  129. url: $api.collection.save.url.replace(':openid', app.globalData.UserInfo.openid) + '?buildingId=' + this.data.EstateDetail.buildingId,
  130. method: $api.collection.save.method,
  131. }).then((data) => {
  132. wx.showToast({
  133. title: '收藏成功!'
  134. })
  135. _that.setData({
  136. EstateDetail: { ..._that.data.EstateDetail,
  137. IsCollect: true
  138. }
  139. })
  140. })
  141. },
  142. OpenPhone() { // 电话咨询
  143. let _self = this
  144. wx.makePhoneCall({
  145. phoneNumber: _self.data.EstateDetail.tel
  146. })
  147. },
  148. onShareAppMessage: function() {
  149. return {
  150. title: this.data.EstateDetail.buildingName,
  151. path: '/pages/EstateDetail/index?id=' + this.data.EstateDetail.buildingId,
  152. imageUrl: this.data.EstateDetail.buildingImg[0].url
  153. }
  154. },
  155. toMore () {
  156. wx.navigateTo({
  157. url: '/pages/VisitorList/index?id=' + this.data.EstateDetail.buildingId,
  158. })
  159. },
  160. toMap (e) {
  161. wx.navigateTo({
  162. url: '/pages/map/testmap?id=' + this.data.EstateDetail.buildingId,
  163. })
  164. }
  165. })