index.jsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. import { Component } from 'react'
  2. import { View, Text, Button, Image, Swiper, SwiperItem, scrollView, Input, Textarea } from '@tarojs/components'
  3. import * as api from '../../../service/index'
  4. import tool from '../../../common/tool'
  5. import TaroCanvasDrawer from '../../../component/taro-plugin-canvas';
  6. import Taro, { getCurrentInstance } from '@tarojs/taro'
  7. import './index.less'
  8. export default class collection extends Component {
  9. $instance = getCurrentInstance()
  10. state = {
  11. // consultImg: 'https://video-h5.fyshark.com/1680752646217.png',
  12. value: '牛渚江头夜色寒,渡口月华如钩弯。孤帆远影千里外,独钓寂寥万重山。',//绘画描述
  13. changeValue: '',//转义文本
  14. imageList: [
  15. ],//作品列表
  16. tmplIds: [],//订阅列表
  17. qrCodeImg: '',
  18. img_size: '1:1',
  19. // 绘图配置文件
  20. config: null,
  21. interval: null,//画画轮训
  22. intervalText: null,//诗词转义轮训
  23. // 绘制的图片
  24. shareImage: null,
  25. // TaroCanvasDrawer 组件状态
  26. canvasStatus: false,
  27. isFill: false,//是否画海报
  28. current: 0,//当前选择的作品
  29. draw_status: 2,//2:已完成
  30. lastTime: 0,
  31. jumpurl: '',//广告id
  32. que_cnt: 0,
  33. task_id: 0,
  34. repeat: 0,//广告次数
  35. }
  36. componentWillMount () {
  37. setTimeout(() => {
  38. this.getWxCodeImg()
  39. }, 1000)
  40. }
  41. componentDidShow () {
  42. this.getWxTemplate()
  43. this.getCoinTaskAd()
  44. }
  45. getCoinTaskAd () {
  46. api.getCoinTaskAd().then(res => {
  47. if (res.code == 200) {
  48. this.setState({
  49. jumpurl: res.data[0].jumpurl,//广告id
  50. task_id: res.data[0].id,//任务id
  51. repeat: res.data[0].repeat
  52. })
  53. }
  54. })
  55. }
  56. getWxCodeImg () {
  57. api.getWxCodeImg({ code_from: 'bill' }).then(res => {
  58. this.dataURLtoFile(res.data)
  59. })
  60. }
  61. //base64转本地路径
  62. dataURLtoFile (dataurl) {
  63. let that = this
  64. /// 获取到base64Data
  65. var base64Data = dataurl;
  66. /// 通过微信小程序自带方法将base64转为二进制去除特殊符号,再转回base64
  67. base64Data = Taro.arrayBufferToBase64(Taro.base64ToArrayBuffer(base64Data));
  68. /// 拼接请求头,data格式可以为image/png或者image/jpeg等,看需求
  69. const base64ImgUrl = "data:image/png;base64," + base64Data;
  70. const base64ImgData = base64ImgUrl.replace(/^data:image\/\w+;base64,/, '');
  71. const buffer = new ArrayBuffer(base64ImgData.length);
  72. const view = new Uint8Array(buffer);
  73. for (let i = 0; i < base64ImgData.length; i++) {
  74. view[i] = base64ImgData.charCodeAt(i);
  75. }
  76. const fileStream = Taro.base64ToArrayBuffer(base64ImgData);
  77. const filePath = Taro.env.USER_DATA_PATH + '/test.png';
  78. Taro.getFileSystemManager().writeFile({
  79. filePath: filePath,
  80. data: fileStream,
  81. encoding: 'binary',
  82. success: function (res) {
  83. console.log('writeFile success:', res, filePath);
  84. that.setState({
  85. qrCodeImg: filePath
  86. }, () => {
  87. })
  88. },
  89. fail: function (res) {
  90. console.log('保存失败')
  91. }
  92. })
  93. /// 刷新数据
  94. return base64ImgUrl;
  95. }
  96. playVideoAll () {
  97. // let lastTime = this.state.lastTime;
  98. // let now = new Date().getTime();
  99. // if (now - lastTime < 2000) return
  100. // this.setState({
  101. // lastTime: now
  102. // })
  103. let params = {
  104. jumpurl: this.state.jumpurl,
  105. id: this.state.task_id
  106. }
  107. if (process.env.TARO_ENV == 'tt') {
  108. this.playVideoTT(params)
  109. } else {
  110. this.playVideo(params)
  111. }
  112. }
  113. //抖音激励广告
  114. playVideoTT (item) {
  115. const videoAd = tt.createRewardedVideoAd({ adUnitId: item.jumpurl });
  116. Taro.showLoading({
  117. title: '加载中...',
  118. })
  119. videoAd.show()
  120. videoAd.onError((err) => {
  121. Taro.hideLoading()
  122. switch (err.errCode) {
  123. case 1004:
  124. // 无合适的广告
  125. break;
  126. default:
  127. // 更多请参考错误码文档
  128. }
  129. });
  130. try {
  131. if (videoAd.closeHandler) {
  132. videoAd.offClose(videoAd.closeHandler);
  133. console.log("videoAd.offClose卸载成功");
  134. }
  135. } catch (e) {
  136. console.log("videoAd.offClose 卸载失败");
  137. console.error(e);
  138. }
  139. videoAd.closeHandler = function (data) {
  140. Taro.hideLoading()
  141. if (data.isEnded) {
  142. api.finishTask({ task_id: item.id }).then(res => {
  143. if (res.code == 200) {
  144. that.getUserInfo()
  145. that.getCoinTaskList()
  146. Taro.showToast({
  147. title: '领取点券成功',
  148. icon: 'none',
  149. duration: 2000
  150. })
  151. }
  152. })
  153. } else {
  154. Taro.showToast({
  155. title: '领取点券失败',
  156. icon: 'none',
  157. duration: 2000
  158. })
  159. }
  160. }
  161. // 监听视频播放完成
  162. videoAd.onClose(videoAd.closeHandler);
  163. }
  164. //微信激励广告
  165. playVideo (item) {
  166. // 在页面中定义激励视频广告
  167. let adUnitId = item.jumpurl
  168. // 在页面中定义激励视频广告
  169. let videoAd = null
  170. let that = this
  171. console.log(videoAd, 'videoAd');
  172. // 在页面onLoad回调事件中创建激励视频广告实例
  173. if (wx.createRewardedVideoAd) {
  174. videoAd = wx.createRewardedVideoAd({
  175. adUnitId: adUnitId
  176. })
  177. videoAd.onLoad(() => { })
  178. videoAd.onError((err) => { })
  179. try {
  180. if (videoAd.closeHandler) {
  181. videoAd.offClose(videoAd.closeHandler);
  182. console.log("videoAd.offClose卸载成功");
  183. }
  184. } catch (e) {
  185. console.log("videoAd.offClose 卸载失败");
  186. console.error(e);
  187. }
  188. videoAd.closeHandler = function (res) {
  189. // 用户点击了【关闭广告】按钮
  190. if (res && res.isEnded || res === undefined) {
  191. // 正常播放结束,可以下发游戏奖励
  192. api.finishTask({ task_id: item.id }).then(res => {
  193. if (res.code == 200) {
  194. that.getUserInfo()
  195. that.getCoinTaskList()
  196. Taro.showToast({
  197. title: '领取点券成功',
  198. icon: 'none',
  199. duration: 2000
  200. })
  201. }
  202. })
  203. } else {
  204. //提前关闭小程序
  205. }
  206. };
  207. videoAd.onClose(videoAd.closeHandler);
  208. }
  209. // 用户触发广告后,显示激励视频广告
  210. if (videoAd) {
  211. videoAd.show().catch(() => {
  212. // 失败重试
  213. videoAd.load()
  214. .then(() => videoAd.show())
  215. .catch(err => {
  216. Taro.showToast({
  217. title: '暂无广告',
  218. icon: 'none',
  219. duration: 2000
  220. })
  221. console.log('激励视频 广告显示失败')
  222. })
  223. })
  224. }
  225. }
  226. download () {
  227. Taro.showLoading({
  228. title: '加载中...'
  229. })
  230. this.downImg()
  231. }
  232. // 鉴权操作 判断是否有保存到相册的权限
  233. // 有就直接下载 没有就弹窗提示给权限
  234. downImg () {
  235. Taro.getSetting({
  236. success: res => {
  237. if (!res.authSetting['scope.writePhotosAlbum']) {
  238. Taro.authorize({
  239. scope: 'scope.writePhotosAlbum',
  240. success: () => {
  241. this.doSaveImg()
  242. },
  243. fail: () => {
  244. this.openConfirm()
  245. }
  246. })
  247. } else {
  248. this.doSaveImg()
  249. }
  250. }
  251. })
  252. }
  253. // 生成临时路径 保存图片到手机
  254. doSaveImg () {
  255. Taro.hideLoading();
  256. Taro.downloadFile({
  257. url: this.state.imageList[this.state.current].img,
  258. success: res => {
  259. Taro.saveImageToPhotosAlbum({
  260. filePath: res.tempFilePath,
  261. success: () => {
  262. Taro.showToast({ title: '已保存到相册', icon: 'success' })
  263. },
  264. fail: () => {
  265. Taro.showToast({ title: '保存失败', icon: 'none' })
  266. }
  267. })
  268. }
  269. })
  270. }
  271. // 权限弹窗
  272. openConfirm () {
  273. Taro.hideLoading();
  274. Taro.showModal({
  275. content: '检测到您没有打开小程序相册权限,是否取设置打开?',
  276. showCancel: true,
  277. success: res => {
  278. if (res.confirm) {
  279. // 打开权限
  280. Taro.openSetting({
  281. success: res => {
  282. this.doSaveImg()
  283. }
  284. })
  285. }
  286. }
  287. })
  288. }
  289. // 调用绘画 => canvasStatus 置为true、同时设置config
  290. canvasDrawFunc () {
  291. let sizeList = this.state.img_size.split(":")
  292. console.log(sizeList, 375 * sizeList[1] / sizeList[0]);
  293. let rssConfig = {
  294. width: 345,
  295. height: 314 * sizeList[1] / sizeList[0] + 69 + 112,
  296. backgroundColor: 'rgba(255,255,255,0.1)',
  297. debug: false,
  298. pixelRatio: 3,
  299. blocks: [
  300. {
  301. x: 0,
  302. y: 0,
  303. width: 345,
  304. height: 314 * sizeList[1] / sizeList[0] + 69 + 112,
  305. paddingLeft: 0,
  306. paddingRight: 0,
  307. borderWidth: 0,
  308. // borderColor: '#ccc',
  309. backgroundColor: '#FFFFFF',
  310. borderRadius: 0,
  311. zIndex: 1,
  312. },
  313. ],
  314. images: [
  315. {
  316. url: 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1679561342726.png',
  317. width: 154,
  318. height: 21,
  319. x: 16,
  320. y: 19,
  321. borderRadius: 12,
  322. zIndex: 8,
  323. },
  324. {
  325. url: 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1679561346368.png',
  326. width: 65,
  327. height: 4,
  328. x: 261,
  329. y: 28,
  330. borderRadius: 12,
  331. zIndex: 8,
  332. },
  333. {
  334. url: this.state.imageList[this.state.current].img,
  335. width: 314,
  336. height: 314 * sizeList[1] / sizeList[0],
  337. x: 16,
  338. y: 69,
  339. borderRadius: 12,
  340. zIndex: 11,
  341. },
  342. {
  343. url: this.state.qrCodeImg,
  344. width: 72,
  345. height: 72,
  346. x: 258,
  347. y: 314 * sizeList[1] / sizeList[0] + 69 + 20,
  348. borderRadius: 12,
  349. zIndex: 12,
  350. },
  351. ],
  352. texts: [
  353. {
  354. x: 20,
  355. y: 314 * sizeList[1] / sizeList[0] + 69 + 35,
  356. text: this.state.value,
  357. fontSize: 14,
  358. color: '#000',
  359. opacity: 1,
  360. fontFamily: 'PingFang SC',
  361. baseLine: 'middle',
  362. lineHeight: 22,
  363. lineNum: 3,
  364. textAlign: 'left',
  365. width: 200,
  366. zIndex: 999,
  367. },
  368. ]
  369. }
  370. console.log('回执');
  371. this.setState({
  372. config: rssConfig,
  373. }, () => {
  374. this.setState({
  375. isFill: true
  376. })
  377. })
  378. Taro.showLoading({
  379. title: '加载中...'
  380. })
  381. }
  382. // 绘制成功回调函数 (必须实现)=> 接收绘制结果、重置 TaroCanvasDrawer 状态
  383. onCreateSuccess = (result) => {
  384. console.log('成功', result);
  385. const { tempFilePath, errMsg } = result;
  386. Taro.hideLoading();
  387. if (errMsg === 'canvasToTempFilePath:ok') {
  388. this.setState({
  389. shareImage: tempFilePath,
  390. // 重置 TaroCanvasDrawer 状态,方便下一次调用
  391. isFill: false,
  392. config: {}
  393. }, () => {
  394. Taro.showShareImageMenu({
  395. path: tempFilePath
  396. })
  397. })
  398. //画图成功之后打开分享
  399. // Taro.downloadFile({
  400. // url: tempFilePath,
  401. // success: (res) => {
  402. // console.log('打开分享');
  403. // Taro.showShareImageMenu({
  404. // path: res.tempFilePath
  405. // })
  406. // }
  407. // })
  408. } else {
  409. // 重置 TaroCanvasDrawer 状态,方便下一次调用
  410. this.setState({
  411. isFill: false,
  412. config: {}
  413. })
  414. Taro.showToast({ icon: 'none', title: errMsg || '出现错误' });
  415. console.log(errMsg);
  416. }
  417. // 预览
  418. // Taro.previewImage({
  419. // current: tempFilePath,
  420. // urls: [tempFilePath]
  421. // })
  422. }
  423. // 绘制失败回调函数 (必须实现)=> 接收绘制错误信息、重置 TaroCanvasDrawer 状态
  424. onCreateFail = (error) => {
  425. console.log('失败');
  426. Taro.hideLoading();
  427. // 重置 TaroCanvasDrawer 状态,方便下一次调用
  428. this.setState({
  429. isFill: false,
  430. config: {}
  431. })
  432. console.log(error);
  433. }
  434. openFill () {
  435. this.canvasDrawFunc()
  436. }
  437. getRadomPrompt () {
  438. api.getRadomPoetry().then(res => {
  439. if (res.code == 200) {
  440. this.setState({
  441. value: res.data.prompt,
  442. })
  443. document.getElementById('textarea-num').innerHTML = res.data.prompt.length + "/1000";
  444. }
  445. })
  446. }
  447. deleteDrawText () {
  448. setTimeout(() => {
  449. this.setState({
  450. value: ''
  451. })
  452. document.getElementById('textarea-num').innerHTML = 0 + "/1000";
  453. }, 200)
  454. }
  455. onInput (e) {
  456. var num = e.detail.cursor;
  457. document.getElementById('textarea-num').innerHTML = num + "/1000";
  458. }
  459. onChangeInput (e) {
  460. // var num = e.detail.cursor;
  461. // document.getElementById('textarea-change-num').innerHTML = num + "/1000";
  462. }
  463. onBlur (e) {
  464. console.log('onBlur');
  465. this.setState({
  466. value: e.detail.value
  467. })
  468. }
  469. onChangeBlur (e) {
  470. this.setState({
  471. changeValue: e.detail.value
  472. })
  473. }
  474. selectModel (item, index) {
  475. this.setState({
  476. current: index
  477. })
  478. }
  479. getWxTemplate () {
  480. api.getWxTemplate().then(res => {
  481. let tmplIds = []
  482. res.data.forEach(item => {
  483. tmplIds.push(item.template_id)
  484. })
  485. this.setState({
  486. tmplIds: tmplIds
  487. })
  488. })
  489. }
  490. //订阅
  491. subscribe (task_id) {
  492. let that = this
  493. console.log('订阅', this.state.tmplIds);
  494. Taro.requestSubscribeMessage({
  495. tmplIds: this.state.tmplIds,
  496. success: function (item) {
  497. console.log('订阅成功');
  498. if (item.errMsg === 'requestSubscribeMessage:ok') {
  499. let keys = Object.keys(item);
  500. let tempids = [];
  501. keys.forEach(element => {
  502. if (item[element] == "accept") {
  503. tempids.push(element)
  504. }
  505. });
  506. console.log(tempids, 'tempidstempids');
  507. let pramas = {
  508. task_id: task_id,
  509. template_ids: tempids
  510. }
  511. api.subscribeTemplate(pramas)
  512. }
  513. Taro.showToast({
  514. title: '已订阅',
  515. icon: 'none',
  516. duration: 2000
  517. })
  518. },
  519. complete: function (res) {
  520. },
  521. fail: function (res) {
  522. }
  523. })
  524. }
  525. aiPoetryDraw () {
  526. console.log('画画');
  527. Taro.showLoading({
  528. title: '加载中...'
  529. })
  530. if (this.state.draw_status != 2) {
  531. Taro.hideLoading()
  532. Taro.showToast({
  533. title: `正在绘画中请稍后...`,
  534. icon: 'none',
  535. });
  536. return
  537. }
  538. let that = this
  539. setTimeout(() => {
  540. console.log('画画2');
  541. this.setState({
  542. draw_status: 0
  543. }, () => {
  544. api.aiPoetryDraw({ prompt: this.state.value }).then(res => {
  545. if (res.code == 200) {
  546. if (process.env.TARO_ENV == 'weapp') {
  547. this.subscribe(res.data.task_id)
  548. }
  549. this.getDrawTaskStatus(res.data.task_id)
  550. this.getDrawPromptText(res.data.task_id)
  551. } else {
  552. Taro.hideLoading()
  553. if (res.code == 4001) {
  554. that.setState({
  555. draw_status: 2
  556. })
  557. Taro.showModal({
  558. title: '您的余额不足',
  559. content: '是否前往获取点券?',
  560. success: function (res) {
  561. if (res.confirm) {
  562. Taro.navigateTo({
  563. url: `/moduleA/pages/earnPoints/index`
  564. })
  565. } else if (res.cancel) {
  566. console.log('用户点击取消')
  567. }
  568. },
  569. })
  570. } if (res.code == 4002) {
  571. that.setState({
  572. draw_status: 2
  573. })
  574. Taro.showModal({
  575. title: '提示',
  576. content: res.msg,
  577. success: function (item) {
  578. if (item.confirm) {
  579. if (process.env.TARO_ENV != 'weapp') {
  580. that.playVideoTT(res.data)
  581. } else {
  582. that.playVideo(res.data)
  583. }
  584. } else if (item.cancel) {
  585. console.log('用户点击取消')
  586. }
  587. }
  588. })
  589. } else {
  590. Taro.showToast({ icon: 'none', title: res.msg })
  591. }
  592. }
  593. })
  594. })
  595. }, 1000)
  596. }
  597. getDrawPromptText (task_id) {
  598. console.log('1111');
  599. api.getDrawPromptText({ task_id: task_id }).then(res => {
  600. if (res.code == 200) {
  601. if (res.data.status == 3) {
  602. this.state.intervalText = setInterval(() => {
  603. clearInterval(this.state.intervalText)
  604. this.getDrawPromptText(task_id)
  605. }, 500 * 1)
  606. this.setState({
  607. changeValue: res.data.prompt,
  608. })
  609. // document.getElementById('textarea-change-num').innerHTML = res.data.prompt.length + "/1000";
  610. } else {
  611. this.setState({
  612. changeValue: res.data.prompt,
  613. })
  614. // document.getElementById('textarea-change-num').innerHTML = res.data.prompt.length + "/1000";
  615. clearInterval(this.state.intervalText)
  616. }
  617. }
  618. })
  619. }
  620. getDrawTaskStatus (task_id) {
  621. api.getDrawTaskStatus({ task_id: task_id }).then(res => {
  622. Taro.hideLoading();
  623. //定时器不要轻易改,避免造成服务器攻击
  624. if (res.code == 200) {
  625. let draw_infos = res.data.draw_infos
  626. if (res.data.draw_status != 2) {
  627. let params = {}
  628. params['img'] = res.data.default_img
  629. params['id'] = -1
  630. draw_infos.push(params)
  631. }
  632. if (res.data.draw_status != 2 && res.data.que_cnt > 1) {
  633. this.state.interval = setInterval(() => {
  634. clearInterval(this.state.interval)
  635. this.getDrawTaskStatus(task_id)
  636. }, 1000 * 30)
  637. } else if (res.data.draw_status != 2 && res.data.que_cnt <= 1) {
  638. clearInterval(this.state.interval)
  639. this.state.interval = setInterval(() => {
  640. this.getDrawTaskStatus(task_id)
  641. }, 1000 * 5)
  642. } else {
  643. clearInterval(this.state.interval)
  644. }
  645. this.setState({
  646. imageList: draw_infos,
  647. draw_status: res.data.draw_status,
  648. que_cnt: res.data.que_cnt,
  649. img_size: res.data.draw_data.img_size
  650. })
  651. }
  652. })
  653. }
  654. onShareAppMessage = (res) => {
  655. let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
  656. if (process.env.TARO_ENV == 'tt') {
  657. path = `/moduleB/pages/comic/index?c=channel_name&s=neibuguazai`
  658. }
  659. let shareData = {
  660. title: tool.shareTitle,
  661. path: path,
  662. imageUrl: tool.shareImg
  663. }
  664. return shareData;
  665. }
  666. changeCurrent (e) {
  667. this.setState({
  668. current: e.detail.current
  669. })
  670. console.log(e, 'eeee');
  671. }
  672. selectModel (item, index) {
  673. this.setState({
  674. current: index
  675. })
  676. }
  677. componentWillUnmount () {
  678. //避免服务器攻击
  679. clearInterval(this.state.interval)
  680. clearInterval(this.state.intervalText)
  681. }
  682. render () {
  683. return (
  684. <View className='mine'>
  685. <View className='draw-content'>
  686. <View className='draw-title'>绘画描述</View>
  687. <View className='draw-text'>
  688. <View className='draw-content-func'>
  689. <View className='recommend'>
  690. <View className='recommend-text' onClick={e => (this.getRadomPrompt())}>使用推荐诗词</View>
  691. <Image className='recommend-img' src='http://video-img.fyshark.com/1681193671211redo%402x.png'></Image>
  692. </View>
  693. <View className='delete-draw-text' onClick={e => (this.deleteDrawText())}>清空</View>
  694. </View>
  695. <Textarea
  696. value={this.state.value}
  697. className='draw-taxtarea'
  698. placeholder='| 请输入相关描述,也可以输入关键词~'
  699. showCount
  700. onInput={e => (this.onInput(e))}
  701. onBlur={e => (this.onBlur(e))}
  702. maxlength='1000' />
  703. <View className='textarea-num' id='textarea-num'>{this.state.value.length}/1000</View>
  704. <View className='generate'>
  705. <View className='generate-button' onClick={e => (this.aiPoetryDraw())}>生成图片(消耗8点券)</View>
  706. </View>
  707. </View>
  708. {
  709. this.state.imageList.length > 0 &&
  710. <View>
  711. <View className='draw-title'>作品展示</View>
  712. <View className='result-content'>
  713. <View className='draw-text'>
  714. <Textarea
  715. value={this.state.changeValue}
  716. className='draw-taxtarea'
  717. placeholder='诗词解读中...'
  718. showCount
  719. disabled
  720. onInput={e => (this.onChangeInput(e))}
  721. onBlur={e => (this.onChangeBlur(e))}
  722. maxlength='1000' />
  723. {/* <View className='textarea-change-num' id='textarea-change-num'>{this.state.changeValue.length}/1000</View> */}
  724. </View>
  725. <View className='banner-content'>
  726. <Swiper
  727. className='banner'
  728. indicatorColor='#121D34'
  729. indicatorActiveColor='#0F84EC'
  730. circular
  731. current={this.state.current}
  732. adjustHeight='first'
  733. onChange={e => (this.changeCurrent(e))}
  734. >
  735. {
  736. this.state.imageList.map((item, index) => (
  737. <SwiperItem key={index}>
  738. <View className='banner-info'>
  739. <Image className='banner-image' mode='aspectFit' src={item.img} onClick={e => (this.previewImage(item, index))}></Image>
  740. </View>
  741. {
  742. this.state.draw_status != 2 && item.id == -1 &&
  743. <View className='banner-tips'>
  744. <View className='tips-left'>
  745. 预计等待{Math.ceil((this.state.que_cnt - 1) * 0.2 + 1)}分钟...
  746. </View>
  747. {
  748. this.state.repeat <= 10 && this.state.jumpurl.length > 0 &&
  749. <View className='tips-right' onClick={e => (tool.throttle(this.playVideoAll(), 2000))}>
  750. 点击观看广告领取积分
  751. </View>
  752. }
  753. </View>
  754. }
  755. </SwiperItem>
  756. ))
  757. }
  758. </Swiper>
  759. <View className='banner-indicatorDots'>
  760. {
  761. this.state.imageList.map((item, index) => (
  762. <View className='indicatorDots-info'
  763. key={index}
  764. style={this.state.current == index ? ' border: 2px solid #0F84EC;' : 'border: 2px solid rgba(2, 2, 2, 0.75);'}
  765. onClick={e => (this.selectModel(item, index))}
  766. >
  767. <Image className='indicatorDots-img' src={item.img}></Image>
  768. </View>
  769. ))
  770. }
  771. </View>
  772. </View>
  773. {
  774. this.state.draw_status == 2 &&
  775. < View className='func'>
  776. <View className='func-list'>
  777. {
  778. this.state.qrCodeImg.length > 0 && process.env.TARO_ENV != 'tt' &&
  779. <View className='func-info' onClick={e => (this.openFill())}>
  780. <Image className='func-image' src='https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1678952396973.png'></Image>
  781. <View>分享</View>
  782. </View>
  783. }
  784. <View className='func-info' onClick={e => (this.download())}>
  785. <Image className='func-image' src='https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1678952411029.png'></Image>
  786. <View>下载</View>
  787. </View>
  788. </View>
  789. </View>
  790. }
  791. </View>
  792. </View>
  793. }
  794. </View>
  795. {
  796. this.state.isFill &&
  797. <TaroCanvasDrawer
  798. config={this.state.config} // 绘制配置
  799. onCreateSuccess={e => (this.onCreateSuccess(e))} // 绘制成功回调
  800. onCreateFail={e => (this.onCreateFail(e))} // 绘制失败回调
  801. />
  802. }
  803. </View >
  804. )
  805. }
  806. }