Bläddra i källkod

更改人物动漫化

黎海 1 år sedan
förälder
incheckning
f50868ab84
41 ändrade filer med 3851 tillägg och 684 borttagningar
  1. 19 1
      app_list.json
  2. 1 1
      config/index.js
  3. 1184 402
      package-lock.json
  4. 4 3
      package.json
  5. 27 0
      private/private.wxcf756553cfb65cb8.key
  6. 5 3
      project.tt.json
  7. 4 2
      src/app.config.js
  8. 3 3
      src/app.js
  9. 26 3
      src/common/tool.js
  10. 6 2
      src/moduleA/pages/communityDetail/index.jsx
  11. 0 0
      src/moduleA/pages/darwDetailIndex/index.config.js
  12. 86 53
      src/moduleA/pages/darwDetail/index.jsx
  13. 6 1
      src/moduleA/pages/darwDetail/index.less
  14. 134 52
      src/moduleA/pages/earnPoints/index.jsx
  15. 5 1
      src/moduleA/pages/invite/index.jsx
  16. 5 1
      src/moduleA/pages/shareCnt/index.jsx
  17. 5 1
      src/moduleA/pages/upload/index.jsx
  18. 6 2
      src/moduleA/pages/wallet/index.jsx
  19. 264 43
      src/moduleB/pages/comic/index.jsx
  20. 130 76
      src/moduleB/pages/comic/index.less
  21. 5 0
      src/moduleB/pages/comicDetail/index.config.js
  22. 378 0
      src/moduleB/pages/comicDetail/index.jsx
  23. 168 0
      src/moduleB/pages/comicDetail/index.less
  24. 40 6
      src/moduleB/pages/faceChanging/index.jsx
  25. 12 1
      src/moduleB/pages/faceChanging/index.less
  26. 1 1
      src/moduleB/pages/works/index.config.js
  27. 6 2
      src/moduleB/pages/works/index.jsx
  28. 0 0
      src/moduleB/pages/imageWorks/index.less
  29. 5 2
      src/moduleB/pages/like/index.jsx
  30. 5 0
      src/moduleB/pages/poetry/index.config.js
  31. 817 0
      src/moduleB/pages/poetry/index.jsx
  32. 218 0
      src/moduleB/pages/poetry/index.less
  33. 5 1
      src/moduleB/pages/point/index.jsx
  34. 5 1
      src/moduleB/pages/real/index.jsx
  35. 5 1
      src/moduleB/pages/realDetail/index.jsx
  36. 5 1
      src/pages/activity/index.jsx
  37. 2 2
      src/pages/collection/index.jsx
  38. 181 10
      src/pages/index/index.jsx
  39. 7 2
      src/pages/index/index.less
  40. 8 3
      src/pages/mine/index.jsx
  41. 58 1
      src/service/index.js

+ 19 - 1
app_list.json

@@ -1,7 +1,7 @@
1 1
 {
2 2
   "taroConfig": {
3 3
     "version": "1.3.3",
4
-    "desc": "添加广告"
4
+    "desc": "更改人物动漫化"
5 5
   },
6 6
   "app_list": [
7 7
     {
@@ -9,6 +9,24 @@
9 9
       "description": "AI绘画练习生",
10 10
       "appid": "wxcf756553cfb65cb8",
11 11
       "path_name": "project.config.json"
12
+    },
13
+    {
14
+      "projectname": "AI绘画实用工具",
15
+      "description": "AI绘画实用工具",
16
+      "appid": "tt93fde5400cc2d78401",
17
+      "path_name": "project.tt.json"
18
+    },
19
+    {
20
+      "projectname": "AI绘画练习生",
21
+      "description": "AI绘画练习生",
22
+      "appid": "tt8534f3891a0bf12e01",
23
+      "path_name": "project.tt.json"
24
+    },
25
+    {
26
+      "projectname": "AI绘画未来派",
27
+      "description": "AI绘画未来派",
28
+      "appid": "tta3fed5433cc1e78401",
29
+      "path_name": "project.tt.json"
12 30
     }
13 31
   ]
14 32
 }

+ 1 - 1
config/index.js

@@ -8,7 +8,7 @@ const CIPluginOpt = {
8 8
   },
9 9
   // 字节跳动小程序
10 10
   tt: {
11
-    email: "lh243434798981008@163.com",
11
+    email: "func@fys1001.onexmail.com",
12 12
     password: "lihai1243434798"
13 13
   },
14 14
 }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1184 - 402
package-lock.json


+ 4 - 3
package.json

@@ -58,7 +58,8 @@
58 58
         "postcss": "^8.2.1",
59 59
         "react": "^18.0.0",
60 60
         "react-dom": "^18.0.0",
61
-        "taro-cropper": "^1.2.3"
61
+        "taro-cropper": "^1.2.3",
62
+        "tt-ide-cli": "^0.1.15"
62 63
     },
63 64
     "devDependencies": {
64 65
         "@babel/core": "^7.8.0",
@@ -81,6 +82,6 @@
81 82
     },
82 83
     "taroConfig": {
83 84
         "version": "1.3.3",
84
-        "desc": "添加广告"
85
+        "desc": "更改人物动漫化"
85 86
     }
86
-}
87
+}

+ 27 - 0
private/private.wxcf756553cfb65cb8.key

@@ -0,0 +1,27 @@
1
+-----BEGIN RSA PRIVATE KEY-----
2
+MIIEpAIBAAKCAQEAtiXHmMyLeuv8l313XejSM01sTFJVU6clTXVA1qrCXjIway1z
3
+nnLW5P4get8lb2Uixojsot6Xy+b9Q+A95eCiuTDbTRtwonnP1pgxlzblkYjouGxg
4
+FNJ9ZkSTBBb4hF4Faskr3GglVt+4fLaxN2ey40op2okZ7FNRy8RT0hwpK1Aunf3n
5
+C4U+ChmSwbBT90CybPVjvcfeYbf4p25/BWa8yVogHnbzk4FhOSRYkuBhceZcjUlX
6
+6yBV3OzejtxGqy8aCD7JLOrmUeBF7wvKeapv9hvvGlZ5p4/BY9HAYf+iHGPh781/
7
+Vvww3sz6CGCz7tRjJ9YLWfzgsMydE6xJUxz0KQIDAQABAoIBAAEiSxPQci3ZukDX
8
+Lx8OjAB1wu7WtGFI8RqCWFz9wygC9/oy1j1uSZgzXNBnAzymTIkf4RlCeX9zeLAr
9
+fTcpJtowS603NoRMbdbQK77dQKCfUZOUWSTICq/QTXoBCpsIWtBHYFaG73SS//sG
10
+yCOoKZzwoUITCG5INoImPr9YHYl/e5bpKDZQ/E03md1+jyNCKOsS7TxK/5m/lXqM
11
+2hy6afFCaZgbFMf1i/8A5baXDSmLysTZNBw8zjeRw97h7vcsnbtpyHk1beVE3Zc6
12
+mbaytpcdT0BX6wLHDrpIvDvpiTwHnR19ay71oKGZweLxtFBgwjLpOe70jbe4sRVq
13
+5ImL1AECgYEA7ytsnPhoNkMQgbAH/suB1mZQHnGC1Kotx+BzQZoJsQYKXK2ujhIT
14
+1NCl25IFFWSiUWRvbRnctz9iRf4cgQr6/tKeKd3O5SxH53bb14VhYEjmP2lcQHEP
15
+eMSJJa+L9CYJG5MyCU7zt7LW4EG+5Q0EoEv1AewNmQeQ0XmqPM7fvFECgYEAwvce
16
+Y4DLEvHDXi+CSf3BQidezVEkejCFp+ioADFO0j4RvNdC0gd/JSkwPBHyCmwKHtYL
17
+gwLitPfnz1/uTHXMorhxAdLvY9iRjhix3g+gGJGqKaJwluTjuzs6eanP0qB9MZdA
18
+r4UDteQwJeJ/IuirAc+w0hmM+a9AT0w4Cbs5vFkCgYEAqOtDj+4GNGTTcLUyQGvd
19
+bN7gMVA8dhUntma5IJk5xRSeFuz4PxFXflRLADQ2cPCdj9zesfC1KZuTvhmGakGm
20
+GnoJCUrGiKfotPsGtEZZCxcRv7GbXUw9AC/XKY29zBddEWO50Ec57QFbsBHfUIkM
21
+PmbHSa89v1pPlxNWABKghLECgYBEhs1UlgFKsFVF9pbp4NoboXDt45ZZqFJiGSFr
22
+p+kXdp+Pa23eGqpy6k483uXfCehovD0hmFMM3pHIzuQYVdNOYlu+E2D3DDjk5AMo
23
+lP9lg1V2+tRuBReSSJgeCTS1yJkYZBxlVPBf70uJFVowb+0jXte8kSR+4j1NYfHU
24
+Yc1CSQKBgQCtJidMaU0+iN56nuGtOIgV/UwhhZ/v1d1ylJUcwYhB3BCCgq8oi6Rs
25
+ucFkuPlAcOodDaSj+jysSgh7mMYoBTfYPhWvehalw2yWKe9HuwcscVlw2nrx3uaR
26
+VSCO4/R1/rJ1oHcXvMdusqPH66iwkT2PPvg+NNlDpXnOu1LSyHwEIw==
27
+-----END RSA PRIVATE KEY-----

+ 5 - 3
project.tt.json

@@ -1,10 +1,12 @@
1 1
 {
2 2
     "miniprogramRoot": "./",
3
-    "projectname": "AI绘画练习生",
4
-    "appid": "tt8534f3891a0bf12e01",
3
+    "projectname": "AI绘画未来派",
4
+    "appid": "tta3fed5433cc1e78401",
5 5
     "setting": {
6
+        "urlCheck": true,
6 7
         "es6": false,
8
+        "postcss": false,
7 9
         "minified": false
8 10
     },
9
-    "description": "AI绘画练习生"
11
+    "description": "AI绘画未来派"
10 12
 }

+ 4 - 2
src/app.config.js

