Commit 607572fb by zhujunjie

增加可下载模块

parent 2053ffdc
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
/> />
</div> </div>
<div v-if="isfile == false"> <div v-if="isfile == false">
<img :src="fileSrc" class="detail-content-right-img"> <img :src="fileSrc" class="detail-content-right-img" />
</div> </div>
</div> </div>
<!-- <el-input <!-- <el-input
...@@ -64,6 +64,13 @@ ...@@ -64,6 +64,13 @@
<div /> <div />
</nuxt-link> </nuxt-link>
</div> </div>
<attachment-list
:file="file"
:is-paid="isPaid"
:price="price"
:is-paid-attachment="isPaidAttachment"
:attachment-price="attachmentPrice"
/>
<topic-reward-list <topic-reward-list
:author="thread.user || {}" :author="thread.user || {}"
:paid-information="paidInformation" :paid-information="paidInformation"
...@@ -94,35 +101,37 @@ ...@@ -94,35 +101,37 @@
</div> </div>
</template> </template>
<script> <script>
import axios from '@/plugins/axios.js'; import axios from "@/plugins/axios.js";
import handleError from '@/mixin/handleError'; import handleError from "@/mixin/handleError";
const threadInclude const threadInclude =
= 'posts.replyUser,threadAudio,user.groups,user,' "posts.replyUser,threadAudio,user.groups,user," +
+ 'user.groups.permissionWithoutCategories,posts,posts.user,posts.likedUsers,posts.images,' "user.groups.permissionWithoutCategories,posts,posts.user,posts.likedUsers,posts.images," +
+ 'firstPost,firstPost.likedUsers,firstPost.images,firstPost.attachments,rewardedUsers,' "firstPost,firstPost.likedUsers,firstPost.images,firstPost.attachments,rewardedUsers," +
+ 'category,threadVideo,paidUsers,question,question.beUser,question.images,onlookers'; "category,threadVideo,paidUsers,question,question.beUser,question.images,onlookers";
import env from '@/utils/env'; import env from "@/utils/env";
import config from '@/config.js'; import config from "@/config.js";
import AttachmentList from "../../components/topic/AttachmentList.vue";
export default { export default {
components: { AttachmentList },
data() { data() {
return { return {
threadId: '26', threadId: "26",
renderComponent: true, renderComponent: true,
loading: false, loading: false,
showViewloading: false, showViewloading: false,
isShowView: false, isShowView: false,
isfile: true, isfile: true,
fileSrc: '', fileSrc: "",
isPost: true, isPost: true,
qywxUserid: '', qywxUserid: "",
publishType: 'knowledge', publishType: "knowledge",
fileMd5: '', fileMd5: "",
title: '', title: "",
inputContent: '', inputContent: "",
data: [], data: [],
defaultProps: { defaultProps: {
children: 'children', children: "children",
label: 'label' label: "label"
}, },
list: [], list: [],
thread: {}, thread: {},
...@@ -131,76 +140,76 @@ export default { ...@@ -131,76 +140,76 @@ export default {
postId: 0, postId: 0,
actions: [ actions: [
{ {
text: this.$t('topic.read'), text: this.$t("topic.read"),
count: 0, count: 0,
command: '', command: "",
canOpera: false, canOpera: false,
icon: 'book' icon: "book"
}, },
{ {
text: this.$t('topic.getLike'), text: this.$t("topic.getLike"),
count: 0, count: 0,
command: 'isLiked', command: "isLiked",
canOpera: true, canOpera: true,
isStatus: false, isStatus: false,
icon: 'like' icon: "like"
}, },
{ {
text: this.$t('topic.collection'), text: this.$t("topic.collection"),
command: 'isFavorite', command: "isFavorite",
canOpera: true, canOpera: true,
isStatus: false, isStatus: false,
icon: 'favor' icon: "favor"
}, },
{ {
text: this.$t('topic.share'), text: this.$t("topic.share"),
command: 'showLink', command: "showLink",
canOpera: true, canOpera: true,
icon: 'link' icon: "link"
} }
], ],
paidInformation: { paidInformation: {
price: '0', price: "0",
paid: false, paid: false,
paidUsers: [], paidUsers: [],
paidCount: 0, paidCount: 0,
isPaidAttachment: false, isPaidAttachment: false,
attachmentPrice: '0' attachmentPrice: "0"
}, },
payment: { wechat_qrcode: '', rewardAmount: '' }, payment: { wechat_qrcode: "", rewardAmount: "" },
location: { location: '', latitude: '', longitude: '' }, location: { location: "", latitude: "", longitude: "" },
managementList: [ managementList: [
{ {
name: 'canEdit', name: "canEdit",
command: 'toEdit', command: "toEdit",
isStatus: false, isStatus: false,
canOpera: false, canOpera: false,
text: this.$t('topic.edit'), text: this.$t("topic.edit"),
type: '0' type: "0"
}, },
{ {
name: 'canEssence', name: "canEssence",
command: 'isEssence', command: "isEssence",
isStatus: false, isStatus: false,
canOpera: false, canOpera: false,
text: this.$t('topic.essence'), text: this.$t("topic.essence"),
type: '1' type: "1"
}, },
{ {
name: 'canSticky', name: "canSticky",
command: 'isSticky', command: "isSticky",
isStatus: false, isStatus: false,
canOpera: false, canOpera: false,
text: this.$t('topic.sticky'), text: this.$t("topic.sticky"),
type: '2' type: "2"
}, },
{ {
name: 'canHide', name: "canHide",
command: 'isDeleted', command: "isDeleted",
isStatus: false, isStatus: false,
canOpera: false, canOpera: false,
text: this.$t('topic.delete'), text: this.$t("topic.delete"),
type: '3' type: "3"
} }
], ],
showCheckoutCounter: false, showCheckoutCounter: false,
...@@ -209,8 +218,28 @@ export default { ...@@ -209,8 +218,28 @@ export default {
defaultLoading: false, defaultLoading: false,
articleLoading: false, articleLoading: false,
passwordError: false, passwordError: false,
passwordErrorTip: '', passwordErrorTip: "",
findPassword: false findPassword: false,
attachmentPrice: "0.00",
file: {
ttachment: "考勤与假期管理制度-百伦全员、歌戈儿办公室人员适用.pdf",
extension: "pdf",
fileName: "考勤与假期管理制度-百伦全员、歌戈儿办公室人员适用.pdf",
filePath: "http://img.blsct.com/imgUrl_1611558105.2312.pdf",
fileSize: 349279,
fileType: "application/pdf",
id: 93,
isApproved: 1,
isRemote: false,
order: 0,
thumbUrl: "http://img.blsct.com/imgUrl_1611558105.2312.pdf",
type: 0,
type_id: 118,
url: "http://img.blsct.com/imgUrl_1611558105.2312.pdf"
},
isPaid: false,
isPaidAttachment: false,
price: "0.00"
}; };
}, },
computed: { computed: {
...@@ -226,21 +255,21 @@ export default { ...@@ -226,21 +255,21 @@ export default {
rewardOrPay() { rewardOrPay() {
const price = parseFloat(this.paidInformation.price); const price = parseFloat(this.paidInformation.price);
const attachmentPrice = parseFloat(this.paidInformation.attachmentPrice); const attachmentPrice = parseFloat(this.paidInformation.attachmentPrice);
const questionPrice const questionPrice =
= Object.keys(this.question).length > 0 Object.keys(this.question).length > 0
? parseFloat(this.question.onlooker_unit_price) ? parseFloat(this.question.onlooker_unit_price)
: 0; : 0;
return price > 0 || attachmentPrice > 0 || questionPrice > 0 return price > 0 || attachmentPrice > 0 || questionPrice > 0
? 'pay' ? "pay"
: 'reward'; : "reward";
}, },
payOrRewardAmount() { payOrRewardAmount() {
const price = parseFloat(this.paidInformation.price || '0'); const price = parseFloat(this.paidInformation.price || "0");
const attachmentPrice = parseFloat( const attachmentPrice = parseFloat(
this.paidInformation.attachmentPrice || '0' this.paidInformation.attachmentPrice || "0"
); );
const questionPrice const questionPrice =
= Object.keys(this.question).length > 0 Object.keys(this.question).length > 0
? parseFloat(this.question.onlooker_unit_price) ? parseFloat(this.question.onlooker_unit_price)
: 0; : 0;
return ( return (
...@@ -248,12 +277,12 @@ export default { ...@@ -248,12 +277,12 @@ export default {
); );
}, },
payOrderType() { payOrderType() {
const price = parseFloat(this.paidInformation.price || '0'); const price = parseFloat(this.paidInformation.price || "0");
const attachmentPrice = parseFloat( const attachmentPrice = parseFloat(
this.paidInformation.attachmentPrice || '0' this.paidInformation.attachmentPrice || "0"
); );
const questionPrice const questionPrice =
= Object.keys(this.question).length > 0 Object.keys(this.question).length > 0
? parseFloat(this.question.onlooker_unit_price) ? parseFloat(this.question.onlooker_unit_price)
: 0; : 0;
// 1:注册,2:打赏,3:付费主题,4:付费用户组,5:问答提问支付,6:问答围观付费, 7: 付费附件 // 1:注册,2:打赏,3:付费主题,4:付费用户组,5:问答提问支付,6:问答围观付费, 7: 付费附件
...@@ -269,11 +298,11 @@ export default { ...@@ -269,11 +298,11 @@ export default {
} }
}, },
created() { created() {
this.fileSrc = ''; this.fileSrc = "";
this.isShowView = false; this.isShowView = false;
this.inputContent = ''; this.inputContent = "";
this.title = ''; this.title = "";
this.qywxUserid = ''; this.qywxUserid = "";
this.data = []; this.data = [];
this.loading = true; this.loading = true;
// 获取知识库带过来的id // 获取知识库带过来的id
...@@ -290,16 +319,13 @@ export default { ...@@ -290,16 +319,13 @@ export default {
// this.data = res.data.result; // this.data = res.data.result;
this.data = this.deleteChildren(res.data.result); this.data = this.deleteChildren(res.data.result);
this.loading = false; this.loading = false;
if(!!this.data) if (this.data) {
{ const file = this.data.filter(item => item.file == true);
let file=this.data.filter(item => item.file==true); if (file) {
if(!!file)
{
// 触发点击事件 // 触发点击事件
this.handleNodeClick(file[0]); this.handleNodeClick(file[0]);
} }
} }
}); });
if (Object.keys(this.thread).length === 0) this.getThread(); if (Object.keys(this.thread).length === 0) this.getThread();
else this.initData(); else this.initData();
...@@ -333,7 +359,7 @@ export default { ...@@ -333,7 +359,7 @@ export default {
return arr; return arr;
}, },
openNewForm() { openNewForm() {
window.open(this.fileSrc, '_blank'); window.open(this.fileSrc, "_blank");
}, },
handleNodeClick(data) { handleNodeClick(data) {
self = this; self = this;
...@@ -378,24 +404,24 @@ export default { ...@@ -378,24 +404,24 @@ export default {
}, },
getThread() { getThread() {
return this.$store return this.$store
.dispatch('jv/get', [ .dispatch("jv/get", [
`threads/${this.threadId}`, `threads/${this.threadId}`,
{ params: { include: threadInclude }} { params: { include: threadInclude } }
]) ])
.then( .then(
data => { data => {
if (data.isDeleted) return this.$router.replace('/error'); if (data.isDeleted) return this.$router.replace("/error");
this.articleLoading = false; this.articleLoading = false;
this.thread = data; this.thread = data;
this.article = data.firstPost; this.article = data.firstPost;
this.postId = this.article._jv.id; this.postId = this.article._jv.id;
this.initData(); this.initData();
}, },
e => this.handleError(e, 'thread') e => this.handleError(e, "thread")
); );
}, },
initData() { initData() {
console.log('thread => ', this.thread); console.log("thread => ", this.thread);
this.initManagementList(this.thread); this.initManagementList(this.thread);
this.initPaidInformation(this.thread); this.initPaidInformation(this.thread);
this.initActions(this.thread, this.article); this.initActions(this.thread, this.article);
...@@ -406,10 +432,10 @@ export default { ...@@ -406,10 +432,10 @@ export default {
filterImages() { filterImages() {
this.article.imageSource = this.article.images; // 把原图路径记为 imageSource this.article.imageSource = this.article.images; // 把原图路径记为 imageSource
if ( if (
this.article.contentAttachIds this.article.contentAttachIds &&
&& this.article.contentAttachIds.length > 0 this.article.contentAttachIds.length > 0 &&
&& this.article.images this.article.images &&
&& this.article.images.length > 0 this.article.images.length > 0
) { ) {
this.article.images = this.article.images.filter( this.article.images = this.article.images.filter(
image => this.article.contentAttachIds.indexOf(image._jv.id) < 0 image => this.article.contentAttachIds.indexOf(image._jv.id) < 0
...@@ -420,7 +446,7 @@ export default { ...@@ -420,7 +446,7 @@ export default {
if (!data.question) return; if (!data.question) return;
this.question = data.question; this.question = data.question;
this.question.onlookerState = data.onlookerState; this.question.onlookerState = data.onlookerState;
console.log(this.question, 'question'); console.log(this.question, "question");
}, },
initLocation(data) { initLocation(data) {
for (const key in this.location) this.location[key] = data[key]; for (const key in this.location) this.location[key] = data[key];
...@@ -433,25 +459,25 @@ export default { ...@@ -433,25 +459,25 @@ export default {
initManagementList(data) { initManagementList(data) {
this.managementList.forEach(item => { this.managementList.forEach(item => {
item.canOpera = data[item.name]; item.canOpera = data[item.name];
if (item.name === 'canEssence') { if (item.name === "canEssence") {
item.isStatus = data.isEssence; item.isStatus = data.isEssence;
item.text = item.isStatus item.text = item.isStatus
? this.$t('topic.cancelEssence') ? this.$t("topic.cancelEssence")
: this.$t('topic.essence'); : this.$t("topic.essence");
} else if (item.name === 'canSticky') { } else if (item.name === "canSticky") {
item.isStatus = data.isSticky; item.isStatus = data.isSticky;
item.text = item.isStatus item.text = item.isStatus
? this.$t('topic.cancelSticky') ? this.$t("topic.cancelSticky")
: this.$t('topic.sticky'); : this.$t("topic.sticky");
} }
}); });
if ( if (
(this.thread.type === 4 || this.thread.type === 5) (this.thread.type === 4 || this.thread.type === 5) &&
&& this.managementList.filter(item => item.name === 'canEdit').length > 0 this.managementList.filter(item => item.name === "canEdit").length > 0
) { ) {
// 语音贴和问答帖,不支持编辑 // 语音贴和问答帖,不支持编辑
this.managementList.filter( this.managementList.filter(
item => item.name === 'canEdit' item => item.name === "canEdit"
)[0].canOpera = false; )[0].canOpera = false;
} }
this.thread.isEssence = data.isEssence; this.thread.isEssence = data.isEssence;
...@@ -465,9 +491,9 @@ export default { ...@@ -465,9 +491,9 @@ export default {
viewInfo.count = data.viewCount; viewInfo.count = data.viewCount;
favorInfo.isStatus = data.isFavorite; favorInfo.isStatus = data.isFavorite;
favorInfo.text = favorInfo.isStatus favorInfo.text = favorInfo.isStatus
? this.$t('topic.collectionAlready') ? this.$t("topic.collectionAlready")
: this.$t('topic.collection'); : this.$t("topic.collection");
favorInfo.icon = favorInfo.isStatus ? 'favored' : 'favor'; favorInfo.icon = favorInfo.isStatus ? "favored" : "favor";
favorInfo.canOpera = data.canFavorite; favorInfo.canOpera = data.canFavorite;
} }
if (firstPost) { if (firstPost) {
...@@ -475,9 +501,9 @@ export default { ...@@ -475,9 +501,9 @@ export default {
likeInfo.isStatus = firstPost.isLiked; likeInfo.isStatus = firstPost.isLiked;
likeInfo.canOpera = firstPost.canLike; likeInfo.canOpera = firstPost.canLike;
likeInfo.text = likeInfo.isStatus likeInfo.text = likeInfo.isStatus
? this.$t('topic.liked') ? this.$t("topic.liked")
: this.$t('topic.getLike'); : this.$t("topic.getLike");
likeInfo.icon = likeInfo.isStatus ? 'liked' : 'like'; likeInfo.icon = likeInfo.isStatus ? "liked" : "like";
} }
this.$set(this.actions, 0, viewInfo); this.$set(this.actions, 0, viewInfo);
...@@ -486,14 +512,14 @@ export default { ...@@ -486,14 +512,14 @@ export default {
}, },
paying({ payWay, hideAvatar, rewardAmount }) { paying({ payWay, hideAvatar, rewardAmount }) {
if ( if (
this.rewardOrPay === 'reward' this.rewardOrPay === "reward" &&
&& (!rewardAmount || parseFloat(rewardAmount) === 0) (!rewardAmount || parseFloat(rewardAmount) === 0)
) { ) {
return this.$message.error(this.$t('pay.AmountCannotBeLessThan0')); return this.$message.error(this.$t("pay.AmountCannotBeLessThan0"));
} }
this.payment.rewardAmount = rewardAmount; this.payment.rewardAmount = rewardAmount;
this.showCheckoutCounter = false; this.showCheckoutCounter = false;
if (payWay === 'walletPay') { if (payWay === "walletPay") {
this.showPasswordInput = true; this.showPasswordInput = true;
this.createOrder( this.createOrder(
hideAvatar, hideAvatar,
...@@ -503,9 +529,9 @@ export default { ...@@ -503,9 +529,9 @@ export default {
).finally(() => { ).finally(() => {
this.defaultLoading = false; this.defaultLoading = false;
}); });
} else if (payWay === 'wxPay') { } else if (payWay === "wxPay") {
if (!this.forums.paycenter.wxpay_close) { if (!this.forums.paycenter.wxpay_close) {
return this.$message.warning(this.$t('pay.wxPayClose')); return this.$message.warning(this.$t("pay.wxPayClose"));
} }
this.createOrder( this.createOrder(
hideAvatar, hideAvatar,
...@@ -521,10 +547,10 @@ export default { ...@@ -521,10 +547,10 @@ export default {
() => { () => {
this.getThread(); this.getThread();
}, },
() => console.log('支付失败') () => console.log("支付失败")
); );
}, },
() => console.log('支付失败') () => console.log("支付失败")
); );
}) })
.finally(() => { .finally(() => {
...@@ -537,32 +563,32 @@ export default { ...@@ -537,32 +563,32 @@ export default {
() => { () => {
this.getThread(); this.getThread();
}, },
() => console.log('支付失败') () => console.log("支付失败")
); );
}, },
postCommand(item) { postCommand(item) {
if (this.defaultLoading) return; if (this.defaultLoading) return;
this.defaultLoading = true; this.defaultLoading = true;
const params const params =
= item.command === 'isLiked' item.command === "isLiked"
? { _jv: { type: `posts`, id: this.postId }} ? { _jv: { type: `posts`, id: this.postId } }
: { _jv: { type: `threads`, id: this.threadId }}; : { _jv: { type: `threads`, id: this.threadId } };
params[item.command] = !item.isStatus; params[item.command] = !item.isStatus;
return this.$store return this.$store
.dispatch('jv/patch', params) .dispatch("jv/patch", params)
.then( .then(
data => { data => {
data.firstPost && this.initManagementList(data); data.firstPost && this.initManagementList(data);
data.firstPost && this.initActions(data); data.firstPost && this.initActions(data);
if (item.command === 'isSticky') { if (item.command === "isSticky") {
return item.isStatus return item.isStatus
? this.$message.success(this.$t('topic.stickySuccess')) ? this.$message.success(this.$t("topic.stickySuccess"))
: this.$message.success(this.$t('topic.cancelStickySuccess')); : this.$message.success(this.$t("topic.cancelStickySuccess"));
} }
if (item.command === 'isLiked') { if (item.command === "isLiked") {
return this.setLikeUser(!item.isStatus, data); return this.setLikeUser(!item.isStatus, data);
} }
if (item.command === 'isDeleted') return this.afterDeleted(); if (item.command === "isDeleted") return this.afterDeleted();
}, },
e => this.handleError(e) e => this.handleError(e)
) )
...@@ -575,41 +601,40 @@ export default { ...@@ -575,41 +601,40 @@ export default {
status status
? this.article.likedUsers.unshift(this.currentUser) ? this.article.likedUsers.unshift(this.currentUser)
: this.article.likedUsers.forEach((item, index, array) => { : this.article.likedUsers.forEach((item, index, array) => {
item.id === this.currentUser.id && array.splice(index, 1); item.id === this.currentUser.id && array.splice(index, 1);
}); });
}, },
afterDeleted() { afterDeleted() {
this.$message({ this.$message({
typeInformation: 'success', typeInformation: "success",
message: this.$t('topic.deleteSuccessAndJumpToBack') message: this.$t("topic.deleteSuccessAndJumpToBack")
}); });
setTimeout(() => { setTimeout(() => {
this.$router.push('/'); this.$router.push("/");
}, 1000); }, 1000);
} }
}, },
head() { head() {
return { return {
title: title: "知识库",
'知识库',
meta: [ meta: [
{ {
hid: 'keywords', hid: "keywords",
name: 'keywords', name: "keywords",
content: (this.thread.category && this.thread.category.name) || '' content: (this.thread.category && this.thread.category.name) || ""
}, },
{ {
hid: 'description', hid: "description",
name: 'description', name: "description",
content: content:
(this.thread.firstPost (this.thread.firstPost &&
&& this.thread.firstPost.summaryText.slice(0, 80)) this.thread.firstPost.summaryText.slice(0, 80)) ||
|| '' ""
}, },
{ {
name: 'og:video', name: "og:video",
content: content:
(this.thread.threadVideo && this.thread.threadVideo.media_url) || '' (this.thread.threadVideo && this.thread.threadVideo.media_url) || ""
} }
] ]
}; };
...@@ -632,18 +657,21 @@ export default { ...@@ -632,18 +657,21 @@ export default {
width: 200px; width: 200px;
overflow: hidden; overflow: hidden;
} */ } */
.detail-content-left-text .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{ .detail-content-left-text
color: #2e8cf0 !important; .el-tree--highlight-current
.el-tree-node.is-current
> .el-tree-node__content {
color: #2e8cf0 !important;
} }
.detail-content-left-text .el-tree-node:focus > .el-tree-node__content { .detail-content-left-text .el-tree-node:focus > .el-tree-node__content {
background-color: transparent !important; background-color: transparent !important;
color: #2e8cf0 !important; color: #2e8cf0 !important;
} }
.detail-content-left-text .el-tree-node.is-current > .el-tree-node__content { .detail-content-left-text .el-tree-node.is-current > .el-tree-node__content {
background-color:transparent !important; background-color: transparent !important;
} }
.detail-content-left-text .el-tree-node__hover{ .detail-content-left-text .el-tree-node__hover {
color: #2e8cf0 !important; color: #2e8cf0 !important;
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment