class Utils { footer() { var html = ` ` $("body").insertAdjacentHTML("beforeend", html); } item (father, data) { father.innerHTML = "" data.forEach(v => { father.innerHTML+=`
${v.total || v.shuliang}P
${v.title}
${v.user || `模特: ${v.renwulist[0].name}`}
${v.source || `机构: ${v.jigoulist[0].name}`}
${(v.tags || v.biaoqianlist) == undefined ? '' : `
${ (v.tags || v.biaoqianlist).forH(val => { return ` ${val.title || val.name} ` }) }
` }
` }) } title(text = "", rightIcon = "") { var html = `
${text} ${rightIcon}
` $("body").insertAdjacentHTML("beforeend", html); click(".icon-back1", () => { history.back() }) } click(className, callback) { _(className).forEach((v,i) => v.onclick = () => callback(v,i)) } query(name) { let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); let r = window.location.search.substr(1).match(reg); if (r != null) { return decodeURIComponent(r[2]); }; return null; } cover() { // 对map进行重写 // map的实现原理 // function a(callback) { // return callback(v).toString() // } // var c = a( function (v) { // return "v" // } ) Array.prototype.forH = function (callback) { var res = [] for (var index = 0; index < this.length; index++) { res.push(callback(this[index])) } return res.toString().replaceAll(",", "") } // 其他很多重写 } $(className) { return document.querySelector(className) } _(className) { return document.querySelectorAll(className) } } var { footer, $, _, query, cover, click, item, title } = new Utils(); cover()