details1.vue 34 KB

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