const app = getApp()
import {
    meetingRoomDetailRq,
    selectCoordinateRq
} from "../../../api/meeting/meetingRoom.js"


Page({

    /**
     * 页面的初始数据
     */
    data: {
        IMG_NAME: app.IMG_NAME,
        meetingRoomId: null,
        detail: {},
        bannerList: [],
        mapData: {}
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        let _this = this;
        console.log('onLoad', options);
        let meetingRoomId = options.id;
        meetingRoomDetailRq(meetingRoomId).then(res => {
            console.log('meetingRoomDetailRq', res);
            _this.setData({
                meetingRoomId,
                detail: res.roomContent,
                bannerList: [res.roomContent.indoorPicUrl]
            })
        })
        // 获取地址信息
        _this.getAddress()
    },

    // 获取地址信息
    getAddress() {
        let _this = this;
        selectCoordinateRq().then(res => {
            _this.setData({
                address: res,
                mapData: {
                    latitude: res.lat,
                    longitude: res.lng,
                    markers: [{
                        id: 1,
                        latitude: res.lat,
                        longitude: res.lng,
                        title: res.address,
                    }]
                },
            })
        })
    },

    // 打开地图
    openMap(e) {
        console.log('openMap', e);
        let _this = this;
        wx.openLocation({
            name: _this.data.address.address,
            latitude: _this.data.address.lat,
            longitude: _this.data.address.lng,
        })
    },

    // 跳转空间设施
    jumpMeetingFacilities() {
        let meetingRoomId = this.data.meetingRoomId;
        wx.navigateTo({
            url: '/pages/meeting/meetingRoom/meetingFacilities/meetingFacilities?meetingRoomId=' + meetingRoomId,
        })
    },

    // 跳转-会议室已预约
    jumpMeetingBooked() {
        let meetingRoomId = this.data.meetingRoomId;
        wx.navigateTo({
            url: "/pages/meeting/meetingRoom/meetingBooked/meetingBooked?meetingRoomId=" + meetingRoomId,
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})