makeDetail.vue 27 KB

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