@@ -16,7 +16,7 @@ export default defineAppConfig({
16 16
         "pages/wallet/index",
17 17
         "pages/shareCnt/index",
18 18
         "pages/upload/index",//图片裁剪页面
19
-        "pages/darwDetail/index",
19
+        "pages/darwDetailIndex/index",//图片作品页面
20 20
         "pages/communityDetail/index",
21 21
         "pages/earnPoints/index",
22 22
       ]
@@ -25,9 +25,11 @@ export default defineAppConfig({
25 25
       root: "moduleB",
26 26
       name: "分包B",
27 27
       pages: [
28
-        "pages/works/index",//我的作品
28
+        "pages/imageWorks/index",//图画作品
29 29
         "pages/like/index",//我的喜欢
30 30
         "pages/comic/index",//人物动漫画
31
+        "pages/comicDetail/index",//人物动漫画详情页
32
+        "pages/poetry/index",//诗词绘画
31 33
         "pages/faceChanging/index",//AI换脸
32 34
         "pages/point/index",//新手指引
33 35
         "pages/real/index",//资讯

+ 3 - 3
src/app.js

@@ -9,13 +9,13 @@ class App extends Component {
9 9
   componentDidMount () { }
10 10
 
11 11
   componentDidShow () {
12
+  
13
+  }
14
+  onLaunch () {
12 15
     console.log('app启动');
13 16
     if (!Taro.getStorageSync('session_key')) {
14 17
       tool.toLogin();
15 18
     }
16
-  }
17
-  onLaunch () {
18
-
19 19
     // 保持屏幕常亮
20 20
     Taro.setKeepScreenOn({
21 21
       keepScreenOn: true

+ 26 - 3
src/common/tool.js

@@ -1,8 +1,8 @@
1 1
 import Taro from '@tarojs/taro'
2 2
 import * as api from '../service/index'
3 3
 const tool = {
4
-  shareTitle:'一款属于自己的AI绘画小程序,快来创作属于自己的独家作品吧。',
5
-  shareImg:'http://video-img.fyshark.com/1680599995457%E5%88%86%E4%BA%AB%E5%9B%BE%20200-200.png',
4
+  shareTitle: '一款属于自己的AI绘画小程序,快来创作属于自己的独家作品吧。',
5
+  shareImg: 'http://video-img.fyshark.com/1680599995457%E5%88%86%E4%BA%AB%E5%9B%BE%20200-200.png',
6 6
   //去登录
7 7
   toLogin: function (rescallback = () => { }) {
8 8
     Taro.login({
@@ -10,6 +10,7 @@ const tool = {
10 10
         let params = {
11 11
           code: res.code,
12 12
         }
13
+        console.log(res.code,'res.code');
13 14
         if (res.code) {
14 15
           api.login(params).then(item => {
15 16
             Taro.setStorage({
@@ -43,6 +44,7 @@ const tool = {
43 44
         }
44 45
       }
45 46
     })
47
+    console.log(is_ios, 'is_ios');
46 48
     return is_ios;
47 49
   },
48 50
   //判断是否为安卓
@@ -79,6 +81,27 @@ const tool = {
79 81
       return value.slice(0, lmit) + '...'
80 82
     }
81 83
     return value
82
-  }
84
+  },
85
+
86
+  //简化版js节流,默认2s内只能点击一次
87
+  throttle: function (fn, wait = 2000) {
88
+    let timer = null;
89
+    let lastTime = 0;
90
+
91
+    return function (...args) {
92
+      const now = +new Date();
93
+
94
+      if (now - lastTime > wait) {
95
+        lastTime = now;
96
+        fn.apply(this, args);
97
+      } else {
98
+        clearTimeout(timer);
99
+        timer = setTimeout(() => {
100
+          lastTime = now;
101
+          fn.apply(this, args);
102
+        }, wait - (now - lastTime));
103
+      }
104
+    };
105
+  },
83 106
 }
84 107
 export default tool

+ 6 - 2
src/moduleA/pages/communityDetail/index.jsx

@@ -37,9 +37,13 @@ export default class Task extends Component {
37 37
     })
38 38
   }
39 39
   onShareAppMessage = (res) => {
40
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
41
+    if (process.env.TARO_ENV == 'tt') {
42
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
43
+    }
40 44
     let shareData = {
41 45
       title: tool.shareTitle,
42
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
46
+      path: path,
43 47
       imageUrl: tool.shareImg
44 48
     }
45 49
     return shareData;
@@ -351,7 +355,7 @@ export default class Task extends Component {
351 355
     })
352 356
   }
353 357
   copyPromptAI () {
354
-    Taro.reLaunch({
358
+    Taro.navigateTo({
355 359
       url: `/moduleB/pages/faceChanging/index?img=${this.state.img_info.img}`
356 360
     })
357 361
   }

src/moduleA/pages/darwDetail/index.config.js → src/moduleA/pages/darwDetailIndex/index.config.js


+ 86 - 53
src/moduleA/pages/darwDetail/index.jsx

@@ -31,6 +31,8 @@ export default class Task extends Component {
31 31
     jumpurl: '',//广告id
32 32
     task_id: 0,//任务id
33 33
     repeat: 0,//广告次数
34
+    dy_ad: {
35
+    },//抖音广告id
34 36
   }
35 37
 
36 38
   componentDidShow () {
@@ -60,9 +62,13 @@ export default class Task extends Component {
60 62
     })
61 63
   }
62 64
   onShareAppMessage = (res) => {
65
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
66
+    if (process.env.TARO_ENV == 'tt') {
67
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
68
+    }
63 69
     let shareData = {
64 70
       title: tool.shareTitle,
65
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
71
+      path: path,
66 72
       imageUrl: tool.shareImg
67 73
     }
68 74
     return shareData;
@@ -119,6 +125,7 @@ export default class Task extends Component {
119 125
         console.log(draw_infos, 'draw_infos');
120 126
         if (res.data.draw_status != 2 && res.data.que_cnt > 1) {
121 127
           this.state.interval = setInterval(() => {
128
+            clearInterval(this.state.interval)
122 129
             this.getDrawTaskStatus()
123 130
           }, 1000 * 30)
124 131
         } else if (res.data.draw_status != 2 && res.data.que_cnt <= 1) {
@@ -143,6 +150,7 @@ export default class Task extends Component {
143 150
           que_cnt: res.data.que_cnt,
144 151
           draw_infos: draw_infos,
145 152
           current: _current,
153
+          dy_ad: res.data.dy_ad,
146 154
           model_info: res.data.model_info,
147 155
           style_info: res.data.style_info
148 156
         })
@@ -150,17 +158,6 @@ export default class Task extends Component {
150 158
     })
151 159
   }
152 160
   download () {
153
-    // Taro.downloadFile({
154
-    //   url: this.state.draw_infos[0].img, //仅为示例,并非真实的资源
155
-    //   success: function (res) {
156
-    //     // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
157
-    //     if (res.statusCode === 200) {
158
-    //       Taro.playVoice({
159
-    //         filePath: res.tempFilePath
160
-    //       })
161
-    //     }
162
-    //   }
163
-    // })
164 161
     this.downImg()
165 162
   }
166 163
   // 鉴权操作 判断是否有保存到相册的权限
@@ -227,7 +224,7 @@ export default class Task extends Component {
227 224
     })
228 225
   }
229 226
   copyPromptAI () {
230
-    Taro.reLaunch({
227
+    Taro.navigateTo({
231 228
       url: `/moduleB/pages/faceChanging/index?img=${this.state.draw_infos[this.state.current].img}`
232 229
     })
233 230
   }
@@ -325,32 +322,6 @@ export default class Task extends Component {
325 322
           zIndex: 12,
326 323
         },
327 324
       ],
328
-      // texts: [
329
-      //   {
330
-      //     x: 170,
331
-      //     y: 314 * sizeList[1] / sizeList[0] + 69 + 34,
332
-      //     text: '长按扫码',
333
-      //     fontSize: 16,
334
-      //     color: '#333333',
335
-      //     opacity: 1,
336
-      //     baseLine: 'middle',
337
-      //     lineHeight: 22,
338
-      //     textAlign: 'right',
339
-      //     zIndex: 10,
340
-      //   },
341
-      //   {
342
-      //     x: 91,
343
-      //     y: 314 * sizeList[1] / sizeList[0] + 69 + 56,
344
-      //     text: '体验AI人工智能绘画',
345
-      //     fontSize: 16,
346
-      //     color: '#333333',
347
-      //     opacity: 1,
348
-      //     baseLine: 'middle',
349
-      //     lineHeight: 22,
350
-      //     textAlign: 'right',
351
-      //     zIndex: 10,
352
-      //   },
353
-      // ],
354 325
     }
355 326
     console.log('回执');
356 327
     this.setState({
@@ -433,14 +404,56 @@ export default class Task extends Component {
433 404
       });
434 405
     }
435 406
   }
436
-  //激励广告
437 407
   playVideo () {
438
-    let lastTime = this.state.lastTime;
439
-    let now = new Date().getTime();
440
-    if (now - lastTime < 2000) return
441
-    this.setState({
442
-      lastTime: now
408
+    if (process.env.TARO_ENV == 'tt') {
409
+      this.playVideoTT()
410
+    } else {
411
+      this.playVideoWeapp()
412
+    }
413
+  }
414
+  //抖音激励广告
415
+  playVideoTT () {
416
+    let that = this
417
+    Taro.showLoading({
418
+      title: '加载中...',
443 419
     })
420
+    const videoAd = tt.createRewardedVideoAd({ adUnitId: this.state.jumpurl });
421
+    videoAd.show()
422
+    videoAd.onError((err) => {
423
+      Taro.hideLoading()
424
+      switch (err.errCode) {
425
+        case 1004:
426
+          // 无合适的广告
427
+          break;
428
+        default:
429
+        // 更多请参考错误码文档
430
+      }
431
+    });
432
+    // 监听视频播放完成
433
+    videoAd.onClose((data) => {
434
+      Taro.hideLoading()
435
+      if (data.isEnded) {
436
+        api.finishTask({ task_id: that.state.task_id }).then(res => {
437
+          if (res.code == 200) {
438
+            that.getCoinTaskAd()
439
+            Taro.showToast({
440
+              title: '点券+4',
441
+              icon: 'none',
442
+              duration: 2000
443
+            })
444
+          }
445
+        })
446
+      } else {
447
+        Taro.showToast({
448
+          title: '领取点券失败',
449
+          icon: 'none',
450
+          duration: 2000
451
+        })
452
+      }
453
+    });
454
+  }
455
+  //激励广告
456
+  playVideoWeapp () {
444 457
     // 在页面中定义激励视频广告
445 458
     let adUnitId = this.state.jumpurl
446 459
     // 在页面中定义激励视频广告
@@ -513,6 +526,15 @@ export default class Task extends Component {
513 526
     })
514 527
     console.log(e, 'eeee');
515 528
   }
529
+  bindload (e) {
530
+    console.log(e, 'bindload');
531
+  }
532
+  binderror (e) {
533
+    console.log(e, 'binderror');
534
+  }
535
+  bindclose (e) {
536
+    console.log(e, 'bindclose');
537
+  }
516 538
 
517 539
 
518 540
   render () {
@@ -541,8 +563,8 @@ export default class Task extends Component {
541 563
                       预计等待{Math.ceil((this.state.que_cnt - 1) * 0.2 + 1)}分钟...
542 564
                     </View>
543 565
                     {
544
-                      this.state.repeat <= 10 && process.env.TARO_ENV != 'tt' &&
545
-                      <View className='tips-right' onClick={e => (this.playVideo())}>
566
+                      this.state.repeat <= 10 && this.state.jumpurl.length > 0 &&
567
+                      < View className='tips-right' onClick={e => (tool.throttle(this.playVideo(), 2000))}>
546 568
                         点击观看广告领取积分
547 569
                       </View>
548 570
                     }
@@ -552,6 +574,21 @@ export default class Task extends Component {
552 574
             ))
553 575
           }
554 576
         </Swiper>
577
+        {
578
+          process.env.TARO_ENV == 'tt' && this.state.dy_ad.status && this.state.dy_ad.status == 1 &&
579
+          <View className='ad-video'>
580
+            <ad
581
+              unit-id={this.state.dy_ad.ad_id}
582
+              ad-intervals="30"
583
+              bindload={e => (this.bindload(e))}
584
+              binderror={e => (this.binderror(e))}
585
+              bindclose={e => (this.bindclose(e))}
586
+              fixed="{{fixed}}"
587
+              type="{{type}}"
588
+              scale="{{scale}}"
589
+            />
590
+          </View>
591
+        }
555 592
         <View className='content'>
556 593
           <View className='draw-title'>绘画描述</View>
557 594
           <View className='draw-text'>
@@ -619,12 +656,8 @@ export default class Task extends Component {
619 656
           this.state.draw_status == 2 &&
620 657
           <View className='func'>
621 658
             <View className='func-list'>
622
-              {/* <View className='func-info'>
623
-              <Image className='func-image' src='https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1678952380367.png'></Image>
624
-              <View>发布</View>
625
-            </View> */}
626 659
               {
627
-                this.state.qrCodeImg.length > 0 &&
660
+                this.state.qrCodeImg.length > 0 && process.env.TARO_ENV != 'tt' &&
628 661
                 <View className='func-info' onClick={e => (this.openFill())}>
629 662
                   <Image className='func-image' src='https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1678952396973.png'></Image>
630 663
                   <View>分享</View>
@@ -645,7 +678,7 @@ export default class Task extends Component {
645 678
             onCreateFail={e => (this.onCreateFail(e))} // 绘制失败回调
646 679
           />
647 680
         }
648
-      </View>
681
+      </View >
649 682
     )
650 683
   }
651 684
 }

+ 6 - 1
src/moduleA/pages/darwDetail/index.less

@@ -7,6 +7,11 @@
7 7
     width: 750px;
8 8
     height: 750px;
9 9
     position: relative;
10
+    .ad-video{
11
+      margin-top: 10px;
12
+      width: 100%;
13
+      height: 800px;
14
+    }
10 15
 
11 16
     .banner-tips {
12 17
       font-family: PingFangSC-Regular;
@@ -33,7 +38,7 @@
33 38
 
34 39
       .banner-image {
35 40
         width: 100%;
36
-        min-height: 800px;
41
+        height: 800px;
37 42
       }
38 43
     }
39 44
   }

+ 134 - 52
src/moduleA/pages/earnPoints/index.jsx

@@ -16,22 +16,33 @@ export default class Task extends Component {
16 16
     isIos: false,
17 17
     lastTime: 0,
18 18
   }
19
-
19
+  componentDidMount() {
20
+    this.finishTask = tool.throttle(this.finishTask.bind(this), 2000);
21
+  }
20 22
   componentWillMount () {
21
-    if (tool.notAndroid()) {
22
-      this.setState({
23
-        isIos: true
24
-      })
25
-    }
23
+    let that = this
24
+    Taro.getSystemInfo({
25
+      success: function (res) {
26
+        if (res.platform != "android") {
27
+          that.setState({
28
+            isIos: true
29
+          })
30
+        }
31
+      }
32
+    })
26 33
     this.getCoinTaskList()
27 34
     this.getShopList()
28 35
     this.getUserInfo()
29
-   
36
+
30 37
   }
31 38
   onShareAppMessage = (res) => {
39
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
40
+    if (process.env.TARO_ENV == 'tt') {
41
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
42
+    }
32 43
     let shareData = {
33 44
       title: tool.shareTitle,
34
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
45
+      path: path,
35 46
       imageUrl: tool.shareImg
36 47
     }
37 48
     return shareData;
@@ -65,11 +76,15 @@ export default class Task extends Component {
65 76
       }
66 77
     })
67 78
   }
68
-  finishTask (item, index) {
79
+  finishTask (item,index) {
69 80
     if (item.status != 0) return
70 81
     if (item.btn_title == '观看') {
71 82
       console.log('观看');
72
-      this.playVideo(item)
83
+      if (process.env.TARO_ENV == 'tt') {
84
+        this.playVideoTT(item)
85
+      } else {
86
+        this.playVideo(item)
87
+      }
73 88
       return
74 89
     }
75 90
     if (item.btn_title == '去点赞') {
@@ -91,15 +106,48 @@ export default class Task extends Component {
91 106
       }
92 107
     })
93 108
   }
94
-  //激励广告
109
+  //抖音激励广告
110
+  playVideoTT (item) {
111
+    let that = this
112
+    tt.showLoading();
113
+    const videoAd = tt.createRewardedVideoAd({ adUnitId: item.jumpurl });
114
+    videoAd.show()
115
+    videoAd.onError((err) => {
116
+      tt.hideLoading();
117
+      switch (err.errCode) {
118
+        case 1004:
119
+          // 无合适的广告
120
+          break;
121
+        default:
122
+        // 更多请参考错误码文档
123
+      }
124
+    });
125
+    // 监听视频播放完成
126
+    videoAd.onClose((data) => {
127
+      tt.hideLoading();
128
+      if (data.isEnded) {
129
+        api.finishTask({ task_id: item.id }).then(res => {
130
+          if (res.code == 200) {
131
+            that.getUserInfo()
132
+            that.getCoinTaskList()
133
+            Taro.showToast({
134
+              title: '领取点券成功',
135
+              icon: 'none',
136
+              duration: 2000
137
+            })
138
+          }
139
+        })
140
+      } else {
141
+        Taro.showToast({
142
+          title: '领取点券失败',
143
+          icon: 'none',
144
+          duration: 2000
145
+        })
146
+      }
147
+    });
148
+  }
149
+  //微信激励广告
95 150
   playVideo (item) {
96
-    let lastTime = this.state.lastTime;
97
-    let now = new Date().getTime();
98
-    if (now - lastTime < 2000) return
99
-    console.log(item, 'itehndodjd');
100
-    this.setState({
101
-      lastTime: now
102
-    })
103 151
     // 在页面中定义激励视频广告
104 152
     let adUnitId = item.jumpurl
105 153
     // 在页面中定义激励视频广告
@@ -171,39 +219,70 @@ export default class Task extends Component {
171 219
   //充值
172 220
   toOrder (item, index) {
173 221
     let that = this
174
-    Taro.getSystemInfo({
175
-      success: function (res) {
176
-        Taro.showLoading({
177
-          title: '加载中...',
178
-        })
179
-        api.createOrder({ shop_id: item.id }).then(res => {
180
-          if (res.code == 200) {
181
-            Taro.hideLoading()
182
-            Taro.requestPayment({
183
-              timeStamp: res.data.timeStamp,
184
-              nonceStr: res.data.nonceStr,
185
-              package: res.data.package,
186
-              signType: res.data.signType,
187
-              paySign: res.data.paySign,
188
-              success: function (res) {
189
-                // console.log(res);
190
-                //添加2s延迟在刷新数据
222
+    if (process.env.TARO_ENV === 'tt') {
223
+      Taro.showLoading({
224
+        title: '加载中...',
225
+      })
226
+      api.ttCreateOrder({ pay_info_id: item.id }).then(res => {
227
+        if (res.code == 200) {
228
+          Taro.hideLoading()
229
+          tt.pay({
230
+            orderInfo: {
231
+              order_id: res.data.order_id,
232
+              order_token: res.data.order_token
233
+            },
234
+            service: 5,
235
+            success (item) {
236
+              if (item.code == 0) {
237
+                that.getUserInfo()
191 238
                 setTimeout(() => {
192 239
                   that.getUserInfo()
193 240
                 }, 2000);
194
-              },
195
-              fail: function (err) {
196
-                try {
197
-                  const res = Taro.getSystemInfoSync()
198
-                  console.log(res, 'iphone=====');
199
-                } catch (e) {
200
-                }
241
+                // 支付成功处理逻辑,只有res.code=0时,才表示支付成功
242
+                // 但是最终状态要以商户后端结果为准
201 243
               }
202
-            })
203
-          }
204
-        })
205
-      }
206
-    })
244
+            },
245
+            fail (item) {
246
+              // 调起收银台失败处理逻辑
247
+            },
248
+          });
249
+        }
250
+      })
251
+    } else if (process.env.TARO_ENV === 'weapp') {
252
+      Taro.getSystemInfo({
253
+        success: function (res) {
254
+          Taro.showLoading({
255
+            title: '加载中...',
256
+          })
257
+          api.createOrder({ shop_id: item.id }).then(res => {
258
+            if (res.code == 200) {
259
+              Taro.hideLoading()
260
+              Taro.requestPayment({
261
+                timeStamp: res.data.timeStamp,
262
+                nonceStr: res.data.nonceStr,
263
+                package: res.data.package,
264
+                signType: res.data.signType,
265
+                paySign: res.data.paySign,
266
+                success: function (res) {
267
+                  // console.log(res);
268
+                  //添加2s延迟在刷新数据
269
+                  setTimeout(() => {
270
+                    that.getUserInfo()
271
+                  }, 2000);
272
+                },
273
+                fail: function (err) {
274
+                  try {
275
+                    const res = Taro.getSystemInfoSync()
276
+                    console.log(res, 'iphone=====');
277
+                  } catch (e) {
278
+                  }
279
+                }
280
+              })
281
+            }
282
+          })
283
+        }
284
+      })
285
+    }
207 286
 
208 287
   }
209 288
   //会员充值
@@ -247,7 +326,6 @@ export default class Task extends Component {
247 326
     })
248 327
 
249 328
   }
250
-  componentDidMount () { }
251 329
   //页面销毁之前调用
252 330
   componentWillUnmount () {
253 331
     //避免服务器攻击
@@ -274,7 +352,11 @@ export default class Task extends Component {
274 352
                   <View className='register-title'><Image className='register-icon' src={item.img} ></Image> {item.title}</View>
275 353
                   <View className='register-tips'>{item.sub_title}</View>
276 354
                 </View>
277
-                <View className='register-right' style={item.status == 0 ? '' : 'background-image: linear-gradient(-45deg, #0c1419 0%, #3b3d3e 100%);opacity: 0.5;'} onClick={e => (this.finishTask(item, index))}>{item.btn_title}</View>
355
+                <View className='register-right'
356
+                  style={item.status == 0 ? '' : 'background-image: linear-gradient(-45deg, #0c1419 0%, #3b3d3e 100%);opacity: 0.5;'}
357
+                  onClick={e => (this.finishTask(item,index))}>
358
+                  {item.btn_title}
359
+                </View>
278 360
               </View>
279 361
             ))
280 362
           }
@@ -283,14 +365,14 @@ export default class Task extends Component {
283 365
             this.state.userInfo.p_user_id == 1 &&
284 366
             <View className='register'>
285 367
               <View className='register-left'>
286
-                <View className='register-title'><Image className='register-icon' src='http://video-img.fyshark.com/1680060033169%E5%88%86%E9%94%80.png' ></Image> 分销明细</View>
368
+                <View className='register-title'><Image className='register-icon' src='http://video-img.fyshark.com/1680060033169%E5%88%86%E9%94%80.png'></Image> 分销明细</View>
287 369
                 {/* <View className='register-tips'>{item.sub_title}</View> */}
288 370
               </View>
289 371
               <View className='register-right' onClick={e => (this.toShareCnt())}>查看</View>
290 372
             </View>
291 373
           }
292 374
           {
293
-            !this.state.isIos &&process.env.TARO_ENV!='tt'&&
375
+            !this.state.isIos &&
294 376
             < View >
295 377
               <View className='contact-title'>
296 378
                 点券充值
@@ -335,7 +417,7 @@ export default class Task extends Component {
335 417
             </View>
336 418
           }
337 419
           {
338
-            this.state.isIos &&process.env.TARO_ENV!='tt'&&
420
+            this.state.isIos &&
339 421
             <View className='ios-tips'>
340 422
               ios暂不支持充值
341 423
             </View>

+ 5 - 1
src/moduleA/pages/invite/index.jsx

@@ -37,9 +37,13 @@ export default class Task extends Component {
37 37
     })
38 38
   }
39 39
   onShareAppMessage = (res) => {
40
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
41
+    if (process.env.TARO_ENV == 'tt') {
42
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
43
+    }
40 44
     let shareData = {
41 45
       title: tool.shareTitle,
42
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
46
+      path: path,
43 47
       imageUrl: tool.shareImg
44 48
     }
45 49
     return shareData;

+ 5 - 1
src/moduleA/pages/shareCnt/index.jsx

@@ -34,9 +34,13 @@ export default class Mine extends Component {
34 34
     })
35 35
   }
36 36
   onShareAppMessage = (res) => {
37
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
38
+    if (process.env.TARO_ENV == 'tt') {
39
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
40
+    }
37 41
     let shareData = {
38 42
       title: tool.shareTitle,
39
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
43
+      path: path,
40 44
       imageUrl: tool.shareImg
41 45
     }
42 46
     return shareData;

+ 5 - 1
src/moduleA/pages/upload/index.jsx

@@ -57,9 +57,13 @@ export default class Mine extends Component {
57 57
     })
58 58
   }
59 59
   onShareAppMessage = (res) => {
60
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
61
+    if (process.env.TARO_ENV == 'tt') {
62
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
63
+    }
60 64
     let shareData = {
61 65
       title: tool.shareTitle,
62
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
66
+      path: path,
63 67
       imageUrl: tool.shareImg
64 68
     }
65 69
     return shareData;

+ 6 - 2
src/moduleA/pages/wallet/index.jsx

@@ -32,9 +32,13 @@ export default class Mine extends Component {
32 32
     })
33 33
   }
