@uxda/appkit 4.3.6 → 4.3.8

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.
Files changed (135) hide show
  1. package/.eslintrc.mjs +7 -7
  2. package/COMPONENT_USAGE.md +1523 -1523
  3. package/PROJECT_DOCS.md +142 -142
  4. package/README.md +187 -187
  5. package/babel.config.js +12 -12
  6. package/dist/appkit.css +15 -63
  7. package/dist/assets/asset-DcH8Kg-2 +1 -0
  8. package/dist/index.js +259 -806
  9. package/package.json +79 -79
  10. package/project.config.json +15 -15
  11. package/project.tt.json +13 -13
  12. package/rollup.config.mjs +78 -78
  13. package/src/Appkit.ts +72 -72
  14. package/src/balance/api/endpoints.ts +133 -133
  15. package/src/balance/api/index.ts +118 -118
  16. package/src/balance/components/AccountView.vue +770 -770
  17. package/src/balance/components/BalanceCard.vue +210 -210
  18. package/src/balance/components/BalanceReminder.vue +84 -84
  19. package/src/balance/components/ConsumptionFilter.vue +218 -218
  20. package/src/balance/components/ConsumptionRules.vue +68 -68
  21. package/src/balance/components/DateFilter.vue +259 -259
  22. package/src/balance/components/DateRange.vue +111 -111
  23. package/src/balance/components/ListFilter.vue +62 -62
  24. package/src/balance/components/ListFilterPicker.vue +191 -191
  25. package/src/balance/components/PromoterCard.vue +307 -308
  26. package/src/balance/components/SecondBalance.vue +77 -77
  27. package/src/balance/components/Tip.vue +45 -45
  28. package/src/balance/components/index.ts +8 -8
  29. package/src/balance/types.ts +99 -99
  30. package/src/components/bt-cropper/index.vue +730 -730
  31. package/src/components/bt-cropper/utils/calcCropper.js +42 -42
  32. package/src/components/bt-cropper/utils/calcImagePosition.js +23 -23
  33. package/src/components/bt-cropper/utils/calcImageSize.js +37 -37
  34. package/src/components/bt-cropper/utils/calcPointDistance.js +12 -12
  35. package/src/components/bt-cropper/utils/calcRightAndBottom.js +7 -7
  36. package/src/components/bt-cropper/utils/ratio.js +3 -3
  37. package/src/components/bt-cropper/utils/tools.js +25 -25
  38. package/src/components/dd-area/index.vue +225 -225
  39. package/src/components/dd-icon/doc.md +21 -21
  40. package/src/components/dd-icon/index.vue +23 -23
  41. package/src/components/dd-notice-bar/index.vue +78 -78
  42. package/src/components/dd-search/doc.md +34 -34
  43. package/src/components/dd-search/index.vue +168 -168
  44. package/src/components/dd-selector/index.vue +124 -124
  45. package/src/components/dd-skeleton/doc.md +19 -19
  46. package/src/components/dd-skeleton/index.vue +36 -36
  47. package/src/global.ts +6 -6
  48. package/src/index.ts +101 -101
  49. package/src/main.scss +1 -1
  50. package/src/notice/api/endpoints.ts +54 -54
  51. package/src/notice/api/index.ts +121 -121
  52. package/src/notice/components/NoticeBanner.vue +247 -247
  53. package/src/notice/components/NoticeEntry.vue +99 -99
  54. package/src/notice/components/NoticeList.vue +311 -311
  55. package/src/notice/components/NoticeList2.vue +400 -399
  56. package/src/notice/components/NoticePopup.vue +163 -163
  57. package/src/notice/components/index.ts +6 -6
  58. package/src/notice/components/useCommonList.ts +86 -87
  59. package/src/notice/components/useNotice.ts +35 -35
  60. package/src/notice/index.ts +1 -1
  61. package/src/notice/types.ts +25 -25
  62. package/src/payment/api/config.ts +7 -7
  63. package/src/payment/api/endpoints.ts +96 -98
  64. package/src/payment/api/index.ts +107 -108
  65. package/src/payment/components/AmountPicker.vue +90 -90
  66. package/src/payment/components/RechargeResult.vue +69 -68
  67. package/src/payment/components/RechargeView.vue +191 -191
  68. package/src/payment/components/RightsPicker.vue +105 -105
  69. package/src/payment/components/TradeView.vue +363 -571
  70. package/src/payment/components/UserAgreement.vue +234 -234
  71. package/src/payment/components/index.ts +22 -22
  72. package/src/payment/index.ts +5 -5
  73. package/src/payment/services/index.ts +16 -16
  74. package/src/payment/services/invoke-recharge.ts +25 -25
  75. package/src/payment/services/request-payment.ts +130 -132
  76. package/src/payment/types.ts +33 -34
  77. package/src/register/components/SelfRegistration.vue +233 -233
  78. package/src/register/components/index.ts +2 -2
  79. package/src/scenarios/components/SharePoster.vue +364 -364
  80. package/src/scenarios/components/index.ts +2 -2
  81. package/src/scenarios/components/poster-paste.vue +93 -93
  82. package/src/scenarios/components/share-poster.md +273 -273
  83. package/src/shared/components/AppDrawer.vue +53 -53
  84. package/src/shared/components/AppVerify.vue +128 -137
  85. package/src/shared/components/DeviceVersion.vue +78 -78
  86. package/src/shared/components/EmptyView.vue +33 -33
  87. package/src/shared/components/OcrBusinessLicense.vue +137 -120
  88. package/src/shared/components/OcrIcon.vue +229 -267
  89. package/src/shared/components/PageHeader.vue +84 -84
  90. package/src/shared/components/index.ts +8 -10
  91. package/src/shared/composables/index.ts +9 -10
  92. package/src/shared/composables/useAmount.ts +46 -46
  93. package/src/shared/composables/useCountdown.ts +46 -46
  94. package/src/shared/composables/useCrypto.ts +76 -76
  95. package/src/shared/composables/useDeviceEnv.ts +26 -26
  96. package/src/shared/composables/useDragBox.ts +97 -97
  97. package/src/shared/composables/useEncode.ts +43 -43
  98. package/src/shared/composables/useLogger.ts +144 -144
  99. package/src/shared/composables/useSafeArea.ts +46 -46
  100. package/src/shared/composables/useTabbar.ts +24 -24
  101. package/src/shared/composables/useUpload.ts +61 -106
  102. package/src/shared/composables/useValidator.ts +32 -32
  103. package/src/shared/composables/useWxAuth.ts +48 -48
  104. package/src/shared/http/Http.ts +148 -149
  105. package/src/shared/http/index.ts +1 -1
  106. package/src/shared/http/types.ts +163 -163
  107. package/src/shared/index.ts +9 -9
  108. package/src/shared/tracking/directives/index.ts +40 -40
  109. package/src/shared/tracking/examples/page-tracking-template.vue +27 -27
  110. package/src/shared/tracking/tracking-sdk.ts +1 -0
  111. package/src/shared/weixin/index.ts +9 -9
  112. package/src/shared/weixin/jssdk.ts +103 -104
  113. package/src/shared/weixin/payment.ts +38 -38
  114. package/src/styles/vars.scss +3 -3
  115. package/src/user/api/endpoints.ts +17 -17
  116. package/src/user/api/index.ts +123 -123
  117. package/src/user/components/LoginSetting.vue +114 -114
  118. package/src/user/components/UserAuth.vue +218 -218
  119. package/src/user/components/UserBinding.vue +277 -277
  120. package/src/user/components/UserBindingSuccess.vue +80 -80
  121. package/src/user/components/UserEntry.vue +139 -139
  122. package/src/user/components/UserFeedback.vue +427 -428
  123. package/src/user/components/UserFeedbackEntry.vue +175 -175
  124. package/src/user/components/UserHeadCrop.vue +65 -65
  125. package/src/user/components/UserInfo.vue +709 -711
  126. package/src/user/components/UserResourceEmpty.vue +75 -75
  127. package/src/user/components/index.ts +23 -23
  128. package/src/user/index.ts +1 -1
  129. package/src/utils/utils.ts +33 -33
  130. package/tsconfig.json +30 -30
  131. package/types/global.d.ts +22 -24
  132. package/types/vue.d.ts +10 -10
  133. package/src/shared/components/OcrBank.vue +0 -202
  134. package/src/shared/components/OcrInvoice.vue +0 -218
  135. package/src/shared/composables/useCompress.ts +0 -64
