You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
256 lines
9.7 KiB
256 lines
9.7 KiB
let scaleW;
|
|
|
|
var QMUtil = {
|
|
initDate: function (){
|
|
let date = new Date();
|
|
let minu = date.getMinutes()>9?date.getMinutes():"0"+date.getMinutes();
|
|
let hour = date.getHours()>9?date.getHours():"0"+date.getHours();
|
|
document.getElementById("timeTxt").innerText = hour+":"+minu;
|
|
let mouth = date.getMonth()+1>9?date.getMonth()+1:"0"+(date.getMonth()+1);
|
|
let day = date.getDate()>9?date.getDate() : "0"+date.getDate();
|
|
document.getElementById("dateTxt").innerText = date.getFullYear()+"-"+mouth+"-"+day;
|
|
let week = date.getDay();
|
|
let weekName = "星期一";
|
|
switch(week){
|
|
case 0:
|
|
weekName = "星期日";
|
|
break;
|
|
case 1:
|
|
weekName = "星期一";
|
|
break;
|
|
case 2:
|
|
weekName = "星期二";
|
|
break;
|
|
case 3:
|
|
weekName = "星期三";
|
|
break;
|
|
case 4:
|
|
weekName = "星期四";
|
|
break;
|
|
case 5:
|
|
weekName = "星期五";
|
|
break;
|
|
case 6:
|
|
weekName = "星期六";
|
|
break;
|
|
}
|
|
document.getElementById("weekTxt").innerText = weekName;
|
|
},
|
|
|
|
onchangeSize: function (){
|
|
scaleW = window.innerHeight/(1248/704);
|
|
document.getElementById("bg").style.width = scaleW+"px";
|
|
document.getElementById("txtBg").style.width = scaleW/(1080/540)+"px";
|
|
document.getElementById("overImg").style.width = scaleW+"px";
|
|
document.getElementById("overImg").style.height = 261/(1080/scaleW)+"px";
|
|
document.getElementById("overTop").style.width = scaleW+"px";
|
|
document.getElementById("overTop").style.height = 180/(1080/scaleW)+"px";
|
|
document.getElementById("txtBg").style.height = window.innerHeight/(1920/1312)+"px";
|
|
document.getElementById("txtBg").style.right = scaleW/(1080/36)+"px";
|
|
document.getElementById("txtBg").style.bottom = window.innerHeight/(1920/250)+"px";
|
|
document.getElementById("startBnt").style.bottom = window.innerHeight/(1920/130)+"px";
|
|
document.getElementById("stopBnt").style.bottom = window.innerHeight/(1920/125)+"px";
|
|
},
|
|
|
|
//设置滚动条位置
|
|
setScrollPosition:function () {
|
|
setTimeout(()=>{
|
|
let h0 = document.getElementById("cont").offsetHeight;
|
|
let h1 = (window.innerHeight/(1920/1312)-56);
|
|
if(h0-h1>0){
|
|
document.getElementById("txtBg").scrollTo({
|
|
top: h0-h1,
|
|
behavior: 'smooth'
|
|
});
|
|
}
|
|
},200);
|
|
},
|
|
|
|
addQRCode:function (){
|
|
let wli1 = document.createElement("li");
|
|
wli1.className = "left"
|
|
wli1.innerHTML="<div>扫描下方二维码查看详细路线</div>";
|
|
document.getElementById("cont").appendChild(wli1);
|
|
|
|
let wli2 = document.createElement("li");
|
|
wli2.className = "left"
|
|
wli2.innerHTML='<div><img src="./assets/er.png" width="150" /></div>';
|
|
document.getElementById("cont").appendChild(wli2);
|
|
},
|
|
|
|
addredHot:function (){
|
|
let aili = document.createElement("li");
|
|
aili.className = "left"
|
|
aili.innerHTML="<span>小红帽</span>";
|
|
document.getElementById("cont").appendChild(aili);
|
|
},
|
|
//活动
|
|
addBackItemAction:function (obj){
|
|
let li = document.createElement("li");
|
|
li.className = "left"
|
|
document.getElementById("cont").appendChild(li);
|
|
let div = document.createElement("div");
|
|
li.appendChild(div);
|
|
let w = (scaleW/(1080/240));
|
|
let num = (typeof obj.shopNum) == "string" ? 2:3;
|
|
let dip = num == 3 ? "none":"";
|
|
div.innerHTML = `<img src="${obj.logo}" style="border-radius: 12px;" width="110" />
|
|
<div style="display: flex;flex-direction: column;width: ${w}px;padding: 0 0 0 20px;gap: 10px;">
|
|
<span style="color:#000; white-space:nowrap;text-overflow: ellipsis;overflow: hidden;word-break: break-all;">${obj.name}</span>
|
|
<span style="color:#000; white-space:nowrap;text-overflow: ellipsis;overflow: hidden;word-break: break-all;display:${dip};">店铺编号: ${obj.shopNum}</span>
|
|
<span style="color:#000; overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: ${num};line-clamp: ${num};-webkit-box-orient: vertical;">${obj.intro}</span>
|
|
</div>`;
|
|
},
|
|
//店铺
|
|
addBackShopAction:function (div,list,clickFun){
|
|
list.forEach((item, index)=>{
|
|
let all = document.createElement("div");
|
|
all.className="shop-list";
|
|
all.innerHTML = `<img src="${item.logo}" height="110" width="110" />
|
|
<div class="shop-item">
|
|
<span class="shop-name">${item.name}</span>
|
|
<span class="shop-add">${item.building+item.floor}</span>
|
|
</div>
|
|
<div class="shop-tip">${item.industryName?item.industryName:item.industryFname}</div>`;
|
|
div.appendChild(all);
|
|
});
|
|
},
|
|
//文本
|
|
addBackItemText:function (msg, idName="", isTTS=true){
|
|
let li = document.createElement("li");
|
|
idName && (li.id = idName);
|
|
li.className = "left"
|
|
document.getElementById("cont").appendChild(li);
|
|
let div = document.createElement("div");
|
|
li.appendChild(div);
|
|
if(typeof msg == "string"){
|
|
div.innerText = msg;
|
|
}else if(typeof msg.length == "number"){
|
|
div.innerText = msg[0].name || "您的问题我还在持续学习中.";
|
|
}else{
|
|
div.innerText = msg.name || "您的问题我还在持续学习中.";
|
|
}
|
|
if(isTTS){
|
|
window.isHello = false;
|
|
window.isplayHello=false;
|
|
startTTS(div.innerText);
|
|
}
|
|
},
|
|
//单图片
|
|
addItemImg:function (imgUrl, clickFun=null,houseNum){
|
|
let li_img = document.createElement("li");
|
|
li_img.className = "left"
|
|
document.getElementById("cont").appendChild(li_img);
|
|
let w = (scaleW/(1080/535));
|
|
li_img.innerHTML = `<img width="${w}" style="pointer-events:none;" src="${imgUrl}" />`;
|
|
li_img.dataset.num = houseNum || "";
|
|
if(clickFun){
|
|
li_img.addEventListener("click", clickFun);
|
|
}
|
|
},
|
|
//单图片
|
|
addItemSmallImg:function (imgUrl){
|
|
let li_img = document.createElement("li");
|
|
li_img.className = "left"
|
|
document.getElementById("cont").appendChild(li_img);
|
|
let w = (scaleW/(1080/200));
|
|
li_img.innerHTML = `<img width="${w}" src="${imgUrl}" />`;
|
|
},
|
|
addItemBigImg:function (imgUrl, videoUrl, clickFun){
|
|
let li_img = document.createElement("img");
|
|
document.getElementById("cont").appendChild(li_img);
|
|
let w = (scaleW/(1080/535));
|
|
li_img.style.width = w+"px";
|
|
li_img.style.borderRadius = "20px";
|
|
li_img.src = imgUrl;
|
|
li_img.width = w;
|
|
li_img.dataset.video = videoUrl;
|
|
if(videoUrl && clickFun){
|
|
li_img.addEventListener("click", clickFun);
|
|
}
|
|
},
|
|
|
|
addClickItemImg:function (div,url,popUrl,width,height,clickFun){
|
|
let img = document.createElement("img");
|
|
img.className = "scroll-img";
|
|
img.width = width;
|
|
img.height = height;
|
|
img.src = url;
|
|
img.dataset.pop = popUrl;
|
|
if(popUrl && clickFun){
|
|
img.addEventListener("click", clickFun);
|
|
}
|
|
div.appendChild(img);
|
|
},
|
|
addClickWCList:function(div,clickFun){
|
|
QMUtil.washroom.forEach((item, index)=>{
|
|
let img = document.createElement("img");
|
|
img.className = "scroll-img";
|
|
item.width = 160;
|
|
img.height = 160;
|
|
img.src = item.url;
|
|
img.dataset.name = item.name;
|
|
img.dataset.floor = item.floor;
|
|
img.dataset.img = item.img;
|
|
img.addEventListener("click", clickFun);
|
|
div.appendChild(img);
|
|
})
|
|
},
|
|
|
|
addWrapper:function (){
|
|
let li = document.createElement("li");
|
|
document.getElementById("cont").appendChild(li);
|
|
li.className = "scroll-container";
|
|
let wrapper = document.createElement("div");
|
|
wrapper.className="scroll-wrapper";
|
|
li.appendChild(wrapper);
|
|
return wrapper;
|
|
},
|
|
config:{
|
|
"APPID":"5c2055f8",
|
|
"API_SECRET":"2bc7168506a38cf1a7a52fb3ba63d873",
|
|
"API_KEY":"2d1e9e5604d66089bda42ff4797201c1"
|
|
},
|
|
|
|
washroom:[
|
|
{
|
|
"name": "蓝调俱乐部",
|
|
"floor": "一期二楼",
|
|
"img":"./assets/wc/0102.png",
|
|
"url":"./assets/wc/t_02.png"
|
|
},
|
|
{
|
|
"name": "赛博奇幻夜",
|
|
"floor": "一期三楼",
|
|
"img":"./assets/wc/0103.png",
|
|
"url":"./assets/wc/t_03.png"
|
|
},
|
|
{
|
|
"name": "禅韵流光庭",
|
|
"floor": "一期四楼",
|
|
"img":"./assets/wc/0104.png",
|
|
"url":"./assets/wc/t_04.png"
|
|
},
|
|
{
|
|
"name": "印象波普厅",
|
|
"floor": "一期五楼",
|
|
"img":"./assets/wc/0105.png",
|
|
"url":"./assets/wc/t_05.png"
|
|
},
|
|
{
|
|
"name": "庇护所花园",
|
|
"floor": "一期六楼",
|
|
"img":"./assets/wc/0106.png",
|
|
"url":"./assets/wc/t_06.png"
|
|
},
|
|
{
|
|
"name": "游墨字句间",
|
|
"floor": "一期七楼",
|
|
"img":"./assets/wc/0107.png",
|
|
"url":"./assets/wc/t_07.png"
|
|
}
|
|
]
|
|
|
|
}
|
|
|
|
export default QMUtil;
|
|
|