var indexNo = 0;
WUI = (WUI || {});
WUI.Hotel = function() {
var obj = arguments[0];
this.pager_ = {
size : 15 //酒店显示列表页,修改成15条记录。
};
this.hotelList_ = [];
this.queryHotelList_ = [];
var this_ = this;
$(function() {
WUI.Hotel.pop_map = new WUI.Dialog($('#pop_map')[0]);
WUI.Hotel.pop_map_show = new WUI.Map();
var mapOptions = {
mapTypeControl : false
};
WUI.Hotel.pop_map_show.create('pop_map_show', mapOptions);
this_.load = new WUI.Dialog($('#loadding')[0]);
});
}
WUI.Hotel.ShowMap = function(position, name) {
position = new google.maps.LatLng(position[1], position[0]);
WUI.Hotel.pop_map.show();
WUI.Hotel.pop_map_show.resize();
WUI.Hotel.pop_map_show.clearMarker();
var marker = WUI.Hotel.pop_map_show.createMarker( {
position : position,
id : name,
infoWindowOpts : {
content : name
}
});
WUI.Hotel.pop_map_show.fitMarker();
WUI.Hotel.pop_map_show.get().setZoom(15);
marker.info.show(marker);
}
/**
* 此对象为酒店的基础信息对象
* 解析服务端的数据到JS对象
*/
WUI.HotelBo = function(opts) {
this.id = opts[0];//唯一标识
this.name = opts[1];//酒店名
this.logo = opts[2]; // LOGO图片
this.star = opts[3]; // 星级
this.intro = opts[4];//概要描述
this.longitude = opts[5]; // 经度
this.latitude = opts[6]; // 纬度
this.keywords = opts[7]; // 关键字
this.topPrice = opts[8]; // 最高价
this.bottomPrice = opts[9]; // 最低价
this.district = opts[10]; //酒店行政区
this.brandId = opts[11];//品牌
this.hasStar = opts[12];//是否挂牌
this.busiArea = opts[13];//商圈
this.busiAreaName = opts[14];//商圈名
this.districtId = opts[15]; //酒店行政区ID
this.score = opts[16];//评分
this.recLevel = opts[17];//推荐级别(金牌、银牌)
}
WUI.RoomBo = function(opts) {
this.id = opts[0]; // 唯一标识
this.name = opts[1]; // 酒店名
this.logo = opts[2]; // LOGO图片
this.marketPrice = opts[3]; // 市场价
this.frontPrices = opts[4] || []; // 前台现付列表
this.woyoPrices = opts[5] || []; // woyo预付价列表
this.breakfasts = opts[6] || []; // 早餐列表
this.bedType = opts[7]; // 床型
this.bedTypeDesc = opts[8]; //床型描述
this.boardband = opts[9]; // 宽带
this.area = opts[10]; // 面积
this.floor = opts[11]; // 楼层
this.extraBed = opts[12]; // 可加床
this.smoke = opts[13]; // 无烟房描述
this.booking = opts[14]; // 是否可定
this.woyoBreakfasts = opts[15] || []; // woyo早餐列表
this.sales = opts[16] || []; // 现付礼盒
this.woyoSales = opts[17] || []; // 预付礼盒
this.pic = opts[18] || null;//酒店图片
this.prepaidShowModes = opts[19] || [];//显示模式
this.consultPayPrice = opts[20]; // 参考现付卖价
this.info = opts[21]; //额外信息
var frontPriceCount = 0;
$.each(this.frontPrices, function(idx, val) {
if (typeof val == 'number') {
frontPriceCount += this;
}
})
this.frontPriceCount = frontPriceCount;
var woyoPriceCount = 0;
$.each(this.woyoPrices, function(idx, val) {
if (typeof val == 'number') {
woyoPriceCount += this;
}
})
this.woyoPriceCount = woyoPriceCount;
}
/**
* 服务器请求的地址定义0
*/
WUI.Hotel.URL = {
LOAD_HOTEL_LIST : "/searchHotel!findHotelListByCity.do",//加载酒店列表
LOAD_ROOM_LIST : "/searchHotel!findRoomListByHotelIds.do",//加载房型列表
LOAD_HOTEL_SALE_MAP : "/searchHotel!getSalesForHotels.do"//加载酒店礼盒
}
with (WUI.Hotel) {
/**
* 检索列表
*/
prototype.query = function(query_) {
query = query || {};
$.extend(query, query_ || {});
var hotelList = [];
for ( var i = 0; i < this.hotelList_.length; i++) {
var hotelBo = this.hotelList_[i];
if (query.name && hotelBo.name.indexOf(query.name) == -1 && (hotelBo.keywords == null || hotelBo.keywords.indexOf(query.name) == -1)) {
continue;
}
if (query.level == -1) {
if(hotelBo.star >= 2){
continue;
}
} else if (query.level && hotelBo.star != query.level) {
continue;
}
if(query.maxPrice != ""){
if (query.minPrice && hotelBo.topPrice < query.minPrice) {
continue;
} else if (query.maxPrice && hotelBo.bottomPrice > query.maxPrice || hotelBo.bottomPrice == 0) {
continue;
}
}
if (query.busiArea && hotelBo.busiArea != query.busiArea) {
continue;
}
if (query.brandId && hotelBo.brandId != query.brandId) {
continue;
}
if (query.districtId && hotelBo.districtId != query.districtId) {
continue;
}
if(hotelBo.score == 0 || hotelBo.score == ""){
hotelBo.score = 4.5;
}
if (query.minScore && hotelBo.score < query.minScore) {
continue;
}
if (query.maxScore && hotelBo.score > query.maxScore) {
continue;
}
hotelList.push(hotelBo);
}
this.queryHotelList_ = hotelList;
this.queryHotelList_.sort(WUI.HotelBo.sortfunction);
}
prototype.showPage = function(id, page, h_fn, fn) {
var W_hotel = this;
var no_msgNum = 0;
WUI.RoomBo.index = 99;
var title = document.title;
window.location.hash = '#';
document.title = title;
var this_ = this;
this_.load.show();
var html = '';
var hotelList = this.getPageHotelList(page);
if (hotelList.length == 0) {
$('#pager').empty();
$('#total').text('0');
alert("没有查询到该城市酒店信息!");
$("#" + id).html("");
this_.load.close();
window.location = "#";
}
var hotelIds = [];
$.each(hotelList, function() {
hotelIds.push(this.id);
});
WUI.RoomBo.showPricesCutover = new WUI.Cutover(function() {
this.show();
}, function() {
this.hide();
});
$.getJSON(URL.LOAD_HOTEL_SALE_MAP, {
hotelIds : hotelIds.join(','),
checkin : query.checkin,
checkout : query.checkout
}, function(saleMap) {
$.getJSON(URL.LOAD_ROOM_LIST, {
hotelIds : hotelIds.join(','),
checkin : query.checkin,
checkout : query.checkout
}, function(data) {
data = data.result;
this_.rooms = [];
var boxIndex = 15; //设置页面记录的层次(据每页的记录数变化而变化)
$.each(hotelList, function() {
var hotelId = this.id;
var roomList = data[hotelId] || [];
this.sales = saleMap[this.id];
if (roomList.length > 0) {
html += '<div class="hotel_box bxbox" style="overflow: visible; position: relative;z-index:' + (boxIndex--) + '">';
html += this.toHTML();
if (roomList.length > 0) {
html += ('<table style="width: 100%;" border="0" class="table_b">' + '<thead>' + '<tr>' + '<th width="18%">房型</th>' + '<th>门市价</th>' + '<th>前台现付</th>' + '<th>网上支付</th>' + '<th>早餐</th>'
+ '<th>床型</th>' + '<th>宽带</th>' + '<th>预订</th>' + '</tr>' + '</thead>' + '<tbody>');
this.rooms = [];
WUI.RoomBo.sort(roomList);
for ( var i = 0; i < roomList.length; i++) {
var roomBo = new WUI.RoomBo(roomList[i]);
roomBo.index = i;
roomBo.hotelId = hotelId;
html += roomBo.toHTML();
this.rooms.push(roomBo);
}
html += '</tbody>';
html += '</table>';
if (roomList.length > 3) {
html += ('<div class="change_btn"><a href="javascript:void(0)" οnclick="WUI.HotelBo.showAllRoom(this,' + this.id + ');">所有房型 <i class="ico4"></i></a></div>');
}
}
html += '</div>';
if (h_fn) {
h_fn.apply(this);
}
} else {
no_msgNum++;
if (no_msgNum == hotelIds.length) {
if (fn) {
fn.apply(hotelList);
}
return pager.gotopage(page + 1);
}
}
});
if(no_msgNum != hotelIds.length){
$("#" + id).html(html);
getCommentCountList(10, hotelIds, [], false);
this_.load.close();
if (fn) {
fn.apply(hotelList);
}
}
});
});
}
prototype.getPageTotal = function() {
return (this.queryHotelList_.length / this.pager_.size) + (this.queryHotelList_.length % this.pager_.size > 0 ? 1 : 0);
}
prototype.getPageSize = function() {
return this.pager_.size;
}
prototype.getTotal = function() {
return this.queryHotelList_.length;
}
prototype.getPageHotelList = function(page) {
var hotelList = [];
if (page <= this.getPageTotal() && page > 0) {
var begin = (page - 1) * this.pager_.size;
var end = begin + this.pager_.size;
for ( var i = begin; i < end; i++) {
if (i < this.queryHotelList_.length) {
hotelList.push(this.queryHotelList_[i]);
} else {
break;
}
}
}
return hotelList;
}
/**
* 加载酒店列表数据
* fn : 回调方法
*/
prototype.loadHotelList = function(fn) {
var this_ = this;
this_.hotelList_ = [];
$.getJSON(
URL.LOAD_HOTEL_LIST,
{cityId : query.cityId},
function(hotelList) {
$.each(hotelList, function() {
var hotelBo = new WUI.HotelBo(this);
this_.hotelList_.push(hotelBo);
});
this_.query();
if (fn) {
fn.apply(hotelList);
}
});
}
}
function showRoomList(id,checkin,checkout){
WUI.RoomBo.showPricesCutover = new WUI.Cutover(function() {
this.show();
}, function() {
this.hide();
});
with (WUI.Hotel) {
$.getJSON(URL.LOAD_ROOM_LIST, {hotelIds : id,checkin : checkin,checkout : checkout}, function(data) {
data = data.result;
var roomList = data[id] || [];
var html = "暂无房型";
if (roomList.length > 0) {
html = ('<table style="width: 100%;" border="0" class="table_b">' + '<thead>' + '<tr>' + '<th>房型</th>' + '<th>门市价</th>' + '<th>前台现付</th>' + '<th>网上支付</th>' + '<th>早餐</th>'
+ '<th>床型</th>' + '<th>宽带</th>' + '<th>预订</th>' + '</tr>' + '</thead>' + '<tbody>');
this.rooms = [];
WUI.RoomBo.sort(roomList);
for ( var i = 0; i < roomList.length; i++) {
var roomBo = new WUI.RoomBo(roomList[i]);
roomBo.index = 0;
roomBo.hotelId = id;
html += roomBo.toHTML();
this.rooms.push(roomBo);
}
html += '</tbody>';
html += '</table>';
}
$('#room_price_li').html(html);
});
}
}
/** 以下代码是针对HotelBo转换成HTML元素的代码 */
with (WUI.HotelBo) {
prototype.toMap = function(map) {
if (this.latitude != null && this.longitude != null) {
var latLng = new google.maps.LatLng(this.latitude, this.longitude);
map.createMarker( {
position : latLng,
id : this.id,
infoWindowOpts : {
content : this.name
}
});
}
}
prototype.toHTML = function() {
var detailUrl = '/hotel!detail.do?checkin=' + query.checkin + '&checkout=' + query.checkout + '&id=' + this.id + '&addOrder=' + query.addOrder
+ '&updateOrder=' + query.updateOrder + '&cityId=' + query.cityId + '&orderNo=' + query.orderNo;
var detailPhotoUrl = '/hotel!detail.do?checkin=' + query.checkin + '&checkout=' + query.checkout + '&id=' + this.id + '&addOrder=' + query.addOrder
+ '&updateOrder=' + query.updateOrder + '&cityId=' + query.cityId + '&orderNo=' + query.orderNo+ '&tabType=photo';
var recDis = null;
if(!this.recLevel || this.recLevel == 0){
recDis = "";
}else{
if(this.recLevel == 5){
recDis = "<i class=\"icon_silver\"></i>";
}else if(this.recLevel == 10){
recDis = "<i class=\"icon_gold\"></i>";
}
}
var html = '<div class="hotel_info">' + '<div class="pic"><a href="' + detailPhotoUrl + '"><img alt="" src="' + this.logo + '"></a><i><a href="' + detailPhotoUrl + '">酒店图片</a></i></div>'
+ '<div class="tit">' + recDis + '<h3><a href="' + detailUrl + '">' + this.name + '</a></h3>' + '<ul class="pfxt pfxt_v2">';
if(this.star > 1){
for ( var i = 0; i < this.star; i++) {
html += ('<li class="' + (this.hasStar == 1 ? 'on' : 'quasi') + '"></li>');
}
}
html += '</ul>';
if (this.sales && this.sales[0] && this.sales[0][1]) {
html += '<i title="' + this.sales[0][0] + ' ' + this.sales[0][1] + '" class="tip_cx_v2"></i>';
}
this.district = $('#point_1_' + this.districtId).text();
this.busiAreaName = $('#point_0_' + this.busiArea).text();
html += '</div>';
html += '<p>位置:';
html += (this.district ? ('<a href="javascript:void(0)" οnclick=\'$("#point_1_' + this.districtId + '").click()\'>' + this.district + '</a>' + (this.busiAreaName ? '、' : '')) : '');
html += (this.busiAreaName ? ('<a href="javascript:void(0)" οnclick=\'$("#point_0_' + this.busiArea + '").click()\'>' + this.busiAreaName + '</a>') : '');
html += (this.longitude && this.latitude ? (' <a class="map_link" href="javascript:void(0)" οnclick="WUI.Hotel.ShowMap([' + this.longitude + ',' + this.latitude + '],\'' + this.name + '\')">电子地图</a></p>') : '');
html += '</p>';
//html += ('<p>评定指数:<span class="c_f60 hack"><em class="c_288">' + (this.score) + '</em>分</span> 点评:<span class="c_f60"><em class="c_288" id="comment_count_' + this.id
// + '"></em>人进行了点评</span></p>' + '<p class="hack_v2"><span class="c_666">' + this.intro + '</span><a href="' + detailUrl + '">查看详情</a></p>' + '</div>');
var voterCount = 10;
var avgScore = 0;
$.ajax({
url : '/hotel!detailHotelScore.do?id=' + this.id + '&refresh=' + Math.random(),
type : 'GET',
async : false,
complete : function(resp) {
var json = eval('(' + resp.responseText + ')');
if(json && json.code ==200){
voterCount = json.voterCount;
avgScore = json.avgScore;
}
}
});
html += ('<p>评定指数:<span class="c_f60 hack"><em class="c_288">' + (avgScore == 0 ? '4.5' : avgScore.toFixed(1)) + '</em>分</span> 点评:<span class="c_f60"><em class="c_288">' + (voterCount==0?10:(voterCount<10?voterCount+10:voterCount))
+ '</em>人进行了点评</span></p>' + '<p class="hack_v2"><span class="c_666">' + this.intro + '</span><a href="' + detailUrl + '">查看详情</a></p>' + '</div>');
return html;
}
}
WUI.RoomBo.reSetCutover = function() {
}
WUI.RoomBo.onmouseoverPrice = function(id, this_) {
var price = $('#' + id);
var this_ = $(this_);
price.css( {
top : this_.offset().top + this_.height(),
left : this_.offset().left - price.width() / 2
});
WUI.RoomBo.showPricesCutover.on(id);
}
WUI.RoomBo.checkPrice=function(markerPrice,frontPrice,woyoPrice){
var minPrice="";
if( (frontPrice=='-' && woyoPrice=='null') || markerPrice=="-" ){
return "-";
}
if(frontPrice!='-' && woyoPrice!='null'){
minPrice = (frontPrice>woyoPrice)?frontPrice:woyoPrice;
}
if(minPrice!=""){
return (markerPrice>minPrice)?"RMB "+markerPrice:"-";
}else{
minPrice=(frontPrice!="-")?frontPrice:woyoPrice;
}
return (minPrice=="")?markerPrice:((markerPrice>minPrice)?"RMB "+markerPrice: "-");
}
with (WUI.RoomBo) {
prototype.toHTML = function() {
var frontPriceAvg = 0.00; //现付平均价格frontPriceAvg
var woyoPriceAvg = 0.00; //预付平均价格woyoPriceAvg
for(var i=0 ; i<this.frontPrices.length ; i++){
frontPriceAvg += this.frontPrices[i];
}
frontPriceAvg = (frontPriceAvg/this.frontPrices.length).toFixed(2);
for(var i = 0 ;i < this.woyoPrices.length;i++){
woyoPriceAvg += this.woyoPrices[i];
}
woyoPriceAvg = (woyoPriceAvg / this.woyoPrices.length).toFixed(2);
// 如何显示现付价
var showFrontPrice = function(bo){
if (bo.frontPrices[0]) return 'RMB ' + frontPriceAvg + "";
if (bo.consultPayPrice && bo.consultPayPrice[0]) return '<del>RMB ' + bo.consultPayPrice[0] + '</del>';
return '-';
}
// 如何显示预付价
var showWoyoPrice = function(bo){
if (!bo.woyoPrices[0]) return '-'; // none
if (bo.prepaidShowModes[0]) return 'RMB ' + woyoPriceAvg; // 直接显示
if (bo.frontPrices[0]) return '立省 ' + Math.ceil(frontPriceAvg - woyoPriceAvg);
if (bo.consultPayPrice && bo.consultPayPrice[0]) return '立省 ' + Math.ceil(bo.consultPayPrice[0] - woyoPriceAvg);
return 'RMB ' + woyoPriceAvg;
};
var priceId = 'hotel_room_price_' + this.id;
var indexNo = 1;
var detailHtml = '<tr id="room_detail_'
+ this.id
+ '"'
+ ' hotel="'
+ this.hotelId
+ '" style="display:none" type="room_detail">'
+ '<td colspan="8" class="drop_down">'
+ '<div class="sidebar">'
+ '<div class="drop_info_box clearfix">'
+ (this.pic ? ('<div class="pic"><img alt="" src="' + this.pic + '"></div>') : '')
+ '<ul class="drop_info">'
+ (this.area ? ('<li>面积:<em>' + this.area + '㎡</em></li>') : '')
+ (this.floor ? ('<li>楼层:<em>' + this.floor + '</em></li>') : '')
+ (this.bedType ? ('<li>床型:<em' + (this.bedTypeDesc ? (' title="' + this.bedTypeDesc + '"') : '') + '>' + this.bedType + '</em></li>') : '')
+ (this.extraBed ? ('<li>加床:<em>' + (this.extraBed == 1 ? '可加床' : '不可加') + '</em></li>') : '')
+ (this.smoke ? ('<li' + (this.smoke.length > 6 ? (' title="' + this.smoke + '"') : '') + '>无烟房:<em>' + (this.smoke.length > 6 ? (this.smoke.substring(0, 5) + '...') : this.smoke) + '</em></li>')
: '')
// 原来那个ul因为不是所有项都显示,所以info很长的时候换行有问题了,因此新弄个ul
+ '</ul>'
+ '<ul class="drop_info">'
+ (this.info ? ('额外信息:' + this.info + '') : '')
+ '</ul>'
+ '</div>'
+ '<div class="hide" οnclick="WUI.RoomBo.hideDetail(' + this.id + ')">隐藏</div>' + '</div>' + '</td>' + '</tr>';
var html = '<tr id="room_info_' + this.id + '" hotel="' + this.hotelId + '"' + (this.index < WUI.RoomBo.DEFAULT_SHOW ? '' : 'style="display:none" type="room_display"') + '>'
+ '<td class="txtL">' + (this.pic ? '<a class="ico1" href="javascript:void(0)"></a>' : '')
+ ($(detailHtml).find("li").length > 0 ? ('<a href="javascript:void(0)" οnclick="WUI.RoomBo.toggleDetail(' + this.id + ')">') : '') + this.name
+ ($(detailHtml).find("li").length > 0 ? '</a>' : '') + '</td>' + '<td class="dark_red">' + (checkPrice((this.marketPrice || '-') ,(frontPriceAvg || '-'),woyoPriceAvg )) + '</td>'
+ '<td class="dark_red"><i href="javascript:void(0)" οnmοuseοver="WUI.RoomBo.onmouseoverPrice(\'' + priceId
+ '\',this)" οnmοuseοut="WUI.RoomBo.showPricesCutover.on(null)">' + showFrontPrice(this) + '</i>'
+ (this.sales && this.sales[0] ? ('<a href="javascript:void(0)" class="qt_pay" title="' + this.sales[0][0] + ' ' + this.sales[0][1] + '"></a>') : '');
$('#'+priceId).remove();
$('body').append(WUI.RoomBo.getPriceHTML(priceId, this.frontPrices, null, this.breakfasts, this.prepaidShowModes, this.consultPayPrice));
//woyoPriceAvg我友均价 frontPriceAvg前台现付均价
html += '</td>'
+ '<td class="dark_red">'
+ '<i href="javascript:void(0)" οnmοuseοver="WUI.RoomBo.onmouseoverPrice(\''
+ priceId
+ '_woyo\',this)" οnmοuseοut="WUI.RoomBo.showPricesCutover.on(null)">'
+ showWoyoPrice(this)
+ '</i>'
+ (this.woyoSales && this.woyoSales[0] ? ('<a href="javascript:void(0)" class="woyo_pay" title="' + this.woyoSales[0][0] + ' ' + this.woyoSales[0][1] + '"></a>') : '');
$('#' + priceId + '_woyo').remove();
$('body').append(WUI.RoomBo.getPriceHTML(priceId + '_woyo', this.frontPrices, this.woyoPrices, this.woyoBreakfasts, this.prepaidShowModes, this.consultPayPrice));
html += '</td>' + '<td>' + (this.frontPrices[0] ? this.breakfasts[0] : this.woyoBreakfasts[0]) + '</td>' + '<td>' + (this.bedType || '-') + '</td>' + '<td>' + this.boardband + '</td>' + '<td class="txtR">';
if (this.booking == true) {
html += '<input type="button" class="btn_destine" οnclick="window.open(\'/order/hotelOrder!destineHotelOrder.do?checkin=' + query.checkin + '&checkout=' + query.checkout
+ '&paymentPrice=' + this.frontPriceCount + '&prepayPrice=' + this.woyoPriceCount + '&destineRoomID=' + this.id + '&destineHotelID=' + this.hotelId + '&addOrder=' + query.addOrder
+ '&updateOrder=' + query.updateOrder + '&cityId=' + query.cityId + '&orderNo=' + query.orderNo + '\');">'
} else {
html += '<input class="btn_ash" type="button" value="售 完"/>';
}
html += '</td>' + '</tr>';
html += detailHtml;
return html;
}
}
WUI.HotelBo.sortfunction = function(i, j) {
if (query.sort == 0) {
return j.bottomPrice - i.bottomPrice;
} else if (query.sort == 1) {
return i.bottomPrice - j.bottomPrice;
} else if (query.sort == 2) {
return j.score - i.score;
} else if (query.sort == 3) {
return i.score - j.score;
} else {
return i.bottomPrice - j.bottomPrice;
}
}
WUI.HotelBo.showAllRoom = function(a, hotelId) {
$(a).find('i').attr("class", "ico3");
a.onclick = function() {
WUI.HotelBo.hideAllRoom(a, hotelId);
}
$('tr[hotel="' + hotelId + '"][type="room_display"]').show();
}
WUI.HotelBo.hideAllRoom = function(a, hotelId) {
$(a).find('i').attr("class", "ico4");
a.onclick = function() {
WUI.HotelBo.showAllRoom(a, hotelId);
}
$('tr[hotel="' + hotelId + '"][type="room_display"]').hide();
$('tr[hotel="' + hotelId + '"][type="room_detail"]').hide();
}
WUI.RoomBo.DEFAULT_SHOW = 3;//默认显示数量
WUI.RoomBo.showDetail = function(roomId) {
$('#room_detail_' + roomId).show();
}
WUI.RoomBo.toggleDetail = function(roomId) {
$('#room_detail_' + roomId).toggle();
}
WUI.RoomBo.hideDetail = function(roomId) {
$('#room_detail_' + roomId).hide();
}
WUI.RoomBo.sortfunction = function(i, j) {
i = i instanceof Array ? new WUI.RoomBo(i) : i;
j = j instanceof Array ? new WUI.RoomBo(j) : j;
var i_c = i.frontPriceCount + i.woyoPriceCount + (i.booking == true ? 0 : 1000000) + (i.frontPrices[0] ? -1000000 : 0) + (i.woyoPrices[0] ? -1000000 : 0) ;//+ (i.marketPrice ? -1000000 : 0);
var j_c = j.frontPriceCount + j.woyoPriceCount + (j.booking == true ? 0 : 1000000) + (j.frontPrices[0] ? -1000000 : 0) + (j.woyoPrices[0] ? -1000000 : 0) ;//+ (j.marketPrice ? -1000000 : 0);
return i_c - j_c;
//return (i.frontPriceCount - (i.woyoPriceCount - j.woyoPriceCount) + (i.booking == true ? 0 : 1000000)) - (j.frontPriceCount + (j.booking == true ? 0 : 1000000));
}
WUI.RoomBo.sort = function(list) {
list.sort(WUI.RoomBo.sortfunction);
}
WUI.RoomBo.getPriceHTML = function(id, prices, woyoprices, breakfasts, prepaidShowModes, consultPayPrice) {
var showPrice = function(i, prices, woyoprices, prepaidShowModes, consultPayPrice){
if (woyoprices==null){
if (prices[i]) return 'RMB ' + prices[i] + "";
if (consultPayPrice && consultPayPrice[i]) return '<del>RMB ' + consultPayPrice[i] + '</del>';
return '-';
}else{
if (!woyoprices[i])return '-';
if (prepaidShowModes[i]) return 'RMB ' + woyoprices[i];
if (prices[i]) return '立省 ' + Math.ceil(prices[i] - woyoprices[i]);
if (consultPayPrice && consultPayPrice[i]) return '立省 ' + Math.ceil(consultPayPrice[i] - woyoprices[i]);
return 'RMB ' + woyoprices[i];
}
};
WUI.RoomBo.showPricesCutover.push(id);
var html = '<div style="left: -257px; top: 25px; display: none;zoom:1;position: absolute;z-index:100;" id="' + id + '" class="d_box"><div class="ash"></div><div class="d_con">';
var datTime = 1000 * 60 * 60 * 24;
var checkin = query.checkinDate;
var checkout = query.checkoutDate;
var day = checkin.getDay();
for ( var i = 0; i < query.day; i++) {
if (i % 7 == 0) {
html += '<ul class="xq">';
for ( var y = 0; y < 7 && i + y < query.day; y++, day++) {
day = day > 6 ? 0 : day;
var dayStr = _toDayStr(day);
var dt = new Date(checkin.getTime() + datTime * (i + y));
html += '<li><p>' + (dt.format('yyyy-MM-dd')) + '</p><p>' + dayStr + '</p></li>';
}
html += '</ul>';
html += '<dl class="zq"><dt>第 ' + (i / 7 + 1) + ' 周</dt>';
}
html += '<dd><p>'
+ showPrice(i, prices, woyoprices, prepaidShowModes, consultPayPrice)
+ '</p><p>' + (breakfasts && breakfasts[i] ? breakfasts[i] : '-') + '</p></dd>';
if (i % 7 == 6) {
html += '</dl>';
}
}
html += '</div>';
return html;
}
_toDayStr = function(day) {
var dayStr = null;
switch (day) {
case 0:
dayStr = '周日';
break;
case 1:
dayStr = '周一';
break;
case 2:
dayStr = '周二';
break;
case 3:
dayStr = '周三';
break;
case 4:
dayStr = '周四';
break;
case 5:
dayStr = '周五';
break;
case 6:
dayStr = '周六';
break;
}
return dayStr;
}
/**
* 时间对象的格式化;
*/
Date.prototype.format = function(format) {
/*
* eg:format="YYYY-MM-dd hh:mm:ss";
*/
var o = {
"M+" : this.getMonth() + 1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
"S" : this.getMilliseconds()
//millisecond
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for ( var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
}