makeDetail.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. <template>
  2. <view class="page">
  3. <!-- 权限申请提示 -->
  4. <view v-if="showRights" class="permission-tip">
  5. <text class="permission-title">正在获取相机、存储权限</text>
  6. <text class="permission-desc">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
  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="false">
  15. <image class="navbar-avatar" :src="myinfo.avator" mode="aspectFill"></image>
  16. <text class="navbar-text">{{ myinfo.nickname }}</text>
  17. <text class="navbar-badge" v-if="myinfo.is_vip > 0">VIP</text>
  18. </view>
  19. </view>
  20. <view class="navbar-right" @click="showActionSheet">
  21. <image src="@/static/icon/more2.png" style="width: 64rpx;height: 64rpx; margin-top: 15rpx;" mode="widthFix"></image>
  22. </view>
  23. </view>
  24. <view class="topStatusBar inProgress" v-if="fileInformation.status == 2"
  25. :class="queueDetail.task_type == 1 ? 'mb20' : ''"> 审核中</view>
  26. <view class="topStatusBar fail" v-if="fileInformation.status == 4"
  27. :class="queueDetail.task_type == 2 ? 'mb20' : ''" @click="openConfirmationBox"> 审核未通过,点击查看原因</view>
  28. <!-- 灵感 -->
  29. <template v-if="queueDetail.task_type == 1">
  30. <view class="inspiration-content" v-if="home_image">
  31. <image v-if="home_image" src="../../static/makedetail/cz_img_zhanshi.png" mode="widthFix"></image>
  32. <image :src="home_image" class="inspirationPictures" mode="widthFix"></image>
  33. </view>
  34. </template>
  35. <!-- 音乐 -->
  36. <template v-else-if="queueDetail.task_type == 2">
  37. <view class="musicContentBox">
  38. <view class="headCard">
  39. <image :src="home_image" class="songCover"></image>
  40. <view class="songInfo">
  41. <view class="songTitle">{{ addBrackets(queueDetail.song_name) }}</view>
  42. <view class="songTag">
  43. <view class="tag" v-for="(item, index) in commaToArray(queueDetail.style)"
  44. :key="index + item">{{ item }}</view>
  45. </view>
  46. </view>
  47. <template v-if="queueDetail.task_type == 2 && queueDetail.status >= 9">
  48. <image @click="toggleAudio" v-if="isPlaying" src="@/static/makedetail/cz_icon_zanting.png"
  49. class="playerButton"></image>
  50. <image @click="toggleAudio" v-else src="@/static/makedetail/cz_icon_bofang.png"
  51. class="playerButton"></image>
  52. </template>
  53. </view>
  54. <view class="contentHeader">
  55. <view class="musicContent">
  56. <text style="max-width: 350rpx; display: inline-block;"> {{ queueDetail.description }}</text>
  57. <image class="roll" src="@/static/icon/roll.png"></image>
  58. </view>
  59. <view class="maskLayer"></view>
  60. </view>
  61. </view>
  62. </template>
  63. <!-- 作品描述 -->
  64. <view class="workDescription">
  65. <view class="workDescription-title">
  66. <view>创作描述 </view>
  67. <!-- <image class="pen" src="@/static/icon/wd_icon_bianji.png"></image> -->
  68. </view>
  69. <view class="workDescription-content">
  70. <uv-text :text="queueDetail.lyrics || queueDetail.description" class=" ">
  71. </uv-text>
  72. <!--{{ queueDetail.lyrics || queueDetail.description }}-->
  73. </view>
  74. </view>
  75. <!-- 作品描述 -->
  76. <view class="workDescription" v-if="queueDetail.content">
  77. <view class="workDescription-title">
  78. <view>创作说明 </view>
  79. <!-- <image class="pen" src="@/static/icon/wd_icon_bianji.png"></image> -->
  80. </view>
  81. <view class="workDescription-content">
  82. {{ noteContent }}
  83. </view>
  84. </view>
  85. <view class="thread2"></view>
  86. <!-- 音频元素 -->
  87. <audio id="audioPlayer" :src="queueDetail.result_audio" style="display:none;"></audio>
  88. <!-- 用于处理图片像素的隐藏canvas -->
  89. <canvas canvas-id="pixelCanvas"
  90. style="width: 10px; height: 10px; position: absolute; left: -100px; top: -100px;"></canvas>
  91. <!-- 底部漂浮栏 -->
  92. <view class="floating-bar"
  93. v-if="queueDetail.status == 9 && (fileInformation.status == 3 || fileInformation.status == 0)">
  94. <view class="floating-bar-content">
  95. <view class="add-note-btn" @click="openContentPopUpWindow">
  96. <text>添加说明</text>
  97. </view>
  98. <view class="publish-btn" @click="publishWork">
  99. <text>公布作品</text>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 自定义 ActionSheet -->
  104. <ActionSheet ref="actionSheet" :items="[
  105. { text: '分享作品', icon: '../../static/icon/cz_icon_fenxiangzuopin.png' },
  106. { text: '修改封面', icon: '../../static/icon/cz_icon_xiugaifengmian.png' },
  107. { text: '举报', icon: '../../static/icon/jubao.png' },
  108. { text: '删除作品', icon: '../../static/icon/sy_icon_shanchu.png', danger: true },
  109. ]" @select="handleActionSelect" @cancel="handleActionCancel" />
  110. <NicknamePopup title="添加说明" subtitle="" class="openContentPopUpWindow" ref="openContentPopUpWindow">
  111. <template v-slot:content>
  112. <uv-textarea v-model="noteContent" maxlength="500" count placeholder="请描述你添加的内容"></uv-textarea>
  113. <view class="btn-box" @click="confirmAddNote">确认</view>
  114. </template>
  115. </NicknamePopup>
  116. <CustomPopup ref="confirmationBox">
  117. <view class="failureReason">
  118. <view class="title"> 审核未通关</view>
  119. <view class="reviewContent">
  120. <uv-parse :content="fileInformation.reason"></uv-parse>
  121. </view>
  122. <view class="btn-box" @click="closeConfirmationBox">知道了</view>
  123. </view>
  124. </CustomPopup>
  125. <DialogBox ref="customConfirm"></DialogBox>
  126. <SharePopup :visible="showShare" :userId="userId" :share-title="shareTitle" :share-desc="shareDesc"
  127. :share-img="shareImg" view="makeDetail" @close="showShare = false" />
  128. </view>
  129. </template>
  130. <script>
  131. import previewImage from '@/components/kxj-previewImage/kxj-previewImage.vue'; //引用插件
  132. import NicknamePopup from '@/components//NicknamePopup/NicknamePopup.vue';
  133. import CustomPopup from '@/components/CustomPopup/CustomPopup.vue';
  134. import ActionSheet from '@/components/ActionSheet/ActionSheet.vue';
  135. import SharePopup from "@/components/SharePopup/SharePopup.vue";
  136. import permission from '@/common/permission.js';
  137. export default {
  138. components: {
  139. previewImage,
  140. NicknamePopup,
  141. CustomPopup,
  142. ActionSheet,
  143. SharePopup,
  144. },
  145. data() {
  146. return {
  147. title: '',
  148. arcID: 0,
  149. selImg: 0,
  150. home_image: '',
  151. myinfo: {},
  152. tag_list: [],
  153. image_list: [],
  154. imgs: [],
  155. descs: [],
  156. isPlaying: false,
  157. audioPlayer: null,
  158. showNotePopup: false,
  159. noteContent: '',
  160. pixelColor: null, // 存储像素颜色值
  161. queueId: 0,
  162. showShare: false,
  163. shareTitle: "",
  164. shareDesc: "",
  165. shareImg: "",
  166. userId: 0,
  167. showRights: false,
  168. // 队列详情数据
  169. queueDetail: {
  170. id: 0,
  171. sso_id: 0,
  172. task_type: 1,
  173. title: '',
  174. description: '',
  175. action: '',
  176. environment: '',
  177. subject: '',
  178. style: '',
  179. song_name: '',
  180. lyrics: '',
  181. generate_uuid: '',
  182. result_images: '',
  183. result_audio: '',
  184. queue_position: 0,
  185. status: 1,
  186. generate_status: 1,
  187. points_cost: 0,
  188. error_msg: '',
  189. create_time: '',
  190. update_time: '',
  191. all_position: 0
  192. },
  193. fileInformation: {
  194. age: 0,
  195. author: "",
  196. avator: "",
  197. city: "",
  198. content: "",
  199. create_time: "",
  200. dtime: "",
  201. id: 0,
  202. images: "",
  203. is_like: 0,
  204. is_vip: 0,
  205. like_count: 0,
  206. lyrics: "",
  207. nickname: "",
  208. num_comment: 0,
  209. num_like: 0,
  210. num_view: 0,
  211. queue_id: 0,
  212. reason: "",
  213. result_audio: "",
  214. sex: 0,
  215. sso_id: 0,
  216. status: 0, //1是成功 2是审核中 4是失败 3是未公布也就是私人状态
  217. task_type: 0,
  218. tdate: "",
  219. title: "",
  220. userID: 0,
  221. xinzuo: "",
  222. },
  223. myinfo: {},
  224. offsetY: 0,
  225. isDragging: false,
  226. startY: 0,
  227. initialOffsetY: 0,
  228. }
  229. },
  230. onLoad(parms) {
  231. let self = this;
  232. this.arcID = parms.id;
  233. this.queueId = parms.queueId;
  234. this.getMyInfo();
  235. },
  236. onShow() {
  237. this.loadData();
  238. this.getInfoData();
  239. },
  240. onReady() {
  241. // 获取音频元素
  242. this.audioPlayer = uni.createInnerAudioContext();
  243. this.audioPlayer.onEnded(() => {
  244. this.isPlaying = false;
  245. });
  246. },
  247. onUnload() {
  248. // 页面卸载时停止音频播放
  249. if (this.audioPlayer) {
  250. this.audioPlayer.stop();
  251. this.audioPlayer.destroy();
  252. }
  253. },
  254. mounted() {
  255. },
  256. methods: {
  257. openConfirmationBox() {
  258. this.$refs.confirmationBox.open();
  259. },
  260. closeConfirmationBox() {
  261. this.$refs.confirmationBox.close();
  262. },
  263. openContentPopUpWindow() {
  264. this.$refs.openContentPopUpWindow.open();
  265. },
  266. closeContentPopUpWindow() {
  267. this.$refs.openContentPopUpWindow.close();
  268. },
  269. // 获取图片第一个像素的RGB值
  270. getImagePixelColor() {
  271. console.log("图片加载完成,准备获取像素颜色");
  272. // 清空之前的颜色值,进入加载状态
  273. this.pixelColor = null;
  274. // 如果是默认图片或空图片,则直接返回
  275. if (!this.home_image || this.home_image === '../../static/home/avator.png') {
  276. console.log("无有效图片,不获取像素颜色");
  277. return;
  278. }
  279. // 使用uni.getImageInfo获取图片信息
  280. uni.getImageInfo({
  281. src: this.home_image,
  282. success: (res) => {
  283. console.log("图片信息:", res);
  284. // 创建临时canvas绘制上下文
  285. const ctx = uni.createCanvasContext('pixelCanvas', this);
  286. // 修改绘制参数,确保只绘制图片左上角的一小块区域
  287. // drawImage(图片路径, 源图片裁剪x, 源图片裁剪y, 源图片裁剪宽度, 源图片裁剪高度, canvas目标x, canvas目标y, canvas目标宽度, canvas目标高度)
  288. // 这里我们只从源图片左上角裁剪10x10的区域,绘制到canvas的左上角
  289. ctx.drawImage(res.path, 0, 0, 10, 10, 0, 0, 10, 10);
  290. ctx.draw(false, () => {
  291. // 绘制完成后,获取像素数据
  292. setTimeout(() => { // 添加短暂延迟确保绘制完成
  293. uni.canvasGetImageData({
  294. canvasId: 'pixelCanvas',
  295. x: 0, // 获取(0,0)位置的像素
  296. y: 0,
  297. width: 1,
  298. height: 1,
  299. success: (res) => {
  300. // 获取像素RGB值
  301. this.pixelColor = {
  302. r: res.data[0],
  303. g: res.data[1],
  304. b: res.data[2],
  305. a: res.data[3]
  306. };
  307. console.log("第一个像素的RGB值:", this
  308. .pixelColor);
  309. },
  310. fail: (err) => {
  311. console.error("获取像素数据失败:", err);
  312. // 显示错误提示
  313. uni.showToast({
  314. title: '获取颜色失败',
  315. icon: 'none',
  316. duration: 2000
  317. });
  318. }
  319. });
  320. }, 100);
  321. });
  322. },
  323. fail: (err) => {
  324. console.error("获取图片信息失败:", err);
  325. // 显示错误提示
  326. uni.showToast({
  327. title: '图片加载失败',
  328. icon: 'none',
  329. duration: 2000
  330. });
  331. }
  332. });
  333. },
  334. // 返回上一页
  335. goBack() {
  336. uni.navigateBack({
  337. delta: 1
  338. });
  339. },
  340. getMyInfo() {
  341. uni.request({
  342. url: this.$apiHost + '/My/getnum',
  343. method: 'GET',
  344. header: {
  345. 'content-type': 'application/json',
  346. 'sign': getApp().globalData.headerSign
  347. },
  348. data: {
  349. uuid: getApp().globalData.uuid
  350. },
  351. success: (res) => {
  352. console.log("获取用户信息:", res.data);
  353. this.myinfo = res.data
  354. }
  355. })
  356. },
  357. selPhoto(item, sel) {
  358. this.selImg = sel;
  359. this.home_image = this.image_list[sel];
  360. },
  361. toArr(imgs) {
  362. let arr = imgs.split("|");
  363. return arr;
  364. },
  365. previewOpen(imgs1, index) {
  366. this.imgs = imgs1.split("|");
  367. setTimeout(() => this.$refs.previewImage.open(index), 0)
  368. // 传入当前选中的图片地址或序号
  369. return; //如需测试和uni原生预览差别可注释这两行
  370. },
  371. // 切换音频播放状态
  372. toggleAudio() {
  373. if (!this.queueDetail.result_audio) return;
  374. if (this.isPlaying) {
  375. this.audioPlayer.pause();
  376. this.isPlaying = false;
  377. } else {
  378. this.audioPlayer.src = this.queueDetail.result_audio;
  379. this.audioPlayer.play();
  380. this.isPlaying = true;
  381. }
  382. },
  383. // 获取进度条宽度
  384. getProgressWidth() {
  385. if (this.queueDetail.all_position === 0) return '0%';
  386. const progress = (1 - (this.queueDetail.queue_position / this.queueDetail.all_position)) * 100;
  387. return `${progress}%`;
  388. },
  389. // 加载数据
  390. loadData() {
  391. uni.showLoading({
  392. title: '加载中...'
  393. });
  394. let that = this;
  395. if (this.queueId) {
  396. that.workInformation()
  397. }
  398. uni.request({
  399. url: this.$apiHost + '/WorkAI/getQueueDetail',
  400. data: {
  401. uuid: getApp().globalData.uuid,
  402. id: this.arcID
  403. },
  404. header: {
  405. "content-type": "application/json",
  406. 'sign': getApp().globalData.headerSign
  407. },
  408. success: (res) => {
  409. console.log("队列详情:", res.data);
  410. if (res.data.success === "yes") {
  411. // 更新队列详情
  412. this.queueDetail = res.data.data;
  413. this.noteContent = res.data.data.content;
  414. // 更新图片列表
  415. if (this.queueDetail.result_images && this.queueDetail.result_images !== "") {
  416. this.image_list = this.queueDetail.result_images.split(",");
  417. this.home_image = this.image_list[0];
  418. // 当图片更新后,手动触发获取像素颜色(因为图片可能从缓存加载,不会触发@load事件)
  419. // setTimeout(() => {
  420. // that.getImagePixelColor();
  421. // }, 500);
  422. } else {
  423. this.home_image = "../../static/home/avator.png";
  424. }
  425. // 如果是音频类型,设置音频源
  426. if (this.queueDetail.task_type == 2 && this.queueDetail.result_audio) {
  427. this.audioPlayer.src = this.queueDetail.result_audio;
  428. }
  429. // 更新分享相关数据
  430. this.shareTitle = res.data.data.song_name || '萌创星球';
  431. this.shareDesc = res.data.data.description;
  432. this.shareImg = this.home_image;
  433. this.userId = res.data.data.sso_id;
  434. console.log(this.shareTitle, 9, this.shareDesc, 2, this.shareImg, 3, this.userId, 4, '分享数据');
  435. } else {
  436. uni.showToast({
  437. title: '获取详情失败',
  438. icon: 'none'
  439. });
  440. }
  441. },
  442. complete: () => {
  443. uni.hideLoading();
  444. },
  445. fail: (e) => {
  446. console.log("请求失败:", e);
  447. uni.showToast({
  448. title: '网络请求失败',
  449. icon: 'none'
  450. });
  451. }
  452. });
  453. },
  454. // 加载作品信息
  455. workInformation() {
  456. uni.request({
  457. url: this.$apiHost + '/Work/getinfo',
  458. data: {
  459. uuid: getApp().globalData.uuid,
  460. id: this.queueId
  461. },
  462. header: {
  463. "content-type": "application/json",
  464. 'sign': getApp().globalData.headerSign
  465. },
  466. success: (res) => {
  467. console.log("文章信息:", res.data);
  468. if (res.data.success === "yes") {
  469. // 更新文章信息
  470. this.fileInformation = res.data.data;
  471. } else {
  472. }
  473. },
  474. complete: (com) => {
  475. // uni.hideLoading();
  476. },
  477. fail: (e) => {
  478. console.log("请求失败:", e);
  479. uni.showToast({
  480. title: '网络请求失败',
  481. icon: 'none'
  482. });
  483. }
  484. });
  485. },
  486. showActionSheet() {
  487. this.$refs.actionSheet.show();
  488. },
  489. handleActionSelect(index, item) {
  490. console.log('ActionSheet selected index:', item.text,);
  491. switch (item.text) {
  492. case '分享作品':
  493. this.showShare = true;
  494. break;
  495. case '修改封面':
  496. // 修改封面
  497. if (this.queueDetail.status == 9 && (this.fileInformation.status == 3 || this.fileInformation.status == 0)) {
  498. this.editCover();
  499. } else {
  500. if (this.queueDetail.status == 9) {
  501. uni.showToast({
  502. title: '作品已完成,无法修改封面!',
  503. icon: 'none'
  504. });
  505. } else {
  506. uni.showToast({
  507. title: '作品未完成,无法修改封面!',
  508. icon: 'none'
  509. });
  510. }
  511. break;
  512. }
  513. break;
  514. case '删除作品':
  515. // 删除作品
  516. this.deleteWork();
  517. break;
  518. case '举报':
  519. this.handleReport();
  520. break;
  521. }
  522. },
  523. handleReport() {
  524. // 实现举报功能
  525. uni.$emit('check_login', () => {
  526. uni.navigateTo({
  527. url: '/pages/my/feedback'
  528. })
  529. })
  530. },
  531. handleActionCancel() {
  532. console.log('ActionSheet cancelled');
  533. },
  534. // 修改封面
  535. async editCover() {
  536. var _self = this;
  537. const hasPermission = await this.checkCameraPermission();
  538. if (!hasPermission) return;
  539. console.log(1111111);
  540. uni.chooseImage({
  541. count: 1,
  542. sizeType: ['compressed'],
  543. sourceType: ['album', 'camera'],
  544. success: async function (res) {
  545. console.log('res:', res)
  546. if (res.tempFilePaths.length > 0) {
  547. _self.imglocal = res.tempFilePaths[0]
  548. const tempFilePaths = res.tempFilePaths[0];
  549. console.log('tempFilePaths:', tempFilePaths);
  550. const uploadTask = uni.uploadFile({
  551. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  552. filePath: res.tempFilePaths[0],
  553. name: 'file',
  554. success: async function (uploadFileRes) {
  555. let resdata = JSON.parse(uploadFileRes.data)
  556. console.log('Success11:', uploadFileRes);
  557. console.log('Success21:', resdata);
  558. if (resdata.success == 'yes') {
  559. // 调用修改封面接口
  560. uni.request({
  561. url: _self.$apiHost + '/WorkAI/queueAction',
  562. method: 'GET',
  563. data: {
  564. uuid: getApp().globalData.uuid,
  565. act: 'editImg',
  566. result_images: resdata.url,
  567. id: _self.arcID
  568. },
  569. header: {
  570. 'content-type': 'application/json',
  571. 'sign': getApp().globalData.headerSign
  572. },
  573. success: async (res) => {
  574. if (res.data.success === "yes") {
  575. _self.home_image = resdata.url;
  576. uni.showToast({
  577. title: '修改封面成功',
  578. icon: 'success'
  579. });
  580. } else {
  581. uni.showToast({
  582. title: '修改封面失败',
  583. icon: 'none'
  584. });
  585. }
  586. },
  587. fail: () => {
  588. uni.showToast({
  589. title: '修改封面失败',
  590. icon: 'none'
  591. });
  592. }
  593. });
  594. }
  595. },
  596. fail: function (uploadFileFail) {
  597. console.log('Error:', uploadFileFail.data);
  598. uni.showToast({
  599. title: '图片上传失败',
  600. icon: 'none'
  601. });
  602. }
  603. });
  604. }
  605. },
  606. error: function (e) {
  607. console.log(e);
  608. uni.showToast({
  609. title: '选择图片失败',
  610. icon: 'none'
  611. });
  612. }
  613. });
  614. },
  615. // 删除作品
  616. deleteWork() {
  617. this.$refs["customConfirm"]
  618. .confirm({
  619. title: "确认删除",
  620. content: "确定要删除这个作品吗?",
  621. DialogType: "inquiry",
  622. btn1: "再考虑一下",
  623. btn2: "确认删除",
  624. animation: 0,
  625. })
  626. .then((res) => {
  627. console.log(res);
  628. if (res.confirm) {
  629. // 用户点击确定,执行删除操作
  630. this.confirmDelete();
  631. }
  632. }, () => { });
  633. },
  634. // 确认删除
  635. confirmDelete() {
  636. uni.showLoading({
  637. title: '删除中...'
  638. });
  639. let url = this.$apiHost + '/WorkAI/queueAction';
  640. let id = this.arcID;
  641. if (this.queueDetail.status == 9) {
  642. url = this.$apiHost + '/Work/doAct';
  643. id = this.queueId;
  644. }
  645. uni.request({
  646. url,
  647. method: 'GET',
  648. data: {
  649. uuid: getApp().globalData.uuid,
  650. act: 'del',
  651. id,
  652. },
  653. header: {
  654. 'content-type': 'application/json',
  655. 'sign': getApp().globalData.headerSign
  656. },
  657. success: (res) => {
  658. uni.hideLoading();
  659. if (res.data.success === "yes") {
  660. uni.showToast({
  661. title: '删除成功',
  662. icon: 'success'
  663. });
  664. // 删除成功后返回上一页
  665. setTimeout(() => {
  666. uni.navigateBack({
  667. delta: 1
  668. });
  669. }, 1500);
  670. } else {
  671. uni.showToast({
  672. title: '删除失败',
  673. icon: 'none'
  674. });
  675. }
  676. },
  677. fail: () => {
  678. uni.hideLoading();
  679. uni.showToast({
  680. title: '删除失败',
  681. icon: 'none'
  682. });
  683. }
  684. });
  685. },
  686. // 显示添加说明弹窗
  687. showAddNotePopup() {
  688. this.showNotePopup = true;
  689. },
  690. // 关闭添加说明弹窗
  691. closeAddNotePopup() {
  692. this.showNotePopup = false;
  693. },
  694. // 确认添加说明
  695. confirmAddNote() {
  696. if (!this.noteContent.trim()) {
  697. uni.showToast({
  698. title: '请输入说明内容',
  699. icon: 'none'
  700. });
  701. return;
  702. }
  703. uni.showLoading({
  704. title: '保存中...'
  705. });
  706. uni.request({
  707. url: this.$apiHost + '/WorkAI/queueAction',
  708. method: 'GET',
  709. data: {
  710. uuid: getApp().globalData.uuid,
  711. act: 'editContent',
  712. content: this.noteContent,
  713. id: this.arcID
  714. },
  715. header: {
  716. 'content-type': 'application/json',
  717. 'sign': getApp().globalData.headerSign
  718. },
  719. success: (res) => {
  720. uni.hideLoading();
  721. if (res.data.success === "yes") {
  722. uni.showToast({
  723. title: res.data.str,
  724. icon: 'success'
  725. });
  726. this.noteContent = '';
  727. this.closeContentPopUpWindow();
  728. // 重新加载数据
  729. this.loadData();
  730. } else {
  731. uni.showToast({
  732. title: res.data.str,
  733. icon: 'none'
  734. });
  735. }
  736. },
  737. fail: () => {
  738. uni.hideLoading();
  739. uni.showToast({
  740. title: '添加说明失败',
  741. icon: 'none'
  742. });
  743. }
  744. });
  745. },
  746. // 发布作品
  747. publishWork() {
  748. uni.showLoading({
  749. title: '发布中...'
  750. });
  751. uni.request({
  752. url: this.$apiHost + '/WorkAI/queueAction',
  753. method: 'GET',
  754. data: {
  755. uuid: getApp().globalData.uuid,
  756. act: 'fabu',
  757. id: this.arcID
  758. },
  759. header: {
  760. 'content-type': 'application/json',
  761. 'sign': getApp().globalData.headerSign
  762. },
  763. success: (res) => {
  764. console.log("resddd", res.data);
  765. uni.hideLoading();
  766. if (res.data.success === "yes") {
  767. uni.showToast({
  768. title: '发布成功',
  769. icon: 'success'
  770. });
  771. // 重新加载数据
  772. // this.loadData();
  773. } else {
  774. uni.showToast({
  775. title: res.data.str || '发布失败',
  776. icon: 'none'
  777. });
  778. }
  779. },
  780. fail: () => {
  781. uni.hideLoading();
  782. uni.showToast({
  783. title: '发布失败',
  784. icon: 'none'
  785. });
  786. },
  787. complete: () => {
  788. setTimeout(() => {
  789. uni.navigateBack({
  790. delta: 1
  791. });
  792. }, 800);
  793. }
  794. });
  795. },
  796. // 新增过滤器方法
  797. commaToArray(str) {
  798. if (!str) return '';
  799. return str.split(',');
  800. },
  801. // 新增过滤器方法
  802. addBrackets(str) {
  803. if (!str) return '';
  804. if (!str.startsWith('《')) {
  805. str = '《' + str;
  806. }
  807. if (!str.endsWith('》')) {
  808. str = str + '》';
  809. }
  810. return str;
  811. },
  812. getInfoData() {
  813. uni.request({
  814. url: this.$apiHost + '/Member/getinfoData',
  815. data: {
  816. uuid: getApp().globalData.uuid
  817. },
  818. header: {
  819. 'content-type': 'application/json'
  820. },
  821. success: (res) => {
  822. console.log('用户信息', res.data);
  823. }
  824. });
  825. },
  826. async chooseImage(sourceType) {
  827. try {
  828. let hasPermission = false;
  829. if (sourceType === 'camera') {
  830. hasPermission = await this.checkCameraPermission();
  831. } else if (sourceType === 'album') {
  832. hasPermission = await this.checkPhotoLibraryPermission();
  833. }
  834. if (!hasPermission) {
  835. uni.showToast({
  836. title: '未获得权限',
  837. icon: 'none'
  838. });
  839. return;
  840. }
  841. uni.chooseImage({
  842. count: 1,
  843. sizeType: ['compressed'],
  844. sourceType: [sourceType],
  845. success: async (res) => {
  846. console.log('res:', res)
  847. if (res.tempFilePaths.length > 0) {
  848. this.imglocal = res.tempFilePaths[0]
  849. const tempFilePath = res.tempFilePaths[0];
  850. console.log('tempFilePaths:', tempFilePath);
  851. await this.uploadImage(tempFilePath);
  852. }
  853. },
  854. fail: (err) => {
  855. console.error('选择图片失败:', err);
  856. uni.showToast({
  857. title: '选择图片失败',
  858. icon: 'none'
  859. });
  860. }
  861. });
  862. } catch (error) {
  863. console.error('权限检查失败:', error);
  864. uni.showToast({
  865. title: '权限检查失败',
  866. icon: 'none'
  867. });
  868. }
  869. },
  870. async checkCameraPermission() {
  871. const hasPermission = await permission.request(permission.PermissionType.CAMERA, {
  872. title: '“萌创星球”想访问你的相机',
  873. describe: '萌创星球想访问您的摄像头,便于拍摄获取图片来替换原有作品封面图'
  874. });
  875. return hasPermission;
  876. },
  877. async checkPhotoLibraryPermission() {
  878. const hasPermission = await permission.request(permission.PermissionType.PHOTO_LIBRARY, {
  879. title: '“萌创星球”想访问你的照片图库',
  880. describe: '萌创星球想访问您本地照片图库,便于获取图片来替换原有作品封面图'
  881. });
  882. return hasPermission;
  883. },
  884. uploadImage(tempFilePath) {
  885. const _self = this;
  886. const uploadTask = uni.uploadFile({
  887. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  888. filePath: tempFilePath,
  889. name: 'file',
  890. success: function (uploadFileRes) {
  891. let resdata = JSON.parse(uploadFileRes.data)
  892. console.log('Success11:', uploadFileRes);
  893. console.log('Success21:', resdata);
  894. if (resdata.success == 'yes') {
  895. // 调用修改封面接口
  896. uni.request({
  897. url: _self.$apiHost + '/WorkAI/queueAction',
  898. method: 'GET',
  899. data: {
  900. uuid: getApp().globalData.uuid,
  901. act: 'editImg',
  902. result_images: resdata.url,
  903. id: _self.arcID
  904. },
  905. header: {
  906. 'content-type': 'application/json',
  907. 'sign': getApp().globalData.headerSign
  908. },
  909. success: async (res) => {
  910. if (res.data.success === "yes") {
  911. _self.showRights = false;
  912. _self.home_image = resdata.url;
  913. uni.showToast({
  914. title: '修改封面成功',
  915. icon: 'success'
  916. });
  917. } else {
  918. uni.showToast({
  919. title: '修改封面失败',
  920. icon: 'none'
  921. });
  922. }
  923. },
  924. fail: () => {
  925. uni.showToast({
  926. title: '修改封面失败',
  927. icon: 'none'
  928. });
  929. }
  930. });
  931. }
  932. },
  933. fail: function (uploadFileFail) {
  934. console.error('Error:', uploadFileFail);
  935. uni.showToast({
  936. title: '上传失败,请重试',
  937. icon: 'none',
  938. duration: 1500
  939. });
  940. },
  941. complete: () => {
  942. console.log('Upload complete');
  943. }
  944. });
  945. // 显示上传进度
  946. uploadTask.onProgressUpdate((res) => {
  947. console.log('上传进度' + res.progress);
  948. console.log('已经上传的数据长度' + res.totalBytesSent);
  949. console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
  950. });
  951. },
  952. editCover() {
  953. uni.showActionSheet({
  954. itemList: ['拍照', '从相册选择'],
  955. success: (res) => {
  956. const sourceType = res.tapIndex === 0 ? 'camera' : 'album';
  957. this.chooseImage(sourceType);
  958. }
  959. });
  960. },
  961. }
  962. }
  963. </script>
  964. <style scoped lang="scss">
  965. @import 'makeDetail.scss';
  966. .openContentPopUpWindow {
  967. ::v-deep.uv-textarea {
  968. width: 694rpx !important;
  969. border-radius: 20rpx !important;
  970. border: 1rpx solid #000000 !important;
  971. margin: 0 auto;
  972. margin-bottom: 44rpx;
  973. min-height: 300rpx;
  974. }
  975. }
  976. .permission-tip {
  977. width: 100%;
  978. height: 300rpx;
  979. background-color: rgba(255, 255, 255, 0.9);
  980. position: fixed;
  981. top: 0;
  982. display: flex;
  983. flex-direction: column;
  984. justify-content: center;
  985. align-items: center;
  986. z-index: 999;
  987. .permission-title {
  988. width: 90%;
  989. color: #000000;
  990. font-size: 38rpx;
  991. text-align: left;
  992. padding: 10rpx 20rpx;
  993. padding-top: 10rpx;
  994. }
  995. .permission-desc {
  996. width: 90%;
  997. color: #666666;
  998. font-size: 28rpx;
  999. text-align: left;
  1000. padding: 10rpx 20rpx;
  1001. }
  1002. }
  1003. </style>