@@ -1,364 +1,364 @@
1
- <template>
2
- <nut-popup round v-model:visible="sheetOpen" position="bottom">
3
- <template v-if="sheetOpen">
4
- <div class="share-dialog column align-stretch">
5
- <div class="swiper-container">
6
- <div
7
- class="poster-display row justify-center"
8
- v-if="posters.length === 1"
9
- >
10
- <poster-paste
11
- :poster="posters[0]"
12
- :logo="config.logo"
13
- :nick="config.nick"
14
- :zoom="zoom"
15
- />
16
- </div>
17
- <swiper
18
- v-if="posters.length > 1"
19
- class="swiper"
20
- :current="current"
21
- :autoplay="false"
22
- :indicator-dots="false"
23
- :circular="true"
24
- display-multiple-items="3"
25
- @change="onSwiperChange"
26
- >
27
- <swiper-item
28
- :class="['swiper-item', { center: isCenter(index) }]"
29
- v-for="(poster, index) in posters"
30
- :key="`${index}`"
31
- >
32
- <div class="slide">
33
- <poster-paste
34
- :poster="poster"
35
- :logo="config.logo"
36
- :nick="config.nick"
37
- :zoom="zoom"
38
- />
39
- </div>
40
- </swiper-item>
41
- </swiper>
42
- </div>
43
- <div class="swiper-dots" justify="center" :gap="8">
44
- <div
45
- class="dot"
46
- :class="{
47
- current:
48
- current === index || current - posters.length / 2 === index,
49
- }"
50
- v-for="(_, index) in Array(posters.length / 2).fill('')"
51
- :key="index"
52
- />
53
- </div>
54
- <div
55
- class="text-center"
56
- style="font-size: 13px; color: #666666; margin: 10px"
57
- v-if="text"
58
- >
59
- {{ text }}
60
- </div>
61
- <div class="line"></div>
62
- <div class="bottom">
63
- <nut-button class="cancel-btn" v-track-click="'海报分享-取消'" @click="onCancelClick"
64
- >取消</nut-button
65
- >
66
- <nut-button type="primary" v-track-click="'海报分享-确定'" @click="onPosterShare">确定</nut-button>
67
- </div>
68
- </div>
69
- <canvas
70
- type="2d"
71
- id="poster-canvas"
72
- :style="`height: ${o.h}px;width:${o.w}px;transform:translate3d(-5000px, 0, 0);position: absolute;`"
73
- >
74
- </canvas>
75
- </template>
76
- </nut-popup>
77
- </template>
78
-
79
- <script lang="ts" setup>
80
- import { ref, watch } from 'vue';
81
- import Taro from '@tarojs/taro';
82
- import PosterPaste from '../components/poster-paste.vue';
83
- import { dataURItoBlob, isWeb } from '../../utils/utils';
84
- import { Swiper, SwiperItem } from '@tarojs/components';
85
-
86
- const emit = defineEmits(['share']);
87
-
88
- export type ShareDialogProps = {
89
- // 海报列表
90
- posters: any[];
91
- text?: string;
92
- };
93
-
94
- const props = defineProps<ShareDialogProps>();
95
-
96
- const o = {
97
- // 图片原始大小
98
- w: 375,
99
- h: 812,
100
- },
101
- z = 480, // 缩放后高度
102
- zoom = z / o.h;
103
-
104
- const config = ref();
105
- config.value = {
106
- nick: '',
107
- logo: '',
108
- qr: '',
109
- };
110
-
111
- // 真实的 current
112
- const current = ref(0);
113
-
114
- const getCentered = () => {
115
- // change 事件返回的 current 为三张图中最左侧一张
116
- // 为了中间放大的效果, 将 swiper 属性 current 设置为 下一张
117
- if (props.posters.length === 1) return 0;
118
- // 多张海报, *假选中*中间一张
119
- let centered: number = current.value + 1;
120
- centered = centered === props.posters.length ? 0 : centered;
121
- return centered;
122
- };
123
-
124
- const isCenter = (index: number) => {
125
- return getCentered() === index;
126
- };
127
-
128
- const onSwiperChange = ({ detail }) => {
129
- current.value = detail.current;
130
- };
131
-
132
- const initCanvas = () => {
133
- return new Promise((resolve) => {
134
- setTimeout(() => {
135
- if (Taro.getEnv() === 'WEB') {
136
- const canvas = document.getElementById(
137
- 'poster-canvas'
138
- ) as HTMLCanvasElement;
139
- const context = canvas.getContext('2d');
140
- canvas.height = o.h * 2;
141
- canvas.width = o.w * 2;
142
- resolve({ context, canvas });
143
- } else {
144
- const pageInstance = Taro.getCurrentInstance()?.page || {}; // 拿到当前页面实例
145
- const query = Taro.createSelectorQuery().in(pageInstance); // 确定在当前页面内匹配子元素
146
- query
147
- .select('#poster-canvas')
148
- .fields({ node: true, size: true, context: true }, (res) => {
149
- const canvas = res.node;
150
- const context = canvas.getContext('2d');
151
- canvas.height = o.h * 2;
152
- canvas.width = o.w * 2;
153
- canvas.destHeight = o.h * 2;
154
- canvas.destWidth = o.w * 2;
155
- resolve({ context, canvas });
156
- })
157
- .exec();
158
- }
159
- }, 300);
160
- });
161
- };
162
-
163
- const drawImage = async (
164
- canvas: any,
165
- context: any,
166
- src: string,
167
- x?: number,
168
- y?: number,
169
- w?: number,
170
- h?: number
171
- ) => {
172
- return new Promise((resolve, reject) => {
173
- if (!src) {
174
- resolve(void 0);
175
- return;
176
- }
177
- const image = !isWeb() ? canvas.createImage() : new Image();
178
- image.crossOrigin = 'Anonymous';
179
- image.src = src;
180
- image.onload = function () {
181
- context.drawImage(image, x || 0, y || 0, w || o.w, h || o.h);
182
- resolve(void 0);
183
- };
184
- image.onerror = (e) => {
185
- resolve(image);
186
- };
187
- });
188
- };
189
- const onPosterShare = async () => {
190
- !isWeb() && Taro.showLoading({ title: '加载中...', mask: true });
191
- // @ts-ignore
192
- const { context, canvas } = await initCanvas(),
193
- c = getCentered();
194
- const p = props.posters[c];
195
- await drawImage(canvas, context, p.back, 0, 0, o.w * 2, o.h * 2);
196
- if (p.qr) {
197
- await drawImage(
198
- canvas,
199
- context,
200
- p.qr,
201
- p.qrX * 2,
202
- p.qrY * 2,
203
- p.qrW * 2,
204
- p.qrH * 2
205
- );
206
- }
207
- if (config.value.nick) {
208
- context.font = '24px sans-serif';
209
- context.fillText(config.value.nick, p.nickX * 2 - 10, p.nickY * 2 + 34);
210
- }
211
- if (config.value.logo) {
212
- await drawImage(
213
- canvas,
214
- context,
215
- config.value.logo,
216
- p.logoX * 2,
217
- p.logoY * 2,
218
- 54,
219
- 54
220
- );
221
- }
222
- context.save();
223
- if (isWeb()) {
224
- const dataURL = canvas.toDataURL('image/png');
225
- const blob = dataURItoBlob(dataURL);
226
- const imgUrl = URL.createObjectURL(blob);
227
- emit('share', imgUrl);
228
- } else {
229
- Taro.canvasToTempFilePath({
230
- canvas,
231
- success: (result) => {
232
- Taro.hideLoading();
233
- Taro.showShareImageMenu({
234
- path: result.tempFilePath,
235
- });
236
- },
237
- fail: () => {
238
- Taro.showToast({
239
- title: '海报生成失败,请重试',
240
- icon: 'none',
241
- });
242
- },
243
- });
244
- }
245
- };
246
-
247
- watch(
248
- () => props.posters,
249
- () => {
250
- if (props.posters[0]?.nick) {
251
- config.value.nick = props.posters[0].nick;
252
- }
253
- if (props.posters[0]?.logo) {
254
- config.value.logo = props.posters[0].logo;
255
- }
256
- }
257
- );
258
-
259
- const sheetOpen = ref(false);
260
- const onCancelClick = () => {
261
- sheetOpen.value = false;
262
- };
263
- function openShareDialog() {
264
- sheetOpen.value = !sheetOpen.value;
265
- }
266
-
267
- defineExpose({
268
- openShareDialog,
269
- });
270
- </script>
271
-
272
- <style lang="scss">
273
- .share-dialog {
274
- padding: 40px 0 0;
275
- overflow: hidden auto;
276
-
277
- .swiper-container {
278
- position: relative;
279
- width: 100%;
280
- height: 480px;
281
- overflow: hidden;
282
- }
283
-
284
- .swiper {
285
- width: 180%;
286
- height: 100%;
287
- margin: 0 -40%;
288
- }
289
-
290
- .swiper-item {
291
- width: 100%;
292
- display: flex;
293
- flex-direction: row;
294
- align-items: center;
295
-
296
- .poster-paste {
297
- transform: scale(0.8);
298
- }
299
-
300
- &.center {
301
- .poster-paste {
302
- transform: scale(1);
303
- }
304
- }
305
- }
306
-
307
- .swiper-dots {
308
- margin-top: 10px;
309
- height: 20px;
310
- display: flex;
311
- justify-content: center;
312
- align-items: center;
313
- .dot {
314
- width: 6px;
315
- height: 6px;
316
- background-color: #b0b7c4;
317
- border-radius: 3px;
318
- transition: width 0.5s;
319
- margin: 0 2px;
320
-
321
- &.current {
322
- background-color: #017fff;
323
- width: 15px;
324
- }
325
- }
326
- }
327
-
328
- .slide {
329
- width: 100%;
330
- }
331
-
332
- .buttons {
333
- margin-top: 60px;
334
-
335
- .btn {
336
- width: 50px;
337
- height: 50px;
338
- background-size: 100% 100%;
339
- background-color: #f8f8f8;
340
- border-radius: 10px;
341
- }
342
- }
343
-
344
- .bottom {
345
- padding: 12px;
346
- display: flex;
347
- .nut-button {
348
- flex: 1;
349
- }
350
- .cancel-btn {
351
- margin-right: 12px;
352
- flex: 1;
353
- border: 1px solid #017fff;
354
- color: #017fff;
355
- background: #fff;
356
- }
357
- }
358
-
359
- .line {
360
- background: #f1f5f9;
361
- height: 8.5px;
362
- }
363
- }
364
- </style>
1
+ <template>
2
+ <nut-popup round v-model:visible="sheetOpen" position="bottom">
3
+ <template v-if="sheetOpen">
4
+ <div class="share-dialog column align-stretch">
5
+ <div class="swiper-container">
6
+ <div
7
+ class="poster-display row justify-center"
8
+ v-if="posters.length === 1"
9
+ >
10
+ <poster-paste
11
+ :poster="posters[0]"
12
+ :logo="config.logo"
13
+ :nick="config.nick"
14
+ :zoom="zoom"
15
+ />
16
+ </div>
17
+ <swiper
18
+ v-if="posters.length > 1"
19
+ class="swiper"
20
+ :current="current"
21
+ :autoplay="false"
22
+ :indicator-dots="false"
23
+ :circular="true"
24
+ display-multiple-items="3"
25
+ @change="onSwiperChange"
26
+ >
27
+ <swiper-item
28
+ :class="['swiper-item', { center: isCenter(index) }]"
29
+ v-for="(poster, index) in posters"
30
+ :key="`${index}`"
31
+ >
32
+ <div class="slide">
33
+ <poster-paste
34
+ :poster="poster"
35
+ :logo="config.logo"
36
+ :nick="config.nick"
37
+ :zoom="zoom"
38
+ />
39
+ </div>
40
+ </swiper-item>
41
+ </swiper>
42
+ </div>
43
+ <div class="swiper-dots" justify="center" :gap="8">
44
+ <div
45
+ class="dot"
46
+ :class="{
47
+ current:
48
+ current === index || current - posters.length / 2 === index,
49
+ }"
50
+ v-for="(_, index) in Array(posters.length / 2).fill('')"
51
+ :key="index"
52
+ />
53
+ </div>
54
+ <div
55
+ class="text-center"
56
+ style="font-size: 13px; color: #666666; margin: 10px"
57
+ v-if="text"
58
+ >
59
+ {{ text }}
60
+ </div>
61
+ <div class="line"></div>
62
+ <div class="bottom">
63
+ <nut-button class="cancel-btn" v-track-click="'海报分享-取消'" @click="onCancelClick"
64
+ >取消</nut-button
65
+ >
66
+ <nut-button type="primary" v-track-click="'海报分享-确定'" @click="onPosterShare">确定</nut-button>
67
+ </div>
68
+ </div>
69
+ <canvas
70
+ type="2d"
71
+ id="poster-canvas"
72
+ :style="`height: ${o.h}px;width:${o.w}px;transform:translate3d(-5000px, 0, 0);position: absolute;`"
73
+ >
74
+ </canvas>
75
+ </template>
76
+ </nut-popup>
77
+ </template>
78
+
79
+ <script lang="ts" setup>
80
+ import { ref, watch } from 'vue';
81
+ import Taro from '@tarojs/taro';
82
+ import PosterPaste from '../components/poster-paste.vue';
83
+ import { dataURItoBlob, isWeb } from '../../utils/utils';
84
+ import { Swiper, SwiperItem } from '@tarojs/components';
85
+
86
+ const emit = defineEmits(['share']);
87
+
88
+ export type ShareDialogProps = {
89
+ // 海报列表
90
+ posters: any[];
91
+ text?: string;
92
+ };
93
+
94
+ const props = defineProps<ShareDialogProps>();
95
+
96
+ const o = {
97
+ // 图片原始大小
98
+ w: 375,
99
+ h: 812,
100
+ },
101
+ z = 480, // 缩放后高度
102
+ zoom = z / o.h;
103
+
104
+ const config = ref();
105
+ config.value = {
106
+ nick: '',
107
+ logo: '',
108
+ qr: '',
109
+ };
110
+
111
+ // 真实的 current
112
+ const current = ref(0);
113
+
114
+ const getCentered = () => {
115
+ // change 事件返回的 current 为三张图中最左侧一张
116
+ // 为了中间放大的效果, 将 swiper 属性 current 设置为 下一张
117
+ if (props.posters.length === 1) return 0;
118
+ // 多张海报, *假选中*中间一张
119
+ let centered: number = current.value + 1;
120
+ centered = centered === props.posters.length ? 0 : centered;
121
+ return centered;
122
+ };
123
+
124
+ const isCenter = (index: number) => {
125
+ return getCentered() === index;
126
+ };
127
+
128
+ const onSwiperChange = ({ detail }) => {
129
+ current.value = detail.current;
130
+ };
131
+
132
+ const initCanvas = () => {
133
+ return new Promise((resolve) => {
134
+ setTimeout(() => {
135
+ if (Taro.getEnv() === 'WEB') {
136
+ const canvas = document.getElementById(
137
+ 'poster-canvas'
138
+ ) as HTMLCanvasElement;
139
+ const context = canvas.getContext('2d');
140
+ canvas.height = o.h * 2;
141
+ canvas.width = o.w * 2;
142
+ resolve({ context, canvas });
143
+ } else {
144
+ const pageInstance = Taro.getCurrentInstance()?.page || {}; // 拿到当前页面实例
145
+ const query = Taro.createSelectorQuery().in(pageInstance); // 确定在当前页面内匹配子元素
146
+ query
147
+ .select('#poster-canvas')
148
+ .fields({ node: true, size: true, context: true }, (res) => {
149
+ const canvas = res.node;
150
+ const context = canvas.getContext('2d');
151
+ canvas.height = o.h * 2;
152
+ canvas.width = o.w * 2;
153
+ canvas.destHeight = o.h * 2;
154
+ canvas.destWidth = o.w * 2;
155
+ resolve({ context, canvas });
156
+ })
157
+ .exec();
158
+ }
159
+ }, 300);
160
+ });
161
+ };
162
+
163
+ const drawImage = async (
164
+ canvas: any,
165
+ context: any,
166
+ src: string,
167
+ x?: number,
168
+ y?: number,
169
+ w?: number,
170
+ h?: number
171
+ ) => {
172
+ return new Promise((resolve, reject) => {
173
+ if (!src) {
174
+ resolve(void 0);
175
+ return;
176
+ }
177
+ const image = !isWeb() ? canvas.createImage() : new Image();
178
+ image.crossOrigin = 'Anonymous';
179
+ image.src = src;
180
+ image.onload = function () {
181
+ context.drawImage(image, x || 0, y || 0, w || o.w, h || o.h);
182
+ resolve(void 0);
183
+ };
184
+ image.onerror = (e) => {
185
+ resolve(image);
186
+ };
187
+ });
188
+ };
189
+ const onPosterShare = async () => {
190
+ !isWeb() && Taro.showLoading({ title: '加载中...', mask: true });
191
+ // @ts-ignore
192
+ const { context, canvas } = await initCanvas(),
193
+ c = getCentered();
194
+ const p = props.posters[c];
195
+ await drawImage(canvas, context, p.back, 0, 0, o.w * 2, o.h * 2);
196
+ if (p.qr) {
197
+ await drawImage(
198
+ canvas,
199
+ context,
200
+ p.qr,
201
+ p.qrX * 2,
202
+ p.qrY * 2,
203
+ p.qrW * 2,
204
+ p.qrH * 2
205
+ );
206
+ }
207
+ if (config.value.nick) {
208
+ context.font = '24px sans-serif';
209
+ context.fillText(config.value.nick, p.nickX * 2 - 10, p.nickY * 2 + 34);
210
+ }
211
+ if (config.value.logo) {
212
+ await drawImage(
213
+ canvas,
214
+ context,
215
+ config.value.logo,
216
+ p.logoX * 2,
217
+ p.logoY * 2,
218
+ 54,
219
+ 54
220
+ );
221
+ }
222
+ context.save();
223
+ if (isWeb()) {
224
+ const dataURL = canvas.toDataURL('image/png');
225
+ const blob = dataURItoBlob(dataURL);
226
+ const imgUrl = URL.createObjectURL(blob);
227
+ emit('share', imgUrl);
228
+ } else {
229
+ Taro.canvasToTempFilePath({
230
+ canvas,
231
+ success: (result) => {
232
+ Taro.hideLoading();
233
+ Taro.showShareImageMenu({
234
+ path: result.tempFilePath,
235
+ });
236
+ },
237
+ fail: () => {
238
+ Taro.showToast({
239
+ title: '海报生成失败,请重试',
240
+ icon: 'none',
241
+ });
242
+ },
243
+ });
244
+ }
245
+ };
246
+
247
+ watch(
248
+ () => props.posters,
249
+ () => {
250
+ if (props.posters[0]?.nick) {
251
+ config.value.nick = props.posters[0].nick;
252
+ }
253
+ if (props.posters[0]?.logo) {
254
+ config.value.logo = props.posters[0].logo;
255
+ }
256
+ }
257
+ );
258
+
259
+ const sheetOpen = ref(false);
260
+ const onCancelClick = () => {
261
+ sheetOpen.value = false;
262
+ };
263
+ function openShareDialog() {
264
+ sheetOpen.value = !sheetOpen.value;
265
+ }
266
+
267
+ defineExpose({
268
+ openShareDialog,
269
+ });
270
+ </script>
271
+
272
+ <style lang="scss">
273
+ .share-dialog {
274
+ padding: 40px 0 0;
275
+ overflow: hidden auto;
276
+
277
+ .swiper-container {
278
+ position: relative;
279
+ width: 100%;
280
+ height: 480px;
281
+ overflow: hidden;
282
+ }
283
+
284
+ .swiper {
285
+ width: 180%;
286
+ height: 100%;
287
+ margin: 0 -40%;
288
+ }
289
+
290
+ .swiper-item {
291
+ width: 100%;
292
+ display: flex;
293
+ flex-direction: row;
294
+ align-items: center;
295
+
296
+ .poster-paste {
297
+ transform: scale(0.8);
298
+ }
299
+
300
+ &.center {
301
+ .poster-paste {
302
+ transform: scale(1);
303
+ }
304
+ }
305
+ }
306
+
307
+ .swiper-dots {
308
+ margin-top: 10px;
309
+ height: 20px;
310
+ display: flex;
311
+ justify-content: center;
312
+ align-items: center;
313
+ .dot {
314
+ width: 6px;
315
+ height: 6px;
316
+ background-color: #b0b7c4;
317
+ border-radius: 3px;
318
+ transition: width 0.5s;
319
+ margin: 0 2px;
320
+
321
+ &.current {
322
+ background-color: #017fff;
323
+ width: 15px;
324
+ }
325
+ }
326
+ }
327
+
328
+ .slide {
329
+ width: 100%;
330
+ }
331
+
332
+ .buttons {
333
+ margin-top: 60px;
334
+
335
+ .btn {
336
+ width: 50px;
337
+ height: 50px;
338
+ background-size: 100% 100%;
339
+ background-color: #f8f8f8;
340
+ border-radius: 10px;
341
+ }
342
+ }
343
+
344
+ .bottom {
345
+ padding: 12px;
346
+ display: flex;
347
+ .nut-button {
348
+ flex: 1;
349
+ }
350
+ .cancel-btn {
351
+ margin-right: 12px;
352
+ flex: 1;
353
+ border: 1px solid #017fff;
354
+ color: #017fff;
355
+ background: #fff;
356
+ }
357
+ }
358
+
359
+ .line {
360
+ background: #f1f5f9;
361
+ height: 8.5px;
362
+ }
363
+ }
364
+ </style>