gree_leran/unpackage/dist/dev/mp-weixin/pages/newsInfo/newsInfo.js

204 lines
6.6 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const apis_cast = require("../../apis/cast.js");
const apis_user = require("../../apis/user.js");
const apis_comments = require("../../apis/comments.js");
const apis_likes = require("../../apis/likes.js");
const apis_collections = require("../../apis/collections.js");
require("../../utils/http.js");
require("../../utils/Auth.js");
if (!Array) {
const _easycom_up_avatar2 = common_vendor.resolveComponent("up-avatar");
const _easycom_up_text2 = common_vendor.resolveComponent("up-text");
const _easycom_CommentsBox2 = common_vendor.resolveComponent("CommentsBox");
const _easycom_InputBox2 = common_vendor.resolveComponent("InputBox");
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
(_easycom_up_avatar2 + _easycom_up_text2 + _easycom_CommentsBox2 + _easycom_InputBox2 + _easycom_up_icon2)();
}
const _easycom_up_avatar = () => "../../node-modules/uview-plus/components/u-avatar/u-avatar.js";
const _easycom_up_text = () => "../../node-modules/uview-plus/components/u-text/u-text.js";
const _easycom_CommentsBox = () => "../../components/CommentsBox/CommentsBox.js";
const _easycom_InputBox = () => "../../components/InputBox/InputBox.js";
const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
if (!Math) {
(_easycom_up_avatar + _easycom_up_text + _easycom_CommentsBox + _easycom_InputBox + _easycom_up_icon)();
}
const _sfc_main = {
__name: "newsInfo",
setup(__props) {
const id = common_vendor.ref(null);
const inputVisible = common_vendor.ref(false);
const inputContent = common_vendor.ref("");
const info = common_vendor.reactive({
caseId: null,
title: null,
content: null,
description: null,
imageUrl: null,
userId: null,
name: null,
createTime: null,
isLike: false,
isCollection: false,
iamge: null
});
const commentList = common_vendor.ref([]);
const currParentCommentId = common_vendor.ref(null);
const currReplyUseId = common_vendor.ref(null);
const getInfo = async (id2) => {
let res = await apis_cast.getCastInfo(id2);
if (res.code == 200) {
return res;
}
return null;
};
const addComment = (data) => {
if (data != void 0) {
currParentCommentId.value = data.parentCommentId | null;
currReplyUseId.value = data.replyUseId | null;
} else {
currParentCommentId.value = null;
currReplyUseId.value = null;
}
showInputBox();
};
const submitNote = (text) => {
inputContent.value = text;
submitComment();
inputContent.value = null;
};
const blurCom = () => {
inputVisible.value = false;
};
const showInputBox = () => {
inputVisible.value = true;
};
const submitComment = async () => {
await apis_comments.addComments({
relatedPostId: info.caseId,
commentContent: inputContent.value,
parentCommentId: currParentCommentId.value,
replyUseId: currReplyUseId.value
});
currParentCommentId.value = null;
currReplyUseId.value = null;
inputContent.value = "";
getData(id.value);
};
const getData = async () => {
let com = await getInfo(id.value);
com = com.data;
let list = await apis_comments.getCommentsByRelatedPostId(id.value);
let image = await apis_user.getImageById(com.userId);
let userName = await apis_user.getUserNameById(com.userId);
list = list.data;
commentList.value = list;
info.name = userName.msg;
info.iamge = image.msg;
info.caseId = com.caseId;
info.title = com.title;
info.content = com.content;
info.description = com.description;
info.imageUrl = com.imageUrl;
info.userId = com.userId;
info.createTime = com.createTime;
info.isLike = com.extField4 == "1";
info.isCollection = com.extField5 == "1";
};
const clickLike = () => {
info.isLike = !info.isLike;
let bo = info.isLike ? "1" : "0";
apis_likes.addLike({ contentType: 0, contentId: info.caseId, extField1: bo });
};
const clickCollection = () => {
info.isCollection = !info.isCollection;
let bo = info.isCollection ? "1" : "0";
apis_collections.addCollections({ contentType: 0, contentId: info.caseId, extField1: bo });
};
common_vendor.onLoad((e) => {
id.value = e.id;
getData();
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.p({
src: info.iamge,
size: "70"
}),
b: common_vendor.p({
text: info.name,
size: "33rpx",
bold: true
}),
c: common_vendor.p({
text: "发布于 " + info.createTime
}),
d: common_vendor.p({
text: info.title,
bold: "true",
size: "47rpx"
}),
e: common_vendor.p({
text: info.content,
color: "#8f8f8f"
}),
f: common_vendor.p({
text: info.description,
size: "40rpx"
}),
g: info.imageUrl,
h: common_vendor.f(commentList.value, (item, index, i0) => {
return {
a: common_vendor.o(addComment, item.id),
b: item.id,
c: "7d230679-6-" + i0,
d: common_vendor.p({
data: item
})
};
}),
i: inputVisible.value
}, inputVisible.value ? {
j: common_vendor.o(submitNote),
k: common_vendor.o(blurCom)
} : {}, {
l: info.isLike
}, info.isLike ? {
m: common_vendor.o(clickLike),
n: common_vendor.p({
name: "heart-fill",
color: "red",
size: "28"
})
} : {
o: common_vendor.o(clickLike),
p: common_vendor.p({
name: "heart",
color: "#000",
size: "28"
})
}, {
q: info.isCollection
}, info.isCollection ? {
r: common_vendor.o(clickCollection),
s: common_vendor.p({
name: "star-fill",
color: "#ffe135",
size: "28"
})
} : {
t: common_vendor.o(clickCollection),
v: common_vendor.p({
name: "star",
color: "#000",
size: "28"
})
}, {
w: common_vendor.o(addComment)
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7d230679"], ["__file", "D:/uniapp1/gree_leran/pages/newsInfo/newsInfo.vue"]]);
wx.createPage(MiniProgramPage);