@uxda/appkit 4.3.28 → 4.3.32

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 (141) hide show
  1. package/.cursor/skills/appkit-build-update-component-rules/SKILL.md +54 -49
  2. package/.cursor/skills/appkit-sync-component-rules/SKILL.md +60 -0
  3. package/.eslintrc.mjs +7 -7
  4. package/Appkit/347/273/204/344/273/266/344/275/277/347/224/250/350/247/204/345/210/231.md +2002 -1786
  5. package/PROJECT_DOCS.md +142 -142
  6. package/README.md +194 -194
  7. package/babel.config.js +12 -12
  8. package/dist/appkit.css +112 -3
  9. package/dist/index.js +158 -28
  10. package/package.json +82 -82
  11. package/project.config.json +15 -15
  12. package/project.tt.json +13 -13
  13. package/rollup.config.mjs +81 -81
  14. package/src/Appkit.ts +72 -72
  15. package/src/balance/api/endpoints.ts +133 -133
  16. package/src/balance/api/index.ts +118 -118
  17. package/src/balance/components/AccountView.vue +770 -770
  18. package/src/balance/components/BalanceCard.vue +210 -210
  19. package/src/balance/components/BalanceReminder.vue +84 -84
  20. package/src/balance/components/ConsumptionFilter.vue +218 -218
  21. package/src/balance/components/ConsumptionRules.vue +68 -68
  22. package/src/balance/components/DateFilter.vue +259 -259
  23. package/src/balance/components/DateRange.vue +111 -111
  24. package/src/balance/components/ListFilter.vue +62 -62
  25. package/src/balance/components/ListFilterPicker.vue +191 -191
  26. package/src/balance/components/PromoterCard.vue +308 -308
  27. package/src/balance/components/SecondBalance.vue +77 -77
  28. package/src/balance/components/Tip.vue +45 -45
  29. package/src/balance/components/index.ts +8 -8
  30. package/src/balance/types.ts +99 -99
  31. package/src/components/bt-cropper/index.vue +730 -730
  32. package/src/components/bt-cropper/utils/calcCropper.js +42 -42
  33. package/src/components/bt-cropper/utils/calcImagePosition.js +23 -23
  34. package/src/components/bt-cropper/utils/calcImageSize.js +37 -37
  35. package/src/components/bt-cropper/utils/calcPointDistance.js +12 -12
  36. package/src/components/bt-cropper/utils/calcRightAndBottom.js +7 -7
  37. package/src/components/bt-cropper/utils/ratio.js +3 -3
  38. package/src/components/bt-cropper/utils/tools.js +25 -25
  39. package/src/components/dd-area/index.vue +225 -225
  40. package/src/components/dd-icon/doc.md +21 -21
  41. package/src/components/dd-icon/index.vue +23 -23
  42. package/src/components/dd-notice-bar/index.vue +78 -78
  43. package/src/components/dd-search/doc.md +34 -34
  44. package/src/components/dd-search/index.vue +168 -168
  45. package/src/components/dd-selector/index.vue +124 -124
  46. package/src/components/dd-skeleton/doc.md +19 -19
  47. package/src/components/dd-skeleton/index.vue +36 -36
  48. package/src/global.ts +6 -6
  49. package/src/index.ts +101 -101
  50. package/src/main.scss +1 -1
  51. package/src/notice/api/endpoints.ts +54 -54
  52. package/src/notice/api/index.ts +121 -121
  53. package/src/notice/components/NoticeBanner.vue +247 -247
  54. package/src/notice/components/NoticeEntry.vue +99 -99
  55. package/src/notice/components/NoticeList.vue +311 -311
  56. package/src/notice/components/NoticeList2.vue +401 -401
  57. package/src/notice/components/NoticePopup.vue +163 -163
  58. package/src/notice/components/index.ts +6 -6
  59. package/src/notice/components/useCommonList.ts +87 -87
  60. package/src/notice/components/useNotice.ts +35 -35
  61. package/src/notice/index.ts +1 -1
  62. package/src/notice/types.ts +25 -25
  63. package/src/payment/api/config.ts +7 -7
  64. package/src/payment/api/endpoints.ts +112 -112
  65. package/src/payment/api/index.ts +108 -108
  66. package/src/payment/components/AmountPicker.vue +77 -68
  67. package/src/payment/components/RechargeResult.vue +68 -68
  68. package/src/payment/components/RechargeView.vue +414 -227
  69. package/src/payment/components/RightsPicker.vue +105 -105
  70. package/src/payment/components/TradeView.vue +616 -616
  71. package/src/payment/components/UserAgreement.vue +234 -234
  72. package/src/payment/components/index.ts +22 -22
  73. package/src/payment/components/recharge-amount.spec.ts +54 -0
  74. package/src/payment/components/recharge-amount.ts +67 -0
  75. package/src/payment/index.ts +5 -5
  76. package/src/payment/services/index.ts +16 -16
  77. package/src/payment/services/invoke-recharge.ts +25 -25
  78. package/src/payment/services/request-payment.ts +136 -136
  79. package/src/payment/types.ts +34 -34
  80. package/src/register/components/SelfRegistration.vue +233 -233
  81. package/src/register/components/index.ts +2 -2
  82. package/src/scenarios/components/SharePoster.vue +364 -364
  83. package/src/scenarios/components/index.ts +2 -2
  84. package/src/scenarios/components/poster-paste.vue +93 -93
  85. package/src/scenarios/components/share-poster.md +273 -273
  86. package/src/shared/components/AppDrawer.vue +53 -53
  87. package/src/shared/components/AppVerify.vue +137 -137
  88. package/src/shared/components/DeviceVersion.vue +78 -78
  89. package/src/shared/components/EmptyView.vue +33 -33
  90. package/src/shared/components/OcrBank.vue +202 -202
  91. package/src/shared/components/OcrBusinessLicense.vue +120 -120
  92. package/src/shared/components/OcrIcon.vue +267 -267
  93. package/src/shared/components/OcrInvoice.vue +323 -323
  94. package/src/shared/components/OfficeDocx.vue +33 -33
  95. package/src/shared/components/OfficePdf.vue +35 -35
  96. package/src/shared/components/PageHeader.vue +84 -84
  97. package/src/shared/components/index.ts +12 -12
  98. package/src/shared/composables/index.ts +10 -10
  99. package/src/shared/composables/useAmount.ts +46 -46
  100. package/src/shared/composables/useCompress.ts +64 -64
  101. package/src/shared/composables/useCountdown.ts +46 -46
  102. package/src/shared/composables/useCrypto.ts +76 -76
  103. package/src/shared/composables/useDeviceEnv.ts +61 -61
  104. package/src/shared/composables/useDragBox.ts +97 -97
  105. package/src/shared/composables/useEncode.ts +43 -43
  106. package/src/shared/composables/useLogger.ts +149 -149
  107. package/src/shared/composables/useSafeArea.ts +46 -46
  108. package/src/shared/composables/useTabbar.ts +24 -24
  109. package/src/shared/composables/useUpload.ts +106 -106
  110. package/src/shared/composables/useValidator.ts +32 -32
  111. package/src/shared/composables/useWxAuth.ts +49 -49
  112. package/src/shared/http/Http.ts +149 -149
  113. package/src/shared/http/index.ts +1 -1
  114. package/src/shared/http/types.ts +163 -163
  115. package/src/shared/index.ts +9 -9
  116. package/src/shared/tracking/directives/index.ts +40 -40
  117. package/src/shared/tracking/examples/page-tracking-template.vue +27 -27
  118. package/src/shared/weixin/index.ts +9 -9
  119. package/src/shared/weixin/jssdk.ts +104 -104
  120. package/src/shared/weixin/payment.ts +38 -38
  121. package/src/styles/vars.scss +3 -3
  122. package/src/user/api/endpoints.ts +17 -17
  123. package/src/user/api/index.ts +123 -123
  124. package/src/user/components/LoginSetting.vue +114 -114
  125. package/src/user/components/UserAuth.vue +218 -218
  126. package/src/user/components/UserBinding.vue +277 -277
  127. package/src/user/components/UserBindingSuccess.vue +80 -80
  128. package/src/user/components/UserEntry.vue +139 -139
  129. package/src/user/components/UserFeedback.vue +428 -428
  130. package/src/user/components/UserFeedbackEntry.vue +175 -175
  131. package/src/user/components/UserHeadCrop.vue +65 -65
  132. package/src/user/components/UserInfo.vue +711 -711
  133. package/src/user/components/UserResourceEmpty.vue +75 -75
  134. package/src/user/components/index.ts +23 -23
  135. package/src/user/index.ts +1 -1
  136. package/src/utils/utils.ts +33 -33
  137. package/tsconfig.json +30 -30
  138. package/types/global.d.ts +23 -23
  139. package/types/vue.d.ts +10 -10
  140. package/dist/assets/asset-3B_CoPto +0 -1
  141. package/dist/assets/asset-DcH8Kg-2 +0 -1
@@ -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>