class Utils { footer() { var curretHref = location.href; var footerList = [ { title: '首页', icon: 'home', href: 'index.html' }, { title: '机构', icon: 'jigou', href: 'institution.html' }, { title: '模特', icon: 'me', href: 'model.html' }, { title: '我的', icon: 'wo', href: 'my.html' }, ]; var html = ` `; $("body").insertAdjacentHTML("beforeend", html) } header(title = "", like = "") { $("body").html(`
${title}
${ like }
`); $(".header_pub .icon-back1").tap(() => { history.back() }) } item(dom, data) { data.forEach((v,i) => { dom.html(`
  • ${v.shuliang || v.total}P
    ${v.title}
    ${v.user || `模特:${(v?.renwulist.length != 0 ? v.renwulist[0].name : '')}`}
    ${v.source || `机构:${v.jigoulist[0].name}`}
    ${ (v.biaoqianlist || v.tags).map(item => { return `${item.name || item.title}` }) }
  • `) }) } $(className) { return document.querySelector(className); } _(className) { return document.querySelectorAll(className); } click(className, callback, type = "click",) { $(`${className}`)[`on${type}`] = (event) => { callback(event) } } query(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return decodeURIComponent(r[2]); return null; } setItem(key, value) { localStorage.setItem( key, value.constructor == Object || value.constructor == Array ? JSON.stringify(value) : value ) } getItem(key) { return localStorage.getItem(key) == null ? false : JSON.parse(localStorage.getItem(key)) } customMethods() { NodeList.prototype.tap = function (callback) { this.forEach((v, i) => bindElementClick(v, callback, i)) } Element.prototype.tap = function (callback) { bindElementClick(this, callback) } var bindElementClick = (v, callback, i) => { v.onclick = (e) => { callback({ v, i, e }) } } Element.prototype.html = function (html = "") { if (html.length == 0) { this.innerHTML = "" } else { this.innerHTML += html } } Element.prototype.addClass = function (className) { this.classList.add(className) return this; } Element.prototype.siblings = function () { return Array.from(this.parentElement.children).filter(v => v != this) } Array.prototype.removeClass = function (className) { this.forEach(v => bindElementRemoveClass(v, className)) return this; } Element.prototype.removeClass = function (className) { bindElementRemoveClass(this, className) return this; } var bindElementRemoveClass = (v, className) => { v.classList.remove(className) } Element.prototype.none = function () { this.style.display = "none" return this; } Element.prototype.show = function () { this.style.display = "block" return this; } Element.prototype.toggle = function () { if (this.style.display == "none") { this.style.display = "block" } else { this.style.display = "none" } } Array.prototype.map = function (callback) { let result = [] for (let index = 0; index < this.length; index++) { result.push(callback(this[index], index, this)) } return result.toString().replaceAll(",", ""); } } } let { $, _, click, customMethods, query, footer, item, header, setItem, getItem } = new Utils() customMethods()