" + params.content + "
"; html += "window.AOS && AOS.init({ mirror: true }); var toI18n = (function toI18n() { var getLangsMap = function(language) { var languageMap = { "ZH-CN": { tips: "提示", close: "關閉", cancel: "取消", confirm: "確定", success: "成功", improveIt: "請完善", enterPhoneNo: "請輸入手機號碼", sendVerificationCode: "發送驗證碼", bedroom: "室", hall: "廳", kitchen: "廚", bathroom: "衛", balcony: "陽臺", your: "您的", RMB: "元", }, EN: { tips: "tips", close: "Close", cancel: "Cancel", confirm: "Confirm", success: "Success", improveIt: "improve it", enterPhoneNo: "enter phone No", sendVerificationCode: "send verification code", bedroom: "bedroom", hall: "hall", kitchen: "kitchen", bathroom: "bathroom", balcony: "balcony", your: "your", RMB: "RMB", }, }; if (!(language in languageMap)) { language = "ZH-CN"; } return languageMap[language]; }; var language = document.documentElement.getAttribute("lang") || "ZH-CN"; return function(str) { return getLangsMap(language)[str]; }; })(); function application() { this.level = 202003121716; this.regular = { realName: /([\u4e00-\u9fa5]{2,4})/, phone: /^[1][3-9][0-9]{9}$/, email: /^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/, }; } application.prototype = { itop: function() { $("html,body") .stop() .animate( { scrollTop: 0, }, 200 ); }, alert: function(params) { var html = ""; var title = params.title || toI18n("tips"); var close = $( '' + toI18n("close") + "" ); var cancel = $('"); var confirm = $( '" ); html += '
" + params.content + "
"; html += "' + params.content + "
", opts ); marker.addEventListener("click", function() { map.openInfoWindow(infoWindow, point); }); map.openInfoWindow(infoWindow, point); }, validate: function(params) { var that = this; var container = $("#" + params.container); container.find('[type="submit"]').bind({ click: function(e) { var boolen = true; container.find("[data-required]").each(function(index, element) { var required = $(this).attr("data-required"); if (!required) { return; } var name = $(this).attr("name"); var label = $(this).data("label"); var type = $(this).attr("type"); var value = $.trim($(this).val()); var placeholder = $(this).attr("placeholder") || toI18n("improveIt") + label; var error = $(this).attr("error") || placeholder; if (required == "required") { var rval = ""; if (type == "radio") { rval = $(':radio[name="' + name + '"]:checked').val(); } else if (type == "checkbox") { rval = $(':checkbox[name="' + name + '"]:checked').val(); } else { rval = value && value !== placeholder ? value : ""; } if (!rval) { that.showToast({ title: error, }); boolen = false; return false; } } else { var valid = true; if ( (required == "realName" && !value.match(that.regular.realName)) || value == "" || value == placeholder ) { valid = false; } else if ( required == "phone" && !value.match(that.regular.phone) ) { valid = false; } else if ( required == "email" && value != "" && !value.match(that.regular.email) ) { valid = false; } else if (required == "huxing") { if ( value == "" || value.indexOf("-1") > -1 || value.indexOf(-1) > -1 ) { valid = false; } } if (!valid) { that.showToast({ title: error, }); boolen = false; return false; } } }); e.preventDefault(); if (boolen && params.success) { return params.success(true); } else { if (!boolen && params.error) { return params.error(false); } } }, }); container.find("input, textarea").bind({ focus: function() { if ($(this).val() == $(this).attr("placeholder")) { $(this).val(""); } }, blur: function() { if ($(this).val() == "") { // todo不再自動val // $(this).val($(this).attr('placeholder')); } }, keyup: function() {}, }); }, scrollThumbs: function(params) { var $this = $("#" + params.id); var $list = $this.find(".carousel-list-box"); var $list2 = $this.find(".carousel-thumb-list-box"); var $prev = $this.find(".prev"); var $next = $this.find(".next"); var length = $this.find(".carousel-item-box").length; var width = $this.width(); var index = 0; var autoplay = params.autoplay; var duration = params.duration; var speed = params.speed; var timer; $list.append($list.html()); $list2.append($list2.html()); $list.find(".carousel-item-box").width(width); function next() { if (index < length) { index++; } else { $list.css({ left: 0, }); $list2.css({ left: 0, }); index = 1; } scroll(); } function prev() { console.log(987); if (index > 0) { index--; } else { $list.css({ left: -width * length, }); $list2.css({ left: -width * 0.2 * length, }); index = length - 1; } scroll(); } function scroll() { $list.stop().animate( { left: -width * index, }, speed ); $list2.stop().animate( { left: -width * 0.2 * index, }, speed ); $list2 .find(".carousel-thumb-item-box") .eq(index) .addClass("active") .siblings() .removeClass("active"); } if (autoplay) { timer = setInterval(function() { next(); }, duration); } $(window).bind({ resize: function() { clearInterval(timer); width = $this.width(); $list.find(".carousel-item-box").width(width); $list.css({ let: -width * index, }); if (autoplay) { timer = setInterval(function() { next(); }, duration); } }, }); $this.bind({ mouseenter: function() { clearInterval(timer); }, mouseleave: function() { if (autoplay) { timer = setInterval(function() { next(); }, duration); } }, }); $prev.bind({ click: function() { prev(); }, }); $next.bind({ click: function() { next(); }, }); $list2.find(".carousel-thumb-item-box").bind({ click: function() { if ($(this).index() >= length) { index = $(this).index() - length; } else { index = $(this).index(); } scroll(); }, }); }, scroll3D: function(params) { var $this = $("#" + params.id); var $list = $this.find(".carousel-list-box"); var $prev = $this.find(".prev"); var $next = $this.find(".next"); var length = $this.find(".carousel-item-box").length; var width = $this.width(); var index = 0; var autoplay = params.autoplay; var duration = params.duration; var speed = params.speed; var timer; $list.append($list.html()); $list .find(".carousel-item-box") .width(width * 0.3333) .eq(0) .addClass("prevs") .end() .eq(1) .addClass("active") .end() .eq(2) .addClass("nexts"); $list.find(".carousel-item-box").on("click", function() { index = $(this).index() - 1; scroll(); }); function next() { if (index < length) { index++; } else { $list.css({ left: 0, }); index = 1; } scroll(); } function prev() { if (index > 0) { index--; } else { $list.css({ left: -width * length, }); index = length - 1; } scroll(); } function scroll() { $list.stop().animate( { left: -width * 0.3333 * index, }, speed ); $list .find(".carousel-item-box") .eq(index) .addClass("prevs") .siblings() .removeClass("prevs"); $list .find(".carousel-item-box") .eq(index + 1) .addClass("active") .siblings() .removeClass("active"); $list .find(".carousel-item-box") .eq(index + 2) .addClass("nexts") .siblings() .removeClass("nexts"); } if (autoplay) { timer = setInterval(function() { next(); }, duration); } $(window).bind({ resize: function() { clearInterval(timer); width = $this.width(); $list.find(".carousel-item-box").width(width); $list.css({ let: -width * index, }); if (autoplay) { timer = setInterval(function() { next(); }, duration); } }, }); $this.bind({ mouseenter: function() { clearInterval(timer); }, mouseleave: function() { if (autoplay) { timer = setInterval(function() { next(); }, duration); } }, }); $prev.bind({ click: function() { prev(); }, }); $next.bind({ click: function() { next(); }, }); }, showVideoDialog: function(params) { var code = params.code; var soure = params.soure; var poster = params.poster || ""; var autoMode = params.autoMode; if (Number(soure) === 0) { window.videoDialogType = "player"; $("#videoPlayer").show(); if ($("#myVideo").length) { } else { if ($("#newVideo").length) { $("#newVideo").attr({ poster: poster, src: code, }); if (!autoMode) { newPlayer = document.getElementById("newVideo"); newPlayer.play(); } } } } else { window.videoDialogType = "iframe"; $("#videoIframe").show(); $("#videoIframe").html(code); } $("#videoPlayerDialog").show(); $("#videoPlayerDialog .video-player-close") .unbind() .on({ click: function() { app.hideVideoDialog(); }, }); }, hideVideoDialog: function(params) { if ($("#myVideo").length) { } if ($("#newVideo").length) { if (window.videoDialogType === "player") { newPlayer.pause(); } } $("#videoIframe") .hide() .html(""); $("#videoPlayer").hide(); if ($("#myVideo").length) { $("#myVideo").attr({ poster: "", }); $("#myVideo .source").attr({ src: "", }); } else { if ($("#newVideo").length) { $("#newVideo").attr({ poster: "", src: "", }); } } $("#videoPlayerDialog").hide(); }, download: function(url, name) { console.log(987); if (url == "" || name == "") { return; } if (url.indexOf(".pdf") > 0) { return window.open(url, "_blank"); } var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "blob"; xhr.onload = function() { if (xhr.status === 200) { if (window.navigator.msSaveOrOpenBlob) { navigator.msSaveBlob(xhr.response, name); } else { var link = document.createElement("a"); var body = document.querySelector("body"); link.href = window.URL.createObjectURL(xhr.response); link.download = name; link.style.display = "none"; body.appendChild(link); link.click(); body.removeChild(link); window.URL.revokeObjectURL(link.href); } } }; xhr.send(); }, formatForceNumber: function(obj) { obj.value = obj.value.replace(/[^\d.]/g, ""); obj.value = obj.value.replace(/\.{2,}/g, "."); obj.value = obj.value .replace(".", "$#$") .replace(/\./g, "") .replace("$#$", "."); obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); if (obj.value.indexOf(".") < 0 && obj.value != "") { obj.value = parseFloat(obj.value); } }, sendSms: function(name) { var that = this; var timer = 120; var scode = $("#scode-" + name); var phone = $('input[name="' + name + '"]') .val() .trim(); if (!phone.match(that.regular.phone)) { app.showToast({ title: toI18n("enterPhoneNo"), }); } else { $.post( SCENEID + "/sms", { phone: phone, }, function(res) { scode.attr({ "data-disabled": "disabled", }); function clicker() { timer -= 1; scode.text(timer + "S"); if (timer > 0) { setTimeout(clicker, 1000); } else { scode .removeAttr("data-disabled") .text(toI18n("sendVerificationCode")); } } clicker(); } ); } }, refreshHits: function(params) { $.post(SCENEID + "/view", params); }, }; var app = new application(); (function() { var $id = $(".ui-product-album-box"); var $list = $id.find(".ui-product-album"); var $dots = $id.find(".dots"); var $prev = $id.find(".prev"); var $next = $id.find(".next"); var $video = document.getElementById("mainVideo"); var width = $list.width(); var offset = 67; var interval = 5000; var index = 0; var timer; var autoplay = false; var length = $list.find(".auto-img-box").length; var NEED_SCROLL = length > 6; var HAS_VIDEO = !!$("#mainVideo").length; $list.find(".auto-img-box").width(width); $list.append($list.html()); if (NEED_SCROLL) { $dots.width(2 * length * offset); $dots.append($dots.html()); } if (length < 2) { $dots.remove(); } $dots .find(".auto-img-box") .eq(0) .addClass("active"); function prev() { if (index < 0) { $list.css({ left: -length * width, }); if (NEED_SCROLL) { $dots.css({ left: -length * offset, }); } index = length - 1; } $list.stop().animate({ left: -index * width, }); if (NEED_SCROLL) { $dots.stop().animate({ left: -index * offset, }); } videoStatus(); $dots .find(".auto-img-box") .eq(index) .addClass("active") .siblings() .removeClass("active"); } function next() { if (index >= length) { $list.css({ left: width, }); if (NEED_SCROLL) { $dots.css({ left: offset, }); } index = 0; } $list.stop().animate({ left: -index * width, }); if (NEED_SCROLL) { $dots.stop().animate({ left: -index * offset, }); } videoStatus(); $dots .find(".auto-img-box") .eq(index) .addClass("active") .siblings() .removeClass("active"); } function videoStatus() { if (HAS_VIDEO) { if (index === 0) { $video.paused && $video.play(); } else { $video.paused || $video.pause(); } } } $id.bind({ mouseenter: function() { if (autoplay) { clearInterval(timer); } }, mouseleave: function() { if (length > 1) { if (autoplay) { timer = setInterval(function() { index += 1; next(); }, interval); } } }, }); $dots.on("click", ".auto-img-box", function() { index = $(this).index(); next(); }); $prev.bind({ click: function() { index -= 1; prev(); }, }); $next.bind({ click: function() { index += 1; next(); }, }); if (length > 1) { if (autoplay) { timer = setInterval(function() { index += 1; next(); }, interval); } } // 放大鏡功能 (function handleImgZoom($) { var previewContainer = $(".img-zoom-viewer"); var lastShowingImg = null; var showingImg = null; var $container = $(".ui-page-product-detail .loop-item"); var containerWidth = $container.width(); var containerHeight = $container.height(); var $zoomIcon = $container.find(".zoom-icon"); var $previewImgs = $(".img-zoom-viewer .target"); var targetImg = ""; // 全局偏移變量 var wider = false; //圖片更寬還是更高 var left = 0; var top = 0; var imageScale = 1; previewContainer.css("height", containerHeight); function getPreviewImg(img) { var src = img.src; // targetImg = Array.from($previewImgs).find(item => item.src === src) targetImg = [].slice.call($previewImgs).find(function(item) { return item.src === src; }); } function getCurrentImg() { var $album = $(".ui-product-album"); var index = Math.abs(parseInt($album.css("left"))) / containerWidth; if (parseInt(index) !== index) return; var $img = $album.find("img.auto-img")[index]; return $img; } function ifImgTooSmall(img) { var naturalWidth = img.naturalWidth, naturalHeight = img.naturalHeight; return naturalWidth <= containerWidth && naturalHeight <= containerHeight; } function changeGlobalScale(img) { if (!img) return; var naturalWidth = img.naturalWidth, naturalHeight = img.naturalHeight, width = img.width, height = img.height; var containerAspectRatio = containerWidth / containerHeight; var imgAspectRatio = naturalWidth / naturalHeight; wider = imgAspectRatio > containerAspectRatio; if (wider) { imageScale = width / naturalWidth; } else { imageScale = height / naturalHeight; } } function handleSourceOffset(e) { var container = $container[0]; var containerRect = container.getBoundingClientRect(), containerY = containerRect.top, containerX = containerRect.left; var clientX = e.clientX, clientY = e.clientY; var iconWidth = $zoomIcon.width(); var iconHeight = $zoomIcon.height(); left = clientX - containerX - iconWidth / 2; top = clientY - containerY - iconHeight / 2; if (left <= 0) left = 0; if (left > containerWidth - iconWidth) left = containerWidth - iconWidth; if (top <= 0) top = 0; if (top > containerHeight - iconHeight) top = containerHeight - iconHeight; } function showIcon(e) { lastShowingImg = showingImg; showingImg = getCurrentImg(); if (!showingImg) return; if (ifImgTooSmall(showingImg)) { $zoomIcon.css({ visibility: "hidden", }); return $previewImgs.css("visibility", "hidden"); } changeGlobalScale(showingImg); $zoomIcon.css({ width: containerWidth * imageScale, height: containerHeight * imageScale, visibility: "visible", }); } function handleZoomIconMove(e) { lastShowingImg = showingImg; showingImg = getCurrentImg(); if (!showingImg) return; if (ifImgTooSmall(showingImg)) { $zoomIcon.css({ visibility: "hidden", }); return $previewImgs.css("visibility", "hidden"); } else if (lastShowingImg !== showingImg) { showIcon(e); } handleSourceOffset(e); $zoomIcon.css({ left: left, top: top, }); previewContainer.show(); var scaleLeft = -left / imageScale; var scaleTop = -top / imageScale; var naturalWidth = showingImg.naturalWidth; var naturalHeight = showingImg.naturalHeight; if (wider) scaleTop += (containerHeight - imageScale * naturalHeight) / 2 / imageScale; else scaleLeft += (containerWidth - imageScale * naturalWidth) / 2 / imageScale; $previewImgs.css("visibility", "hidden"); getPreviewImg(showingImg); if (targetImg) { $(targetImg).css("visibility", "visible"); } $(targetImg).css({ left: scaleLeft, top: scaleTop, }); } function handleMouseout() { $zoomIcon.css("visibility", "hidden"); previewContainer.hide(); } $(".ui-page-product-detail").on("mouseenter", ".loop-item", showIcon); $(".ui-page-product-detail").on( "mousemove", ".loop-item", handleZoomIconMove ); $(".ui-page-product-detail").on("mouseleave", ".loop-item", handleMouseout); })(jQuery); })(window, jQuery); (function() { var huxing_height = 260; var window_height = $(window).height(); var hid = ""; var timer; var $picker = $("#huxingPicker"); function getList(length) { return Array(length) .fill(void 0) .map(function(item, index) { return index + 1; }); } function ImproveListUnit(list, name) { return list.map(function(item) { return (item += name); }); } $(".form-huxing") .on("mouseenter", function() { var left = $(this).offset().left; var top = $(this).offset().top; var height = $(this).height(); var currentValue = $(this) .find("input") .val(); hid = $(this).attr("id"); var values = currentValue ? currentValue.split(",").map(Number) : [-1, -1, -1, -1, -1]; toI18n("bedroom"); var arrays = [ ImproveListUnit(getList(6), toI18n("bedroom")), ImproveListUnit(getList(6), toI18n("hall")), ImproveListUnit(getList(6), toI18n("kitchen")), ImproveListUnit(getList(6), toI18n("bathroom")), ImproveListUnit(getList(6), toI18n("balcony")), ]; var htmlArr = arrays.map(function(item, index) { var strArr = item.map(function(it, i) { var temp = i == values[index] ? '