110 lines
4.0 KiB
JavaScript
110 lines
4.0 KiB
JavaScript
class Utils {
|
|
footer() {
|
|
var footerArr = [
|
|
{title: '首页', icon: 'icon-home', href: 'index.html'},
|
|
{title: '机构', icon: 'icon-jigou', href: 'mechanism.html'},
|
|
{title: '模特', icon: 'icon-me', href: 'model.html'},
|
|
{title: '我的', icon: 'icon-wo', href: 'my.html'},
|
|
];
|
|
// 用户当前正在访问的页面地址
|
|
// http://localhost:63342/page/mechanism.html
|
|
var currentPath = location.href;
|
|
$("body").innerHTML += `
|
|
<ul class="footer">
|
|
${
|
|
footerArr.map((v, index) => {
|
|
return `
|
|
<li class="${currentPath.includes(v.href) ? 'footer_active' : ''}">
|
|
<a href="./${v.href}">
|
|
<i class="iconfont ${v.icon}"></i>
|
|
<p>${v.title}</p>
|
|
</a>
|
|
</li>
|
|
`
|
|
}).toString().replaceAll(",", "")
|
|
}
|
|
</ul>
|
|
`
|
|
}
|
|
|
|
header(title, action = "") {
|
|
$("body").innerHTML = `
|
|
<div class="pub_header">
|
|
<div class="pub_header_left">
|
|
<i class="iconfont icon-back1"></i>
|
|
<span>${title}</span>
|
|
</div>
|
|
<div class="pub_header_action">
|
|
${action}
|
|
</div>
|
|
</div>
|
|
` + $("body").innerHTML;
|
|
|
|
$(".icon-back1").onclick = () => {
|
|
history.back();
|
|
}
|
|
}
|
|
|
|
item(el, data) {
|
|
data.forEach((item, i) => {
|
|
el.append(
|
|
`
|
|
<div class="do_together_item">
|
|
<a href="info.html?url=${item.path}">
|
|
<div class="item_img">
|
|
<img src="${Array.isArray(item.img) ? item.img[0] : item.img}" alt="">
|
|
</div>
|
|
|
|
<div class="item_padd">
|
|
<div class="tips_titles">${item.title}</div>
|
|
<span class="tips_text">养</span>
|
|
${
|
|
typeof item.label == "string" || item.label == null
|
|
? ''
|
|
: `<p class="tips">${item.label.desc}</p>`
|
|
}
|
|
</div>
|
|
${
|
|
Array.isArray(item.author)
|
|
? ''
|
|
: `
|
|
<div class="item_avatr item_pa">
|
|
<div class="avatr_left">
|
|
<img src="${item.author.avatar_url}" alt="">
|
|
<span>${item.author.nickname}</span>
|
|
</div>
|
|
<div class="avatr_view">
|
|
<i class="iconfont icon-yanjing"></i>
|
|
<span>${item.total_amount}</span>
|
|
</div>
|
|
</div>
|
|
`
|
|
|
|
}
|
|
|
|
</a>
|
|
</div>
|
|
`
|
|
)
|
|
})
|
|
|
|
}
|
|
|
|
query(variable) {
|
|
var query = window.location.search.substring(1);
|
|
var vars = query.split("&");
|
|
for (var i=0;i<vars.length;i++) {
|
|
var pair = vars[i].split("=");
|
|
if(pair[0] == variable){
|
|
return decodeURI(pair[1]);
|
|
}
|
|
}
|
|
return(false);
|
|
}
|
|
}
|
|
|
|
// 对象的解构赋值
|
|
var {
|
|
footer,
|
|
item,query, header
|
|
} = new Utils() |