gree_leran/unpackage/dist/dev/mp-weixin/components/CaseBox/CaseBox.js

208 lines
5.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
const _easycom_up_text2 = common_vendor.resolveComponent("up-text");
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
(_easycom_up_text2 + _easycom_up_icon2)();
}
const _easycom_up_text = () => "../../node-modules/uview-plus/components/u-text/u-text.js";
const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
if (!Math) {
(_easycom_up_text + _easycom_up_icon)();
}
const _sfc_main = {
__name: "CaseBox",
props: {
id: {
type: Number,
default: null
},
title: {
type: String,
default: "标题"
},
text: {
type: String,
default: "正文嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻徐"
},
data: {
type: String,
default: "日期"
},
cover: {
type: String,
default: "/static/image/imgerr.png"
},
userImage: {
type: String,
default: "地址"
},
userName: {
type: String,
default: "作者"
},
userId: {
type: Number,
default: null
},
isLike: {
type: Boolean,
default: false
},
likeNumber: {
type: Number,
default: 0
},
isComments: {
type: Boolean,
default: false
},
commentsNumber: {
type: Number,
default: 0
},
isCollection: {
type: Boolean,
default: false
},
collectionNumber: {
type: Number,
default: 0
}
},
emits: ["ClickCollection", "ClickLike"],
setup(__props, { emit: __emit }) {
const emit = __emit;
const errorImg = () => {
info.cover;
};
common_vendor.ref("name");
const props = __props;
const info = common_vendor.reactive({
id: "文章id",
title: "标题",
cover: "封面地址",
text: "正文嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻徐",
data: "发布于2024-11-11",
userImage: "",
userName: "作者",
userId: "作者id",
isLike: false,
likeNumber: 0,
isComments: false,
commentsNumber: 0,
isCollection: false,
collectionNumber: 0
});
common_vendor.watch(props, (a) => {
ggg();
});
const toLike = () => {
info.isLike = !info.isLike;
console.log("sss", info);
if (info.isLike) {
info.likeNumber++;
} else {
info.likeNumber--;
}
console.log("点赞0");
emit("ClickLike", {
id: info.id,
is: info.isLike
});
console.log("点赞1");
};
const toCollection = () => {
info.isCollection = !info.isCollection;
if (info.isCollection) {
info.collectionNumber++;
} else {
info.collectionNumber--;
}
emit("ClickCollection", {
id: info.id,
is: info.isCollection
});
};
const ggg = () => {
info.id = props.id;
info.title = props.title;
info.cover = props.cover;
info.text = props.text;
info.data = props.data;
info.userImage = props.userImage;
info.userName = props.userName;
info.userId = props.userId;
info.isLike = props.isLike;
info.likeNumber = props.likeNumber;
info.isComments = props.isComments;
info.commentsNumber = props.commentsNumber;
info.isCollection = props.isCollection;
info.collectionNumber = props.collectionNumber;
};
const getInfo = () => {
common_vendor.index.navigateTo({
url: "/pages/newsInfo/newsInfo?id=" + info.id
});
};
common_vendor.onMounted(() => {
ggg();
});
return (_ctx, _cache) => {
return common_vendor.e({
a: props.cover,
b: common_vendor.o(errorImg),
c: common_vendor.p({
lines: 1,
text: info.title,
bold: true,
size: "30rpx"
}),
d: common_vendor.p({
lines: 3,
text: info.text
}),
e: common_vendor.p({
lines: 1,
text: info.data,
color: "#bfbfbf"
}),
f: common_vendor.o(getInfo),
g: info.isLike
}, info.isLike ? {
h: common_vendor.o(toLike),
i: common_vendor.p({
name: "heart-fill",
color: "#ff0004",
size: "28"
})
} : {
j: common_vendor.o(toLike),
k: common_vendor.p({
name: "heart",
color: "#000",
size: "28"
})
}, {
l: info.isCollection
}, info.isCollection ? {
m: common_vendor.o(toCollection),
n: common_vendor.p({
name: "star-fill",
color: "#ffe623",
size: "28"
})
} : {
o: common_vendor.o(toCollection),
p: common_vendor.p({
name: "star",
color: "#000",
size: "28"
})
});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-13ba89b0"], ["__file", "D:/uniapp1/gree_leran/components/CaseBox/CaseBox.vue"]]);
wx.createComponent(Component);