| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const uni_modules_zPaging_components_zPaging_js_hooks_useZPaging = require("../../uni_modules/z-paging/components/z-paging/js/hooks/useZPaging.js");
- require("../../uni_modules/uview-plus/index.js");
- const hooks_useToast = require("../../hooks/useToast.js");
- const uni_modules_uviewPlus_libs_function_index = require("../../uni_modules/uview-plus/libs/function/index.js");
- if (!Array) {
- const _component_up_avatar = common_vendor.resolveComponent("up-avatar");
- const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
- const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
- const _component_up_action_sheet = common_vendor.resolveComponent("up-action-sheet");
- (_component_up_avatar + _easycom_uni_icons2 + _easycom_z_paging2 + _component_up_action_sheet)();
- }
- const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
- const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
- if (!Math) {
- (_easycom_uni_icons + _easycom_z_paging)();
- }
- const _sfc_main = {
- __name: "index",
- props: {
- /**
- * @param add 新增评论
- * @param reply 回复评论
- */
- commentType: {
- type: String,
- default: "add"
- }
- },
- emits: ["clickComment", "moveMessageTop", "inputDone"],
- setup(__props, { emit: __emit }) {
- const { Toast } = hooks_useToast.useToast();
- const emit = __emit;
- const showActionSheet = common_vendor.ref(false);
- function closeActionSheet() {
- showActionSheet.value = false;
- }
- function clickActionSheet(item) {
- if (item.value === 0) {
- handleDeleteComment();
- } else if (item.value === 1) {
- let comment = null;
- if (pressTwoLevelId.value !== 0) {
- const result = findCommentById(pressTwoLevelId.value, "two");
- if (result && result.twoItem) {
- comment = result.twoItem;
- }
- } else if (pressOneLevelId.value !== 0) {
- comment = findCommentById(pressOneLevelId.value, "one");
- }
- if (comment) {
- handleClickComment(comment);
- }
- }
- showActionSheet.value = false;
- }
- async function handleDeleteComment() {
- try {
- await deleteComment(deleteId.value);
- Toast({ title: "删除成功" });
- removeItemComment();
- } catch (error) {
- common_vendor.index.__f__("error", "at components/comment/index.vue:236", "deleteComment", error);
- } finally {
- pressOneLevelId.value = pressTwoLevelId.value = deleteId.value = 0;
- }
- }
- function removeItemComment() {
- if (pressOneLevelId.value !== 0 && pressTwoLevelId.value === 0) {
- const oneItem = findCommentById(pressOneLevelId.value, "one");
- if (oneItem) {
- const itemIndex = oneCommentList.value.findIndex(
- (v) => v.id === oneItem.id
- );
- if (itemIndex !== -1) {
- oneCommentList.value.splice(itemIndex, 1);
- }
- }
- } else if (pressTwoLevelId.value !== 0) {
- const result = findCommentById(pressTwoLevelId.value, "two");
- if (result && result.oneItem && result.twoItem) {
- const twoIndex = result.oneItem.replyList.findIndex(
- (two) => two.id === result.twoItem.id
- );
- if (twoIndex !== -1) {
- result.oneItem.replyList.splice(twoIndex, 1);
- }
- }
- }
- }
- function findCommentById(id, type = "one") {
- if (type === "one") {
- return oneCommentList.value.find((item) => item.id === id) || null;
- } else if (type === "two") {
- for (const oneItem of oneCommentList.value) {
- if (Array.isArray(oneItem.replyList)) {
- const twoItem = oneItem.replyList.find((two) => two.id === id);
- if (twoItem) {
- return { oneItem, twoItem };
- }
- }
- }
- return null;
- }
- return null;
- }
- const deleteId = common_vendor.ref(0);
- const pressOneLevelId = common_vendor.ref(0);
- const pressTwoLevelId = common_vendor.ref(0);
- function longpress(event) {
- var _a, _b, _c;
- if ((_a = event.currentTarget.dataset) == null ? void 0 : _a.twoLevelId) {
- deleteId.value = pressTwoLevelId.value = event.currentTarget.dataset.twoLevelId;
- } else if ((_b = event.currentTarget.dataset) == null ? void 0 : _b.oneLevelId) {
- deleteId.value = pressOneLevelId.value = (_c = event.currentTarget.dataset) == null ? void 0 : _c.oneLevelId;
- }
- showActionSheet.value = true;
- }
- const actionList = common_vendor.computed(() => {
- return [
- { name: "删除", value: 0 },
- { name: "回复", value: 1 }
- ];
- });
- const articleId = common_vendor.ref("");
- common_vendor.onLoad((options) => {
- if (!options.id)
- return;
- articleId.value = options.id;
- });
- const oneCommentList = common_vendor.ref([]);
- const parentId = common_vendor.ref(0);
- const currentReplyId = common_vendor.ref(0);
- const replyId = common_vendor.ref(0);
- const oneLevelId = common_vendor.ref(0);
- function handleClickComment(comment) {
- if (comment.parentId === 0) {
- currentReplyId.value = comment.id;
- parentId.value = comment.id;
- oneLevelId.value = comment.id;
- } else {
- currentReplyId.value = comment.id;
- parentId.value = comment.parentId;
- oneLevelId.value = comment.oneLevelId;
- }
- replyId.value = comment.userId;
- emit("clickComment", comment);
- }
- function closeF2() {
- }
- const paging = common_vendor.ref(null);
- uni_modules_zPaging_components_zPaging_js_hooks_useZPaging.useZPaging(paging);
- function queryList(page, pageSize) {
- }
- common_vendor.ref(false);
- const likeAnimationIds = common_vendor.ref([]);
- function toUserPage(id) {
- common_vendor.index.navigateTo({ url: `/pages/user/personal?id=${id}` });
- }
- return (_ctx, _cache) => {
- return {
- a: common_vendor.f(oneCommentList.value, (oneItem, k0, i0) => {
- return common_vendor.e({
- a: common_vendor.o(($event) => toUserPage(oneItem.userId), oneItem.id),
- b: "05fcfa07-1-" + i0 + ",05fcfa07-0",
- c: common_vendor.p({
- shape: "circle",
- src: oneItem.usePicture
- }),
- d: common_vendor.t(oneItem.userName),
- e: oneItem.authorMark
- }, oneItem.authorMark ? {} : {}, {
- f: common_vendor.o(($event) => toUserPage(oneItem.userId), oneItem.id),
- g: common_vendor.t(oneItem.content),
- h: common_vendor.t(common_vendor.unref(uni_modules_uviewPlus_libs_function_index.timeFormat)(oneItem.createTime, "yyyy-mm-dd")),
- i: common_vendor.o(longpress, oneItem.id),
- j: oneItem.id,
- k: common_vendor.o(($event) => handleClickComment(oneItem), oneItem.id),
- l: !oneItem.likeMark,
- m: likeAnimationIds.value.includes(oneItem.id) ? 1 : "",
- n: likeAnimationIds.value.includes(oneItem.id) ? 1 : "",
- o: "05fcfa07-2-" + i0 + ",05fcfa07-0",
- p: oneItem.likeMark,
- q: likeAnimationIds.value.includes(oneItem.id) ? 1 : "",
- r: likeAnimationIds.value.includes(oneItem.id) ? 1 : "",
- s: "05fcfa07-3-" + i0 + ",05fcfa07-0",
- t: common_vendor.t(oneItem.likeCount),
- v: common_vendor.n(oneItem.replyList && oneItem.replyList.length > 0 ? "child" : ""),
- w: oneItem.replyList && oneItem.replyList.length > 0
- }, oneItem.replyList && oneItem.replyList.length > 0 ? common_vendor.e({
- x: common_vendor.f(oneItem.replyList, (twoItem, idx, i1) => {
- return common_vendor.e({
- a: "05fcfa07-4-" + i0 + "-" + i1 + ",05fcfa07-0",
- b: common_vendor.p({
- shape: "circle",
- size: "25",
- src: twoItem.usePicture
- }),
- c: common_vendor.t(twoItem.userName),
- d: twoItem.authorMark
- }, twoItem.authorMark ? {} : {}, {
- e: twoItem.replyMark
- }, twoItem.replyMark ? {
- f: common_vendor.t(twoItem.replyName),
- g: common_vendor.t(twoItem.content)
- } : {
- h: common_vendor.t(twoItem.content)
- }, {
- i: common_vendor.t(common_vendor.unref(uni_modules_uviewPlus_libs_function_index.timeFormat)(twoItem.createTime, "yyyy-mm-dd")),
- j: common_vendor.o(longpress, idx),
- k: twoItem.id,
- l: !twoItem.likeMark,
- m: likeAnimationIds.value.includes(twoItem.id) ? 1 : "",
- n: likeAnimationIds.value.includes(twoItem.id) ? 1 : "",
- o: "05fcfa07-5-" + i0 + "-" + i1 + ",05fcfa07-0",
- p: twoItem.likeMark,
- q: likeAnimationIds.value.includes(twoItem.id) ? 1 : "",
- r: likeAnimationIds.value.includes(twoItem.id) ? 1 : "",
- s: "05fcfa07-6-" + i0 + "-" + i1 + ",05fcfa07-0",
- t: common_vendor.t(twoItem.likeCount),
- v: idx
- });
- }),
- y: oneItem.id,
- z: common_vendor.p({
- customPrefix: "iconfont",
- size: "18",
- color: "#2E2E2E"
- }),
- A: common_vendor.p({
- customPrefix: "iconfont",
- size: "18",
- color: "#FF2442"
- }),
- B: oneItem.replyList && oneItem.replyList.length > 0 && oneItem.replyPage.hasMore && oneItem.replyCount > 1
- }, oneItem.replyList && oneItem.replyList.length > 0 && oneItem.replyPage.hasMore && oneItem.replyCount > 1 ? {} : {}) : {}, {
- C: oneItem.id
- });
- }),
- b: common_vendor.p({
- customPrefix: "iconfont",
- size: "18",
- color: "#2E2E2E"
- }),
- c: common_vendor.p({
- customPrefix: "iconfont",
- size: "18",
- color: "#FF2442"
- }),
- d: common_vendor.sr(paging, "05fcfa07-0", {
- "k": "paging"
- }),
- e: common_vendor.o(closeF2),
- f: common_vendor.o(queryList),
- g: common_vendor.o(($event) => oneCommentList.value = $event),
- h: common_vendor.p({
- ["use-page-scroll"]: true,
- modelValue: oneCommentList.value
- }),
- i: common_vendor.o(closeActionSheet),
- j: common_vendor.o(clickActionSheet),
- k: common_vendor.p({
- actions: actionList.value,
- closeOnClickOverlay: true,
- cancelText: "取消",
- show: showActionSheet.value
- })
- };
- };
- }
- };
- const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-05fcfa07"]]);
- wx.createComponent(Component);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/components/comment/index.js.map
|