Files
ClassContent/历届学生/font-end-nine/项目练习/上课项目/枸杞社/js/page/info.js
2024-09-27 02:06:13 +08:00

96 lines
2.5 KiB
JavaScript

class Info {
// a = {
// id: query("id"),
// total: query("total")
// }
constructor() {
header("详情", `<i class="iconfont icon-xin "></i>
<i class="iconfont icon-aixin hidden"></i>`)
this.getInfo();
this.Like()
}
Like() {
click($(".icon-xin"), function () {
console.log(111);
if ($(".icon-xin")) {
$(".icon-aixin").remove(hidden)
// $(".icon-xin").addClass(hidden)
}
})
}
// setLike(a) {
// const like = this.getLike()
// if (!!like && Array.isArray(like)) {
// like.push(this.a)
// localStorage.setItem("like", JSON.stringify(like))
// } else {
// localStorage.setItem("like", JSON.stringify([this.a]))
// }
// }
// getLike() {
// const like = JSON.parse(localStorage.getItem("like"))
// if (!!like && Array.isArray(like)) {
// return like
// }
// return []
// }
// removeLinke(a) {
// // let like = this.getLike()
// // like = like.filter(v => v !== id)
// this.a.splice(this.index, 1)
// // localStorage.removeItem("like", JSON.stringify(this.a))
// }
// changeLikeStyle() {
// const collectionDom = $("#collection")
// const id = query("id")
// const like = this.getLike()
// if (like.indexOf(id) === -1) {
// collectionDom.remove("icon-aixin")
// collectionDom.add("icon-xin")
// } else {
// collectionDom.remove("icon-xin")
// collectionDom.add("icon-aixin")
// }
// }
// onLinke() {
// const id = query("id")
// const like = this.getLike()
// if (like.indexOf(id) === -1) {
// this.setLike(id)
// this.changeLikeStyle()
// } else {
// this.removeLinke(id)
// this.changeLikeStyle()
// }
// }
// Like() {
// const collectionDom = $("#collection")
// this.changeLikeStyle()
// click(collectionDom, () => {
// this.onLinke()
// })
// }
async getInfo() {
var res = await indexServe.info({
id: query("id"),
quantity: query("total")
});
res.forEach(v => {
$(".content").html(`<img src="${v}" alt="">`)
});
//console.log("res: ", res);
}
}
new Info();