//index.js //获取应用实例 const app = getApp() var QQMapWX = require('../../utils/qqmap-wx-jssdk.js'); var qqmapsdk const page = require('../../utils/page.js'); import fetch from '../../utils/http' const $api = require('../../config/api.js').$api; Page({ onShow() { wx.setNavigationBarTitle({ title: '楼盘详情' }) }, onLoad: function(options) { const id = page.getCurrentPageOptions().id const _that = this //调用wx.getSystemInfo接口,然后动态绑定组件高度 wx.getSystemInfo({ success: function(res) { _that.setData({ height: (res.windowWidth - 40) * 0.45 }) } }) qqmapsdk = new QQMapWX({ key: 'KJCBZ-G2MKX-DB443-Z4CBR-7E6K2-GJF5D' }) fetch({ url: $api.visit.url.replace(':id', id), method: $api.visit.method, data: { customerId: app.globalData.UserInfo.customerId, customerName: app.globalData.UserInfo.name, avatar: app.globalData.UserInfo.avatar, visitType: 'building', visitContent: id } }).then(() => { fetch({ url: $api.collection.getByUser.url.replace(':openid', app.globalData.UserInfo.openid), method: $api.collection.getByUser.method, data: { pageNum: 1, pageSize: 100 } }).then((collects) => { _that.setData({ Collects: collects.data.records }) fetch({ url: $api.building.detail.url.replace(':id', id), method: $api.building.detail.method, }).then((data) => { const dicts = app.globalData.Dict const apart = data.data.buildingApartment.filter(x => x.apartmentType === 'apart').map(x => { return { ...x, imgUrl: (x.buildingImgList[0] || {}).url, marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name } }) const photo = data.data.buildingApartment.filter(x => x.apartmentType === 'photo').map(x => { return { ...x, imgUrl: (x.buildingImgList[0] || {}).url, marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name } }) let propertyType = '' data.data.propertyType.split(',').map(x => { const f = dicts.filter(d => d.id == x) if (f.length > 0) { propertyType += (propertyType === '' ? '' : ',') + f[0].name } }) _that.setData({ EstateDetail: { ...data.data, latitude: data.data.coordinate.split(',')[0] - 0, longitude: data.data.coordinate.split(',')[1] - 0, markers: [{ id: data.data.buildingId, latitude: data.data.coordinate.split(',')[0] - 0, longitude: data.data.coordinate.split(',')[1] - 0, }], openingDate: data.data.openingDate.split(' ')[0], propertyType: propertyType, buildingApartment: apart, IsCollect: (_that.data.Collects.filter(x => x.buildingId == data.data.buildingId).length > 0 ? true : false), Photos: photo || [] } }) }) }) }) }, data: { height: 0, UserInfo: app.globalData.UserInfo, ScreenBottomHeight: app.globalData.ScreenBottomHeight, EstateDetail: {}, Collects: [], ShowMaxSwiper: false, CurrentImgList: [], CurrentIndex: 0 }, CloseMaxSwiper() { // 关闭大图 this.setData({ ShowMaxSwiper: false, CurrentIndex: 0 }) }, CheckMaxImg(e) { // 查看大图 // console.log(e.target.dataset) this.setData({ CurrentImgList: this.data.EstateDetail[e.target.dataset.type][e.target.dataset.index].buildingImgList, ShowMaxSwiper: true }) }, MakeAnAppointment() { // 预约看房 wx.navigateTo({ url: '/pages/AppointmentTime/index?id=' + this.data.EstateDetail.buildingId + '&name=' + this.data.EstateDetail.buildingName }) }, MakeCollect() { const _that = this fetch({ url: $api.collection.save.url.replace(':openid', app.globalData.UserInfo.openid) + '?buildingId=' + this.data.EstateDetail.buildingId, method: $api.collection.save.method, }).then((data) => { wx.showToast({ title: '收藏成功!' }) _that.setData({ EstateDetail: { ..._that.data.EstateDetail, IsCollect: true } }) }) }, OpenPhone() { // 电话咨询 let _self = this wx.makePhoneCall({ phoneNumber: _self.data.EstateDetail.tel }) }, onShareAppMessage: function() { return { title: this.data.EstateDetail.buildingName, path: '/pages/EstateDetail/index?id=' + this.data.EstateDetail.buildingId, imageUrl: this.data.EstateDetail.buildingImg[0].url } }, toMore () { wx.navigateTo({ url: '/pages/VisitorList/index?id=' + this.data.EstateDetail.buildingId, }) }, toMap (e) { wx.navigateTo({ url: '/pages/map/testmap?id=' + this.data.EstateDetail.buildingId, }) } })