articleDetail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. <template>
  2. <view class="page">
  3. <!-- 引入FontAwesome -->
  4. <view>
  5. <link rel="stylesheet"
  6. href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
  7. </view>
  8. <!-- 顶部导航栏 -->
  9. <view class="custom-navbar">
  10. <view class="navbar-left" @click="goBack">
  11. <text class="fa fa-angle-left"></text>
  12. </view>
  13. <view class="navbar-center">
  14. <view class="navbar-title" v-if="isMessage" @click="goToUserHomepage(author.id)">
  15. <image class="navbar-avatar" :src="author.avator" mode="aspectFill"></image>
  16. <text class="navbar-text">{{ author.nickname }}</text>
  17. <!-- <text class="navbar-badge" v-if="author.is_vip > 0">VIP</text> -->
  18. </view>
  19. </view>
  20. <view class="navbar-right">
  21. <template v-if="!isItMe">
  22. <text class="followTheAuthor followTheAuthor1" v-if="author.is_attention == 0"
  23. @click="followTheAuthor(1)">+关注</text>
  24. <text class="followTheAuthor followTheAuthor0" v-if="author.is_attention == 1"
  25. @click="followTheAuthor(0)">已关注</text>
  26. </template>
  27. <template v-if="isMessage">
  28. <image v-if="!isItMe" @click="showActionSheet(0)" src="@/static/icon/sy_icon_fenxiang.png"
  29. mode="widthFix"></image>
  30. <view v-else class="navbar-right" @click="showActionSheet(1)">
  31. <image src="@/static/icon/more2.png" style="width: 64rpx;height: 64rpx; margin-top: 15rpx;" mode="widthFix"></image>
  32. </view>
  33. </template>
  34. <image v-else @click="showActionSheet(2)" src="@/static/icon/sy_icon_fenxiang.png" mode="widthFix">
  35. </image>
  36. </view>
  37. </view>
  38. <view class="topStatusBar inProgress" v-if="articleInfo.status == 2">
  39. 审核中</view>
  40. <view class="topStatusBar fail" v-else-if="articleInfo.status == 3" @click="openConfirmationBox">
  41. 审核未通过,点击查看原因</view>
  42. <template v-if="isMessage">
  43. <!-- 轮播图部分 -->
  44. <uv-swiper v-if="articleInfo.type == 'user'" class="swiper-box" height="1048rpx" :list="swperImages"
  45. indicator indicatorMode="dot" bgColor="#fff" :autoplay="false" @click="previewImage">
  46. </uv-swiper>
  47. <!-- 文章内容区域 -->
  48. <view class="body">
  49. <!-- 文章标题与元信息 -->
  50. <view class="article-header">
  51. <view class="title">
  52. {{ articleInfo.title || "暂无标题" }}
  53. </view>
  54. <view class="article-content">
  55. <view class="content">
  56. <!-- <rich-text :nodes="content" style="font-size: 14px"></rich-text> -->
  57. <uv-parse :content="articleInfo.content"></uv-parse>
  58. </view>
  59. </view>
  60. <view class="cardLink" v-if="workInfo.id" @click="goToDetails(workInfo.id)">
  61. <image :src="workInfo.images" mode="heightFix"></image>
  62. <view class="content">
  63. <view class="tit">{{ workInfo.title || "暂无标题" }}</view>
  64. <view class="tex">{{
  65. cutTime(workInfo.create_time) || "暂无时间"
  66. }}</view>
  67. </view>
  68. </view>
  69. <view v-if="false" class="meta-info">
  70. <view class="meta-item">
  71. <text class="fa fa-calendar"></text>
  72. <text class="meta-text">{{
  73. articleInfo.create_time || "暂无时间"
  74. }}</text>
  75. </view>
  76. <view class="meta-item">
  77. <text class="fa fa-eye"></text>
  78. <text class="meta-text">{{ articleInfo.num_view || 0 }}次阅读</text>
  79. </view>
  80. <view class="meta-item" v-if="articleInfo.author">
  81. <text class="fa fa-user"></text>
  82. <text class="meta-text">{{ articleInfo.author }}</text>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 文章底部区域 -->
  87. <view class="article-footer" v-if="false">
  88. <view class="action-bar">
  89. <view class="action-item" @tap="likeArticle">
  90. <text class="fa" :class="articleInfo.is_like ? 'fa-thumbs-up liked' : 'fa-thumbs-o-up'
  91. "></text>
  92. <text class="action-text">{{ articleInfo.like_count || 0 }}</text>
  93. </view>
  94. <view class="action-item" @tap="openComment">
  95. <text class="fa fa-comment-o"></text>
  96. <text class="action-text">{{ tableTotal || 0 }}</text>
  97. </view>
  98. <view class="action-item" @tap="shareArticle">
  99. <text class="fa fa-share-alt"></text>
  100. <text class="action-text">分享</text>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- <view class="btn_submit" @click="chatTA()">
  106. <image class="icon" src="../../static/icon/icon_chat_white.png" mode="widthFix"></image>
  107. 私聊
  108. </view> -->
  109. <previewImage ref="previewImage" :opacity="0.8" :circular="true" :imgs="imgs" :descs="descs"></previewImage>
  110. </template>
  111. <template v-else>
  112. <!-- <rich-text :nodes="content" style="font-size: 14px"></rich-text> -->
  113. <uv-parse :content="articleInfo.content"></uv-parse>
  114. </template>
  115. <!-- 评论区域 -->
  116. <template v-if="articleInfo.status == 1">
  117. <CommentSection style="background: #fff; border-top: #F2F6F2 2rpx solid;" v-if="userInfo.id != 0"
  118. ref="commentSection" @totalNumberOfComments="totalNumberOfComments" :articleInfo="articleInfo"
  119. :myInfo="myInfo" :userInfo="userInfo" :author="author" :articleId="arcID" :type="'article'">
  120. </CommentSection>
  121. </template>
  122. <view class="thread2"></view>
  123. <!-- 自定义 ActionSheet -->
  124. <ActionSheet ref="actionSheet" :items="items" @select="handleActionSelect" @cancel="handleActionCancel" />
  125. <CustomPopup ref="confirmationBox">
  126. <view class="failureReason">
  127. <view class="title"> 审核未通关</view>
  128. <view class="reviewContent">
  129. <!-- {{ fileInformation.reason }} -->
  130. <uv-parse :content="articleInfo.reason"></uv-parse>
  131. </view>
  132. <view class="btn-box" @click="closeConfirmationBox">知道了</view>
  133. </view>
  134. </CustomPopup>
  135. <DialogBox ref="DialogBox"></DialogBox>
  136. <SharePopup :visible="showShare" :userId="userId" :share-title="shareTitle" :share-desc="shareDesc"
  137. :share-img="shareImg" view="makeDetail" @close="showShare = false" />
  138. </view>
  139. </template>
  140. <script>
  141. import htmlParser from "../../common/html-parser";
  142. import CommentSection from "@/components/CommentSection/CommentSection.vue";
  143. import previewImage from "@/components/kxj-previewImage/kxj-previewImage.vue"; //引用插件
  144. import CustomPopup from "@/components/CustomPopup/CustomPopup.vue";
  145. import SharePopup from "@/components/SharePopup/SharePopup.vue";
  146. function parseImgs(nodes) {
  147. nodes.forEach((node) => {
  148. if (node.name === "img" && node.attrs && node.attrs["data-img-size-val"]) {
  149. const sizes = node.attrs["data-img-size-val"].split(",");
  150. const width = uni.upx2px(720 * 0.9);
  151. const height = parseInt(width * (sizes[1] / sizes[0]));
  152. node.attrs.style = `width:${width};height:${height};`;
  153. }
  154. if (Array.isArray(node.children)) {
  155. parseImgs(node.children);
  156. }
  157. });
  158. return nodes;
  159. }
  160. export default {
  161. components: {
  162. previewImage,
  163. CommentSection,
  164. CustomPopup,
  165. SharePopup,
  166. },
  167. data() {
  168. return {
  169. swperImages: [],
  170. items: [],
  171. title: "",
  172. arcID: 0,
  173. selImg: 0,
  174. home_image: "",
  175. myinfo: {},
  176. tag_list: [],
  177. image_list: [],
  178. imgs: [],
  179. descs: [],
  180. list_wish: [],
  181. content: "",
  182. tableTotal: 0,
  183. author: {},
  184. // 添加文章信息字段
  185. articleInfo: {
  186. title: "",
  187. content: "",
  188. create_time: "",
  189. images: "",
  190. view_count: 0,
  191. author: "",
  192. like_count: 0,
  193. is_like: false,
  194. },
  195. workInfo: {},
  196. myInfo: {
  197. user_id: getApp().globalData.user_id, // 用户id
  198. user_name: getApp().globalData.nickname, // 用户名
  199. user_avatar: getApp().globalData.avator, // 用户头像地址
  200. },
  201. // 文章作者信息(提示: 一般来自localstorage, 如果是实时获取的话, 那么获取到数据后再v-if显示评论组件)
  202. userInfo: {
  203. user_id: 0, // 用户id
  204. user_name: "", // 用户名
  205. user_avatar: "", // 用户头像地址
  206. },
  207. isItMe: false,
  208. sms_id: 0,
  209. isMessage: true,
  210. showShare: false,
  211. shareTitle: "",
  212. shareDesc: "",
  213. shareImg: "",
  214. userId: 0,
  215. };
  216. },
  217. onLoad(parms) {
  218. let self = this;
  219. this.arcID = parms.id;
  220. if (parms.type == "sms") {
  221. this.isMessage = false;
  222. }
  223. if (parms.sms_id) {
  224. this.sms_id = parms.sms_id;
  225. }
  226. },
  227. onShow() {
  228. uni.$emit("check_update");
  229. this.$nextTick(() => {
  230. if (this.$refs.commentSection) {
  231. this.$refs.commentSection.loadCommentData();
  232. }
  233. });
  234. this.loadData();
  235. },
  236. methods: {
  237. openConfirmationBox() {
  238. this.$refs.confirmationBox.open();
  239. },
  240. closeConfirmationBox() {
  241. this.$refs.confirmationBox.close();
  242. },
  243. // 返回上一页
  244. goBack() {
  245. uni.navigateBack({
  246. delta: 1,
  247. });
  248. },
  249. // 文章点赞
  250. likeArticle() {
  251. uni.request({
  252. url: this.$apiHost + "/Work/zanTA",
  253. data: {
  254. uuid: getApp().globalData.uuid,
  255. id: this.arcID,
  256. },
  257. header: {
  258. "content-type": "application/json",
  259. sign: getApp().globalData.headerSign,
  260. },
  261. success: (res) => {
  262. console.log("点赞结果:", res.data);
  263. if (res.data.success === "yes") {
  264. // 更新点赞状态
  265. if (!this.articleInfo.is_like) {
  266. this.articleInfo.like_count =
  267. (this.articleInfo.like_count || 0) + 1;
  268. this.articleInfo.is_like = true;
  269. uni.showToast({
  270. title: "点赞成功",
  271. icon: "none",
  272. });
  273. } else {
  274. this.articleInfo.like_count =
  275. (this.articleInfo.like_count || 0) - 1;
  276. this.articleInfo.is_like = false;
  277. uni.showToast({
  278. title: res.data.str,
  279. icon: "none",
  280. });
  281. }
  282. } else {
  283. uni.showToast({
  284. title: res.data.str,
  285. icon: "none",
  286. });
  287. }
  288. },
  289. fail: (e) => {
  290. console.log("点赞失败:", e);
  291. uni.showToast({
  292. title: "网络请求失败",
  293. icon: "none",
  294. });
  295. },
  296. });
  297. },
  298. // 关注作者
  299. followTheAuthor(n) {
  300. uni.$emit('check_login', () => {
  301. uni.request({
  302. url: this.$apiHost + "/Member/attention",
  303. data: {
  304. uuid: getApp().globalData.uuid,
  305. id: this.author.id,
  306. },
  307. header: {
  308. "content-type": "application/json",
  309. sign: getApp().globalData.headerSign,
  310. },
  311. success: (res) => {
  312. console.log("点赞结果:", res.data);
  313. uni.showToast({
  314. title: res.data.str,
  315. icon: "none",
  316. });
  317. if (res.data.success === "yes") {
  318. console.log("关注结果:", res.data, n);
  319. this.author.is_attention = n;
  320. }
  321. },
  322. fail: (e) => {
  323. console.log("关注失败:", e);
  324. uni.showToast({
  325. title: "网络请求失败",
  326. icon: "none",
  327. });
  328. },
  329. });
  330. })
  331. },
  332. totalNumberOfComments(tableTotal) {
  333. this.tableTotal = tableTotal;
  334. },
  335. onLinqu(item) {
  336. uni.navigateTo({
  337. url: "/pages/my/wishHelp?id=" + item.myid,
  338. });
  339. },
  340. selPhoto(item, sel) {
  341. this.selImg = sel;
  342. this.home_image = this.image_list[sel];
  343. },
  344. goToDetails(id) {
  345. console.log("goToDetails", id);
  346. uni.navigateTo({
  347. url: "/pages/index/workDetail?id=" + id,
  348. });
  349. console.log("goToDetails", id);
  350. },
  351. toArr(imgs) {
  352. let arr = imgs.split("|");
  353. return arr;
  354. },
  355. previewOpen(imgs1, index) {
  356. this.imgs = imgs1.split("|");
  357. setTimeout(() => this.$refs.previewImage.open(index), 0);
  358. return; //如需测试和uni原生预览差别可注释这两行
  359. },
  360. loadData() {
  361. uni.request({
  362. url: this.$apiHost + "/Article/getinfo",
  363. data: {
  364. uuid: getApp().globalData.uuid,
  365. id: this.arcID,
  366. },
  367. header: {
  368. "content-type": "application/json",
  369. sign: getApp().globalData.headerSign,
  370. },
  371. success: (res) => {
  372. console.log("文章信息:", res.data);
  373. if (res.data.success === "yes") {
  374. // 更新文章信息
  375. if (res.data.article) {
  376. this.articleInfo = res.data.article;
  377. }
  378. this.articleInfo.sms_id = this.sms_id;
  379. this.swperImages = this.imageString(res.data.article.images);
  380. console.log("swperImages", this.swperImages);
  381. this.userInfo.user_id = res.data.id; // 用户id
  382. this.userInfo.user_name = res.data.nickname; // 用户名
  383. this.userInfo.user_avatar = res.data.avator; // 用户头像地址
  384. this.author = res.data.author;
  385. this.workInfo = res.data.work_info;
  386. this.isItMe =
  387. res.data.article.userID == getApp().globalData.user_id
  388. ? true
  389. : false;
  390. // 更新分享相关数据
  391. this.shareTitle = this.articleInfo.title || '萌创星球';
  392. this.shareDesc = this.articleInfo.content;
  393. this.shareImg = this.articleInfo.images;
  394. this.userId = this.articleInfo.userID;
  395. const nodes = htmlParser(res.data.article.content);
  396. // #ifdef APP-PLUS-NVUE
  397. parseImgs(nodes);
  398. // #endif
  399. this.content = nodes;
  400. // 更新图片列表
  401. if (res.data.article.images && res.data.article.images !== "") {
  402. this.image_list = res.data.article.images.split(",");
  403. this.home_image = this.image_list[0];
  404. } else {
  405. this.home_image = "../../static/home/avator.png";
  406. }
  407. console.log("img", this.home_image);
  408. // 更新标签列表
  409. // if (res.data.data.tags && res.data.data.tags !== "") {
  410. // this.tag_list = res.data.data.tags.split(",");
  411. // }
  412. } else {
  413. uni.showToast({
  414. title: "获取文章信息失败",
  415. icon: "none",
  416. });
  417. }
  418. },
  419. complete: (com) => {
  420. // uni.hideLoading();
  421. },
  422. fail: (e) => {
  423. console.log("请求失败:", e);
  424. uni.showToast({
  425. title: "网络请求失败",
  426. icon: "none",
  427. });
  428. },
  429. });
  430. },
  431. // 评论相关方法已移至CommentSection组件
  432. // 唤起新评论弹框
  433. openComment() {
  434. if (this.$refs.commentSection) {
  435. this.$refs.commentSection.openComment();
  436. }
  437. },
  438. // 文章点赞
  439. // 分享文章
  440. shareArticle() {
  441. // 如果在微信小程序环境
  442. if (uni.getSystemInfoSync().platform === "mp-weixin") {
  443. uni.showShareMenu({
  444. withShareTicket: true,
  445. menus: ["shareAppMessage", "shareTimeline"],
  446. });
  447. } else {
  448. // 其他环境,如APP
  449. uni.share({
  450. provider: "weixin",
  451. scene: "WXSceneSession",
  452. type: 0,
  453. title: this.articleInfo.title,
  454. summary: this.articleInfo.content.substring(0, 40) + "...",
  455. imageUrl: this.home_image,
  456. success: function (res) {
  457. console.log("分享成功:" + JSON.stringify(res));
  458. },
  459. fail: function (err) {
  460. console.log("分享失败:" + JSON.stringify(err));
  461. },
  462. });
  463. }
  464. },
  465. // 评论回调事件
  466. replyFun({ params }, callback) {
  467. // params = {
  468. // ...params,
  469. // user_id: this.myInfo.user_id, // 用户id
  470. // user_name: this.myInfo.user_name, // 用户名
  471. // user_avatar: this.myInfo.user_avatar, // 用户头像地址
  472. // user_content: this.commentValue, // 用户评论内容
  473. // is_like: false, // 是否点赞
  474. // like_count: 0, // 点赞数统计
  475. // create_time: "刚刚", // 创建时间
  476. // owner: true, // 是否为所有者 所有者可以进行删除 管理员默认true
  477. // };
  478. console.log("replyFun", {
  479. uuid: getApp().globalData.uuid,
  480. article_id: this.arcID, // 文章ID
  481. content: params.user_content, // 评论内容
  482. parent_id: params.parent_id || 0, // 父评论ID
  483. reply_id: params.reply_id || 0, // 回复的评论ID
  484. reply_name: params.reply_name || "", // 被回复人名称
  485. });
  486. uni.request({
  487. url: this.$apiHost + "/Article/newComment",
  488. data: {
  489. uuid: getApp().globalData.uuid,
  490. type: "article",
  491. article_id: this.arcID, // 文章ID
  492. content: params.user_content, // 评论内容
  493. parent_id: params.parent_id || 0, // 父评论ID
  494. reply_id: params.reply_id || 0, // 回复的评论ID
  495. reply_name: params.reply_name || "", // 被回复人名称
  496. },
  497. header: {
  498. "content-type": "application/json",
  499. sign: getApp().globalData.headerSign,
  500. },
  501. success: (res) => {
  502. console.log("评论结果:", res.data);
  503. if (res.data.success === "yes") {
  504. callback(res.data); // 评论成功,传入后端返回的数据
  505. }
  506. },
  507. fail: (e) => {
  508. console.log("评论失败:", e);
  509. uni.showToast({
  510. title: "评论失败,请重试",
  511. icon: "none",
  512. });
  513. },
  514. });
  515. },
  516. /** 删除回调事件
  517. * mode 删除模式
  518. * -- bind: 当被删除的一级评论存在回复评论, 那么该评论内容变更显示为[当前评论内容已被移除]
  519. * -- only: 仅删除当前评论(后端删除相关联的回复评论, 否则总数显示不对)
  520. * -- all : 删除所有评论包括回复评论 前端遍历子评论上报
  521. */
  522. deleteFun({ params, mode }, callback) {
  523. console.log("deleteFun", {
  524. params,
  525. mode,
  526. });
  527. // 将params转换为逗号分隔的字符串
  528. const idsString = Array.isArray(params)
  529. ? params.join(",")
  530. : params.toString();
  531. console.log("删除评论", idsString, mode);
  532. uni.request({
  533. url: this.$apiHost + "/Article/delComment",
  534. data: {
  535. uuid: getApp().globalData.uuid,
  536. ids: idsString, // 将params转换为逗号分隔的字符串传递给ids
  537. mode: mode,
  538. },
  539. header: {
  540. "content-type": "application/json",
  541. sign: getApp().globalData.headerSign,
  542. },
  543. success: (res) => {
  544. console.log("删除结果:", res.data);
  545. if (res.data.success === "yes") {
  546. callback(res);
  547. }
  548. },
  549. fail: (e) => { },
  550. });
  551. // switch (mode) {
  552. // case "bind":
  553. // // 逻辑: 调用接口进行评论内容修改 update
  554. // setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
  555. // break;
  556. // case "only":
  557. // // 逻辑: 调用接口删除一个评论 delete
  558. // setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
  559. // break;
  560. // default:
  561. // // all
  562. // // 逻辑: 调用接口删除多个评论 [delete]
  563. // setTimeout(() => callback(), 500); // 目前为了展示效果, 直接执行callback
  564. // break;
  565. // }
  566. },
  567. showActionSheet(n) {
  568. uni.$emit('check_login', () => {
  569. if (n == 0) {
  570. // this.items = [
  571. // {
  572. // text: "分享作品",
  573. // icon: "../../static/icon/cz_icon_fenxiangzuopin.png",
  574. // },
  575. // ];
  576. // 如果只有一个分享按钮,直接唤醒分享弹窗
  577. this.showShare = true;
  578. return;
  579. }
  580. if (n == 1) {
  581. this.items = [
  582. {
  583. text: "分享作品",
  584. icon: "../../static/icon/cz_icon_fenxiangzuopin.png",
  585. },
  586. {
  587. text: "修改帖子",
  588. icon: "../../static/icon/cz_icon_xiugaifengmian.png",
  589. },
  590. {
  591. text: "举报",
  592. icon: "../../static/icon/jubao.png",
  593. },
  594. {
  595. text: "删除作品",
  596. icon: "../../static/icon/sy_icon_shanchu.png",
  597. danger: true,
  598. },
  599. ];
  600. }
  601. if (n == 2) {
  602. // this.items = [
  603. // {
  604. // text: "分享消息",
  605. // icon: "../../static/icon/cz_icon_fenxiangzuopin.png",
  606. // },
  607. // ];
  608. // 如果只有一个分享按钮,直接唤醒分享弹窗
  609. this.showShare = true;
  610. return;
  611. }
  612. this.$refs.actionSheet.show();
  613. })
  614. },
  615. handleActionCancel() {
  616. console.log("ActionSheet cancelled");
  617. },
  618. handleActionSelect(index, item) {
  619. console.log("ActionSheet selected index:", item.text);
  620. if (item.text === "分享作品") {
  621. this.showShare = true;
  622. } else if (item.text === "修改帖子") {
  623. uni.navigateTo({
  624. url: "/pages/make/fabuArticle?id=" + this.articleInfo.id,
  625. });
  626. } else if (item.text === "删除作品") {
  627. this.deleteArticle();
  628. } else if (item.text === "举报") {
  629. this.handleReport();
  630. }
  631. },
  632. handleReport() {
  633. // 实现举报功能
  634. uni.$emit('check_login', () => {
  635. uni.navigateTo({
  636. url: '/pages/my/feedback'
  637. })
  638. })
  639. },
  640. imageString(str) {
  641. if (!str) {
  642. return [];
  643. }
  644. return str.split("|");
  645. },
  646. cutTime(time) {
  647. if (!time) {
  648. return "";
  649. }
  650. return time.split(" ")[0];
  651. },
  652. deleteArticle() {
  653. this.$refs["DialogBox"]
  654. .confirm({
  655. title: "提示",
  656. content: "确定删除该文章吗",
  657. DialogType: "inquiry",
  658. btn1: "取消",
  659. btn2: "确定",
  660. animation: 0,
  661. })
  662. .then(() => {
  663. uni.showLoading({
  664. title: '删除中...'
  665. });
  666. uni.request({
  667. url: this.$apiHost + "/Article/doAct",
  668. data: {
  669. uuid: getApp().globalData.uuid,
  670. act: "del",
  671. id: this.articleInfo.id,
  672. },
  673. header: {
  674. "content-type": "application/json",
  675. sign: getApp().globalData.headerSign,
  676. },
  677. success: (res) => {
  678. uni.hideLoading();
  679. if (res.data.success === "yes") {
  680. uni.showToast({
  681. title: "删除成功",
  682. icon: "success",
  683. });
  684. // 删除成功后返回上一页
  685. setTimeout(() => {
  686. uni.navigateBack({
  687. delta: 1
  688. });
  689. }, 1500);
  690. } else {
  691. uni.showToast({
  692. title: res.data.str || "删除失败",
  693. icon: "none",
  694. });
  695. }
  696. },
  697. fail: () => {
  698. uni.hideLoading();
  699. uni.showToast({
  700. title: "删除失败",
  701. icon: "none",
  702. });
  703. }
  704. });
  705. })
  706. .catch(() => {
  707. // 用户取消删除
  708. });
  709. },
  710. goToUserHomepage(id) {
  711. uni.$emit('check_login', () => {
  712. if (!id) {
  713. return;
  714. }
  715. uni.navigateTo({
  716. url: "/pages/my/userHomepage?id=" + id,
  717. });
  718. })
  719. },
  720. // 预览图片
  721. previewImage(index) {
  722. if (!this.swperImages || this.swperImages.length === 0) return;
  723. uni.previewImage({
  724. urls: this.swperImages,
  725. current: index,
  726. indicator: 'number',
  727. loop: true,
  728. showmenu: false
  729. });
  730. },
  731. },
  732. };
  733. </script>
  734. <style scoped lang="scss">
  735. @import "articleDetail.scss";
  736. </style>