189 lines
4.0 KiB
JavaScript
189 lines
4.0 KiB
JavaScript
// packageC/hotel/HotelChooseRoom/HotelChooseRoom.js
|
|
var location = require("../../../mybehaviors/location/location");
|
|
var app = getApp();
|
|
Page({
|
|
behaviors: [location],
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
show1: true,
|
|
show2: true,
|
|
wxTitie: "",
|
|
PageNameList: {},
|
|
location: {},
|
|
data_info: {},
|
|
hotel_introduce: '',
|
|
// 是否展示所有文本内容
|
|
showTotal: false,
|
|
// 显示展开还是收起
|
|
exchangeButton: true,
|
|
// 是否显示展开收起按钮
|
|
showExchangeButton: false,
|
|
id: "",
|
|
cityData: '',
|
|
city: '',
|
|
title: '',
|
|
address: "",
|
|
point: {
|
|
lat: '',
|
|
lng: ''
|
|
},
|
|
HOME_PAGE_URL: "plugin.hotel.frontend.hotel.get-hotel-info.get-info-by-hotel-id"
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
if (options.id) {
|
|
this.setData({
|
|
id: options.id
|
|
});
|
|
}
|
|
if (options.city) {
|
|
this.setData({
|
|
cityData: options.city
|
|
});
|
|
}
|
|
this.getCustomizeHotelHead();
|
|
this._getLocation(() => {this.getHomePageData();});
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
},
|
|
//获取酒店自定义字段
|
|
getCustomizeHotelHead() {
|
|
let that = this;
|
|
let isQuestHotel = "";
|
|
try {
|
|
const value = wx.getStorageSync('customizeHotelHead');
|
|
if (value) {
|
|
isQuestHotel = value;
|
|
// Do something with return value
|
|
}
|
|
} catch (e) {
|
|
// Do something when catch error
|
|
}
|
|
if (!app._isTextEmpty(isQuestHotel)) {
|
|
this.setData({
|
|
PageNameList: JSON.parse(isQuestHotel)
|
|
});
|
|
wx.setNavigationBarTitle({
|
|
title: this.data.PageNameList.hotels ? (this.data.PageNameList.hotels + '详情') : ''
|
|
});
|
|
} else {
|
|
let urlStr = app.getNetAddresss("plugin.hotel.frontend.hotel.get-hotel-info.get-custom-name");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
PageNameList: res.data
|
|
});
|
|
wx.setNavigationBarTitle({
|
|
title: res.data.hotels ? (res.data.hotels + '详情') : ''
|
|
});
|
|
try {
|
|
wx.setStorageSync('customizeHotelHead', JSON.stringify(res.data));
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
}
|
|
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
}
|
|
},
|
|
getHomePageData() {
|
|
var that = this;
|
|
let urlStr = app.getNetAddresss(that.data.HOME_PAGE_URL);
|
|
urlStr += '&hotel_id=' + this.data.id;
|
|
urlStr += '&lng=' + this.data.point.lng;
|
|
urlStr += '&lat=' + this.data.point.lat;
|
|
urlStr += '&city_name=' + this.data.cityData;
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
data_info: res.data,
|
|
hotel_introduce: res.data.hotel_introduce
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
showTotalIntro() {
|
|
this.setData({
|
|
showTotal: !this.data.showTotal,
|
|
exchangeButton: !this.data.exchangeButton
|
|
});
|
|
},
|
|
toggleShow1() {
|
|
this.setData({
|
|
show1: !this.data.show1
|
|
});
|
|
},
|
|
toggleShow2() {
|
|
this.setData({
|
|
show2: !this.data.show2
|
|
});
|
|
},
|
|
});
|