stellar-ui-v2 1.40.17 → 1.40.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,15 @@
1
+ async function getImage(src) {
2
+ const image = await uni.getImageInfo({ src: src });
3
+ if (Array.isArray(image)) {
4
+ const [e, img] = image;
5
+ if (e) throw e;
6
+ return img;
7
+ } else if (image.path) {
8
+ return image;
9
+ }
10
+ throw new Error('获取图片失败');
11
+ }
12
+
1
13
  /**
2
14
  * @param {UniApp.CanvasContext} ctx
3
15
  * @param {{background:string;title:string;message:string;qrcode:string}} poster
@@ -21,7 +33,7 @@ export function drawPoster(ctx, poster, data) {
21
33
  // 绘制宽高一致的图片
22
34
  if (data.image) {
23
35
  try {
24
- const image = await uni.getImageInfo({ src: data.image });
36
+ const image = await getImage(data.image);
25
37
  ctx.drawImage(image.path, 0, 40, width, width);
26
38
  } catch (e) {
27
39
  console.error(e);
@@ -46,7 +58,7 @@ export function drawPoster(ctx, poster, data) {
46
58
  ctx.setFontSize(20);
47
59
  ctx.setFillStyle('#ff0000');
48
60
  ctx.setTextAlign('left');
49
- ctx.fillText(`¥${data.price}`, 10, width + 125);
61
+ ctx.fillText(`¥${data.price}`, 10, width + 130);
50
62
  }
51
63
 
52
64
  // 绘制文字
@@ -54,12 +66,12 @@ export function drawPoster(ctx, poster, data) {
54
66
  ctx.setFontSize(12);
55
67
  ctx.setFillStyle('#666666');
56
68
  ctx.setTextAlign('left');
57
- ctx.fillText(poster.message, 10, height - 20);
69
+ ctx.fillText(poster.message, 10, height - 25);
58
70
  }
59
71
  // 绘制qrcode
60
72
  if (poster.qrcode) {
61
73
  try {
62
- const qrcode = await uni.getImageInfo({ src: poster.qrcode });
74
+ const qrcode = await getImage(poster.qrcode);
63
75
  ctx.drawImage(qrcode.path, width - 80, width + 80, 70, 70);
64
76
  } catch (e) {
65
77
  console.error(e);
@@ -25,14 +25,12 @@
25
25
  <image class="footer-icon" src="../../static/shoucang.png" mode="widthFix"></image>
26
26
  <text>微信收藏</text>
27
27
  </view>
28
+ <view class="footer-item" @click="downloadPoster" v-if="viewPoster">
29
+ <image class="footer-icon" src="../../static/haibao.png" mode="widthFix"></image>
30
+ <text>生成海报</text>
31
+ </view>
28
32
  </view>
29
33
  </scroll-view>
30
- <view class="footer-share-list">
31
- <view class="footer-item" @click="downloadPoster" v-if="viewPoster">
32
- <image class="footer-icon" src="../../static/haibao.png" mode="widthFix"></image>
33
- <text>生成海报</text>
34
- </view>
35
- </view>
36
34
  </view>
37
35
  </view>
38
36
  </template>
@@ -116,13 +114,13 @@ export default {
116
114
  this.ctx.width = canvas.width;
117
115
  this.ctx.height = canvas.height;
118
116
 
119
- drawPoster(this.ctx, this.poster, this.data).then(() => {
117
+ drawPoster(this.ctx, this.poster, this.data).finally(() => {
120
118
  this.loading = false;
121
119
  });
122
120
  })
123
121
  .exec();
124
122
  } else {
125
- drawPoster(this.ctx, this.poster, this.data).then(() => {
123
+ drawPoster(this.ctx, this.poster, this.data).finally(() => {
126
124
  this.loading = false;
127
125
  });
128
126
  }
@@ -166,8 +164,8 @@ export default {
166
164
  .content-box {
167
165
  position: absolute;
168
166
  width: 660rpx;
169
- height: 1020rpx;
170
- top: 120rpx;
167
+ height: 960rpx;
168
+ top: 90rpx;
171
169
  left: 50%;
172
170
  transform: translateX(-50%);
173
171
  z-index: 9;
@@ -525,13 +525,15 @@ export default {
525
525
  this.isInitCapture = true;
526
526
  const p = video.play();
527
527
  if (p !== undefined) {
528
- p.then(() => {
529
- video.pause();
530
- video.currentTime = 0;
531
- this.isInitCapture = false;
532
- }).catch(() => {
533
- this.isInitCapture = false;
534
- });
528
+ setTimeout(() => {
529
+ p.then(() => {
530
+ video.pause();
531
+ video.currentTime = 0;
532
+ this.isInitCapture = false;
533
+ }).catch(() => {
534
+ this.isInitCapture = false;
535
+ });
536
+ }, 100)
535
537
  } else {
536
538
  this.isInitCapture = false;
537
539
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellar-ui-v2",
3
- "version": "1.40.17",
3
+ "version": "1.40.18",
4
4
  "description": "StellarUI组件库",
5
5
  "main": "stellar-ui/index.js",
6
6
  "private": false,