34 34
   onShareAppMessage = (res) => {
35
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
36
+    if (process.env.TARO_ENV == 'tt') {
37
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
38
+    }
35 39
     let shareData = {
36 40
       title: tool.shareTitle,
37
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
41
+      path: path,
38 42
       imageUrl: tool.shareImg
39 43
     }
40 44
     return shareData;
@@ -50,7 +54,7 @@ export default class Mine extends Component {
50 54
   }
51 55
   toBuyPage (e) {
52 56
     Taro.navigateTo({
53
-      url: `/pages/earnPoints/index`
57
+      url: `/moduleA/pages/earnPoints/index`
54 58
     })
55 59
   }
56 60
 

+ 264 - 43
src/moduleB/pages/comic/index.jsx

@@ -7,19 +7,28 @@ import './index.less'
7 7
 
8 8
 export default class collection extends Component {
9 9
   state = {
10
-    consultImg: 'http://video-img.fyshark.com/1680144082044%E7%BC%96%E7%BB%84.png',
10
+    consultImg: 'http://video-img.fyshark.com/1681721632520%E4%B8%8A.png',
11 11
     sizeIndex: 0,
12
-    mass:0,
13
-    isImage: false
12
+    mass: 0,
13
+    modelIndex: 0,
14
+    isImage: false,
15
+    creatInfo: {},
16
+    isOpen: false,
17
+    jumpurl: '',//广告id
18
+    task_id: 0,//任务id
19
+    repeat: 0,//广告次数
20
+    drawTaskId:0,//任务id
14 21
   }
15 22
 
16 23
   componentWillMount () {
24
+    this.getDrawGcImgIndex()
25
+    this.getCoinTaskAd()
17 26
   }
18 27
   componentDidShow () {
19 28
     //接收裁剪图片
20 29
     let pages = Taro.getCurrentPages();
21 30
     let currentPage = pages[pages.length - 1]; // 获取当前页面
22
-    console.log(currentPage,'currentPage');
31
+    console.log(currentPage, 'currentPage');
23 32
     if (process.env.TARO_ENV == 'weapp') {
24 33
       if (currentPage.__data__.consultImg) { // 获取值
25 34
         this.setState({
@@ -27,6 +36,7 @@ export default class collection extends Component {
27 36
           sizeIndex: currentPage.__data__.sizeIndex,
28 37
           isImage: true
29 38
         })
39
+        currentPage.__data__.consultImg = ''
30 40
       }
31 41
     } else if (process.env.TARO_ENV == 'tt') {
32 42
       if (currentPage.data.consultImg) { // 获取值
@@ -35,14 +45,51 @@ export default class collection extends Component {
35 45
           sizeIndex: currentPage.data.sizeIndex,
36 46
           isImage: true
37 47
         })
48
+        currentPage.data.consultImg = ''
38 49
       }
39 50
     }
40 51
   }
52
+  getCoinTaskAd () {
53
+    api.getCoinTaskAd().then(res => {
54
+      if (res.code == 200) {
55
+        this.setState({
56
+          jumpurl: res.data[0].jumpurl,//广告id
57
+          task_id: res.data[0].id,//任务id
58
+          repeat: res.data[0].repeat
59
+        })
60
+      }
61
+    })
62
+  }
63
+  getDrawGcImgIndex () {
64
+    api.getDrawGcImgIndex().then(res => {
65
+      if (res.code == 200) {
66
+        this.setState({
67
+          creatInfo: res.data
68
+        })
69
+      }
70
+    })
71
+  }
72
+  changeOpen () {
73
+    this.setState({
74
+      isOpen: !this.state.isOpen
75
+    })
76
+  }
77
+  updateButton () {
78
+    if (!this.state.isImage) {
79
+      this.upLode()
80
+    } else if (this.state.creatInfo.wallet_status == 0) {
81
+      this.playVideoGeneratePictures()
82
+    } else {
83
+      this.generatePictures()
84
+    }
85
+  }
86
+  //上传图片
41 87
   upLode () {
42 88
     let that = this
43 89
     Taro.chooseMedia({
44 90
       count: 1, // 默认
45 91
       sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
92
+      mediaType:['image'],
46 93
       sourceType: ['album', 'camera'],
47 94
       success: function (res) {
48 95
         console.log(res, 'res');
@@ -61,71 +108,245 @@ export default class collection extends Component {
61 108
       }
62 109
     })
63 110
   }
111
+  //画图
64 112
   generatePictures () {
65 113
     if (!this.state.isImage) {
66 114
       Taro.showToast({ title: '请先上传图片', icon: 'none' })
67 115
       return
68 116
     }
69
-    api.drawGcImg({ img_url: this.state.consultImg,img_type:this.state.mass }).then(res => {
117
+    api.drawGcImg({ img_url: this.state.consultImg, style_id: this.state.creatInfo.models[this.state.modelIndex].id }).then(res => {
70 118
       if (res.code == 200) {
71 119
         Taro.navigateTo({
72
-          url: `/moduleA/pages/darwDetail/index?task_id=${res.data.task_id}`
120
+          url: `/moduleB/pages/comicDetail/index?task_id=${res.data.task_id}`
73 121
         })
74
-      }else {
122
+      } else {
75 123
         Taro.hideLoading()
76
-        if (res.code == 4001) {
77
-          Taro.showModal({
78
-            title: '您的余额不足',
79
-            content: '是否前往获取点券?',
80
-            success: function (res) {
81
-              if (res.confirm) {
82
-                Taro.navigateTo({
83
-                  url: `/moduleA/pages/earnPoints/index`
84
-                })
85
-              } else if (res.cancel) {
86
-                console.log('用户点击取消')
87
-              }
88
-            }
124
+        Taro.showToast({ icon: 'none', title: res.msg })
125
+      }
126
+    })
127
+  }
128
+  //看广告画图
129
+  playVideoGeneratePictures () {
130
+    if (!this.state.isImage) {
131
+      Taro.showToast({ title: '请先上传图片', icon: 'none' })
132
+      return
133
+    }
134
+    api.drawGcImg({ img_url: this.state.consultImg, style_id: this.state.creatInfo.models[this.state.modelIndex].id }).then(res => {
135
+      if (res.code == 200) {
136
+        this.setState({
137
+          drawTaskId:res.data.task_id
138
+        },()=>{
139
+          this.playVideo()
140
+        })
141
+       
142
+      } else {
143
+        Taro.hideLoading()
144
+        Taro.showToast({ icon: 'none', title: res.msg })
145
+      }
146
+    })
147
+  }
148
+
149
+  //观看广告
150
+  playVideo () {
151
+    if (process.env.TARO_ENV == 'tt') {
152
+      this.playVideoTT()
153
+    } else {
154
+      this.playVideoWeapp()
155
+    }
156
+  }
157
+  //抖音激励广告
158
+  playVideoTT () {
159
+    let that = this
160
+    Taro.showLoading({
161
+      title: '加载中...',
162
+    })
163
+    const videoAd = tt.createRewardedVideoAd({ adUnitId: this.state.jumpurl });
164
+    videoAd.show()
165
+    videoAd.onError((err) => {
166
+      Taro.hideLoading()
167
+      switch (err.errCode) {
168
+        case 1004:
169
+          // 无合适的广告
170
+          break;
171
+        default:
172
+        // 更多请参考错误码文档
173
+      }
174
+    });
175
+    // 监听视频播放完成
176
+    videoAd.onClose((data) => {
177
+      Taro.hideLoading()
178
+      if (data.isEnded) {
179
+        Taro.navigateTo({
180
+          url: `/moduleB/pages/comicDetail/index?task_id=${that.drawTaskId}`
181
+        })
182
+      } else {
183
+       
184
+      }
185
+    });
186
+  }
187
+  //激励广告
188
+  playVideoWeapp () {
189
+    // 在页面中定义激励视频广告
190
+    let adUnitId = this.state.jumpurl
191
+    // 在页面中定义激励视频广告
192
+    let videoAd = null
193
+    let that = this
194
+    console.log(videoAd, 'videoAd');
195
+    // 在页面onLoad回调事件中创建激励视频广告实例
196
+    if (wx.createRewardedVideoAd) {
197
+      videoAd = wx.createRewardedVideoAd({
198
+        adUnitId: adUnitId
199
+      })
200
+      videoAd.onLoad(() => { })
201
+      videoAd.onError((err) => { })
202
+      try {
203
+        if (videoAd.closeHandler) {
204
+          videoAd.offClose(videoAd.closeHandler);
205
+          console.log("videoAd.offClose卸载成功");
206
+        }
207
+      } catch (e) {
208
+        console.log("videoAd.offClose 卸载失败");
209
+        console.error(e);
210
+      }
211
+      videoAd.closeHandler = function (res) {
212
+        // 用户点击了【关闭广告】按钮
213
+        if (res && res.isEnded || res === undefined) {
214
+          // 正常播放结束,可以下发游戏奖励
215
+          Taro.navigateTo({
216
+            url: `/moduleB/pages/comicDetail/index?task_id=${that.drawTaskId}`
89 217
           })
90 218
         } else {
91
-          Taro.showToast({ icon: 'none', title: res.msg })
219
+          //提前关闭小程序
92 220
         }
93
-      }
221
+      };
222
+      videoAd.onClose(videoAd.closeHandler);
223
+    }
224
+
225
+    // 用户触发广告后,显示激励视频广告
226
+    if (videoAd) {
227
+      videoAd.show().catch(() => {
228
+        // 失败重试
229
+        videoAd.load()
230
+          .then(() => videoAd.show())
231
+          .catch(err => {
232
+            Taro.showToast({
233
+              title: '暂无广告',
234
+              icon: 'none',
235
+              duration: 2000
236
+            })
237
+            console.log('激励视频 广告显示失败')
238
+          })
239
+      })
240
+    }
241
+
242
+  }
243
+  deleteImg () {
244
+    this.setState({
245
+      consultImg: 'http://video-img.fyshark.com/1681721632520%E4%B8%8A.png',
246
+      isImage: false,
94 247
     })
95 248
   }
249
+  onShareAppMessage = (res) => {
250
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
251
+    if (process.env.TARO_ENV == 'tt') {
252
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
253
+    }
254
+    let shareData = {
255
+      title: tool.shareTitle,
256
+      path: path,
257
+      imageUrl: tool.shareImg
258
+    }
259
+    return shareData;
260
+  }
96 261
   changeMass (e) {
97 262
     this.setState({
98 263
       mass: e
99 264
     })
100 265
   }
266
+  selectModel (item, index) {
267
+    this.setState({
268
+      modelIndex: index,
269
+    })
270
+  }
101 271
 
102 272
   render () {
103 273
     return (
104 274
       <View className='mine'>
105
-        <View className='title'>人物动漫化</View>
106
-        <View className='content' onClick={e => (this.upLode())}>
107
-          <Image className='content-img'
108
-            mode='aspectFit'
109
-            src={this.state.consultImg}
110
-          ></Image>
111
-          {
112
-            !this.state.isImage &&
113
-            <View className='add-content'>
114
-              <Image className='add-img' src='http://video-img.fyshark.com/1680144257329%2B.png'></Image>
115
-              <View className='add-tips'>上传图片</View>
116
-            </View>
117
-          }
275
+        <View className='banner'>
276
+          <View className='banner-content'>
277
+
278
+            <Image className='content-img'
279
+              mode='aspectFit'
280
+              src={this.state.consultImg}
281
+            ></Image>
282
+            {
283
+              this.state.isImage &&
284
+              <Image className='delete' src='http://video-img.fyshark.com/1680147210173guanbi.png' onClick={e => (this.deleteImg())}></Image>
285
+            }
286
+          </View>
287
+          <View className='banner-tips'>绝美的动漫头像,上传图片一件生成</View>
288
+
118 289
         </View>
119
-        <View className='img-tips'>绝美的动漫头像,上传图片一件生成</View>
120
-        <View className='draw-title'>图片质量</View>
121
-          <View className='draw-mass'>
122
-            <View className='mass-same' style={this.state.mass == 0 ? 'border: 2px solid #0F84EC;' : ''} onClick={e => (this.changeMass(0))}>普通</View>
123
-            <View className='mass-high' style={this.state.mass == 1 ? 'border: 2px solid #0F84EC;' : ''} onClick={e => (this.changeMass(1))}>高清</View>
290
+        {
291
+          this.state.creatInfo.models &&
292
+          <View className='model-list'>
293
+            {
294
+
295
+              !this.state.isOpen ?
296
+                this.state.creatInfo.models.slice(0, 6).map((item, index) => (
297
+                  <View className='model-info'
298
+                    style={`background:url(${item.img});background-size: 100% 100%;`}
299
+                    key={index}
300
+                    onClick={e => (this.selectModel(item, index))}>
301
+                    <View className='model-info-bottom'>
302
+                      {item.name}
303
+                    </View>
304
+                    {
305
+                      this.state.modelIndex == index &&
306
+                      <View className='moonlight'>
307
+                        {item.name}
308
+                      </View>
309
+                    }
310
+                  </View>
311
+                )) :
312
+                this.state.creatInfo.models.map((item, index) => (
313
+                  <View className='model-info'
314
+                    style={`background:url(${item.img});background-size: 100% 100%;`}
315
+                    key={index}
316
+                    onClick={e => (this.selectModel(item, index))}>
317
+                    <View className='model-info-bottom'>
318
+                      {item.name}
319
+                    </View>
320
+                    {
321
+                      this.state.modelIndex == index &&
322
+                      <View className='moonlight'>
323
+                        {item.name}
324
+                      </View>
325
+                    }
326
+                  </View>
327
+                ))
328
+            }
329
+          </View>
330
+        }
331
+        {
332
+          this.state.creatInfo.models && this.state.creatInfo.models.length > 6 &&
333
+          <View className='isOpen'>
334
+            <View className='open-content' onClick={e => (this.changeOpen())}>
335
+              <View className='open-title'>{!this.state.isOpen ? '展开' : '收起'}</View>
336
+              <Image className='open-img' src={!this.state.isOpen ? 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1678935050487.png' : 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1678935114571.png'}></Image>
337
+            </View>
338
+          </View>
339
+        }
340
+        <View className='update' onClick={e => (tool.throttle(this.updateButton()), 2000)}>
341
+          <View className='update-button'>
342
+            <Image className='update-img' src={!this.state.isImage ? 'http://video-img.fyshark.com/1681719589061%E7%BB%98%E7%94%BB%402x.png' : 'http://video-img.fyshark.com/1681719637510%E5%9B%BE%E7%89%87%402x.png'}></Image>
343
+            {!this.state.isImage ? '上传图片' : this.state.creatInfo.wallet_status == 0 ? '点击绘制 (当前点券不足,看广告绘制图片)' : '点击绘制 (当前点券充足,前往绘制吧)'}
124 344
           </View>
125
-        
126
-        <View className='generate-pictures' onClick={e => (this.generatePictures(e))} >
127
-          生成图片(消耗{2*(this.state.mass+1)}点券)
128 345
         </View>
346
+        <View className='tip-img'>
347
+          <Image className='ps-image' src='http://video-img.fyshark.com/1681720619915%E4%B8%8B%E5%9B%BE.png'></Image>
348
+        </View>
349
+
129 350
       </View>
130 351
     )
131 352
   }

+ 130 - 76
src/moduleB/pages/comic/index.less

@@ -1,106 +1,160 @@
1 1
 .mine {
2
-  padding: 48px 32px;
2
+  padding: 48px 20px;
3 3
   min-height: 100vh;
4 4
   background-color: #041129;
5 5
 
6
-  .title {
7
-    margin-top: 48px;
8
-    font-family: PingFangSC-Regular;
9
-    font-size: 32px;
10
-    color: #FFFFFF;
11
-  }
12 6
 
13
-  .content {
7
+  .banner {
14 8
     position: relative;
15 9
     margin-top: 20px;
16
-
17
-    .add-content {
18
-      position: absolute;
10
+    .banner-content{
11
+      position: relative;
19 12
       left: 50%;
20
-      top: 50%;
21
-      transform: translate(-50%,-50%);
22
-      // display: flex;
23
-      // justify-content: center;
24
-
25
-      .add-img {
26
-        position: relative;
27
-        left: 50%;
28
-        transform: translateX(-50%);
29
-        width: 80px;
30
-        height: 80px;
13
+      transform: translateX(-50%);
14
+      width: 312px;
15
+      height: 312px;
16
+      .content-img {
17
+        width: 100%;
18
+        height: 100%;
31 19
       }
32
-
33
-      .add-tips {
34
-        margin-top: 12px;
35
-        font-family: PingFangSC-Regular;
36
-        font-size: 28px;
37
-        color: #FFFFFF;
38
-        text-align: center;
20
+      .delete{
21
+        position: absolute;
22
+        right: -20px;
23
+        top: -20px;
24
+        width: 40px;
25
+        height: 40px;
39 26
       }
40 27
     }
41 28
 
42
-    .content-img {
43
-      width: 100%;
44
-      max-height: 760px;
45
-    }
46
-  }
47 29
 
48
-  .generate-pictures {
49
-    width: 382px;
50
-    height: 96px;
51
-    border-radius: 96px;
52
-    line-height: 96px;
53
-    text-align: center;
54
-    position: fixed;
55
-    bottom: 40px;
56
-    left: 50%;
57
-    z-index: 100;
58
-    transform: translateX(-50%);
59
-    background-image: linear-gradient(-49deg, #5D81FF 0%, #0F84EC 100%);
60
-    font-family: PingFangSC-Regular;
61
-    font-size: 28px;
62
-    color: #FFFFFF;
30
+    .banner-tips {
31
+      margin-top: 20px;
32
+      text-align: center;
33
+      font-size: 28px;
34
+      font-family: PingFang SC;
35
+      font-weight: bold;
36
+      color: #FDFDFD;
37
+      line-height: 40px;
38
+    }
63 39
   }
64 40
 
65
-  .img-tips {
66
-    margin-top: 20px;
67
-    font-family: PingFangSC-Regular;
68
-    font-size: 24px;
69
-    color: #FFFFFF;
70
-  }
71
-  .draw-title {
72
-    margin-top: 48px;
73
-    font-family: PingFangSC-Regular;
74
-    font-size: 32px;
75
-    color: #FFFFFF;
76
-  }
77
-  .draw-mass {
41
+  .model-list {
78 42
     margin-top: 20px;
79 43
     display: flex;
80
-    font-family: PingFangSC-Regular;
81
-    font-size: 28px;
82
-    color: rgba(255, 255, 255, .5);
44
+    flex-wrap: wrap;
83 45
 
84
-    .mass-same {
85
-      width: 150px;
46
+    .model-info {
47
+      position: relative;
48
+      background-size: 100% 100%;
49
+      margin-bottom: 16px;
50
+      width: 220px;
51
+      margin-left: 14px;
52
+      height: 220px;
53
+      display: block;
54
+      -webkit-box-sizing: border-box;
55
+      -moz-box-sizing: border-box;
86 56
       box-sizing: border-box;
87
-      height: 80px;
88
-      line-height: 80px;
89
-      text-align: center;
57
+
90 58
       background-color: rgba(255, 255, 255, .05);
91 59
       border-radius: 16px;
60
+
61
+      .model-info-bottom {
62
+        position: absolute;
63
+        z-index: 1;
64
+        bottom: 0;
65
+        left: 0;
66
+        width: 100%;
67
+        font-size: 32px;
68
+        background-color: rgba(0, 0, 0, 0.4);
69
+        ;
70
+        color: #FFFFFF;
71
+        text-align: center;
72
+      }
73
+
74
+      .moonlight {
75
+        position: absolute;
76
+        top: 0;
77
+        left: 0;
78
+        z-index: 2;
79
+        width: 100%;
80
+        height: 100%;
81
+        background: rgba(0, 0, 0, 0.6);
82
+        display: flex;
83
+        justify-content: center;
84
+        align-items: center;
85
+        font-size: 28px;
86
+        font-family: PingFang SC;
87
+        font-weight: bold;
88
+        color: #FFFFFF;
89
+      }
92 90
     }
91
+  }
92
+
93
+  .isOpen {
94
+    display: flex;
95
+    justify-content: center;
93 96
 
94
-    .mass-high {
95
-      width: 150px;
97
+    .open-content {
98
+      width: 174px;
96 99
       height: 80px;
97
-      box-sizing: border-box;
98
-      line-height: 80px;
99
-      text-align: center;
100 100
       background-color: rgba(255, 255, 255, .05);
101 101
       border-radius: 16px;
102
-      margin-left: 24px;
102
+      display: flex;
103
+      justify-content: center;
104
+      align-items: center;
105
+
106
+      .open-title {
107
+        font-family: PingFangSC-Regular;
108
+        font-size: 32px;
109
+        color: #0F84EC;
110
+        letter-spacing: 0;
111
+        text-align: center;
112
+      }
113
+
114
+      .open-img {
115
+        width: 40px;
116
+        height: 40px;
117
+        margin-left: 5px;
118
+        display: block;
119
+      }
103 120
     }
104 121
   }
105 122
 
123
+  .update {
124
+    margin-top: 40px;
125
+
126
+    .update-button {
127
+      background: linear-gradient(90deg, #038EFF, #3342FF);
128
+      border-radius: 46px;
129
+      width: 100%;
130
+      height: 94px;
131
+      display: flex;
132
+      align-items: center;
133
+      justify-content: center;
134
+      font-size: 28px;
135
+      font-family: PingFang SC;
136
+      font-weight: bold;
137
+      color: #FDFDFD;
138
+
139
+      .update-img {
140
+        width: 52px;
141
+        height: 52px;
142
+        display: block;
143
+      }
144
+    }
145
+  }
146
+
147
+  .tip-img {
148
+    margin-top: 54px;
149
+    width: 100%;
150
+    display: flex;
151
+    justify-content: center;
152
+
153
+    .ps-image {
154
+      width: 566px;
155
+      height: 194px;
156
+    }
157
+  }
158
+
159
+
106 160
 }

+ 5 - 0
src/moduleB/pages/comicDetail/index.config.js

@@ -0,0 +1,5 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '人物动漫化详情',
3
+  enableShareAppMessage: true,
4
+  enableShareTimeline: true ,
5
+})

+ 378 - 0
src/moduleB/pages/comicDetail/index.jsx

@@ -0,0 +1,378 @@
1
+import { Component } from 'react'
2
+import { View, Text, Button, Image, ScrollView, Input } from '@tarojs/components'
3
+import * as api from '../../../service/index'
4
+import tool from '../../../common/tool'
5
+import Taro, { getCurrentInstance } from '@tarojs/taro'
6
+import './index.less'
7
+
8
+export default class collection extends Component {
9
+  $instance = getCurrentInstance()
10
+  state = {
11
+    jumpurl: '',//广告id
12
+    task_id: 0,//任务id
13
+    repeat: 0,//广告次数
14
+    current: 0,
15
+    interval: null,
16
+    draw_status: 0,
17
+    draw_infos: [],
18
+    que_cnt: 0,
19
+    default_img: '',
20
+    interval: null,
21
+    wallet_balance: 0,//用户当前余额
22
+  }
23
+
24
+  componentWillMount () {
25
+    let routers = this.$instance.router.params
26
+    this.getCoinTaskAd()
27
+    api.unlockGcImg({ task_id: routers.task_id }).then(res => {
28
+      if (res.code == 200) {
29
+        this.getDrawTaskStatus(routers.task_id)
30
+      }
31
+    })
32
+  }
33
+  componentDidShow () {
34
+
35
+  }
36
+  //页面销毁之前调用
37
+  componentWillUnmount () {
38
+    //避免服务器攻击
39
+    clearInterval(this.state.interval)
40
+  }
41
+  getCoinTaskAd () {
42
+    api.getCoinTaskAd().then(res => {
43
+      if (res.code == 200) {
44
+        this.setState({
45
+          jumpurl: res.data[0].jumpurl,//广告id
46
+          task_id: res.data[0].id,//任务id
47
+          repeat: res.data[0].repeat
48
+        })
49
+      }
50
+    })
51
+  }
52
+  //解锁成功
53
+  unlockGcImg (item, index) {
54
+    api.unlockGcImg({ task_id: item.task_id }).then(res => {
55
+      if (res.code == 200) {
56
+        this.setState({
57
+          current: index
58
+        })
59
+        this.getDrawTaskStatus(item.task_id)
60
+      }
61
+    })
62
+  }
63
+
64
+  selectedLabel (item, index) {
65
+    let that = this
66
+    console.log(item, 'itemitem');
67
+    if (item.unlock_status == 0) {
68
+      Taro.showModal({
69
+        title: '提示',
70
+        content: '是否观看广告解锁?',
71
+        success: function (res) {
72
+          if (res.confirm) {
73
+            if (item.status == 4) {
74
+              that.generatePictures(item, index)
75
+            }
76
+            that.playVideo(item, index)
77
+          } else if (res.cancel) {
78
+            console.log('用户点击取消')
79
+          }
80
+        }
81
+      })
82
+    } else {
83
+      this.setState({
84
+        current: index
85
+      })
86
+    }
87
+
88
+  }
89
+  //观看广告
90
+  playVideo (item, index) {
91
+    if (process.env.TARO_ENV == 'tt') {
92
+      this.playVideoTT(item, index)
93
+    } else {
94
+      this.playVideoWeapp(item, index)
95
+    }
96
+  }
97
+  //抖音激励广告
98
+  playVideoTT (item, index) {
99
+    let that = this
100
+    Taro.showLoading({
101
+      title: '加载中...',
102
+    })
103
+    const videoAd = tt.createRewardedVideoAd({ adUnitId: this.state.jumpurl });
104
+    videoAd.show()
105
+    videoAd.onError((err) => {
106
+      Taro.hideLoading()
107
+      switch (err.errCode) {
108
+        case 1004:
109
+          // 无合适的广告
110
+          break;
111
+        default:
112
+        // 更多请参考错误码文档
113
+      }
114
+    });
115
+    // 监听视频播放完成
116
+    videoAd.onClose((data) => {
117
+      Taro.hideLoading()
118
+      if (data.isEnded) {
119
+        Taro.showToast({
120
+          title: '解锁成功',
121
+          icon: 'none',
122
+          duration: 2000
123
+        })
124
+        that.unlockGcImg(item, index)
125
+        that.getDrawTaskStatus(item.task_id)
126
+      } else {
127
+        that.getDrawTaskStatus(item.task_id)
128
+        Taro.showToast({
129
+          title: '解锁失败',
130
+          icon: 'none',
131
+          duration: 2000
132
+        })
133
+      }
134
+    });
135
+  }
136
+  //激励广告
137
+  playVideoWeapp (item, index) {
138
+    console.log(item, 'guanggao');
139
+    // 在页面中定义激励视频广告
140
+    let adUnitId = this.state.jumpurl
141
+    // 在页面中定义激励视频广告
142
+    let videoAd = null
143
+    let that = this
144
+    // 在页面onLoad回调事件中创建激励视频广告实例
145
+    if (wx.createRewardedVideoAd) {
146
+      videoAd = wx.createRewardedVideoAd({
147
+        adUnitId: adUnitId
148
+      })
149
+      videoAd.onLoad(() => {
150
+      })
151
+      videoAd.onError((err) => { })
152
+      try {
153
+        if (videoAd.closeHandler) {
154
+          videoAd.offClose(videoAd.closeHandler);
155
+          console.log("videoAd.offClose卸载成功");
156
+        }
157
+      } catch (e) {
158
+        console.log("videoAd.offClose 卸载失败");
159
+        console.error(e);
160
+      }
161
+      videoAd.closeHandler = function (res) {
162
+        Taro.hideLoading()
163
+        // 用户点击了【关闭广告】按钮
164
+        if (res && res.isEnded || res === undefined) {
165
+          // 正常播放结束,可以下发游戏奖励
166
+          Taro.showToast({
167
+            title: '解锁成功',
168
+            icon: 'none',
169
+            duration: 2000
170
+          })
171
+          console.log(item, '关闭');
172
+          that.unlockGcImg(item, index)
173
+        } else {
174
+          console.log(item, '关闭1');
175
+          //提前关闭小程序
176
+          that.getDrawTaskStatus(item.task_id)
177
+          Taro.showToast({
178
+            title: '解锁失败',
179
+            icon: 'none',
180
+            duration: 2000
181
+          })
182
+        }
183
+      };
184
+      videoAd.onClose(videoAd.closeHandler);
185
+
186
+    }
187
+
188
+    // 用户触发广告后,显示激励视频广告
189
+    if (videoAd) {
190
+      videoAd.show().catch(() => {
191
+        // 失败重试
192
+        videoAd.load()
193
+          .then(() => videoAd.show())
194
+          .catch(err => {
195
+            Taro.showToast({
196
+              title: '暂无广告',
197
+              icon: 'none',
198
+              duration: 2000
199
+            })
200
+            console.log('激励视频 广告显示失败')
201
+          })
202
+      })
203
+    }
204
+
205
+  }
206
+  //画画
207
+  generatePictures (item, index) {
208
+    console.log(item, '画画');
209
+    api.drawGcImgTask({ task_id: item.task_id }).then(res => {
210
+      if (res.code == 200) {
211
+        this.getDrawTaskStatus(item.task_id)
212
+      }
213
+    })
214
+  }
215
+  getDrawTaskStatus (task_id) {
216
+    api.getDrawTaskStatusGc({ task_id: task_id }).then(res => {
217
+      //定时器不要轻易改,避免造成服务器攻击
218
+      if (res.code == 200) {
219
+        let draw_infos = res.data.draw_infos
220
+        // if (res.data.draw_status != 2) {
221
+        //   let params = {}
222
+        //   params['img'] = res.data.default_img
223
+        //   params['id'] = -1
224
+        //   draw_infos.push(params)
225
+        // }
226
+        console.log(draw_infos, 'draw_infos');
227
+        if (res.data.draw_status != 2 && res.data.que_cnt > 1) {
228
+          this.state.interval = setInterval(() => {
229
+            clearInterval(this.state.interval)
230
+            this.getDrawTaskStatus(task_id)
231
+          }, 1000 * 10)
232
+        } else if (res.data.draw_status != 2 && res.data.que_cnt <= 1) {
233
+          clearInterval(this.state.interval)
234
+          this.state.interval = setInterval(() => {
235
+            this.getDrawTaskStatus(task_id)
236
+          }, 1000 * 5)
237
+        } else {
238
+          clearInterval(this.state.interval)
239
+        }
240
+        this.setState({
241
+          draw_status: res.data.draw_status,
242
+          que_cnt: res.data.que_cnt,
243
+          draw_infos: draw_infos,
244
+          wallet_balance: res.data.wallet_balance
245
+        })
246
+      }
247
+    })
248
+  }
249
+
250
+  download () {
251
+    this.downImg()
252
+  }
253
+  // 鉴权操作 判断是否有保存到相册的权限
254
+  // 有就直接下载 没有就弹窗提示给权限
255
+  downImg () {
256
+    Taro.getSetting({
257
+      success: res => {
258
+        if (!res.authSetting['scope.writePhotosAlbum']) {
259
+          Taro.authorize({
260
+            scope: 'scope.writePhotosAlbum',
261
+            success: () => {
262
+              this.doSaveImg()
263
+            },
264
+            fail: () => {
265
+              this.openConfirm()
266
+            }
267
+          })
268
+        } else {
269
+          this.doSaveImg()
270
+        }
271
+      }
272
+    })
273
+  }
274
+  // 生成临时路径 保存图片到手机
275
+  doSaveImg () {
276
+    Taro.downloadFile({
277
+      url: this.state.draw_infos[this.state.current].img,
278
+      success: res => {
279
+        Taro.saveImageToPhotosAlbum({
280
+          filePath: res.tempFilePath,
281
+          success: () => {
282
+            Taro.showToast({ title: '已保存到相册', icon: 'success' })
283
+          },
284
+          fail: () => {
285
+            Taro.showToast({ title: '保存失败', icon: 'none' })
286
+          }
287
+        })
288
+      }
289
+    })
290
+  }
291
+  // 权限弹窗
292
+  openConfirm () {
293
+    Taro.showModal({
294
+      content: '检测到您没有打开小程序相册权限,是否取设置打开?',
295
+      showCancel: true,
296
+      success: res => {
297
+        if (res.confirm) {
298
+          // 打开权限
299
+          Taro.openSetting({
300
+            success: res => {
301
+              this.doSaveImg()
302
+            }
303
+          })
304
+        }
305
+      }
306
+    })
307
+  }
308
+  toIndex () {
309
+    Taro.reLaunch({
310
+      url: `/pages/index/index`
311
+    })
312
+  }
313
+  previewImage () {
314
+    Taro.previewImage({
315
+      current: this.state.draw_infos[this.state.current].img, // 当前显示图片的http链接  
316
+      urls: [`${this.state.draw_infos[this.state.current].img}`] // 需要预览的图片http链接列表  
317
+    })
318
+  }
319
+
320
+
321
+  render () {
322
+    return (
323
+      <View className='mine'>
324
+        {
325
+          this.state.draw_infos.length > 0 &&
326
+          <View className='banner'>
327
+            <View className='banner-content'>
328
+              <Image className='content-img'
329
+                mode='aspectFit'
330
+                onClick={e => (this.previewImage())}
331
+                src={this.state.draw_infos[this.state.current].img}
332
+              ></Image>
333
+              {
334
+                this.state.draw_infos[this.state.current].id == -1 &&
335
+                <View className='content-wait'>
336
+                  <View className='wait-date'>预计等待{Math.ceil((this.state.que_cnt - 1) * 0.2 + 1)}分钟...</View>
337
+                  <View className='wait-middle'>{this.state.draw_status == 0 ? '等待中' : this.state.draw_status == 1 ? '正在绘画...' : '已完成'}</View>
338
+                  <View className='wait-bottom'>
339
+                    <View className='wait-num'>当前点券余额:{this.state.wallet_balance}</View>
340
+                    <View className='wait-get-num' onClick={e => (tool.throttle(this.playVideo()), 2000)}>点击观看广告领取更多点券</View>
341
+                  </View>
342
+                </View>
343
+              }
344
+
345
+            </View>
346
+          </View>
347
+        }
348
+        <ScrollView
349
+          className='recharge'
350
+          scrollX
351
+        >
352
+          {
353
+            this.state.draw_infos.map((item, index) => (
354
+              <View className='recharge-info'
355
+                key={index}
356
+                onClick={e => (this.selectedLabel(item, index))}>
357
+                <Image className='recharge-image' mode='aspectFit' src={item.img}></Image>
358
+                {
359
+                  item.unlock_status == 0 &&
360
+                  <View className='lock'>
361
+                    <View className='lock-content'>
362
+                      <Image className='lock-img' src='http://video-img.fyshark.com/1681733630830%E8%A7%A3%E9%94%81%402x.png'></Image>
363
+                      <View className='lock-title'>解锁</View>
364
+                    </View>
365
+                  </View>
366
+                }
367
+              </View>
368
+            ))
369
+          }
370
+        </ScrollView>
371
+        <View className='control'>
372
+          <View className='download' onClick={e => (this.download())}>保存图片</View>
373
+          <View className='toIndex' onClick={e => (this.toIndex())}>前往探索更多玩法</View>
374
+        </View>
375
+      </View>
376
+    )
377
+  }
378
+}

+ 168 - 0
src/moduleB/pages/comicDetail/index.less

@@ -0,0 +1,168 @@
1
+.mine {
2
+  padding: 48px 40px;
3
+  min-height: 100vh;
4
+  background-color: #041129;
5
+
6
+
7
+  .banner {
8
+    position: relative;
9
+    margin-top: 20px;
10
+    border-radius: 20px;
11
+
12
+    .banner-content {
13
+      position: relative;
14
+      border-radius: 20px;
15
+      left: 50%;
16
+      transform: translateX(-50%);
17
+      width: 500px;
18
+      height: 890px;
19
+    }
20
+
21
+    .content-img {
22
+      background-color: #545353;
23
+      border-radius: 20px;
24
+      width: 100%;
25
+      height: 100%;
26
+    }
27
+
28
+    .content-wait {
29
+      border-radius: 20px;
30
+      position: absolute;
31
+      top: 0;
32
+      left: 0;
33
+      width: 100%;
34
+      height: 100%;
35
+      background: rgba(0, 0, 0, 0.6);
36
+
37
+      .wait-date {
38
+        margin-top: 12px;
39
+        margin-left: 16px;
40
+        font-size: 36px;
41
+        font-family: PingFang SC;
42
+        font-weight: bold;
43
+        color: #FFFFFF;
44
+      }
45
+
46
+      .wait-middle {
47
+        position: absolute;
48
+        top: 50%;
49
+        left: 50%;
50
+        transform: translate(-50%, -50%);
51
+        font-size: 40px;
52
+        font-family: PingFang SC;
53
+        font-weight: 800;
54
+        color: #FFFFFF;
55
+      }
56
+
57
+      .wait-bottom {
58
+        width: 100%;
59
+        position: absolute;
60
+        bottom: 40px;
61
+        left: 0;
62
+        font-size: 40px;
63
+        font-family: PingFang SC;
64
+        font-weight: 500;
65
+        color: #FFFFFF;
66
+
67
+        .wait-num {
68
+          text-align: center;
69
+        }
70
+
71
+        .wait-get-num {
72
+          text-align: center;
73
+          margin-top: 16px;
74
+          text-decoration: underline
75
+        }
76
+      }
77
+    }
78
+
79
+  }
80
+
81
+  .recharge {
82
+    margin-top: 30px;
83
+    width: 100%;
84
+    white-space: nowrap;
85
+
86
+    .recharge-info {
87
+      position: relative;
88
+      border-radius: 10px;
89
+      margin-right: 20px;
90
+      display: inline-block;
91
+
92
+      .recharge-image {
93
+        width: 130px;
94
+        height: 230px;
95
+        display: block;
96
+        background-color: #545353;
97
+        border-radius: 10px;
98
+      }
99
+
100
+      .lock {
101
+        border-radius: 10px;
102
+        position: absolute;
103
+        top: 0;
104
+        left: 0;
105
+        width: 100%;
106
+        height: 100%;
107
+        background: rgba(0, 0, 0, 0.6);
108
+
109
+
110
+        .lock-content {
111
+          position: relative;
112
+          top: 50%;
113
+          transform: translateY(-50%);
114
+
115
+          .lock-img {
116
+            position: relative;
117
+            left: 50%;
118
+            transform: translateX(-50%);
119
+            width: 36px;
120
+            display: block;
121
+            height: 36px;
122
+          }
123
+
124
+          .lock-title {
125
+            text-align: center;
126
+            margin-top: 10px;
127
+            font-size: 26px;
128
+            font-family: PingFang SC;
129
+            font-weight: 500;
130
+            color: #FFFFFF;
131
+          }
132
+        }
133
+      }
134
+    }
135
+
136
+  }
137
+
138
+  .control {
139
+    width: 100%;
140
+    margin-top: 100px;
141
+    display: flex;
142
+    justify-content: space-between;
143
+    align-items: center;
144
+    font-size: 28px;
145
+    font-family: PingFang SC;
146
+    font-weight: 500;
147
+    color: #FFFFFF;
148
+
149
+    .download {
150
+      width: 260px;
151
+      height: 80px;
152
+      line-height: 80px;
153
+      text-align: center;
154
+      background: linear-gradient(90deg, #038EFF, #3342FF);
155
+      border-radius: 14px;
156
+    }
157
+
158
+    .toIndex {
159
+      width: 260px;
160
+      height: 80px;
161
+      line-height: 80px;
162
+      text-align: center;
163
+      background: linear-gradient(90deg, #038EFF, #3342FF);
164
+      border-radius: 14px;
165
+    }
166
+  }
167
+
168
+}

+ 40 - 6
src/moduleB/pages/faceChanging/index.jsx

@@ -28,22 +28,43 @@ export default class collection extends Component {
28 28
         isModelImage: true,
29 29
       })
30 30
     }
31
+
31 32
   }
32 33
   componentDidShow () {
34
+    this.getImage()
35
+  }
36
+  onShareAppMessage = (res) => {
37
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
38
+    if (process.env.TARO_ENV == 'tt') {
39
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
40
+    }
41
+    let shareData = {
42
+      title: tool.shareTitle,
43
+      path: path,
44
+      imageUrl: tool.shareImg
45
+    }
46
+    return shareData;
47
+  }
48
+  getImage () {
33 49
     //接收裁剪图片
34 50
     let pages = Taro.getCurrentPages();
35 51
     let currentPage = pages[pages.length - 1]; // 获取当前页面
52
+    console.log(currentPage, 'currentPage');
36 53
     if (process.env.TARO_ENV == 'weapp') {
37 54
       if (currentPage.__data__.consultImg) { // 获取值
38 55
         if (this.state.type == 'demol') {
39 56
           this.setState({
40 57
             consultImg: currentPage.__data__.consultImg,
41 58
             isModelImage: true
59
+          }, () => {
60
+            currentPage.__data__.consultImg = ''
42 61
           })
43 62
         } else {
44 63
           this.setState({
45 64
             consultImgOther: currentPage.__data__.consultImg,
46 65
             isUserImage: true
66
+          }, () => {
67
+            currentPage.__data__.consultImg = ''
47 68
           })
48 69
         }
49 70
 
@@ -54,11 +75,15 @@ export default class collection extends Component {
54 75
           this.setState({
55 76
             consultImg: currentPage.data.consultImg,
56 77
             isModelImage: true
78
+          }, () => {
79
+            currentPage.data.consultImg = ''
57 80
           })
58 81
         } else {
59 82
           this.setState({
60 83
             consultImgOther: currentPage.data.consultImg,
61 84
             isUserImage: true
85
+          }, () => {
86
+            currentPage.data.consultImg = ''
62 87
           })
63 88
         }
64 89
       }
@@ -72,12 +97,13 @@ export default class collection extends Component {
72 97
     if (type == 'demol') {
73 98
       this.setState({
74 99
         isRsoutImage: false,
75
-        isChangeButton:false
100
+        isChangeButton: false
76 101
       })
77 102
     }
78 103
     Taro.chooseMedia({
79 104
       count: 1, // 默认
80 105
       sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
106
+      mediaType:['image'],
81 107
       sourceType: ['album', 'camera'],
82 108
       success: function (res) {
83 109
         console.log(res, 'res');
@@ -112,8 +138,8 @@ export default class collection extends Component {
112 138
     Taro.showLoading({
113 139
       title: '加载中...',
114 140
     })
115
-    let params = { 
116
-      image_template: this.state.consultImg, 
141
+    let params = {
142
+      image_template: this.state.consultImg,
117 143
       image_target: this.state.consultImgOther,
118 144
     }
119 145
     api.aiFaceMege(params).then(res => {
@@ -123,7 +149,7 @@ export default class collection extends Component {
123 149
         this.setState({
124 150
           resultImage: `data:image/png;base64,${res.data.imgdata}`,
125 151
           isRsoutImage: true,
126
-          isChangeButton:true
152
+          isChangeButton: true
127 153
         })
128 154
       } else {
129 155
         Taro.hideLoading()
@@ -166,12 +192,12 @@ export default class collection extends Component {
166 192
   }
167 193
   onTouchStart () {
168 194
     this.setState({
169
-      isRsoutImage:false
195
+      isRsoutImage: false
170 196
     })
171 197
   }
172 198
   onTouchEnd () {
173 199
     this.setState({
174
-      isRsoutImage:true
200
+      isRsoutImage: true
175 201
     })
176 202
   }
177 203
 
@@ -182,6 +208,10 @@ export default class collection extends Component {
182 208
           <Image className='demo-img' mode='aspectFit' onClick={e => (this.previewImage())} src={this.state.isRsoutImage ? this.state.resultImage : this.state.consultImg}></Image>
183 209
           <View className='update' onClick={e => (this.upLode('demol'))}>
184 210
             <Image className='updata-img' src='http://video-img.fyshark.com/1680849432427%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87.png'></Image>
211
+            {
212
+              !this.state.isModelImage &&
213
+              <View className='from'></View>
214
+            }
185 215
             <View className='updata-title'>上传模板图</View>
186 216
           </View>
187 217
           {
@@ -197,6 +227,10 @@ export default class collection extends Component {
197 227
           <Image className='demo-img' mode='aspectFit' onClick={e => (this.previewUserImage())} src={this.state.consultImgOther}></Image>
198 228
           <View className='update' onClick={e => (this.upLode('user'))}>
199 229
             <Image className='updata-img' src='http://video-img.fyshark.com/1680849432427%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87.png'></Image>
230
+            {
231
+              !this.state.isUserImage &&
232
+              <View className='from'></View>
233
+            }
200 234
             <View className='updata-title'>上传人脸图</View>
201 235
           </View>
202 236
         </View>

+ 12 - 1
src/moduleB/pages/faceChanging/index.less

@@ -15,7 +15,18 @@
15 15
       border-top-right-radius: 30px;
16 16
       width: 100%;
17 17
       background-color: #4a4a4c;
18
-      min-height: 500px;
18
+      height: 500px;
19
+    }
20
+    .from{
21
+      border-top-left-radius: 30px;
22
+      border-top-right-radius: 30px;
23
+      position: absolute;
24
+      width: 100%;
25
+      background-color: #010101;
26
+      opacity: 0.5;
27
+      height: 500px;
28
+      top: 0;
29
+      left: 0;
19 30
     }
20 31
 
21 32
     .update {

+ 1 - 1
src/moduleB/pages/works/index.config.js

@@ -1,5 +1,5 @@
1 1
 export default definePageConfig({
2
-  navigationBarTitleText: '我的作品',
2
+  navigationBarTitleText: '绘画作品',
3 3
   enableShareAppMessage: true,
4 4
   enableShareTimeline: true ,
5 5
 })

+ 6 - 2
src/moduleB/pages/works/index.jsx

@@ -116,7 +116,7 @@ export default class Task extends Component {
116 116
 
117 117
     } else {
118 118
         Taro.navigateTo({
119
-          url: `/moduleA/pages/darwDetail/index?task_id=${item.task_id}&img_id=${item.id}`
119
+          url: `/moduleA/pages/darwDetailIndex/index?task_id=${item.task_id}&img_id=${item.id}`
120 120
         })
121 121
       
122 122
     }
@@ -209,9 +209,13 @@ export default class Task extends Component {
209 209
     })
210 210
   }
211 211
   onShareAppMessage = (res) => {
212
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
213
+    if (process.env.TARO_ENV == 'tt') {
214
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
215
+    }
212 216
     let shareData = {
213 217
       title: tool.shareTitle,
214
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
218
+      path: path,
215 219
       imageUrl: tool.shareImg
216 220
     }
217 221
     return shareData;

src/moduleB/pages/works/index.less → src/moduleB/pages/imageWorks/index.less


+ 5 - 2
src/moduleB/pages/like/index.jsx

@@ -124,14 +124,17 @@ export default class Task extends Component {
124 124
     })
125 125
   }
126 126
   onShareAppMessage = (res) => {
127
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
128
+    if (process.env.TARO_ENV == 'tt') {
129
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
130
+    }
127 131
     let shareData = {
128 132
       title: tool.shareTitle,
129
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
133
+      path: path,
130 134
       imageUrl: tool.shareImg
131 135
     }
132 136
     return shareData;
133 137
   }
134
-
135 138
   render () {
136 139
     return (
137 140
       <View className='mine'>

+ 5 - 0
src/moduleB/pages/poetry/index.config.js

@@ -0,0 +1,5 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '诗词绘画',
3
+  enableShareAppMessage: true,
4
+  enableShareTimeline: true ,
5
+})

+ 817 - 0
src/moduleB/pages/poetry/index.jsx

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

+ 218 - 0
src/moduleB/pages/poetry/index.less

@@ -0,0 +1,218 @@
1
+.mine {
2
+  min-height: 100vh;
3
+  background-color: #041129;
4
+
5
+  .draw-content {
6
+    padding: 48px 30px;
7
+
8
+    .draw-title {
9
+      margin-top: 48px;
10
+      font-family: PingFangSC-Regular;
11
+      font-size: 28px;
12
+      color: #FFFFFF;
13
+    }
14
+
15
+
16
+    .draw-text {
17
+      margin-top: 30px;
18
+      position: relative;
19
+
20
+      .draw-content-func {
21
+        display: flex;
22
+        position: absolute;
23
+        right: 0;
24
+        top: -84px;
25
+      }
26
+
27
+      .delete-draw-text {
28
+        padding: 0 20px;
29
+        height: 64px;
30
+        line-height: 64px;
31
+        font-family: PingFangSC-Regular;
32
+        font-size: 24px;
33
+        letter-spacing: 0;
34
+        text-align: center;
35
+        background-color: rgba(255, 255, 255, .05);
36
+        color: rgba(255, 255, 255, .5);
37
+      }
38
+
39
+      .recommend {
40
+        margin-right: 20px;
41
+        width: 222px;
42
+        height: 64px;
43
+        display: flex;
44
+        align-items: center;
45
+        border-radius: 16px;
46
+        justify-content: center;
47
+        background-color: rgba(255, 255, 255, .05);
48
+        color: rgba(255, 255, 255, .5);
49
+
50
+        .recommend-img {
51
+          margin-left: 10px;
52
+          width: 32px;
53
+          height: 32px;
54
+          display: block;
55
+        }
56
+
57
+        .recommend-text {
58
+          font-family: PingFangSC-Regular;
59
+          font-size: 24px;
60
+          letter-spacing: 0;
61
+          text-align: center;
62
+        }
63
+      }
64
+
65
+      .draw-taxtarea {
66
+        width: 642px;
67
+        background-color: rgba(255, 255, 255, .05);
68
+        font-size: 28px;
69
+        color: rgba(255, 255, 255, .5);
70
+        height: 150px;
71
+        padding: 24rpx 24rpx 44rpx 24rpx;
72
+      }
73
+
74
+      .textarea-num {
75
+        margin-top: -50px;
76
+        margin-right: 20px;
77
+        text-align: end;
78
+        color: rgba(255, 255, 255, .5);
79
+      }
80
+
81
+      .generate {
82
+        margin-top: 40px;
83
+        display: flex;
84
+        justify-content: flex-end;
85
+      }
86
+
87
+      .generate-button {
88
+        padding: 20px 40px;
89
+        border-radius: 96px;
90
+        text-align: center;
91
+        position: relative;
92
+        right: 0;
93
+        z-index: 100;
94
+        background-image: linear-gradient(-49deg, #5D81FF 0%, #0F84EC 100%);
95
+        font-family: PingFangSC-Regular;
96
+        font-size: 28px;
97
+        color: #FFFFFF;
98
+      }
99
+    }
100
+
101
+
102
+  }
103
+
104
+  .result-content {
105
+    // margin-top: 40px;
106
+    display: flex;
107
+    justify-content: space-between;
108
+    flex-wrap: wrap;
109
+
110
+    .content-info {
111
+      width: 330px;
112
+      margin-bottom: 20px;
113
+      -webkit-box-sizing: border-box;
114
+      -moz-box-sizing: border-box;
115
+      box-sizing: border-box;
116
+
117
+      .info-img {
118
+        width: 100%;
119
+        display: block;
120
+      }
121
+    }
122
+  }
123
+
124
+  .func {
125
+    width: 100%;
126
+    margin-top: 76px;
127
+
128
+    .func-list {
129
+      padding: 0 30px;
130
+      display: flex;
131
+      justify-content: space-evenly;
132
+    }
133
+
134
+    .func-info {
135
+      display: flex;
136
+      justify-content: center;
137
+      align-items: center;
138
+      width: 218px;
139
+      height: 80px;
140
+      border-radius: 8px;
141
+      border: 2px solid rgba(16, 133, 237, 1);
142
+      font-family: PingFangSC-Regular;
143
+      font-size: 32px;
144
+      color: #38ADF4;
145
+      letter-spacing: 0;
146
+      text-align: center;
147
+
148
+      .func-image {
149
+        margin-right: 22px;
150
+        width: 48px;
151
+        height: 48px;
152
+      }
153
+    }
154
+  }
155
+
156
+  .banner-content {
157
+    margin-top: 40px;
158
+    width: 100%;
159
+    position: relative;
160
+  }
161
+
162
+  .banner {
163
+    width: 100%;
164
+    min-height: 420px;
165
+    position: relative;
166
+
167
+    .banner-tips {
168
+      font-family: PingFangSC-Regular;
169
+      font-size: 32px;
170
+      color: rgba(255, 255, 255, .75);
171
+
172
+      .tips-left {
173
+        position: absolute;
174
+        top: 50px;
175
+        left: 10px;
176
+      }
177
+
178
+      .tips-right {
179
+        position: absolute;
180
+        top: 50px;
181
+        right: 10px;
182
+        text-decoration: underline
183
+      }
184
+    }
185
+
186
+    .banner-info {
187
+      background-color: #535353;
188
+      
189
+      width: 100%;
190
+      height: 390px;
191
+      .banner-image {
192
+        width: 100%;
193
+        height: 100%;
194
+      }
195
+    }
196
+  }
197
+
198
+  .banner-indicatorDots {
199
+    margin-top: 10px;
200
+    display: flex;
201
+    justify-content: center;
202
+
203
+    .indicatorDots-info {
204
+      -webkit-box-sizing: border-box;
205
+      -moz-box-sizing: border-box;
206
+      box-sizing: border-box;
207
+      margin-left: 10px;
208
+      width: 100px;
209
+      height: 57px;
210
+
211
+      .indicatorDots-img {
212
+        width: 100%;
213
+        height: 100%;
214
+      }
215
+    }
216
+  }
217
+
218
+}

+ 5 - 1
src/moduleB/pages/point/index.jsx

@@ -14,9 +14,13 @@ export default class Task extends Component {
14 14
   }
15 15
  
16 16
   onShareAppMessage = (res) => {
17
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
18
+    if (process.env.TARO_ENV == 'tt') {
19
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
20
+    }
17 21
     let shareData = {
18 22
       title: tool.shareTitle,
19
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
23
+      path: path,
20 24
       imageUrl: tool.shareImg
21 25
     }
22 26
     return shareData;

+ 5 - 1
src/moduleB/pages/real/index.jsx

@@ -61,9 +61,13 @@ export default class Task extends Component {
61 61
     })
62 62
   }
63 63
   onShareAppMessage = (res) => {
64
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
65
+    if (process.env.TARO_ENV == 'tt') {
66
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
67
+    }
64 68
     let shareData = {
65 69
       title: tool.shareTitle,
66
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
70
+      path: path,
67 71
       imageUrl: tool.shareImg
68 72
     }
69 73
     return shareData;

+ 5 - 1
src/moduleB/pages/realDetail/index.jsx

@@ -29,9 +29,13 @@ export default class Task extends Component {
29 29
   }
30 30
 
31 31
   onShareAppMessage = (res) => {
32
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
33
+    if (process.env.TARO_ENV == 'tt') {
34
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
35
+    }
32 36
     let shareData = {
33 37
       title: tool.shareTitle,
34
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
38
+      path: path,
35 39
       imageUrl: tool.shareImg
36 40
     }
37 41
     return shareData;

+ 5 - 1
src/pages/activity/index.jsx

@@ -53,9 +53,13 @@ export default class collection extends Component {
53 53
     })
54 54
   }
55 55
   onShareAppMessage = (res) => {
56
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
57
+    if (process.env.TARO_ENV == 'tt') {
58
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
59
+    }
56 60
     let shareData = {
57 61
       title: tool.shareTitle,
58
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
62
+      path: path,
59 63
       imageUrl: tool.shareImg
60 64
     }
61 65
     return shareData;

+ 2 - 2
src/pages/collection/index.jsx

@@ -17,10 +17,10 @@ export default class collection extends Component {
17 17
   }
18 18
 
19 19
   componentWillMount () {
20
-    // this.setInit(1, 'hot')
20
+    this.setInit(1, 'hot')
21 21
   }
22 22
   componentDidShow(){
23
-    this.setInit(1, 'hot')
23
+    // this.setInit(1, 'hot')
24 24
   }
25 25
   setInit (page, type) {
26 26
     this.setState({

+ 181 - 10
src/pages/index/index.jsx

@@ -1,5 +1,5 @@
1 1
 import { Component } from 'react'
2
-import { View, Text, Button, Image, ScrollView, Input, Textarea, Slider, Block } from '@tarojs/components'
2
+import { View, Text, Button, Image, Swiper, SwiperItem, ScrollView, Input, Textarea, Slider, Block } from '@tarojs/components'
3 3
 import Taro, { getCurrentInstance } from '@tarojs/taro'
4 4
 import tool from '../../common/tool'
5 5
 import { AtFloatLayout } from 'taro-ui'
@@ -14,6 +14,8 @@ export default class Mine extends Component {
14 14
     models: [],//模板
15 15
     imgSize: [],//图片尺寸
16 16
     sampling: [],//采样方式
17
+    draw_infos: [
18
+    ],//banner
17 19
     samplingIndex: 0,//当前选择的采样方式
18 20
     loraIndex: 0,//当前选择的风格
19 21
     sizeIndex: 0,//当前选择的尺寸
@@ -29,19 +31,20 @@ export default class Mine extends Component {
29 31
     tagsIndex: 0,//当前选择的主标签
30 32
     isTags: false,//是否打开标签弹窗
31 33
     consultImg: '',//参考图
34
+    lastTime: 0
32 35
   }
33 36
 
34 37
   componentDidShow () {
35 38
     //接收裁剪图片
36 39
     let pages = Taro.getCurrentPages();
37 40
     let currentPage = pages[pages.length - 1]; // 获取当前页面
38
-    console.log(currentPage, 'currentPage');
39 41
     if (process.env.TARO_ENV == 'weapp') {
40 42
       if (currentPage.__data__.consultImg) { // 获取值
41 43
         this.setState({
42 44
           consultImg: currentPage.__data__.consultImg,
43 45
           sizeIndex: currentPage.__data__.sizeIndex
44 46
         })
47
+        currentPage.__data__.consultImg = ''
45 48
       }
46 49
     } else if (process.env.TARO_ENV == 'tt') {
47 50
       if (currentPage.data.consultImg) { // 获取值
@@ -49,6 +52,7 @@ export default class Mine extends Component {
49 52
           consultImg: currentPage.data.consultImg,
50 53
           sizeIndex: currentPage.data.sizeIndex
51 54
         })
55
+        currentPage.data.consultImg = ''
52 56
       }
53 57
     }
54 58
     this.getDrawIndex()
@@ -77,9 +81,13 @@ export default class Mine extends Component {
77 81
   }
78 82
 
79 83
   onShareAppMessage = (res) => {
84
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
85
+    if (process.env.TARO_ENV == 'tt') {
86
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
87
+    }
80 88
     let shareData = {
81 89
       title: tool.shareTitle,
82
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
90
+      path: path,
83 91
       imageUrl: tool.shareImg
84 92
     }
85 93
     return shareData;
@@ -94,7 +102,8 @@ export default class Mine extends Component {
94 102
         this.setState({
95 103
           models: res.data.models,
96 104
           imgSize: res.data.img_size,
97
-          sampling: res.data.Sampler
105
+          sampling: res.data.Sampler,
106
+          draw_infos: res.data.banner_info
98 107
         }, () => {
99 108
           let routers = this.$instance.router.params
100 109
           console.log(routers, 'rou');
@@ -171,6 +180,7 @@ export default class Mine extends Component {
171 180
       this.setState({
172 181
         value: ''
173 182
       })
183
+      document.getElementById('textarea-num').innerHTML = 0 + "/1000";
174 184
     }, 200)
175 185
   }
176 186
   deleteNegativeValue () {
@@ -178,6 +188,7 @@ export default class Mine extends Component {
178 188
       this.setState({
179 189
         negativeValue: ''
180 190
       })
191
+      document.getElementById('negative_prompt').innerHTML = 0 + "/1000";
181 192
     }, 200)
182 193
   }
183 194
   onInput (e) {
@@ -300,6 +311,7 @@ export default class Mine extends Component {
300 311
   }
301 312
   //生成图片
302 313
   generatePictures () {
314
+    let that = this
303 315
     Taro.showLoading({
304 316
       title: '加载中',
305 317
     })
@@ -335,9 +347,10 @@ export default class Mine extends Component {
335 347
           this.subscribe(res.data.task_id)
336 348
         }
337 349
         Taro.navigateTo({
338
-          url: `/moduleA/pages/darwDetail/index?task_id=${res.data.task_id}`
350
+          url: `/moduleA/pages/darwDetailIndex/index?task_id=${res.data.task_id}`
339 351
         })
340 352
       } else {
353
+        console.log('11111111111');
341 354
         Taro.hideLoading()
342 355
         if (res.code == 4001) {
343 356
           Taro.showModal({
@@ -353,6 +366,23 @@ export default class Mine extends Component {
353 366
               }
354 367
             }
355 368
           })
369
+        } if (res.code == 4002) {
370
+          Taro.showModal({
371
+            title: '提示',
372
+            content: res.msg,
373
+            success: function (item) {
374
+              if (item.confirm) {
375
+                if (process.env.TARO_ENV != 'weapp') {
376
+                  that.playVideoTT(res.data)
377
+                } else {
378
+                  that.playVideo(res.data)
379
+                }
380
+              } else if (item.cancel) {
381
+                console.log('用户点击取消')
382
+              }
383
+            }
384
+          })
385
+
356 386
         } else {
357 387
           Taro.showToast({ icon: 'none', title: res.msg })
358 388
         }
@@ -360,6 +390,126 @@ export default class Mine extends Component {
360 390
     })
361 391
     // }, 1000)
362 392
   }
393
+  //抖音激励广告
394
+  playVideoTT (item) {
395
+    let lastTime = this.state.lastTime;
396
+    let now = new Date().getTime();
397
+    if (now - lastTime < 2000) return
398
+    console.log(item, 'itehndodjd');
399
+    this.setState({
400
+      lastTime: now
401
+    })
402
+    Taro.showLoading({
403
+      title: '加载中...'
404
+    })
405
+    const videoAd = tt.createRewardedVideoAd({ adUnitId: item.jumpurl });
406
+    videoAd.show()
407
+    videoAd.onError((err) => {
408
+      Taro.hideLoading();
409
+      switch (err.errCode) {
410
+        case 1004:
411
+          // 无合适的广告
412
+          break;
413
+        default:
414
+        // 更多请参考错误码文档
415
+      }
416
+    });
417
+    // 监听视频播放完成
418
+    videoAd.onClose((data) => {
419
+      Taro.hideLoading();
420
+      if (data.isEnded) {
421
+        api.finishTask({ task_id: item.id }).then(res => {
422
+          if (res.code == 200) {
423
+            that.getUserInfo()
424
+            that.getCoinTaskList()
425
+            Taro.showToast({
426
+              title: '领取点券成功',
427
+              icon: 'none',
428
+              duration: 2000
429
+            })
430
+          }
431
+        })
432
+      } else {
433
+        Taro.showToast({
434
+          title: '领取点券失败',
435
+          icon: 'none',
436
+          duration: 2000
437
+        })
438
+      }
439
+    });
440
+  }
441
+  //微信激励广告
442
+  playVideo (item) {
443
+    let lastTime = this.state.lastTime;
444
+    let now = new Date().getTime();
445
+    if (now - lastTime < 2000) return
446
+    console.log(item, 'itehndodjd');
447
+    this.setState({
448
+      lastTime: now
449
+    })
450
+    // 在页面中定义激励视频广告
451
+    let adUnitId = item.jumpurl
452
+    // 在页面中定义激励视频广告
453
+    let videoAd = null
454
+    let that = this
455
+    console.log(videoAd, 'videoAd');
456
+    // 在页面onLoad回调事件中创建激励视频广告实例
457
+    if (wx.createRewardedVideoAd) {
458
+      videoAd = wx.createRewardedVideoAd({
459
+        adUnitId: adUnitId
460
+      })
461
+      videoAd.onLoad(() => { })
462
+      videoAd.onError((err) => { })
463
+      try {
464
+        if (videoAd.closeHandler) {
465
+          videoAd.offClose(videoAd.closeHandler);
466
+          console.log("videoAd.offClose卸载成功");
467
+        }
468
+      } catch (e) {
469
+        console.log("videoAd.offClose 卸载失败");
470
+        console.error(e);
471
+      }
472
+      videoAd.closeHandler = function (res) {
473
+        // 用户点击了【关闭广告】按钮
474
+        if (res && res.isEnded || res === undefined) {
475
+          // 正常播放结束,可以下发游戏奖励
476
+          api.finishTask({ task_id: item.id }).then(res => {
477
+            if (res.code == 200) {
478
+              that.getUserInfo()
479
+              that.getCoinTaskList()
480
+              Taro.showToast({
481
+                title: '领取点券成功',
482
+                icon: 'none',
483
+                duration: 2000
484
+              })
485
+            }
486
+          })
487
+        } else {
488
+          //提前关闭小程序
489
+        }
490
+      };
491
+      videoAd.onClose(videoAd.closeHandler);
492
+
493
+    }
494
+
495
+    // 用户触发广告后,显示激励视频广告
496
+    if (videoAd) {
497
+      videoAd.show().catch(() => {
498
+        // 失败重试
499
+        videoAd.load()
500
+          .then(() => videoAd.show())
501
+          .catch(err => {
502
+            Taro.showToast({
503
+              title: '暂无广告',
504
+              icon: 'none',
505
+              duration: 2000
506
+            })
507
+            console.log('激励视频 广告显示失败')
508
+          })
509
+      })
510
+    }
511
+
512
+  }
363 513
   toChat (e) {
364 514
   }
365 515
   //选择标签
@@ -417,6 +567,7 @@ export default class Mine extends Component {
417 567
     Taro.chooseMedia({
418 568
       count: 1, // 默认9
419 569
       sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
570
+      mediaType:['image'],
420 571
       sourceType: ['album', 'camera'],
421 572
       success: function (res) {
422 573
         console.log(res, 'res');
@@ -437,18 +588,38 @@ export default class Mine extends Component {
437 588
       consultImg: ''
438 589
     })
439 590
   }
440
-  toRealDetail () {
591
+  toRealDetail (item, index) {
441 592
     Taro.navigateTo({
442
-      url: `/moduleB/pages/realDetail/index?task_id=${23}`
593
+      url: item.jpath
443 594
     })
444 595
   }
445 596
 
446 597
   render () {
447 598
     return (
448 599
       <View className='mine'>
449
-        <View className='banner'>
450
-          <Image className='banner-image' onClick={e => (this.toRealDetail())} mode='aspectFit' src='http://video-img.fyshark.com/1680600043693banner-02.png'></Image>
451
-        </View>
600
+        {
601
+          this.state.draw_infos.length > 0 &&
602
+          <Swiper
603
+            className='banner'
604
+            indicatorColor='#121D34'
605
+            indicatorActiveColor='#0F84EC'
606
+            circular
607
+            autoplay
608
+            interval='3000'
609
+            adjustHeight='first'
610
+            indicatorDots
611
+          >
612
+            {
613
+              this.state.draw_infos.map((item, index) => (
614
+                <SwiperItem key={index}>
615
+                  <View className='banner-info'>
616
+                    <Image className='banner-image' src={item.img} onClick={e => (this.toRealDetail(item, index))}></Image>
617
+                  </View>
618
+                </SwiperItem>
619
+              ))
620
+            }
621
+          </Swiper>
622
+        }
452 623
         <View className='draw-content'>
453 624
           <View className='draw-title'>绘画描述</View>
454 625
           <View className='draw-text'>

+ 7 - 2
src/pages/index/index.less

@@ -2,8 +2,14 @@
2 2
   min-height: 100vh;
3 3
   background-color: #041129;
4 4
 .banner{
5
-  .banner-image{
5
+  height: 362px;
6
+  .banner-info{
6 7
     width: 100%;
8
+    height: 100%;
9
+    .banner-image{
10
+      width: 100%;
11
+      height: 100%;
12
+    }
7 13
   }
8 14
 }
9 15
   .draw-content {
@@ -435,7 +441,6 @@
435 441
       }
436 442
       .delete{
437 443
         position: absolute;
438
-        position: absolute;
439 444
         right: -20px;
440 445
         top: -20px;
441 446
         width: 40px;

+ 8 - 3
src/pages/mine/index.jsx

@@ -13,12 +13,17 @@ export default class Mine extends Component {
13 13
   }
14 14
 
15 15
   componentDidShow () {
16
+    console.log('111');
16 17
     this.getUserInfo()
17 18
   }
18 19
   onShareAppMessage = (res) => {
20
+    let path = `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`
21
+    if (process.env.TARO_ENV == 'tt') {
22
+      path = `/pages/index/index?c=channel_name&s=douyinguazai`
23
+    }
19 24
     let shareData = {
20 25
       title: tool.shareTitle,
21
-      path: `/pages/index/index?c=${Taro.getStorageSync('user_id')}&s=rightTap`,
26
+      path: path,
22 27
       imageUrl: tool.shareImg
23 28
     }
24 29
     return shareData;
@@ -47,7 +52,7 @@ export default class Mine extends Component {
47 52
     switch (index) {
48 53
       case 0:
49 54
         Taro.navigateTo({
50
-          url: `/moduleB/pages/works/index`
55
+          url: `/moduleB/pages/imageWorks/index`
51 56
         })
52 57
         break;
53 58
       case 1:
@@ -102,7 +107,7 @@ export default class Mine extends Component {
102 107
         <View className='work-list'>
103 108
           <View className='work-info' onClick={e => (this.toDetail(0))}>
104 109
             <Image className='work-img' src='http://video-img.fyshark.com/1680506115183icon-%E6%88%91%E7%9A%84%E4%BD%9C%E5%93%81.png'></Image>
105
-            <View className='work-title'>我的作品</View>
110
+            <View className='work-title'>绘画作品</View>
106 111
           </View>
107 112
           <View className='work-info' onClick={e => (this.toDetail(1))}>
108 113
             <Image className='work-img' src='http://video-img.fyshark.com/1680506124768icon-%E9%82%80%E8%AF%B7%E5%A5%BD%E5%8F%8B.png'></Image>

+ 58 - 1
src/service/index.js

@@ -107,13 +107,20 @@ export const getShopList = data =>
107 107
     method: 'POST',
108 108
     data,
109 109
   });
110
-//获取商品列表
110
+//创建微信订单
111 111
 export const createOrder = data =>
112 112
   Request({
113 113
     url: '/api/wx_create_order',
114 114
     method: 'POST',
115 115
     data,
116 116
   });
117
+//创建抖音订单
118
+export const ttCreateOrder = data =>
119
+  Request({
120
+    url: '/api/pay/tt_create_order',
121
+    method: 'POST',
122
+    data,
123
+  });
117 124
 //删除作品
118 125
 export const userDelImg = data =>
119 126
   Request({
@@ -207,6 +214,56 @@ export const aiFaceMege = data =>
207 214
     method: 'POST',
208 215
     data,
209 216
   });
217
+//诗文成画
218
+export const aiPoetryDraw = data =>
219
+  Request({
220
+    url: '/api/ai_poetry_draw',
221
+    method: 'POST',
222
+    data,
223
+  });
224
+//诗文推荐词
225
+export const getRadomPoetry = data =>
226
+  Request({
227
+    url: '/api/get_radom_poetry',
228
+    method: 'POST',
229
+    data,
230
+  });
231
+//诗文推荐词转义
232
+export const getDrawPromptText = data =>
233
+  Request({
234
+    url: '/api/get_draw_prompt_text',
235
+    method: 'POST',
236
+    data,
237
+  });
238
+//人物动漫化
239
+export const getDrawGcImgIndex = data =>
240
+  Request({
241
+    url: '/api/get_draw_gc_img_index',
242
+    method: 'POST',
243
+    data,
244
+  });
245
+//人物动漫化详情
246
+export const getDrawTaskStatusGc = data =>
247
+  Request({
248
+    url: '/api/get_draw_task_status_gc',
249
+    method: 'POST',
250
+    data,
251
+  });
252
+  //人物动漫化解锁
253
+export const unlockGcImg = data =>
254
+Request({
255
+  url: '/api/unlock_gc_img',
256
+  method: 'POST',
257
+  data,
258
+});
259
+  //人物动漫化解锁
260
+  export const drawGcImgTask = data =>
261
+  Request({
262
+    url: '/api/draw_gc_img_task',
263
+    method: 'POST',
264
+    data,
265
+  });
266
+  
210 267
 
211 268
 
212 269