articleDetail.vue 21 KB

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