|
@@ -1,7 +1,19 @@
|
|
<template>
|
|
<template>
|
|
<view class="page">
|
|
<view class="page">
|
|
- <view class="topUser">
|
|
|
|
|
|
+ <!-- 引入FontAwesome -->
|
|
|
|
+ <view>
|
|
|
|
+ <link rel="stylesheet"
|
|
|
|
+ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
|
|
+ </view>
|
|
|
|
+
|
|
|
|
+ <!-- 文章头图区域 -->
|
|
|
|
+ <view class="topUser" v-if="articleInfo.type == 'user'">
|
|
<image :src="home_image" class="home_image" mode="aspectFill"></image>
|
|
<image :src="home_image" class="home_image" mode="aspectFill"></image>
|
|
|
|
+ <!-- 图片指示器 -->
|
|
|
|
+ <view class="image-indicator" v-if="image_list.length > 1">
|
|
|
|
+ <text>{{ selImg + 1 }}/{{ image_list.length }}</text>
|
|
|
|
+ </view>
|
|
|
|
+ <!-- 缩略图列表 -->
|
|
<view class="list">
|
|
<view class="list">
|
|
<view class="img" :class="selImg==index?'active':''" v-for="(item,index) in image_list" :key="index"
|
|
<view class="img" :class="selImg==index?'active':''" v-for="(item,index) in image_list" :key="index"
|
|
@click="selPhoto(item,index)">
|
|
@click="selPhoto(item,index)">
|
|
@@ -9,19 +21,62 @@
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
+
|
|
|
|
+ <!-- 文章内容区域 -->
|
|
<view class="body">
|
|
<view class="body">
|
|
- <view class="item">
|
|
|
|
|
|
+ <!-- 文章标题与元信息 -->
|
|
|
|
+ <view class="article-header">
|
|
<view class="title">
|
|
<view class="title">
|
|
- 标题标题标题标题标题
|
|
|
|
|
|
+ {{ articleInfo.title || '暂无标题' }}
|
|
</view>
|
|
</view>
|
|
- <view class="title2">
|
|
|
|
- 时间:2025-02-20
|
|
|
|
|
|
+ <view class="meta-info">
|
|
|
|
+ <view class="meta-item">
|
|
|
|
+ <text class="fa fa-calendar"></text>
|
|
|
|
+ <text class="meta-text">{{ articleInfo.create_time || '暂无时间' }}</text>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="meta-item">
|
|
|
|
+ <text class="fa fa-eye"></text>
|
|
|
|
+ <text class="meta-text">{{ articleInfo.view_count || 0 }}次阅读</text>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="meta-item" v-if="articleInfo.author">
|
|
|
|
+ <text class="fa fa-user"></text>
|
|
|
|
+ <text class="meta-text">{{ articleInfo.author }}</text>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
- <view class="item">
|
|
|
|
- <view class="content">内容内容内容内容内容</view>
|
|
|
|
|
|
+
|
|
|
|
+ <!-- 内容分隔线 -->
|
|
|
|
+ <view class="divider"></view>
|
|
|
|
+
|
|
|
|
+ <!-- 文章内容 -->
|
|
|
|
+ <!-- <view class="article-content" v-if="articleInfo.type == 'user'">
|
|
|
|
+ <view class="content">{{ articleInfo.content || '暂无内容' }}</view>
|
|
|
|
+ </view> -->
|
|
|
|
+ <view class="article-content">
|
|
|
|
+ <view class="content">
|
|
|
|
+ <rich-text :nodes="content" style="font-size: 14px;"></rich-text>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
+ <!-- 文章底部区域 -->
|
|
|
|
+ <view class="article-footer">
|
|
|
|
+ <view class="action-bar">
|
|
|
|
+ <view class="action-item" @tap="likeArticle">
|
|
|
|
+ <text class="fa" :class="articleInfo.is_like ? 'fa-thumbs-up liked' : 'fa-thumbs-o-up'"></text>
|
|
|
|
+ <text class="action-text">{{ articleInfo.like_count || 0 }}</text>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="action-item" @tap="openComment">
|
|
|
|
+ <text class="fa fa-comment-o"></text>
|
|
|
|
+ <text class="action-text">{{ tableTotal || 0 }}</text>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="action-item" @tap="shareArticle">
|
|
|
|
+ <text class="fa fa-share-alt"></text>
|
|
|
|
+ <text class="action-text">分享</text>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+
|
|
|
|
+ <!-- 空白占位 -->
|
|
<view class="list_info">
|
|
<view class="list_info">
|
|
<view class="blankHeight"></view>
|
|
<view class="blankHeight"></view>
|
|
</view>
|
|
</view>
|
|
@@ -37,17 +92,51 @@
|
|
|
|
|
|
<previewImage ref="previewImage" :opacity="0.8" :circular="true" :imgs="imgs" :descs="descs"></previewImage>
|
|
<previewImage ref="previewImage" :opacity="0.8" :circular="true" :imgs="imgs" :descs="descs"></previewImage>
|
|
|
|
|
|
- <CComment ref="ccRef" :myInfo="myInfo" :userInfo="userInfo" :tableData="tableData" :tableTotal.sync="tableTotal"
|
|
|
|
- :deleteMode="deleteMode" @likeFun="likeFun" @replyFun="replyFun" @deleteFun="deleteFun"></CComment>
|
|
|
|
- <view class="btn" @tap="openComment">发表新评论</view>
|
|
|
|
|
|
+ <!-- 评论区域 -->
|
|
|
|
+ <view class="comment-section">
|
|
|
|
+ <view class="section-header">
|
|
|
|
+ <text class="fa fa-comments"></text>
|
|
|
|
+ <text class="section-title">评论区</text>
|
|
|
|
+ <text class="comment-count">({{ tableTotal }})</text>
|
|
|
|
+ </view>
|
|
|
|
+
|
|
|
|
+ <CComment ref="ccRef" :myInfo="myInfo" :userInfo="userInfo" :tableData="tableData"
|
|
|
|
+ :tableTotal.sync="tableTotal" :deleteMode="deleteMode" @likeFun="likeFun" @replyFun="replyFun"
|
|
|
|
+ @deleteFun="deleteFun"></CComment>
|
|
|
|
+
|
|
|
|
+ <view class="comment-button" @tap="openComment">
|
|
|
|
+ <text class="fa fa-pencil"></text>
|
|
|
|
+ <text>发表新评论</text>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+
|
|
<view class="thread2"></view>
|
|
<view class="thread2"></view>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ import htmlParser from '../../common/html-parser'
|
|
import CComment from "@/components/cc-comment/cc-comment.vue";
|
|
import CComment from "@/components/cc-comment/cc-comment.vue";
|
|
import previewImage from '@/components/kxj-previewImage/kxj-previewImage.vue'; //引用插件
|
|
import previewImage from '@/components/kxj-previewImage/kxj-previewImage.vue'; //引用插件
|
|
|
|
+ function parseImgs(nodes) {
|
|
|
|
+ nodes.forEach(node => {
|
|
|
|
+ if (
|
|
|
|
+ node.name === 'img' &&
|
|
|
|
+ node.attrs &&
|
|
|
|
+ node.attrs['data-img-size-val']
|
|
|
|
+ ) {
|
|
|
|
+ const sizes = node.attrs['data-img-size-val'].split(',')
|
|
|
|
+ const width = uni.upx2px(720 * 0.9)
|
|
|
|
+ const height = parseInt(width * (sizes[1] / sizes[0]))
|
|
|
|
+ node.attrs.style = `width:${width};height:${height};`
|
|
|
|
+ }
|
|
|
|
+ if (Array.isArray(node.children)) {
|
|
|
|
+ parseImgs(node.children)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return nodes
|
|
|
|
+ }
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
previewImage,
|
|
previewImage,
|
|
@@ -56,7 +145,7 @@
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
title: '',
|
|
title: '',
|
|
- userID: 0,
|
|
|
|
|
|
+ arcID: 0,
|
|
selImg: 0,
|
|
selImg: 0,
|
|
home_image: '',
|
|
home_image: '',
|
|
myinfo: {},
|
|
myinfo: {},
|
|
@@ -66,7 +155,17 @@
|
|
descs: [],
|
|
descs: [],
|
|
list_wish: [],
|
|
list_wish: [],
|
|
|
|
|
|
-
|
|
|
|
|
|
+ // 添加文章信息字段
|
|
|
|
+ articleInfo: {
|
|
|
|
+ title: '',
|
|
|
|
+ content: '',
|
|
|
|
+ create_time: '',
|
|
|
|
+ images: '',
|
|
|
|
+ view_count: 0,
|
|
|
|
+ author: '',
|
|
|
|
+ like_count: 0,
|
|
|
|
+ is_like: false
|
|
|
|
+ },
|
|
|
|
|
|
myInfo: {
|
|
myInfo: {
|
|
user_id: 1, // 用户id
|
|
user_id: 1, // 用户id
|
|
@@ -83,71 +182,19 @@
|
|
// 评论总数
|
|
// 评论总数
|
|
tableTotal: 4,
|
|
tableTotal: 4,
|
|
// 评论表
|
|
// 评论表
|
|
- tableData: [{
|
|
|
|
- id: 120, // 评论id
|
|
|
|
- parent_id: null, // 评论父级的id
|
|
|
|
- reply_id: null, // 被回复评论的id
|
|
|
|
- reply_name: null, // 被回复人的名称
|
|
|
|
- user_id: 2, // 用户id
|
|
|
|
- user_name: "ikun", // 用户名
|
|
|
|
- user_avatar: "https://pic1.zhimg.com/80/v2-a79071a705f55c5d88f6c74e6111fe84_720w.webp", // 用户头像地址
|
|
|
|
- user_content: "唱,跳,rap,篮球", // 用户评论内容
|
|
|
|
- is_like: false, // 用户是否点赞
|
|
|
|
- like_count: 120, // 点赞数统计
|
|
|
|
- create_time: "2025-02-19 09:16", // 创建时间
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: 130, // 评论id
|
|
|
|
- parent_id: 120, // 评论父级的id
|
|
|
|
- reply_id: 120, // 被回复评论的id
|
|
|
|
- reply_name: "ikun", // 被回复人的名称
|
|
|
|
- user_id: 3, // 用户id
|
|
|
|
- user_name: "小黑子", // 用户名
|
|
|
|
- user_avatar: "https://pic2.zhimg.com/80/v2-06eade66ec837713d765b1557bf20b25_720w.webp", // 用户头像地址
|
|
|
|
- user_content: "姬霓太美~祝自己生日快乐~~", // 用户评论内容
|
|
|
|
- is_like: false, // 用户是否点赞
|
|
|
|
- like_count: 67, // 点赞数统计
|
|
|
|
- create_time: "2025-03-07 00:06", // 创建时间
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: 140, // 评论id
|
|
|
|
- parent_id: 120, // 评论父级的id
|
|
|
|
- reply_id: 130, // 被回复评论的id
|
|
|
|
- reply_name: "小黑子", // 被回复人的名称
|
|
|
|
- user_id: 4, // 用户id
|
|
|
|
- user_name: "守护宗主维护宗门", // 用户名
|
|
|
|
- user_avatar: "https://pic3.zhimg.com/80/v2-244696a62fa750b8570cf56bfaa5b26a_720w.webp", // 用户头像地址
|
|
|
|
- user_content: "你露出鸡脚了", // 用户评论内容
|
|
|
|
- is_like: false, // 用户是否点赞
|
|
|
|
- like_count: 16, // 点赞数统计
|
|
|
|
- create_time: "2025-05-10 17:08", // 创建时间
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: 150, // 评论id
|
|
|
|
- parent_id: null, // 评论父级的id
|
|
|
|
- reply_id: null, // 被回复评论的id
|
|
|
|
- reply_name: null, // 被回复人的名称
|
|
|
|
- user_id: 5, // 用户id
|
|
|
|
- user_name: "音乐制作人", // 用户名
|
|
|
|
- user_avatar: "https://pic2.zhimg.com/80/v2-88ec6f8c6d3305122664dd18a28730e5_720w.webp", // 用户头像地址
|
|
|
|
- user_content: "只因你太美baby 只因你太美baby 只因你实在是太美baby 只因你太美baby 迎面走来的你让我如此蠢蠢欲动 这种感觉我从未有 Cause I got a crush on you who you 你是我的 我是你的 谁 再多一眼看一眼就会爆炸 再近一点靠近点快被融化", // 用户评论内容
|
|
|
|
- is_like: true, // 用户是否点赞
|
|
|
|
- like_count: 8, // 点赞数统计
|
|
|
|
- create_time: "2025-12-21 00:45", // 创建时间
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
|
|
+ tableData: [],
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad(parms) {
|
|
onLoad(parms) {
|
|
let self = this;
|
|
let self = this;
|
|
- this.userID = parms.uid || 1069;
|
|
|
|
|
|
+ this.arcID = parms.id || 132;
|
|
},
|
|
},
|
|
onShow() {
|
|
onShow() {
|
|
uni.$emit('check_update');
|
|
uni.$emit('check_update');
|
|
this.loadData();
|
|
this.loadData();
|
|
- this.loadWishData();
|
|
|
|
|
|
+ this.loadCommentData();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
onLinqu(item) {
|
|
onLinqu(item) {
|
|
@@ -159,27 +206,6 @@
|
|
this.selImg = sel;
|
|
this.selImg = sel;
|
|
this.home_image = this.image_list[sel];
|
|
this.home_image = this.image_list[sel];
|
|
},
|
|
},
|
|
- chatTA() {
|
|
|
|
- // uni.navigateTo({
|
|
|
|
- // url: '/pages/chat/detail?userID=1&nickName=' + encodeURIComponent("昵称") +
|
|
|
|
- // "&conversationType=C2C"
|
|
|
|
- // });
|
|
|
|
- let conversationID = "";
|
|
|
|
- let conversationType = "C2C";
|
|
|
|
- let userID = "" + this.myinfo.userID;
|
|
|
|
- let nickName = this.myinfo.nickname;
|
|
|
|
-
|
|
|
|
- var jsonConversationID = encodeURIComponent(JSON.stringify(conversationID));
|
|
|
|
- var jsonConversationType = encodeURIComponent(JSON.stringify(conversationType));
|
|
|
|
-
|
|
|
|
- var jsonUserID = encodeURIComponent(JSON.stringify(userID));
|
|
|
|
- var jsonNickName = encodeURIComponent(JSON.stringify(nickName));
|
|
|
|
-
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url: "/pages/chat/detail?userID=" + jsonUserID + "&nickName=" + jsonNickName +
|
|
|
|
- "&conversationID=" + jsonConversationID + "&conversationType=" + jsonConversationType
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
toArr(imgs) {
|
|
toArr(imgs) {
|
|
let arr = imgs.split("|");
|
|
let arr = imgs.split("|");
|
|
return arr;
|
|
return arr;
|
|
@@ -190,79 +216,83 @@
|
|
// 传入当前选中的图片地址或序号
|
|
// 传入当前选中的图片地址或序号
|
|
return; //如需测试和uni原生预览差别可注释这两行
|
|
return; //如需测试和uni原生预览差别可注释这两行
|
|
},
|
|
},
|
|
- loadWishData() {
|
|
|
|
- uni.request({
|
|
|
|
- url: this.$apiHost + '/Wish/getMyList',
|
|
|
|
- data: {
|
|
|
|
- uuid: getApp().globalData.uuid,
|
|
|
|
- userID: this.userID
|
|
|
|
- },
|
|
|
|
- header: {
|
|
|
|
- 'content-type': 'application/json'
|
|
|
|
- },
|
|
|
|
- success: (res) => {
|
|
|
|
- console.log("res", res.data)
|
|
|
|
- this.list_wish = res.data.list;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
loadData() {
|
|
loadData() {
|
|
- // console.log({
|
|
|
|
- // uuid: getApp().globalData.uuid,
|
|
|
|
- // skey: getApp().globalData.skey
|
|
|
|
- // });
|
|
|
|
uni.request({
|
|
uni.request({
|
|
- url: this.$apiHost + '/Member/getHomeInfo',
|
|
|
|
|
|
+ url: this.$apiHost + '/Article/getinfo',
|
|
data: {
|
|
data: {
|
|
uuid: getApp().globalData.uuid,
|
|
uuid: getApp().globalData.uuid,
|
|
- userID: this.userID
|
|
|
|
|
|
+ id: this.arcID
|
|
},
|
|
},
|
|
header: {
|
|
header: {
|
|
"content-type": "application/json",
|
|
"content-type": "application/json",
|
|
'sign': getApp().globalData.headerSign
|
|
'sign': getApp().globalData.headerSign
|
|
},
|
|
},
|
|
success: (res) => {
|
|
success: (res) => {
|
|
- console.log("----:", res.data);
|
|
|
|
- this.myinfo = res.data;
|
|
|
|
- if (res.data.tags != "") {
|
|
|
|
- this.tag_list = res.data.tags.split(",");
|
|
|
|
- }
|
|
|
|
- if (res.data.images != "") {
|
|
|
|
- this.image_list = res.data.images.split(",");
|
|
|
|
- this.home_image = this.image_list[0];
|
|
|
|
|
|
+ console.log("文章信息:", res.data);
|
|
|
|
+ if (res.data.success === "yes") {
|
|
|
|
+ // 更新文章信息
|
|
|
|
+ this.articleInfo = res.data.article;
|
|
|
|
+ const nodes = htmlParser(res.data.article.content);
|
|
|
|
+ // #ifdef APP-PLUS-NVUE
|
|
|
|
+ parseImgs(nodes)
|
|
|
|
+ // #endif
|
|
|
|
+ this.content = nodes
|
|
|
|
+
|
|
|
|
+ // 更新图片列表
|
|
|
|
+ if (res.data.article.images && res.data.article.images !== "") {
|
|
|
|
+ this.image_list = res.data.article.images.split(",");
|
|
|
|
+ this.home_image = this.image_list[0];
|
|
|
|
+ } else {
|
|
|
|
+ this.home_image = "../../static/home/avator.png";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新标签列表
|
|
|
|
+ // if (res.data.data.tags && res.data.data.tags !== "") {
|
|
|
|
+ // this.tag_list = res.data.data.tags.split(",");
|
|
|
|
+ // }
|
|
} else {
|
|
} else {
|
|
- this.home_image = "../../static/home/avator.png";
|
|
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '获取文章信息失败',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
}
|
|
}
|
|
},
|
|
},
|
|
complete: (com) => {
|
|
complete: (com) => {
|
|
// uni.hideLoading();
|
|
// uni.hideLoading();
|
|
},
|
|
},
|
|
fail: (e) => {
|
|
fail: (e) => {
|
|
- console.log("----e:", e);
|
|
|
|
|
|
+ console.log("请求失败:", e);
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '网络请求失败',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
-
|
|
|
|
- ZhanTA(item, index) {
|
|
|
|
- // this.list[index].is_like = 1;
|
|
|
|
- // this.list[index].num_like++;
|
|
|
|
- // return;
|
|
|
|
- let that = this;
|
|
|
|
|
|
+ loadCommentData() {
|
|
uni.request({
|
|
uni.request({
|
|
- url: this.$apiHost + '/Article/zanTA',
|
|
|
|
|
|
+ url: this.$apiHost + '/Article/getcomments',
|
|
data: {
|
|
data: {
|
|
uuid: getApp().globalData.uuid,
|
|
uuid: getApp().globalData.uuid,
|
|
- id: item.id
|
|
|
|
|
|
+ id: this.arcID,
|
|
|
|
+ page: 1,
|
|
|
|
+ limit: 10
|
|
},
|
|
},
|
|
header: {
|
|
header: {
|
|
"content-type": "application/json",
|
|
"content-type": "application/json",
|
|
'sign': getApp().globalData.headerSign
|
|
'sign': getApp().globalData.headerSign
|
|
},
|
|
},
|
|
success: (res) => {
|
|
success: (res) => {
|
|
- console.log("----:", res.data);
|
|
|
|
|
|
+ console.log("评论列表:", res.data);
|
|
if (res.data.success == "yes") {
|
|
if (res.data.success == "yes") {
|
|
- that.myinfo.article_list[index].is_like = 1;
|
|
|
|
- that.myinfo.article_list[index].num_like++;
|
|
|
|
|
|
+ this.$set(this, 'tableData', res.data.list);
|
|
|
|
+ this.tableTotal = res.data.total;
|
|
|
|
+ console.log("tabddd", this.tableData)
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '获取评论列表失败',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
}
|
|
}
|
|
},
|
|
},
|
|
complete: (com) => {
|
|
complete: (com) => {
|
|
@@ -286,7 +316,7 @@
|
|
}, callback) {
|
|
}, callback) {
|
|
console.log("likeFun", params);
|
|
console.log("likeFun", params);
|
|
uni.request({
|
|
uni.request({
|
|
- url: this.$apiHost + '/ArticleReply/zanTA',
|
|
|
|
|
|
+ url: this.$apiHost + '/Article/zanComment',
|
|
data: {
|
|
data: {
|
|
uuid: getApp().globalData.uuid,
|
|
uuid: getApp().globalData.uuid,
|
|
id: params.id
|
|
id: params.id
|
|
@@ -307,6 +337,80 @@
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ // 文章点赞
|
|
|
|
+ likeArticle() {
|
|
|
|
+ uni.request({
|
|
|
|
+ url: this.$apiHost + '/Article/like',
|
|
|
|
+ data: {
|
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
|
+ id: this.arcID
|
|
|
|
+ },
|
|
|
|
+ header: {
|
|
|
|
+ "content-type": "application/json",
|
|
|
|
+ 'sign': getApp().globalData.headerSign
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ console.log("点赞结果:", res.data);
|
|
|
|
+ if (res.data.success === "yes") {
|
|
|
|
+ // 更新点赞状态
|
|
|
|
+ if (!this.articleInfo.is_like) {
|
|
|
|
+ this.articleInfo.like_count = (this.articleInfo.like_count || 0) + 1;
|
|
|
|
+ this.articleInfo.is_like = true;
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '点赞成功',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }else {
|
|
|
|
+ this.articleInfo.like_count = (this.articleInfo.like_count || 0) - 1;
|
|
|
|
+ this.articleInfo.is_like = false;
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '取消点赞',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '点赞失败',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (e) => {
|
|
|
|
+ console.log("点赞失败:", e);
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '网络请求失败',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 分享文章
|
|
|
|
+ shareArticle() {
|
|
|
|
+ // 如果在微信小程序环境
|
|
|
|
+ if (uni.getSystemInfoSync().platform === 'mp-weixin') {
|
|
|
|
+ uni.showShareMenu({
|
|
|
|
+ withShareTicket: true,
|
|
|
|
+ menus: ['shareAppMessage', 'shareTimeline']
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ // 其他环境,如APP
|
|
|
|
+ uni.share({
|
|
|
|
+ provider: "weixin",
|
|
|
|
+ scene: "WXSceneSession",
|
|
|
|
+ type: 0,
|
|
|
|
+ title: this.articleInfo.title,
|
|
|
|
+ summary: this.articleInfo.content.substring(0, 40) + "...",
|
|
|
|
+ imageUrl: this.home_image,
|
|
|
|
+ success: function(res) {
|
|
|
|
+ console.log("分享成功:" + JSON.stringify(res));
|
|
|
|
+ },
|
|
|
|
+ fail: function(err) {
|
|
|
|
+ console.log("分享失败:" + JSON.stringify(err));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
// 评论回调事件
|
|
// 评论回调事件
|
|
replyFun({
|
|
replyFun({
|
|
params
|
|
params
|
|
@@ -322,12 +426,19 @@
|
|
// create_time: "刚刚", // 创建时间
|
|
// create_time: "刚刚", // 创建时间
|
|
// owner: true, // 是否为所有者 所有者可以进行删除 管理员默认true
|
|
// owner: true, // 是否为所有者 所有者可以进行删除 管理员默认true
|
|
// };
|
|
// };
|
|
- console.log("replyFun", params);
|
|
|
|
|
|
+ console.log("replyFun", {
|
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
|
+ article_id: this.arcID, // 文章ID
|
|
|
|
+ content: params.user_content, // 评论内容
|
|
|
|
+ parent_id: params.parent_id || 0, // 父评论ID
|
|
|
|
+ reply_id: params.reply_id || 0, // 回复的评论ID
|
|
|
|
+ reply_name: params.reply_name || '' // 被回复人名称
|
|
|
|
+ });
|
|
uni.request({
|
|
uni.request({
|
|
- url: this.$apiHost + '/ArticleReply/new',
|
|
|
|
|
|
+ url: this.$apiHost + '/Article/newComment',
|
|
data: {
|
|
data: {
|
|
uuid: getApp().globalData.uuid,
|
|
uuid: getApp().globalData.uuid,
|
|
- article_id: this.userID, // 文章ID
|
|
|
|
|
|
+ article_id: this.arcID, // 文章ID
|
|
content: params.user_content, // 评论内容
|
|
content: params.user_content, // 评论内容
|
|
parent_id: params.parent_id || 0, // 父评论ID
|
|
parent_id: params.parent_id || 0, // 父评论ID
|
|
reply_id: params.reply_id || 0, // 回复的评论ID
|
|
reply_id: params.reply_id || 0, // 回复的评论ID
|
|
@@ -367,28 +478,45 @@
|
|
params,
|
|
params,
|
|
mode
|
|
mode
|
|
});
|
|
});
|
|
- // 当请求成功, 调用callback执行评论删除;
|
|
|
|
- // Demo如下:
|
|
|
|
- // axios.post("http://xxx/delete", { ids: params, mode }).then((res) => {
|
|
|
|
- // if (res.code === 0) {
|
|
|
|
- // callback(res);
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- switch (mode) {
|
|
|
|
- case "bind":
|
|
|
|
- // 逻辑: 调用接口进行评论内容修改 update
|
|
|
|
- setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
|
|
|
|
- break;
|
|
|
|
- case "only":
|
|
|
|
- // 逻辑: 调用接口删除一个评论 delete
|
|
|
|
- setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- // all
|
|
|
|
- // 逻辑: 调用接口删除多个评论 [delete]
|
|
|
|
- setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ // 将params转换为逗号分隔的字符串
|
|
|
|
+ const idsString = Array.isArray(params) ? params.join(',') : params.toString();
|
|
|
|
+
|
|
|
|
+ console.log("删除评论", idsString, mode)
|
|
|
|
+ uni.request({
|
|
|
|
+ url: this.$apiHost + '/Article/delComment',
|
|
|
|
+ data: {
|
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
|
+ ids: idsString, // 将params转换为逗号分隔的字符串传递给ids
|
|
|
|
+ mode: mode
|
|
|
|
+ },
|
|
|
|
+ header: {
|
|
|
|
+ "content-type": "application/json",
|
|
|
|
+ 'sign': getApp().globalData.headerSign
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ console.log("删除结果:", res.data);
|
|
|
|
+ if (res.data.success === "yes") {
|
|
|
|
+ callback(res);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (e) => {
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // switch (mode) {
|
|
|
|
+ // case "bind":
|
|
|
|
+ // // 逻辑: 调用接口进行评论内容修改 update
|
|
|
|
+ // setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
|
|
|
|
+ // break;
|
|
|
|
+ // case "only":
|
|
|
|
+ // // 逻辑: 调用接口删除一个评论 delete
|
|
|
|
+ // setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
|
|
|
|
+ // break;
|
|
|
|
+ // default:
|
|
|
|
+ // // all
|
|
|
|
+ // // 逻辑: 调用接口删除多个评论 [delete]
|
|
|
|
+ // setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
|
|
|
|
+ // break;
|
|
|
|
+ // }
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
@@ -400,4 +528,28 @@
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
@import 'articleDetail.scss';
|
|
@import 'articleDetail.scss';
|
|
|
|
+
|
|
|
|
+ /* 确保评论按钮样式 */
|
|
|
|
+ .comment-button {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ width: 650rpx;
|
|
|
|
+ height: 90rpx;
|
|
|
|
+ background-color: #2979ff;
|
|
|
|
+ color: #fff;
|
|
|
|
+ border-radius: 45rpx;
|
|
|
|
+ margin: 40rpx auto 20rpx;
|
|
|
|
+ font-size: 30rpx;
|
|
|
|
+ box-shadow: 0 4rpx 12rpx rgba(41, 121, 255, 0.3);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .comment-button .fa {
|
|
|
|
+ margin-right: 10rpx;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .comment-button:active {
|
|
|
|
+ opacity: 0.9;
|
|
|
|
+ transform: scale(0.98);
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|