makeDetail.vue 27 KB

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