|
@@ -1,6 +1,7 @@
|
1
|
1
|
import Taro, { Component } from '@tarojs/taro';
|
2
|
2
|
import { TaroCanvasDrawer } from '@/components/taro-plugin-canvas';
|
3
|
3
|
import dayjs from 'dayjs'
|
|
4
|
+import rtLog from '@/utils/rtLog'
|
4
|
5
|
/**
|
5
|
6
|
* 文档参考
|
6
|
7
|
* http://taro-ext.jd.com/plugin/view/5d23051670a0f46a87c9785b
|
|
@@ -34,38 +35,38 @@ export default class Index extends Component {
|
34
|
35
|
const texts = [
|
35
|
36
|
|
36
|
37
|
{
|
37
|
|
- x:120,
|
|
38
|
+ x: 120,
|
38
|
39
|
y: 90,
|
39
|
40
|
text: data.nickname,
|
40
|
|
- fontSize:28,
|
|
41
|
+ fontSize: 28,
|
41
|
42
|
color: '#000',
|
42
|
43
|
baseLine: 'middle',
|
43
|
44
|
lineHeight: 48,
|
44
|
45
|
width: 200,
|
45
|
46
|
},
|
46
|
47
|
{
|
47
|
|
- x:250,
|
|
48
|
+ x: 250,
|
48
|
49
|
y: 580,
|
49
|
50
|
text: data.tip,
|
50
|
|
- fontSize:20,
|
|
51
|
+ fontSize: 20,
|
51
|
52
|
color: '#999999',
|
52
|
53
|
baseLine: 'middle',
|
53
|
54
|
lineHeight: 48,
|
54
|
55
|
width: 500,
|
55
|
|
- textAlign:'center'
|
|
56
|
+ textAlign: 'center'
|
56
|
57
|
},
|
57
|
|
-
|
|
58
|
+
|
58
|
59
|
]
|
59
|
60
|
const images = [
|
60
|
|
-
|
|
61
|
+
|
61
|
62
|
{
|
62
|
63
|
url: data.avatarurl || require('@/assets/default-avatar.png'),
|
63
|
64
|
width: 90,
|
64
|
65
|
height: 90,
|
65
|
66
|
y: 30,
|
66
|
67
|
x: 20,
|
67
|
|
- borderWidth:1,
|
68
|
|
- borderRadius:20,
|
|
68
|
+ borderWidth: 1,
|
|
69
|
+ borderRadius: 20,
|
69
|
70
|
},
|
70
|
71
|
{
|
71
|
72
|
url: data.qrcode,
|
|
@@ -77,16 +78,16 @@ export default class Index extends Component {
|
77
|
78
|
]
|
78
|
79
|
const blocks = [
|
79
|
80
|
{
|
80
|
|
- x:300,
|
|
81
|
+ x: 300,
|
81
|
82
|
y: 100,
|
82
|
83
|
color: '#fff',
|
83
|
84
|
baseLine: 'middle',
|
84
|
85
|
lineHeight: 48,
|
85
|
86
|
width: 500,
|
86
|
|
- height:530
|
|
87
|
+ height: 530
|
87
|
88
|
},
|
88
|
89
|
]
|
89
|
|
- const config = Object.assign(basicConfig, {images, texts,blocks })
|
|
90
|
+ const config = Object.assign(basicConfig, { images, texts, blocks })
|
90
|
91
|
this.setState({
|
91
|
92
|
config,
|
92
|
93
|
canvasStatus: true
|
|
@@ -94,11 +95,12 @@ export default class Index extends Component {
|
94
|
95
|
}
|
95
|
96
|
|
96
|
97
|
onCreateSuccess = (result) => {
|
97
|
|
- console.log(result,"生成图片resultresultresultresult")
|
|
98
|
+ rtLog.error(result, "==================================")
|
|
99
|
+ console.log(result, "生成图片resultresultresultresult")
|
98
|
100
|
const { tempFilePath, errMsg } = result;
|
99
|
101
|
Taro.hideLoading();
|
100
|
102
|
if (errMsg === 'canvasToTempFilePath:ok') {
|
101
|
|
-
|
|
103
|
+
|
102
|
104
|
this.setState({
|
103
|
105
|
shareImage: tempFilePath,
|
104
|
106
|
// 重置 TaroCanvasDrawer 状态,方便下一次调用
|
|
@@ -107,13 +109,13 @@ export default class Index extends Component {
|
107
|
109
|
})
|
108
|
110
|
Taro.saveImageToPhotosAlbum({
|
109
|
111
|
filePath: tempFilePath,
|
110
|
|
- success:function(res){
|
|
112
|
+ success: function (res) {
|
111
|
113
|
Taro.showToast({
|
112
|
114
|
title: '已保存到相册',
|
113
|
115
|
icon: 'success',
|
114
|
116
|
duration: 2000,
|
115
|
117
|
});
|
116
|
|
- },fail:function(){
|
|
118
|
+ }, fail: function () {
|
117
|
119
|
Taro.showToast({
|
118
|
120
|
title: '保存失败,请打开相册权限',
|
119
|
121
|
icon: 'none',
|
|
@@ -131,7 +133,7 @@ export default class Index extends Component {
|
131
|
133
|
Taro.showToast({ icon: 'none', title: errMsg || '出现错误' });
|
132
|
134
|
console.log(errMsg);
|
133
|
135
|
}
|
134
|
|
-
|
|
136
|
+
|
135
|
137
|
|
136
|
138
|
// 预览
|
137
|
139
|
// Taro.previewImage({
|