workDetail.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  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" @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. <image v-if="!isItMe" @click="showActionSheet(0)" src="../../static/icon/sy_icon_fenxiang.png" mode="widthFix">
  28. </image>
  29. <view v-else class="navbar-right" @click="showActionSheet(1)">
  30. <text class="fa fa-ellipsis-h"></text>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 灵感 -->
  35. <template v-if="articleInfo.task_type == 1">
  36. <view class="inspiration-content" v-if="home_image">
  37. <image v-if="home_image" :src="home_image" class="inspirationPictures" mode="widthFix" @click="previewImage(home_image)"></image>
  38. </view>
  39. </template>
  40. <!-- 音乐 -->
  41. <template v-else-if="articleInfo.task_type == 2">
  42. <view class="musicContentBox">
  43. <view class="headCard">
  44. <image :src="home_image" class="songCover"></image>
  45. <view class="songInfo">
  46. <view class="songTitle">{{ addBrackets(articleInfo.title) }}</view>
  47. <view class="songTag">
  48. <view class="tag" v-for="(item, index) in commaToArray(articleInfo.style)" :key="index + item">{{ item }}
  49. </view>
  50. </view>
  51. </view>
  52. <template v-if="articleInfo.task_type == 2">
  53. <image @click="toggleAudio" v-if="isPlaying" src="@/static/makedetail/cz_icon_zanting.png"
  54. class="playerButton"></image>
  55. <image @click="toggleAudio" v-else src="@/static/makedetail/cz_icon_bofang.png" class="playerButton">
  56. </image>
  57. </template>
  58. </view>
  59. <view class="contentHeader">
  60. <view class="musicContent">
  61. <text> {{ articleInfo.lyrics }}</text>
  62. <image class="roll" src="@/static/icon/roll.png"></image>
  63. </view>
  64. <view class="maskLayer"></view>
  65. </view>
  66. </view>
  67. </template>
  68. <!-- 作品描述 -->
  69. <view class="workDescription">
  70. <view class="workDescription-title">
  71. <view>创作说明 </view>
  72. <!-- <image class="pen" src="@/static/icon/wd_icon_bianji.png"></image> -->
  73. </view>
  74. <view class="workDescription-content">
  75. {{ content || "暂无内容" }}
  76. </view>
  77. </view>
  78. <view class="goCreate" @click="goCreate()">去创作</view>
  79. <DialogBox ref="customConfirm"></DialogBox>
  80. <!-- 文章头图区域 -->
  81. <view class="topUser" v-if="false">
  82. <image :src="home_image" class="home_image" mode="aspectFill"></image>
  83. <!-- 图片指示器 -->
  84. <view class="image-indicator" v-if="image_list.length > 1">
  85. <text>{{ selImg + 1 }}/{{ image_list.length }}</text>
  86. </view>
  87. <!-- 音乐类型时显示歌词 -->
  88. <view class="lyrics-overlay" v-if="articleInfo.task_type == 2">
  89. <text class="lyrics-text">{{ articleInfo.lyrics }}</text>
  90. </view>
  91. <!-- 音乐类型时显示播放按钮 -->
  92. <view class="play-button" v-if="articleInfo.task_type == 2 && articleInfo.result_audio" @click="toggleAudio">
  93. <text class="fa" :class="isPlaying ? 'fa-pause' : 'fa-play'"></text>
  94. </view>
  95. <!-- 缩略图列表 -->
  96. <view class="list">
  97. <view class="img" :class="selImg == index ? 'active' : ''" v-for="(item, index) in image_list" :key="index"
  98. @click="selPhoto(item, index)">
  99. <image :src="item" mode="aspectFill"></image>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 音频元素 -->
  104. <audio id="audioPlayer" :src="articleInfo.result_audio" style="display: none" v-if="false"></audio>
  105. <!-- 文章内容区域 -->
  106. <view class="body" v-if="false">
  107. <!-- 文章标题与元信息 -->
  108. <view class="article-header">
  109. <view class="title">
  110. {{ articleInfo.title || "暂无标题" }}
  111. </view>
  112. <view class="meta-info">
  113. <view class="meta-item">
  114. <text class="fa fa-calendar"></text>
  115. <text class="meta-text">{{
  116. articleInfo.create_time || "暂无时间"
  117. }}</text>
  118. </view>
  119. <view class="meta-item">
  120. <text class="fa fa-eye"></text>
  121. <text class="meta-text">{{ articleInfo.num_view || 0 }}次阅读</text>
  122. </view>
  123. <view class="meta-item" v-if="articleInfo.author">
  124. <text class="fa fa-user"></text>
  125. <text class="meta-text">{{ articleInfo.author }}</text>
  126. </view>
  127. </view>
  128. </view>
  129. <!-- 内容分隔线 -->
  130. <view class="divider"></view>
  131. <!-- 文章内容 -->
  132. <!-- <view class="article-content" v-if="articleInfo.type == 'user'">
  133. <view class="content">{{ articleInfo.content || '暂无内容' }}</view>
  134. </view> -->
  135. <view class="article-content">
  136. <view class="content">
  137. <!-- <rich-text :nodes="content" style="font-size: 14px"></rich-text> -->
  138. <uv-parse :content="articleInfo.content"></uv-parse>
  139. </view>
  140. </view>
  141. <!-- 文章底部区域 -->
  142. <view class="article-footer">
  143. <view class="action-bar">
  144. <view class="action-item" @tap="likeArticle">
  145. <text class="fa" :class="articleInfo.is_like ? 'fa-thumbs-up liked' : 'fa-thumbs-o-up'
  146. "></text>
  147. <text class="action-text">{{ articleInfo.like_count || 0 }}</text>
  148. </view>
  149. <view class="action-item" @tap="openComment">
  150. <text class="fa fa-comment-o"></text>
  151. <text class="action-text">{{ tableTotal || 0 }}</text>
  152. </view>
  153. <view class="action-item" @tap="shareArticle">
  154. <text class="fa fa-share-alt"></text>
  155. <text class="action-text">分享</text>
  156. </view>
  157. </view>
  158. </view>
  159. <!-- 空白占位 -->
  160. <view class="list_info">
  161. <view class="blankHeight"></view>
  162. </view>
  163. </view>
  164. <!-- <view class="btn_submit" @click="chatTA()">
  165. <image class="icon" src="../../static/icon/icon_chat_white.png" mode="widthFix"></image>
  166. 私聊
  167. </view> -->
  168. <view class="thread2"></view>
  169. <view class="thread2"></view>
  170. <previewImage ref="previewImage" :opacity="0.8" :circular="true" :imgs="imgs" :descs="descs"></previewImage>
  171. <!-- 评论区域 -->
  172. <CommentSection v-if="userInfo.id != 0 && articleInfo.title" ref="commentSection" :myInfo="myInfo"
  173. :userInfo="userInfo" :articleId="arcID" @totalNumberOfComments="totalNumberOfComments" articleInfo="articleInfo">
  174. </CommentSection>
  175. <!-- 自定义 ActionSheet -->
  176. <ActionSheet ref="actionSheet" :items="items" @select="handleActionSelect" @cancel="handleActionCancel" />
  177. <view class="thread2"></view>
  178. <SharePopup :visible="showShare" :userId="userId" :share-title="shareTitle" :share-desc="shareDesc"
  179. :share-img="shareImg" view="workDetail" @close="showShare = false" />
  180. </view>
  181. </template>
  182. <script>
  183. import htmlParser from "../../common/html-parser";
  184. import previewImage from "@/components/kxj-previewImage/kxj-previewImage.vue"; //引用插件
  185. import CommentSection from "@/components/CommentSection/CommentSection.vue";
  186. import ActionSheet from "@/components/ActionSheet/ActionSheet.vue";
  187. import SharePopup from "@/components/SharePopup/SharePopup.vue";
  188. function parseImgs(nodes) {
  189. nodes.forEach((node) => {
  190. if (node.name === "img" && node.attrs && node.attrs["data-img-size-val"]) {
  191. const sizes = node.attrs["data-img-size-val"].split(",");
  192. const width = uni.upx2px(720 * 0.9);
  193. const height = parseInt(width * (sizes[1] / sizes[0]));
  194. node.attrs.style = `width:${width};height:${height};`;
  195. }
  196. if (Array.isArray(node.children)) {
  197. parseImgs(node.children);
  198. }
  199. });
  200. return nodes;
  201. }
  202. export default {
  203. components: {
  204. previewImage,
  205. CommentSection,
  206. ActionSheet,
  207. SharePopup,
  208. },
  209. data() {
  210. return {
  211. title: "",
  212. arcID: 0,
  213. selImg: 0,
  214. home_image: "",
  215. articleInfo: {},
  216. tag_list: [],
  217. image_list: [],
  218. imgs: [],
  219. descs: [],
  220. list_wish: [],
  221. content: "",
  222. author: {},
  223. showShare: false,
  224. shareTitle: "",
  225. shareDesc: "",
  226. shareImg: "",
  227. userId: 0,
  228. // 添加文章信息字段
  229. articleInfo: {
  230. title: "",
  231. content: "",
  232. create_time: "",
  233. images: "",
  234. view_count: 0,
  235. author: "",
  236. like_count: 0,
  237. is_like: false,
  238. },
  239. items: [],
  240. myInfo: {
  241. user_id: getApp().globalData.user_id, // 用户id
  242. user_name: getApp().globalData.nickname, // 用户名
  243. user_avatar: getApp().globalData.avator, // 用户头像地址
  244. },
  245. // 文章作者信息(提示: 一般来自localstorage, 如果是实时获取的话, 那么获取到数据后再v-if显示评论组件)
  246. userInfo: {
  247. user_id: 0, // 用户id
  248. user_name: "", // 用户名
  249. user_avatar: "", // 用户头像地址
  250. },
  251. deleteMode: "all", //删除模式
  252. // 评论总数
  253. tableTotal: 4,
  254. // 评论表
  255. tableData: [],
  256. isPlaying: false, // 添加播放状态
  257. audioPlayer: null, // 添加音频播放器实例
  258. sms_id: 0,
  259. isMessage: true,
  260. isItMe: false,
  261. };
  262. },
  263. onLoad(parms) {
  264. let self = this;
  265. this.arcID = parms.id
  266. if (parms.type == "sms") {
  267. this.isMessage = false;
  268. }
  269. if (parms.sms_id) {
  270. this.sms_id = parms.sms_id;
  271. }
  272. },
  273. onShow() {
  274. uni.$emit("check_update");
  275. this.loadData();
  276. this.$nextTick(() => {
  277. if (this.$refs.commentSection) {
  278. this.$refs.commentSection.loadCommentData();
  279. }
  280. });
  281. },
  282. onReady() {
  283. // 初始化音频播放器
  284. this.audioPlayer = uni.createInnerAudioContext();
  285. this.audioPlayer.onEnded(() => {
  286. this.isPlaying = false;
  287. });
  288. },
  289. onUnload() {
  290. // 页面卸载时停止音频播放
  291. if (this.audioPlayer) {
  292. this.audioPlayer.stop();
  293. this.audioPlayer.destroy();
  294. }
  295. },
  296. methods: {
  297. // 返回上一页
  298. goBack() {
  299. uni.navigateBack({
  300. delta: 1,
  301. });
  302. },
  303. totalNumberOfComments(tableTotal) {
  304. this.tableTotal = tableTotal;
  305. },
  306. onLinqu(item) {
  307. uni.navigateTo({
  308. url: "/pages/my/wishHelp?id=" + item.myid,
  309. });
  310. },
  311. selPhoto(item, sel) {
  312. this.selImg = sel;
  313. this.home_image = this.image_list[sel];
  314. },
  315. toArr(imgs) {
  316. let arr = imgs.split("|");
  317. return arr;
  318. },
  319. previewOpen(imgs1, index) {
  320. this.imgs = imgs1.split("|");
  321. setTimeout(() => this.$refs.previewImage.open(index), 0);
  322. // 传入当前选中的图片地址或序号
  323. return; //如需测试和uni原生预览差别可注释这两行
  324. },
  325. loadData() {
  326. uni.request({
  327. url: this.$apiHost + "/Work/getinfo",
  328. data: {
  329. uuid: getApp().globalData.uuid,
  330. id: this.arcID,
  331. },
  332. header: {
  333. "content-type": "application/json",
  334. sign: getApp().globalData.headerSign,
  335. },
  336. success: (res) => {
  337. console.log("文章信息:", res.data);
  338. if (res.data.success === "yes") {
  339. console.log("文章信息:", res.data.data);
  340. // 更新文章信息
  341. if (res.data.article) {
  342. this.articleInfo = res.data.article;
  343. }
  344. this.articleInfo = res.data.data;
  345. this.articleInfo.sms_id = this.sms_id;
  346. this.content = res.data.data.content;
  347. this.home_image = res.data.data.images;
  348. this.author = res.data.author;
  349. // 更新分享相关数据
  350. this.shareTitle = this.articleInfo.title || '萌创星球';
  351. this.shareDesc = this.articleInfo.content;
  352. this.shareImg = this.home_image;
  353. this.userId = this.articleInfo.userID;
  354. this.isItMe = this.userId == getApp().globalData.user_id
  355. ? true
  356. : false;
  357. this.userInfo.user_id = res.data.id; // 用户id
  358. this.userInfo.user_name = res.data.nickname; // 用户名
  359. this.userInfo.user_avatar = res.data.avator; // 用户头像地址
  360. } else {
  361. uni.showToast({
  362. title: "获取信息失败",
  363. icon: "none",
  364. });
  365. }
  366. },
  367. complete: (com) => {
  368. // uni.hideLoading();
  369. },
  370. fail: (e) => {
  371. console.log("请求失败:", e);
  372. uni.showToast({
  373. title: "网络请求失败",
  374. icon: "none",
  375. });
  376. },
  377. });
  378. },
  379. // 唤起新评论弹框
  380. openComment() {
  381. if (this.$refs.commentSection) {
  382. this.$refs.commentSection.openComment();
  383. }
  384. },
  385. // 文章点赞
  386. likeArticle() {
  387. uni.request({
  388. url: this.$apiHost + "/Work/zanTA",
  389. data: {
  390. uuid: getApp().globalData.uuid,
  391. id: this.arcID,
  392. },
  393. header: {
  394. "content-type": "application/json",
  395. sign: getApp().globalData.headerSign,
  396. },
  397. success: (res) => {
  398. console.log("点赞结果:", res.data);
  399. if (res.data.success === "yes") {
  400. // 更新点赞状态
  401. if (!this.articleInfo.is_like) {
  402. this.articleInfo.like_count =
  403. (this.articleInfo.like_count || 0) + 1;
  404. this.articleInfo.is_like = true;
  405. uni.showToast({
  406. title: "点赞成功",
  407. icon: "none",
  408. });
  409. } else {
  410. this.articleInfo.like_count =
  411. (this.articleInfo.like_count || 0) - 1;
  412. this.articleInfo.is_like = false;
  413. uni.showToast({
  414. title: res.data.str,
  415. icon: "none",
  416. });
  417. }
  418. } else {
  419. uni.showToast({
  420. title: res.data.str,
  421. icon: "none",
  422. });
  423. }
  424. },
  425. fail: (e) => {
  426. console.log("点赞失败:", e);
  427. uni.showToast({
  428. title: "网络请求失败",
  429. icon: "none",
  430. });
  431. },
  432. });
  433. },
  434. // 关注作者
  435. followTheAuthor(n) {
  436. uni.$emit('check_login', () => {
  437. uni.request({
  438. url: this.$apiHost + "/Member/attention",
  439. data: {
  440. uuid: getApp().globalData.uuid,
  441. id: this.author.id,
  442. },
  443. header: {
  444. "content-type": "application/json",
  445. sign: getApp().globalData.headerSign,
  446. },
  447. success: (res) => {
  448. console.log("点赞结果:", res.data);
  449. uni.showToast({
  450. title: res.data.str,
  451. icon: "none",
  452. });
  453. if (res.data.success === "yes") {
  454. console.log("关注结果:", res.data, n);
  455. this.author.is_attention = n;
  456. }
  457. },
  458. fail: (e) => {
  459. console.log("关注失败:", e);
  460. uni.showToast({
  461. title: "网络请求失败",
  462. icon: "none",
  463. });
  464. },
  465. });
  466. })
  467. },
  468. // 分享文章
  469. shareArticle() {
  470. // 如果在微信小程序环境
  471. if (uni.getSystemInfoSync().platform === "mp-weixin") {
  472. uni.showShareMenu({
  473. withShareTicket: true,
  474. menus: ["shareAppMessage", "shareTimeline"],
  475. });
  476. } else {
  477. // 其他环境,如APP
  478. uni.share({
  479. provider: "weixin",
  480. scene: "WXSceneSession",
  481. type: 0,
  482. title: this.articleInfo.title,
  483. summary: this.articleInfo.content.substring(0, 40) + "...",
  484. imageUrl: this.home_image,
  485. success: function (res) {
  486. console.log("分享成功:" + JSON.stringify(res));
  487. },
  488. fail: function (err) {
  489. console.log("分享失败:" + JSON.stringify(err));
  490. },
  491. });
  492. }
  493. },
  494. // 切换音频播放状态
  495. toggleAudio() {
  496. if (!this.articleInfo.result_audio) return;
  497. if (this.isPlaying) {
  498. this.audioPlayer.pause();
  499. this.isPlaying = false;
  500. } else {
  501. this.audioPlayer.src = this.articleInfo.result_audio;
  502. this.audioPlayer.play();
  503. this.isPlaying = true;
  504. }
  505. },
  506. // 新增过滤器方法
  507. commaToArray(str) {
  508. if (!str) return "";
  509. return str.split(",");
  510. },
  511. // 新增过滤器方法
  512. addBrackets(str) {
  513. if (!str) return "";
  514. if (!str.startsWith("《")) {
  515. str = "《" + str;
  516. }
  517. if (!str.endsWith("》")) {
  518. str = str + "》";
  519. }
  520. return str;
  521. },
  522. getInfoData() {
  523. uni.request({
  524. url: this.$apiHost + "/Member/getinfoData",
  525. data: {
  526. uuid: getApp().globalData.uuid,
  527. },
  528. header: {
  529. "content-type": "application/json",
  530. },
  531. success: (res) => {
  532. console.log("用户信息", res.data);
  533. },
  534. });
  535. },
  536. showActionSheet(n) {
  537. uni.$emit('check_login', () => {
  538. if (n == 0) {
  539. // 如果只有一个分享按钮,直接唤醒分享弹窗
  540. this.showShare = true;
  541. return;
  542. }
  543. if (n == 1) {
  544. this.items = [
  545. {
  546. text: "分享作品",
  547. icon: "../../static/icon/cz_icon_fenxiangzuopin.png",
  548. },
  549. {
  550. text: "修改封面",
  551. icon: "../../static/icon/cz_icon_xiugaifengmian.png",
  552. },
  553. {
  554. text: "删除作品",
  555. icon: "../../static/icon/sy_icon_shanchu.png",
  556. danger: true,
  557. },
  558. ];
  559. }
  560. this.$refs.actionSheet.show();
  561. })
  562. },
  563. handleActionCancel() {
  564. console.log("ActionSheet cancelled");
  565. },
  566. handleActionSelect(index, item) {
  567. console.log("ActionSheet selected index:", item.text);
  568. if (item.text === "分享作品") {
  569. this.showShare = true;
  570. } else if (item.text === "修改封面") {
  571. // 修改封面
  572. if (this.articleInfo.status == 3) {
  573. uni.showToast({
  574. title: '作品已完成,无法修改封面!',
  575. icon: 'success'
  576. });
  577. return;
  578. }
  579. this.editCover();
  580. } else if (item.text === "删除作品") {
  581. // 删除作品
  582. this.deleteWork();
  583. }
  584. },
  585. // 修改封面
  586. editCover() {
  587. var _self = this;
  588. uni.chooseImage({
  589. count: 1,
  590. sizeType: ['compressed'],
  591. sourceType: ['album', 'camera'],
  592. success: function (res) {
  593. console.log('res:', res)
  594. if (res.tempFilePaths.length > 0) {
  595. _self.imglocal = res.tempFilePaths[0]
  596. const tempFilePaths = res.tempFilePaths[0];
  597. console.log('tempFilePaths:', tempFilePaths);
  598. const uploadTask = uni.uploadFile({
  599. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  600. filePath: res.tempFilePaths[0],
  601. name: 'file',
  602. success: function (uploadFileRes) {
  603. let resdata = JSON.parse(uploadFileRes.data)
  604. console.log('Success11:', uploadFileRes);
  605. console.log('Success21:', resdata);
  606. if (resdata.success == 'yes') {
  607. // 调用修改封面接口
  608. uni.request({
  609. url: _self.$apiHost + '/WorkAI/queueAction',
  610. method: 'GET',
  611. data: {
  612. uuid: getApp().globalData.uuid,
  613. act: 'editImg',
  614. result_images: resdata.url,
  615. id: _self.arcID
  616. },
  617. header: {
  618. 'content-type': 'application/json',
  619. 'sign': getApp().globalData.headerSign
  620. },
  621. success: (res) => {
  622. if (res.data.success === "yes") {
  623. // 只有在修改封面成功时才更新页面中的图片
  624. _self.home_image = resdata.url;
  625. uni.showToast({
  626. title: '修改封面成功',
  627. icon: 'success'
  628. });
  629. } else {
  630. uni.showToast({
  631. title: '修改封面失败',
  632. icon: 'none'
  633. });
  634. }
  635. },
  636. fail: () => {
  637. uni.showToast({
  638. title: '修改封面失败',
  639. icon: 'none'
  640. });
  641. }
  642. });
  643. }
  644. },
  645. fail: function (uploadFileFail) {
  646. console.log('Error:', uploadFileFail.data);
  647. uni.showToast({
  648. title: '图片上传失败',
  649. icon: 'none'
  650. });
  651. }
  652. });
  653. }
  654. },
  655. error: function (e) {
  656. console.log(e);
  657. uni.showToast({
  658. title: '选择图片失败',
  659. icon: 'none'
  660. });
  661. }
  662. });
  663. },
  664. // 删除作品
  665. deleteWork() {
  666. this.$refs["customConfirm"]
  667. .confirm({
  668. title: "确认删除",
  669. content: "确定要删除这个作品吗?",
  670. DialogType: "inquiry",
  671. btn1: "再考虑一下",
  672. btn2: "确认解绑",
  673. animation: 0,
  674. })
  675. .then((res) => {
  676. if (res.confirm) {
  677. // 用户点击确定,执行删除操作
  678. this.confirmDelete();
  679. }
  680. });
  681. },
  682. // 确认删除
  683. confirmDelete() {
  684. uni.showLoading({
  685. title: '删除中...'
  686. });
  687. uni.request({
  688. url: this.$apiHost + '/WorkAI/queueAction',
  689. method: 'GET',
  690. data: {
  691. uuid: getApp().globalData.uuid,
  692. act: 'del',
  693. id: this.arcID
  694. },
  695. header: {
  696. 'content-type': 'application/json',
  697. 'sign': getApp().globalData.headerSign
  698. },
  699. success: (res) => {
  700. uni.hideLoading();
  701. if (res.data.success === "yes") {
  702. uni.showToast({
  703. title: '删除成功',
  704. icon: 'success'
  705. });
  706. // 删除成功后返回上一页
  707. setTimeout(() => {
  708. uni.navigateBack({
  709. delta: 1
  710. });
  711. }, 1500);
  712. } else {
  713. uni.showToast({
  714. title: '删除失败',
  715. icon: 'none'
  716. });
  717. }
  718. },
  719. fail: () => {
  720. uni.hideLoading();
  721. uni.showToast({
  722. title: '删除失败',
  723. icon: 'none'
  724. });
  725. }
  726. });
  727. },
  728. goCreate() {
  729. // 切换到标签页
  730. uni.switchTab({
  731. // 指定要切换到的页面路径
  732. url: "/pages/make/index",
  733. });
  734. },
  735. goToUserHomepage(id) {
  736. uni.$emit('check_login', () => {
  737. if (!id) {
  738. return;
  739. }
  740. uni.navigateTo({
  741. url: "/pages/my/userHomepage?id=" + id,
  742. });
  743. })
  744. },
  745. // 预览图片
  746. previewImage(url) {
  747. if (!url) return;
  748. uni.previewImage({
  749. urls: [url],
  750. current: url,
  751. indicator: 'number',
  752. loop: true
  753. });
  754. },
  755. },
  756. };
  757. </script>
  758. <style scoped lang="scss">
  759. @import "workDetail.scss";
  760. </style>