details.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  1. <template>
  2. <view class="template-details">
  3. <block v-if="showdrawing">
  4. <u-notice-bar v-if="drawingtitle=='正在努力绘制中...'||drawingtitle=='图片正在渲染中...'" :text="noticebar" step
  5. bgColor="#000"></u-notice-bar>
  6. <view class="lazy-loading tn-flex justify-center align-center flex-wrap">
  7. <view class="preloader_1">
  8. <view></view>
  9. <view></view>
  10. <view></view>
  11. <view></view>
  12. <view></view>
  13. </view>
  14. <view class="drawing">
  15. {{drawingtitle}}
  16. </view>
  17. <view v-if="showprogress" class="progress">
  18. <u-line-progress :percentage="percentage" activeColor="#9b59b6" height="18"></u-line-progress>
  19. </view>
  20. </view>
  21. </block>
  22. <swiper class="card-swiper" :circular="false" :autoplay="true" duration="500" interval="12000"
  23. @change="cardSwiper">
  24. <swiper-item v-for="(item,index) in swiperList" :key="index" :class="cardCur==index?'cur':''">
  25. <view class="lazy-load" :style="{height: windowHeight+'px'}">
  26. <u--image @load="previewload" @error="previewerror" width="100%" height="100%" :src="item.url"
  27. mode="widthFix">
  28. <view slot="error" style="font-size: 32rpx;text-align: center;">
  29. 图片加载失败
  30. </view>
  31. </u--image>
  32. </view>
  33. </swiper-item>
  34. </swiper>
  35. <view class="indication">
  36. <block v-for="(item,index) in swiperList" :key="index">
  37. <view v-if="swiperList.length>1" class="spot" :class="cardCur==index?'active':''"></view>
  38. </block>
  39. </view>
  40. <view class="tabbar footerfixed dd-glass tn-color-white" style="border-radius: 100rpx;">
  41. <view class="action" @click="getisback">
  42. <view class="bar-icon">
  43. <view class="tn-icon-left-circle">
  44. </view>
  45. </view>
  46. <view class="">立即返回</view>
  47. </view>
  48. <view class="action" @click="downLoad">
  49. <view class="bar-icon">
  50. <view class="tn-icon-download">
  51. </view>
  52. </view>
  53. <view class="">下载</view>
  54. </view>
  55. <view class="action" @click="getdownload(cardCur)">
  56. <view class="bar-icon">
  57. <view class="tn-icon-share-circle">
  58. </view>
  59. </view>
  60. <view class="">分享</view>
  61. </view>
  62. <view class="action" @click="preViewImg_ys(1)" v-if="engin=='rh'">
  63. <view class="bar-icon">
  64. <view class="tn-icon-image">
  65. </view>
  66. </view>
  67. <view class="">模板</view>
  68. </view>
  69. <view class="action" @click="preViewImg_ys(2)" v-if="engin=='rh'">
  70. <view class="bar-icon">
  71. <view class="tn-icon-image">
  72. </view>
  73. </view>
  74. <view class="">照片</view>
  75. </view>
  76. <view class="action" @click="parameters" v-if="engin!='rh'">
  77. <view class="bar-icon">
  78. <view class="tn-icon-creative">
  79. </view>
  80. </view>
  81. <view class="">绘画参数</view>
  82. </view>
  83. <view class="action" @click="preViewImg(1)" v-if="parameter.refImg&&$Route.query.urls">
  84. <view class="bar-icon">
  85. <view class="tn-icon-image">
  86. </view>
  87. </view>
  88. <view class="">参考图</view>
  89. </view>
  90. <view class="action" @click="preViewImg(2)" v-if="form.init_image
  91. ">
  92. <view class="bar-icon">
  93. <view class="tn-icon-image">
  94. </view>
  95. </view>
  96. <view class="">参考图</view>
  97. </view>
  98. <view v-if="show2" class="action"
  99. @click="tn(engin!='rh'?'/pages/painting/draw?prompt='+parameter.promptSame+'&engine='+engin+'&model_name='+parameter.model_name+'&refImg='
  100. +parameter.refImg:'/pages/painting/draw?rh_modalId='+(parameter.templateId?parameter.templateId:-1)+'&rh_modalurl='+parameter.source_image_url)">
  101. <view class="tn-flex-direction-column tn-flex-row-center tn-flex-col-center tn-button--clear-style">
  102. <view class="bar-icon">
  103. <view class="tn-icon-write">
  104. </view>
  105. </view>
  106. <view class="">创作相似</view>
  107. </view>
  108. </view>
  109. <view v-else class="action" @click="setOpen">
  110. <view class="tn-flex-direction-column tn-flex-row-center tn-flex-col-center tn-button--clear-style">
  111. <view class="bar-icon">
  112. <view class="tn-icon-up-circle">
  113. </view>
  114. </view>
  115. <view class="">{{showopen?'已公开':'公开作品'}}</view>
  116. </view>
  117. </view>
  118. </view>
  119. <tn-landscape :show="show1" @close="closeLandscape" closePosition="bottom" :closeSize="60">
  120. <view class="tn-color-white" style="width: 100vw;">
  121. <view class="" style="margin: 120rpx 60rpx;">
  122. <view class="tn-flex tn-flex-row-between tn-flex-col-between tn-margin-top-xl tn-text-justify">
  123. <text class="">AI绘画:{{parameter.engine == 'sd'?'StableDiffusion绘图':'MidJourney绘图'}}</text>
  124. </view>
  125. <view v-if="parameter.prompt&&$Route.query.urls"
  126. class="tn-flex tn-flex-row-between tn-flex-col-between tn-margin-top-xl tn-text-justify">
  127. <text class="">描述词:{{parameter.prompt}}</text>
  128. </view>
  129. <view v-if="form.keywords"
  130. class="tn-flex tn-flex-row-between tn-flex-col-between tn-margin-top-xl tn-text-justify">
  131. <text class="">描述词:{{form.keywords}}</text>
  132. </view>
  133. <view v-if="parameter.model_name"
  134. class="tn-flex tn-flex-row-between tn-flex-col-between tn-margin-top-xl tn-text-justify">
  135. <text class="">模型:{{form.name?form.name:parameter.model_name}}</text>
  136. </view>
  137. <view v-if="parameter.width"
  138. class="tn-flex tn-flex-row-between tn-flex-col-between tn-margin-top-xl tn-text-justify">
  139. <text class="">分辨率:{{parameter.width}}x{{parameter.height}}</text>
  140. </view>
  141. </view>
  142. </view>
  143. </tn-landscape>
  144. <u-popup :show="show" @close="close" @open="open" mode="center">
  145. <view
  146. style="background: rgba(0, 0, 0, 0);width: 300rpx;height: 300rpx;display: flex;align-items: center;flex-direction: column;justify-content: center;color:#207CF7;">
  147. <l-circularProgress :isBgShow="true" :lineWidth="10" boxWidth="100" boxHeight="100"
  148. progressColor="#207CF7" fontColor="#207CF7" gradualColor="#207CF7"
  149. :percent="progress"></l-circularProgress>
  150. <view class="">
  151. 图片下载中...
  152. </view>
  153. </view>
  154. </u-popup>
  155. <wike-painter style="height:1px;margin-top: -9999999px;" :board="posterObj" @done="posterSuccess"
  156. ref="painter"></wike-painter>
  157. </view>
  158. </template>
  159. <script>
  160. import {
  161. mapMutations,
  162. mapActions,
  163. mapState,
  164. mapGetters
  165. } from 'vuex';
  166. let timingr;
  167. let asynchronous;
  168. // 判断是否为微信环境
  169. // const isWechat = () => {
  170. // return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
  171. // }
  172. export default {
  173. data() {
  174. return {
  175. tobheight: 45,
  176. showdrawing: true,
  177. showprogress: true,
  178. drawingtitle: '正在努力绘制中...',
  179. percentage: 0,
  180. show1: false,
  181. show2: true,
  182. cardCur: 0,
  183. swiperList: [],
  184. form: {},
  185. parameter: {},
  186. noticebar: ['精美图片需要时间打磨,预计20-30秒左右出图',
  187. '图片生成中请不要退出此页面,否则可能会无法生成'
  188. // '长时间未出图?可稍后在 我的-绘画记录 里查看'
  189. ],
  190. parameterid: 0,
  191. showopen: false,
  192. failnum: 0,
  193. windowHeight: 0,
  194. engin: '',
  195. progress: 0,
  196. isDowload: false,
  197. show: false,
  198. sd_keywords: '',
  199. // 生成海报data
  200. platform: this.$platform.get(),
  201. qrcode: '',
  202. spmplatform: 0,
  203. posterObj: {},
  204. info: {
  205. // poster_bg_img_path:"",
  206. poster_bg_width: 347,
  207. poster_bg_height: 574,
  208. poster_qrcode_x: 278,
  209. poster_qrcode_y: 495,
  210. poster_qrcode_width: 52,
  211. poster_qrcode_height: 52,
  212. },
  213. }
  214. },
  215. // 生成海报需要的数据由此开始
  216. computed: {
  217. ...mapGetters(['appInfo', 'homeTemplate', 'isLogin', 'userInfo', 'userData'])
  218. },
  219. onShow() {
  220. console.log('this.userInfo-----------------', this.option, this.userInfo);
  221. },
  222. onLoad(o) {
  223. this.spmplatform = ['H5', 'wxOfficialAccount', 'wxMiniProgram', 'App'].indexOf(this.platform) + 1;
  224. this.commonqrcodePath()
  225. var that = this;
  226. this.windowHeight = uni.$u.sys().windowHeight - 60
  227. this.engin = that.$Route.query.from
  228. if (that.$Route.query.urls) {
  229. this.showprogress = false
  230. this.drawingtitle = '图片正在加载中...'
  231. that.gallerydetail(that.$Route.query.urls)
  232. }
  233. if (that.$Route.query.form) {
  234. this.form = that.$Route.query.form
  235. console.log('生成绘画的参数:', this.form);
  236. this.parameter.refImg = this.form.refer_img
  237. this.parameter.prompt = this.form.init_image + this.form.prompt
  238. this.parameter.model_name = this.form.model_id
  239. this.parameter.width = this.form.width
  240. this.parameter.height = this.form.height
  241. this.parameter.engine = 'sd'
  242. this.show2 = false
  243. this.sd_keywords = this.form.keywords
  244. this.aiPlay();
  245. }
  246. },
  247. methods: {
  248. downLoad() {
  249. if (this.showdrawing) {
  250. uni.showToast({
  251. title: '图片生成中',
  252. icon: 'none'
  253. })
  254. return;
  255. }
  256. if (!this.is_weixin()) {
  257. return uni.showModal({
  258. showCancel: false,
  259. title: '提示',
  260. content: '请在微信内置浏览器打开,长按图片下载',
  261. confirmColor: '#207CF7'
  262. })
  263. }
  264. uni.showModal({
  265. showCancel: false,
  266. title: '提示',
  267. content: '长按图片即可下载',
  268. confirmColor: '#207CF7',
  269. confirmText: '知道了',
  270. })
  271. },
  272. preViewImg_ys(type) {
  273. if (type == 1) {
  274. uni.previewImage({
  275. urls: [this.parameter.source_image_url],
  276. longPressActions: {
  277. itemList: ['发送给朋友', '保存图片', '收藏'],
  278. success: function(data) {},
  279. fail: function(err) {
  280. console.log(err.errMsg);
  281. }
  282. }
  283. });
  284. } else {
  285. uni.previewImage({
  286. urls: [this.parameter.target_image_url],
  287. longPressActions: {
  288. itemList: ['发送给朋友', '保存图片', '收藏'],
  289. success: function(data) {},
  290. fail: function(err) {
  291. console.log(err.errMsg);
  292. }
  293. }
  294. });
  295. }
  296. },
  297. downloadPic(e) {
  298. return new Promise((resolve, reject) => {
  299. uni.request({
  300. url: e,
  301. method: 'GET',
  302. responseType: 'arraybuffer',
  303. success: ress => {
  304. let base64 = uni.arrayBufferToBase64(ress.data);
  305. base64 = 'data:image/jpeg;base64,' + base64
  306. resolve(base64);
  307. },
  308. fail: (e) => {
  309. resolve('fail');
  310. }
  311. })
  312. });
  313. },
  314. commonqrcodePath() {
  315. let spm = this.userInfo.id + '.1.0.' + this.spmplatform + '.1';
  316. // console.log(spm);
  317. this.$http('common.qrcodePath', {
  318. spm: spm
  319. }).then(res => {
  320. if (res.code == 0) {
  321. this.qrcode = res.data;
  322. // this.createPoster()
  323. console.log('二维码需要包含的url信息=============', this.qrcode);
  324. }
  325. });
  326. },
  327. async createPoster(e) {
  328. let that = this;
  329. let avatarUrl = '';
  330. let mainUrl = '';
  331. uni.showLoading({
  332. title: '海报渲染中'
  333. });
  334. console.log("that.swiperList[0].url,that.userInfo.avatar", that.userInfo, that.swiperList[0].url, that
  335. .userInfo.avatar);
  336. if (that.swiperList[0].url.indexOf("https") < 0) {
  337. mainUrl = await that.downloadPic(that.swiperList[0].url.replace("http:", "https:"));
  338. } else {
  339. mainUrl = await that.downloadPic(that.swiperList[0].url);
  340. }
  341. if (mainUrl == 'fail') {
  342. uni.hideLoading();
  343. uni.showToast({
  344. title: '生成失败',
  345. icon: 'none'
  346. })
  347. return;
  348. }
  349. // that.userInfo.avatar ="https://face.cdn.zhishuyun.com/attachments/1133012400174534792/1204009950465101866/0d47db66-1faf-42df-a732-22cf18697a65_ins.png?ex=65d32ca5&is=65c0b7a5&hm=7219a0f250453314cfbf9eefaf2e927ba8d6adea944774b3fe32e67c0787a877&"
  350. if (that.userInfo.avatar) {
  351. if (that.userInfo.avatar.indexOf("https") < 0) {
  352. avatarUrl = await that.downloadPic(that.userInfo.avatar.replace("http:", "https:"));
  353. } else {
  354. avatarUrl = await that.downloadPic(that.userInfo.avatar);
  355. }
  356. if (avatarUrl == 'fail') {
  357. uni.hideLoading();
  358. uni.showToast({
  359. title: '生成失败',
  360. icon: 'none'
  361. })
  362. return;
  363. }
  364. }
  365. let proportionally = this.info.poster_bg_width / uni.$u.sys().windowWidth;
  366. (this.posterObj = {
  367. width: (this.info.poster_bg_width / proportionally) + 'px',
  368. height: (this.info.poster_bg_height / proportionally) + 'px',
  369. background: 'rgba(0,0,0,0)',
  370. borderRadius: '16rpx',
  371. views: [
  372. // 背景图
  373. {
  374. src: '/static/shareBg.png',
  375. type: "image",
  376. css: {
  377. width: (this.info.poster_bg_width / proportionally) + 'px',
  378. height: (this.info.poster_bg_height / proportionally) + 'px',
  379. }
  380. },
  381. // 主图
  382. {
  383. type: 'view',
  384. css: {
  385. position: 'absolute',
  386. left: '50%',
  387. },
  388. views: [{
  389. src: mainUrl,
  390. type: "image",
  391. css: {
  392. height: 936 + 'rpx',
  393. borderRadius: '28rpx',
  394. transform: 'translateX(-50%)',
  395. marginTop: "28rpx",
  396. maxWidth: '705rpx'
  397. }
  398. }, ],
  399. },
  400. // 头像
  401. {
  402. type: 'view',
  403. css: {
  404. display: 'flex',
  405. position: 'absolute',
  406. left: '24rpx',
  407. top: '1060rpx',
  408. },
  409. views: [{
  410. type: 'image',
  411. src: that.userInfo.avatar ? avatarUrl : '/static/images/head.jpg',
  412. css: {
  413. marginTop: '-80rpx',
  414. borderRadius: '50%',
  415. width: '94rpx',
  416. height: '94rpx',
  417. objectFit: 'cover'
  418. }
  419. }, ],
  420. },
  421. // 昵称
  422. {
  423. type: 'view',
  424. css: {
  425. display: 'flex',
  426. position: 'absolute',
  427. left: '140rpx',
  428. bottom: '196rpx',
  429. },
  430. views: [{
  431. type: 'text',
  432. text: that.userInfo.nickname ? that.userInfo.nickname : '默认用户',
  433. css: {
  434. fontSize: '28rpx',
  435. color: '#333333',
  436. }
  437. }],
  438. },
  439. // 海报文案1
  440. {
  441. type: 'view',
  442. css: {
  443. display: 'flex',
  444. position: 'absolute',
  445. left: '24rpx',
  446. bottom: '96rpx',
  447. },
  448. views: [{
  449. type: 'text',
  450. text: '免费体验Al生成个人质感艺术照',
  451. css: {
  452. fontSize: '32rpx',
  453. color: '#333333',
  454. }
  455. }],
  456. },
  457. // 海报文案2
  458. {
  459. type: 'view',
  460. css: {
  461. display: 'flex',
  462. position: 'absolute',
  463. left: '24rpx',
  464. bottom: '44rpx',
  465. },
  466. views: [{
  467. type: 'text',
  468. text: '设计微信/抖音/小红书专属头像',
  469. css: {
  470. fontSize: '32rpx',
  471. color: '#333333',
  472. }
  473. }],
  474. },
  475. // 二维码上方文案
  476. {
  477. type: 'view',
  478. css: {
  479. position: 'absolute',
  480. right: '40rpx',
  481. bottom: '196rpx',
  482. },
  483. views: [{
  484. type: 'text',
  485. text: '微信扫码',
  486. css: {
  487. fontSize: '24rpx',
  488. color: '#333333',
  489. }
  490. }],
  491. },
  492. {
  493. type: 'view',
  494. css: {
  495. left: (this.info.poster_qrcode_x / proportionally) + 'px',
  496. top: (this.info.poster_qrcode_y / proportionally) + 'px',
  497. position: 'fixed',
  498. },
  499. views: [{
  500. type: 'qrcode',
  501. text: this.qrcode,
  502. css: {
  503. width: (this.info.poster_qrcode_width / proportionally) + 'px',
  504. height: (this.info.poster_qrcode_width / proportionally) + 'px',
  505. background: '#fff'
  506. }
  507. },
  508. // {
  509. // src: '/static/images/fanyunLogo.png',
  510. // type: "image",
  511. // css: {
  512. // position: 'absolute',
  513. // width: 30 + 'rpx',
  514. // height: 30 + 'rpx',
  515. // left: '44rpx',
  516. // top: '44rpx',
  517. // }
  518. // }
  519. ],
  520. },
  521. ]
  522. }),
  523. (
  524. this.showPoster = true,
  525. // this.revertUrl()
  526. setTimeout(() => {
  527. that.$refs.painter.canvasToTempFilePathSync({
  528. // 在nvue里是jpeg
  529. fileType: 'jpg',
  530. quality: 1,
  531. success: res => {
  532. console.log('res.tempFilePath', res.tempFilePath);
  533. uni.showModal({
  534. title: '提示',
  535. content: '查看图片后长按图片即可保存或分享',
  536. confirmText: '查看',
  537. confirmColor: '#1F79F0',
  538. success: function(res2) {
  539. if (res2.confirm) {
  540. uni.previewImage({
  541. urls: [res.tempFilePath],
  542. longPressActions: {
  543. itemList: ['发送给朋友', '保存图片',
  544. '收藏'
  545. ],
  546. success: function(data) {},
  547. fail: function(err) {
  548. console.log(err
  549. .errMsg);
  550. }
  551. }
  552. });
  553. } else if (res2.cancel) {
  554. console.log('用户点击取消');
  555. }
  556. }
  557. });
  558. }
  559. })
  560. }, 1000)
  561. );
  562. },
  563. posterSuccess() {
  564. uni.hideLoading();
  565. },
  566. // 生成海报需要的数据到此为止
  567. preViewImg(type) {
  568. if (type == 1) {
  569. uni.previewImage({
  570. urls: [this.parameter.refImg],
  571. longPressActions: {
  572. itemList: ['发送给朋友', '保存图片', '收藏'],
  573. success: function(data) {},
  574. fail: function(err) {
  575. console.log(err.errMsg);
  576. }
  577. }
  578. });
  579. } else {
  580. uni.previewImage({
  581. urls: [this.form.init_image],
  582. longPressActions: {
  583. itemList: ['发送给朋友', '保存图片', '收藏'],
  584. success: function(data) {},
  585. fail: function(err) {
  586. console.log(err.errMsg);
  587. }
  588. }
  589. });
  590. }
  591. },
  592. parameters() {
  593. var that = this;
  594. // if(that.showdrawing){
  595. // uni.showToast({
  596. // title:'图片生成中',
  597. // icon:'none'
  598. // })
  599. // return;
  600. // }
  601. that.show1 = true
  602. },
  603. setOpen() {
  604. var that = this;
  605. if (that.showdrawing) {
  606. uni.showToast({
  607. title: '图片生成中',
  608. icon: 'none'
  609. })
  610. return;
  611. }
  612. if (that.showopen) {
  613. uni.showToast({
  614. title: '图片已公开',
  615. icon: 'none'
  616. })
  617. return;
  618. }
  619. uni.showModal({
  620. confirmColor: '#207CF7',
  621. confirmText: '确认公开',
  622. title: '提示',
  623. content: '是否确认公开此绘画作品',
  624. success(src) {
  625. if (src.confirm) {
  626. that.$http('gallery.setOpen', {
  627. id: that.parameterid
  628. }).then(res => {
  629. if (res.code == 0) {
  630. uni.showToast({
  631. title: '提交成功,等待审核'
  632. })
  633. that.showopen = true
  634. }
  635. });
  636. }
  637. }
  638. });
  639. },
  640. gallerydetail(id) {
  641. let that = this;
  642. this.$http('gallery.detail', {
  643. id: id,
  644. type: this.engin
  645. }).then(res => {
  646. if (res.code == 0) {
  647. if (this.engin == 'sd') {
  648. for (var i = 0; i < res.data.imgs_file.length; i++) {
  649. var url = {
  650. id: res.data.id,
  651. type: 'image',
  652. url: res.data.imgs_file[i],
  653. // url: res.data.origin_url,
  654. }
  655. that.swiperList.push(url)
  656. }
  657. this.done = true
  658. } else if (this.engin == 'mj') {
  659. var url = {
  660. id: res.data.id,
  661. type: 'image',
  662. url: res.data.origin_url,
  663. }
  664. that.swiperList.push(url)
  665. this.done = true
  666. } else if (this.engin == 'rh') {
  667. var url = {
  668. id: res.data.id,
  669. type: 'image',
  670. url: res.data.imgs_file[0],
  671. }
  672. that.swiperList.push(url)
  673. console.log("this.engin == 'rh'====", res.data.imgs_file, that.swiperList);
  674. this.done = true
  675. // this.commonqrcodePath()
  676. }
  677. console.log('获取到的图片详情返回值:', res);
  678. this.showdrawing = false
  679. this.parameter = res.data
  680. //this.parameter.prompt =
  681. //'https://mjcdn.iduomi.cc/attachments/1124768570157564029/1129053571321712670/erinramirez_In_a_Chinese_ancient_garden_a_lady_is_playing_the_t_cff28ad6-6f7e-44f0-a7bb-2a8724e573f2.png 关键词测试测'
  682. // this.parameter.prompt = '123'
  683. if (this.parameter.prompt.includes('http') && this.parameter.prompt.includes('.png')) {
  684. this.parameter.refImg = this.parameter.prompt.split('.png')[0] + '.png'
  685. // 创作相似去参考图提示词
  686. let tempKeyWord = ''
  687. this.parameter.prompt.split('.png').forEach((item, index) => {
  688. if (!item.includes('http')) {
  689. tempKeyWord += item
  690. }
  691. })
  692. this.parameter.promptSame = tempKeyWord
  693. this.parameter.prompt = tempKeyWord
  694. } else if (this.parameter.prompt.includes('http') && this.parameter.prompt.includes(
  695. '.jpeg')) {
  696. this.parameter.refImg = this.parameter.prompt.split('.jpeg')[0] + '.jpeg'
  697. // 创作相似去参考图提示词
  698. let tempKeyWord = ''
  699. this.parameter.prompt.split('.jpeg').forEach((item, index) => {
  700. if (!item.includes('http')) {
  701. tempKeyWord += item
  702. }
  703. })
  704. this.parameter.promptSame = tempKeyWord
  705. this.parameter.prompt = tempKeyWord
  706. } else if (this.parameter.prompt.includes('http') && this.parameter.prompt.includes(
  707. '.jpg')) {
  708. this.parameter.refImg = this.parameter.prompt.split('.jpg')[0] + '.jpg'
  709. // 创作相似去参考图提示词
  710. let tempKeyWord = ''
  711. this.parameter.prompt.split('.jpg').forEach((item, index) => {
  712. if (!item.includes('http')) {
  713. tempKeyWord += item
  714. }
  715. })
  716. this.parameter.promptSame = tempKeyWord
  717. this.parameter.prompt = tempKeyWord
  718. } else {
  719. this.parameter.promptSame = this.parameter.prompt
  720. }
  721. console.log('进入这里了没有', this.parameter.promptSame);
  722. } else {
  723. }
  724. });
  725. },
  726. aiPlay() {
  727. let that = this;
  728. this.showdrawing = true
  729. if (that.failnum == 0) {
  730. this.progressbar()
  731. }
  732. this.$http('gallery.create', this.form).then(res => {
  733. if (res.code == 0) {
  734. this.showTask(res.data.id)
  735. } else {
  736. uni.hideToast()
  737. uni.showModal({
  738. confirmText: '退出',
  739. showCancel: false,
  740. confirmColor: '#207CF7',
  741. title: '提示',
  742. content: res.msg,
  743. success(tit) {
  744. if (tit.confirm) {
  745. uni.navigateBack()
  746. }
  747. }
  748. })
  749. }
  750. });
  751. },
  752. progressbar() {
  753. var that = this;
  754. if (that.percentage < 99) {
  755. timingr = setTimeout(() => {
  756. that.percentage = uni.$u.range(0, 99, that.percentage + 1)
  757. that.progressbar()
  758. }, 300);
  759. } else {
  760. clearTimeout(timingr);
  761. }
  762. },
  763. showTask(id) {
  764. let that = this;
  765. this.$http('gallery.getOpensdDetail', {
  766. id: id,
  767. }).then(res => {
  768. if (res.code == 0) {
  769. if (res.data.state == "success") {
  770. this.percentage = 99
  771. this.drawingtitle = '图片正在渲染中,请不要退出此页面'
  772. this.parameterid = res.data.id
  773. this.done = true
  774. clearTimeout(asynchronous);
  775. var url = {
  776. id: 0,
  777. type: 'image',
  778. url: res.data.gen_img,
  779. }
  780. that.swiperList.push(url)
  781. } else if (res.data.state == "in_create") {
  782. asynchronous = setTimeout(() => {
  783. that.showTask(id)
  784. }, 1000);
  785. return;
  786. } else if (res.data.state == "in_wait") {
  787. asynchronous = setTimeout(() => {
  788. that.showTask(id)
  789. }, 1000);
  790. return;
  791. } else {
  792. uni.showModal({
  793. confirmText: '退出',
  794. showCancel: false,
  795. confirmColor: '#207CF7',
  796. title: '提示',
  797. content: res.msg,
  798. success(tit) {
  799. if (tit.confirm) {
  800. uni.navigateBack()
  801. }
  802. }
  803. })
  804. }
  805. } else {
  806. uni.showModal({
  807. confirmText: '退出',
  808. showCancel: false,
  809. confirmColor: '#207CF7',
  810. title: '提示',
  811. content: res.msg,
  812. success(tit) {
  813. if (tit.confirm) {
  814. uni.navigateBack()
  815. }
  816. }
  817. })
  818. }
  819. })
  820. },
  821. previewload() {
  822. // console.log('ch');
  823. this.showdrawing = false
  824. this.percentage = 0
  825. },
  826. previewerror() {
  827. this.showdrawing = false
  828. this.percentage = 0
  829. },
  830. preview(e) {
  831. uni.previewImage({
  832. urls: [e]
  833. })
  834. },
  835. is_weixin() {
  836. var ua = window.navigator.userAgent.toLowerCase();
  837. if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  838. console.log('微信浏览器');
  839. return true;
  840. } else {
  841. console.log("不是微信浏览器");
  842. return false;
  843. }
  844. },
  845. //下载分享
  846. getdownload(index) {
  847. if (this.showdrawing) {
  848. uni.showToast({
  849. title: '图片生成中',
  850. icon: 'none'
  851. })
  852. return;
  853. }
  854. // if (!this.is_weixin()) {
  855. // return uni.showModal({
  856. // showCancel: false,
  857. // title: '提示',
  858. // content: '请在微信内置浏览器打开,长按图片下载/分享',
  859. // confirmColor: '#207CF7'
  860. // })
  861. // }
  862. this.createPoster()
  863. return
  864. uni.showModal({
  865. showCancel: false,
  866. title: '提示',
  867. content: '请在微信内置浏览器打开,长按图片下载/分享',
  868. confirmColor: '#207CF7'
  869. })
  870. return
  871. if (this.engin == 'mj') {
  872. uni.showModal({
  873. showCancel: false,
  874. title: '提示',
  875. content: '请在微信内置浏览器打开,长按图片下载/分享',
  876. confirmColor: '#207CF7'
  877. })
  878. return
  879. }
  880. console.log('要下载的图片地址:', this.parameter.imgs_file[index]);
  881. let url = this.parameter.imgs_file[index]
  882. // return
  883. const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
  884. .test(
  885. navigator.userAgent) ? false : true;
  886. if (this.is_weixin()) {
  887. uni.showModal({
  888. showCancel: false,
  889. title: '提示',
  890. content: '请在微信内置浏览器打开,长按图片下载/分享',
  891. confirmColor: '#207CF7'
  892. })
  893. } else {
  894. if (detectDeviceType()) {
  895. let _this = this
  896. // if (_this.isDowload) {
  897. // uni.showToast({
  898. // icon: 'none',
  899. // title: '请等待上一个视频下载完成后,再下载',
  900. // });
  901. // }
  902. // PC端
  903. // this.delItem.url = 'http://www.liwantao.top/test.mp4'
  904. const downloadTask = uni.downloadFile({
  905. url, //文件链接
  906. timeout: 99999999,
  907. success: (res) => {
  908. if (res.statusCode === 200) {
  909. var oA = document.createElement("a");
  910. // oA.download = _this.delItem.name; // 设置下载的文件名,默认是'下载'
  911. oA.href = res.tempFilePath; //临时路径再保存到本地
  912. document.body.appendChild(oA);
  913. oA.click();
  914. oA.remove(); // 下载之后把创建的元素删除
  915. }
  916. },
  917. fail: (err) => {
  918. _this.show = false;
  919. _this.isDowload = false
  920. _this.progress = 0
  921. // console.log(_this.show, _this.isDowload, _this.progress, err);
  922. uni.showToast({
  923. icon: 'none',
  924. mask: true,
  925. title: '失败请重新下载',
  926. });
  927. },
  928. })
  929. downloadTask.onProgressUpdate((res) => {
  930. if (res.progress > 0) {
  931. _this.show = true;
  932. _this.isDowload = true
  933. }
  934. _this.progress = res.progress;
  935. if (res.progress == 100) {
  936. _this.show = false;
  937. _this.isDowload = false
  938. _this.progress = 0
  939. uni.showToast({
  940. icon: 'success',
  941. title: '图片下载成功!',
  942. });
  943. }
  944. })
  945. } else {
  946. uni.showModal({
  947. showCancel: false,
  948. title: '提示',
  949. content: '请在微信内置浏览器打开,长按图片下载/分享',
  950. confirmColor: '#207CF7'
  951. })
  952. return
  953. // 其他移动端浏览器
  954. // window.open(this.delItem.url)
  955. let _this = this
  956. // this.delItem.url = 'http://www.liwantao.top/test.mp4'
  957. var oA = document.createElement("a");
  958. // oA.download = _this.delItem.name;
  959. oA.href = url;
  960. document.body.appendChild(oA);
  961. oA.click();
  962. oA.remove();
  963. }
  964. }
  965. },
  966. getisback() {
  967. if (!this.done) {
  968. uni.showModal({
  969. confirmColor: '#207CF7',
  970. confirmText: '立即退出',
  971. title: '提示',
  972. content: '图片生成中,退出此页面后可能无法生成',
  973. success(src) {
  974. if (src.confirm) {
  975. uni.navigateBack()
  976. }
  977. }
  978. })
  979. } else {
  980. uni.navigateBack()
  981. }
  982. },
  983. // 跳转
  984. tn(e) {
  985. // console.log(e);
  986. uni.navigateTo({
  987. url: e,
  988. });
  989. },
  990. // cardSwiper
  991. cardSwiper(e) {
  992. // console.log(e.detail);
  993. this.cardCur = e.detail.current
  994. },
  995. // 弹出压屏窗
  996. showLandscape() {
  997. this.openLandscape()
  998. },
  999. // 打开压屏窗
  1000. openLandscape() {
  1001. this.show1 = true
  1002. },
  1003. // 关闭压屏窗
  1004. closeLandscape() {
  1005. this.show1 = false
  1006. },
  1007. },
  1008. onUnload() {
  1009. clearTimeout(timingr);
  1010. clearTimeout(asynchronous);
  1011. },
  1012. }
  1013. </script>
  1014. <style lang="scss" scoped>
  1015. // .shareBox {
  1016. // position: fixed;
  1017. // top: 0;
  1018. // left: 0;
  1019. // height: 100vh;
  1020. // width: 100vw;
  1021. // background: red;
  1022. // z-index: 9999999;
  1023. // }
  1024. .template-details {
  1025. margin: 0;
  1026. width: 100%;
  1027. height: 100vh;
  1028. color: #fff;
  1029. overflow: hidden;
  1030. }
  1031. /* 胶囊*/
  1032. .tn-custom-nav-bar__back {
  1033. width: 100%;
  1034. height: 100%;
  1035. position: relative;
  1036. display: flex;
  1037. justify-content: space-evenly;
  1038. align-items: center;
  1039. box-sizing: border-box;
  1040. background-color: rgba(0, 0, 0, 0.15);
  1041. border-radius: 1000rpx;
  1042. border: 1rpx solid rgba(255, 255, 255, 0.5);
  1043. color: #FFFFFF;
  1044. font-size: 18px;
  1045. .icon {
  1046. display: block;
  1047. flex: 1;
  1048. margin: auto;
  1049. text-align: center;
  1050. }
  1051. &:before {
  1052. content: " ";
  1053. width: 1rpx;
  1054. height: 110%;
  1055. position: absolute;
  1056. top: 22.5%;
  1057. left: 0;
  1058. right: 0;
  1059. margin: auto;
  1060. transform: scale(0.5);
  1061. transform-origin: 0 0;
  1062. pointer-events: none;
  1063. box-sizing: border-box;
  1064. opacity: 0.7;
  1065. background-color: #FFFFFF;
  1066. }
  1067. }
  1068. /* 图标容器15 start */
  1069. .icon15 {
  1070. &__item {
  1071. width: 30%;
  1072. border-radius: 10rpx;
  1073. padding: 30rpx;
  1074. margin: 20rpx 10rpx;
  1075. transform: scale(1);
  1076. transition: transform 0.3s linear;
  1077. transform-origin: center center;
  1078. &--icon {
  1079. width: 100rpx;
  1080. height: 100rpx;
  1081. font-size: 50rpx;
  1082. border-radius: 50%;
  1083. margin-bottom: 18rpx;
  1084. position: relative;
  1085. z-index: 1;
  1086. &::after {
  1087. content: " ";
  1088. position: absolute;
  1089. z-index: -1;
  1090. width: 100%;
  1091. height: 100%;
  1092. left: 0;
  1093. bottom: 0;
  1094. border-radius: inherit;
  1095. opacity: 1;
  1096. transform: scale(1, 1);
  1097. background-size: 100% 100%;
  1098. }
  1099. }
  1100. }
  1101. }
  1102. /* 按钮 */
  1103. .button-1 {
  1104. background-color: rgba(0, 0, 0, 0.15);
  1105. position: fixed;
  1106. /* bottom:200rpx;
  1107. right: 20rpx; */
  1108. top: 25%;
  1109. right: 30rpx;
  1110. z-index: 1001;
  1111. border-radius: 100px;
  1112. }
  1113. .button-2 {
  1114. background-color: rgba(0, 0, 0, 0.15);
  1115. position: fixed;
  1116. /* bottom:200rpx;
  1117. right: 20rpx; */
  1118. top: 35%;
  1119. right: 30rpx;
  1120. z-index: 1001;
  1121. border-radius: 100px;
  1122. }
  1123. .button-3 {
  1124. background-color: rgba(0, 0, 0, 0.15);
  1125. position: fixed;
  1126. /* bottom:200rpx;
  1127. right: 20rpx; */
  1128. top: 45%;
  1129. right: 30rpx;
  1130. z-index: 1001;
  1131. border-radius: 100px;
  1132. }
  1133. /* 用户头像 start */
  1134. .logo-image {
  1135. width: 100rpx;
  1136. height: 100rpx;
  1137. position: relative;
  1138. }
  1139. .logo-pic {
  1140. background-size: cover;
  1141. background-repeat: no-repeat;
  1142. // background-attachment:fixed;
  1143. background-position: top;
  1144. border: 6rpx solid rgba(255, 255, 255, 0.25);
  1145. box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
  1146. border-radius: 50%;
  1147. overflow: hidden;
  1148. // background-color: #FFFFFF;
  1149. }
  1150. /* 底部tabbar start*/
  1151. /* 毛玻璃*/
  1152. .dd-glass {
  1153. width: 100%;
  1154. backdrop-filter: blur(20rpx);
  1155. -webkit-backdrop-filter: blur(20rpx);
  1156. }
  1157. .footerfixed {
  1158. position: fixed;
  1159. // margin: 20rpx;
  1160. margin: 40rpx 5%;
  1161. width: 90%;
  1162. bottom: calc(env(safe-area-inset-bottom) / 2);
  1163. ;
  1164. z-index: 999;
  1165. background-color: rgba(0, 0, 0, 0.15);
  1166. box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
  1167. }
  1168. .tabbar {
  1169. display: flex;
  1170. align-items: center;
  1171. min-height: 110rpx;
  1172. justify-content: space-between;
  1173. padding: 0;
  1174. height: calc(110rpx + env(safe-area-inset-bottom) / 2);
  1175. // padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  1176. }
  1177. .tabbar .action {
  1178. font-size: 22rpx;
  1179. position: relative;
  1180. flex: 1;
  1181. text-align: center;
  1182. padding: 0;
  1183. display: block;
  1184. height: auto;
  1185. line-height: 1;
  1186. margin: 0;
  1187. overflow: initial;
  1188. }
  1189. .tabbar .action .bar-icon {
  1190. width: 100rpx;
  1191. position: relative;
  1192. display: block;
  1193. height: auto;
  1194. margin: 0 auto 10rpx;
  1195. text-align: center;
  1196. font-size: 42rpx;
  1197. }
  1198. .tabbar .action .bar-icon image {
  1199. width: 50rpx;
  1200. height: 50rpx;
  1201. display: inline-block;
  1202. }
  1203. /* 全屏轮播 start*/
  1204. .card-swiper {
  1205. height: 100vh !important;
  1206. }
  1207. .card-swiper swiper-item {
  1208. width: 750rpx !important;
  1209. left: 0rpx;
  1210. box-sizing: border-box;
  1211. overflow: initial;
  1212. background: #000;
  1213. }
  1214. .card-swiper swiper-item .swiper-item {
  1215. // width: 100%;
  1216. // display: block;
  1217. // height: 100vh;
  1218. // border-radius: 0rpx;
  1219. // transform: scale(0.9);
  1220. // transition: all 0.2s ease-in 0s;
  1221. // will-change: transform;
  1222. // overflow: hidden;
  1223. display: flex;
  1224. align-items: center;
  1225. justify-content: center;
  1226. height: 100%;
  1227. background: #000;
  1228. }
  1229. .card-swiper swiper-item.cur .swiper-item {
  1230. transform: scale(1);
  1231. transition: all 0.2s ease-in 0s;
  1232. will-change: transform;
  1233. }
  1234. .image-banner {
  1235. display: flex;
  1236. align-items: center;
  1237. justify-content: center;
  1238. }
  1239. .image-banner image {
  1240. width: 100%;
  1241. // height: 100%;
  1242. }
  1243. /* 轮播指示点 start*/
  1244. .indication {
  1245. z-index: 9999;
  1246. width: 100%;
  1247. height: 36rpx;
  1248. position: fixed;
  1249. display: flex;
  1250. flex-direction: row;
  1251. align-items: center;
  1252. justify-content: center;
  1253. }
  1254. .spot {
  1255. background-color: #FFFFFF;
  1256. opacity: 0.6;
  1257. width: 10rpx;
  1258. height: 10rpx;
  1259. border-radius: 20rpx;
  1260. top: calc(-280rpx - env(safe-area-inset-bottom) / 2);
  1261. top: calc(-280rpx - constant(safe-area-inset-bottom));
  1262. margin: 0 8rpx !important;
  1263. position: relative;
  1264. }
  1265. .spot.active {
  1266. opacity: 1;
  1267. width: 30rpx;
  1268. background-color: #FFFFFF;
  1269. }
  1270. .lazy-load {
  1271. background: #000;
  1272. display: grid;
  1273. align-items: center;
  1274. padding-bottom: env(safe-area-inset-bottom);
  1275. // height: 100%;
  1276. }
  1277. .lazy-load view {
  1278. width: 100%;
  1279. }
  1280. .lazy-loading {
  1281. background: #000;
  1282. height: 100%;
  1283. }
  1284. .drawing {
  1285. position: absolute;
  1286. top: 46%;
  1287. // color: #606266;
  1288. font-size: 18px;
  1289. }
  1290. .progress {
  1291. position: absolute;
  1292. top: 52%;
  1293. width: 60%;
  1294. }
  1295. .preloader_1 {
  1296. position: absolute;
  1297. // right: 8%;
  1298. // bottom: 12%;
  1299. // position: fixed;
  1300. // right: 58%;
  1301. margin-right: 65px;
  1302. top: 42%;
  1303. }
  1304. .preloader_1 view {
  1305. display: block;
  1306. bottom: 0px;
  1307. width: 9px;
  1308. height: 5px;
  1309. background: #9b59b6;
  1310. position: absolute;
  1311. animation: preloader_1 1.5s infinite ease-in-out;
  1312. }
  1313. .preloader_1 view:nth-child(2) {
  1314. left: 11px;
  1315. animation-delay: .2s;
  1316. }
  1317. .preloader_1 view:nth-child(3) {
  1318. left: 22px;
  1319. animation-delay: .4s;
  1320. }
  1321. .preloader_1 view:nth-child(4) {
  1322. left: 33px;
  1323. animation-delay: .6s;
  1324. }
  1325. .preloader_1 view:nth-child(5) {
  1326. left: 44px;
  1327. animation-delay: .8s;
  1328. }
  1329. @keyframes preloader_1 {
  1330. 0% {
  1331. height: 5px;
  1332. transform: translateY(0px);
  1333. background: #9b59b6;
  1334. }
  1335. 25% {
  1336. height: 30px;
  1337. transform: translateY(15px);
  1338. background: #3498db;
  1339. }
  1340. 50% {
  1341. height: 5px;
  1342. transform: translateY(0px);
  1343. background: #9b59b6;
  1344. }
  1345. 100% {
  1346. height: 5px;
  1347. transform: translateY(0px);
  1348. background: #9b59b6;
  1349. }
  1350. }
  1351. </style>