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

208 lines
5.3 KiB
JavaScript
Raw Normal View History

"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");
2024-06-20 15:36:19 +00:00
(_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) {
2024-06-20 15:36:19 +00:00
(_easycom_up_text + _easycom_up_icon)();
}
const _sfc_main = {
__name: "CaseBox",
props: {
id: {
2024-06-22 07:20:39 +00:00
type: Number,
default: null
},
title: {
type: String,
default: "标题"
},
text: {
type: String,
2024-06-20 15:36:19 +00:00
default: "正文嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻徐"
},
data: {
type: String,
default: "日期"
},
cover: {
type: String,
default: "/static/image/imgerr.png"
},
userImage: {
type: String,
default: "地址"
},
userName: {
type: String,
default: "作者"
},
userId: {
2024-06-22 07:20:39 +00:00
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
}
},
2024-06-20 15:36:19 +00:00
emits: ["ClickCollection", "ClickLike"],
setup(__props, { emit: __emit }) {
const emit = __emit;
const errorImg = () => {
2024-06-22 14:19:10 +00:00
info.cover;
};
common_vendor.ref("name");
const props = __props;
const info = common_vendor.reactive({
id: "文章id",
title: "标题",
cover: "封面地址",
2024-06-20 15:36:19 +00:00
text: "正文嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻徐",
data: "发布于2024-11-11",
userImage: "",
userName: "作者",
userId: "作者id",
isLike: false,
likeNumber: 0,
isComments: false,
commentsNumber: 0,
isCollection: false,
collectionNumber: 0
});
2024-06-22 07:20:39 +00:00
common_vendor.watch(props, (a) => {
ggg();
});
const toLike = () => {
info.isLike = !info.isLike;
2024-06-22 07:20:39 +00:00
console.log("sss", info);
if (info.isLike) {
info.likeNumber++;
} else {
info.likeNumber--;
}
2024-06-20 15:36:19 +00:00
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--;
}
2024-06-20 15:36:19 +00:00
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;
2024-06-20 15:36:19 +00:00
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;
};
2024-06-22 07:20:39 +00:00
const getInfo = () => {
common_vendor.index.navigateTo({
url: "/pages/newsInfo/newsInfo?id=" + info.id
});
};
common_vendor.onMounted(() => {
ggg();
});
return (_ctx, _cache) => {
return common_vendor.e({
2024-06-22 14:19:10 +00:00
a: props.cover,
b: common_vendor.o(errorImg),
c: common_vendor.p({
lines: 1,
text: info.title,
2024-06-22 07:20:39 +00:00
bold: true,
size: "30rpx"
}),
d: common_vendor.p({
lines: 3,
text: info.text
}),
e: common_vendor.p({
lines: 1,
text: info.data,
2024-06-20 15:36:19 +00:00
color: "#bfbfbf"
}),
2024-06-22 07:20:39 +00:00
f: common_vendor.o(getInfo),
g: info.isLike
}, info.isLike ? {
2024-06-22 07:20:39 +00:00
h: common_vendor.o(toLike),
i: common_vendor.p({
name: "heart-fill",
color: "#ff0004",
size: "28"
})
} : {
2024-06-22 07:20:39 +00:00
j: common_vendor.o(toLike),
k: common_vendor.p({
name: "heart",
2024-06-23 11:13:34 +00:00
color: "#000",
size: "28"
})
}, {
2024-06-22 07:20:39 +00:00
l: info.isCollection
}, info.isCollection ? {
2024-06-22 07:20:39 +00:00
m: common_vendor.o(toCollection),
n: common_vendor.p({
name: "star-fill",
2024-06-23 11:13:34 +00:00
color: "#ffe623",
size: "28"
})
} : {
2024-06-22 07:20:39 +00:00
o: common_vendor.o(toCollection),
p: common_vendor.p({
name: "star",
2024-06-23 11:13:34 +00:00
color: "#000",
size: "28"
})
});
};
}
};
2024-06-20 15:36:19 +00:00
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);