123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- //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,
- })
- }
- })
|