@uxda/appkit 4.2.74 → 4.2.76

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.
@@ -0,0 +1,273 @@
1
+ ##### 组件说明:
2
+
3
+ 该组件是一个海报分享组件,调用者传入图片数据
4
+
5
+ 数据示例:
6
+
7
+ [
8
+
9
+ {
10
+
11
+ id:"10",
12
+
13
+ back:"https://cdn.ddjf.com/static/images/approve_qmx/qmx-dist-post-bg-3.png",
14
+
15
+ qr: "https://cdn.ddjf.com/static/images/fnfundkit/orderNums-userInfo.png",
16
+
17
+ qrH: 150,
18
+
19
+ qrW: 150,
20
+
21
+ qrX: 110,
22
+
23
+ qrY: 310,
24
+
25
+ },
26
+
27
+ {
28
+
29
+ id:"11",
30
+
31
+ back:"https://cdn.ddjf.com/static/images/approve_qmx/qmx-dist-post-bg-1.png",
32
+
33
+ qr: "https://cdn.ddjf.com/static/images/fnfundkit/orderNums-userInfo.png",
34
+
35
+ qrH: 150,
36
+
37
+ qrW: 150,
38
+
39
+ qrX: 110,
40
+
41
+ qrY: 310,
42
+
43
+ },
44
+
45
+ {
46
+
47
+ id:"12",
48
+
49
+ back:"https://cdn.ddjf.com/static/images/approve_qmx/qmx-dist-post-bg-2.png",
50
+
51
+ qr: "https://cdn.ddjf.com/static/images/fnfundkit/orderNums-userInfo.png",
52
+
53
+ qrH: 150,
54
+
55
+ qrW: 150,
56
+
57
+ qrX: 110,
58
+
59
+ qrY: 310,
60
+
61
+ },
62
+
63
+ {
64
+
65
+ id:"10",
66
+
67
+ back:"https://cdn.ddjf.com/static/images/approve_qmx/qmx-dist-post-bg-3.png",
68
+
69
+ qr: "https://cdn.ddjf.com/static/images/fnfundkit/orderNums-userInfo.png",
70
+
71
+ qrH: 150,
72
+
73
+ qrW: 150,
74
+
75
+ qrX: 110,
76
+
77
+ qrY: 310,
78
+
79
+ },
80
+
81
+ {
82
+
83
+ id:"11",
84
+
85
+ back:"https://cdn.ddjf.com/static/images/approve_qmx/qmx-dist-post-bg-1.png",
86
+
87
+ qr: "https://cdn.ddjf.com/static/images/fnfundkit/orderNums-userInfo.png",
88
+
89
+ qrH: 150,
90
+
91
+ qrW: 150,
92
+
93
+ qrX: 110,
94
+
95
+ qrY: 310,
96
+
97
+ },
98
+
99
+ {
100
+
101
+ id:"12",
102
+
103
+ back:"https://cdn.ddjf.com/static/images/approve_qmx/qmx-dist-post-bg-2.png",
104
+
105
+ qr: "https://cdn.ddjf.com/static/images/fnfundkit/orderNums-userInfo.png",
106
+
107
+ qrH: 150,
108
+
109
+ qrW: 150,
110
+
111
+ qrX: 110,
112
+
113
+ qrY: 310,
114
+
115
+ }]
116
+
117
+ 注意的是, 获取数据后需要 2 倍传入。
118
+
119
+ ##### 属性和方法
120
+
121
+ ![1752718942546](image/share-poster/1752718942546.png)
122
+
123
+ 海报数据如上格式。(back 是海报, qr 是二维码, qrH、qrw 是宽高, qrX、qrY 是二维码坐标位置)
124
+
125
+ 方法 share 是点击确认的回调。
126
+
127
+ 通过 ref 拉起内容 shareRef.value?.openShareDialog()
128
+
129
+ ##### h5 项目中,分享不能够直接弹出分享框,需要先上传到己方服务器,再根据线上的图片地址去分享,示例代码如下:
130
+
131
+ // h5 分享图片
132
+
133
+ lettempFilePath=''
134
+
135
+ lettempFilePath1=''
136
+
137
+ exportasyncfunctiondownloadImage(filePath:string, showTips1=false) {
138
+
139
+ if (!tempFilePath||tempFilePath1!==filePath) {
140
+
141
+ constloginStore=useLoginStore()
142
+
143
+ constsession=loginStore.getLoginSession()
144
+
145
+ constupRes=awaitTaro.uploadFile({
146
+
147
+ url: BASISAPIS.file_uploadImg,
148
+
149
+ filePath: filePath,
150
+
151
+ name: 'file',
152
+
153
+ formData: {
154
+
155
+ objectNo:`H5${USER_TYPE}${Date.now()}`
156
+
157
+ },
158
+
159
+ header: {
160
+
161
+ traceId: generateUniqueId('portal-weapp'),
162
+
163
+ token: session||''
164
+
165
+ }
166
+
167
+ })
168
+
169
+ constres=JSON.parse(upRes.data)
170
+
171
+ if (res.success) {
172
+
173
+ tempFilePath=res.result
174
+
175
+ createImage(tempFilePath, showTips1)
176
+
177
+ setTimeout(() => {
178
+
179
+ tempFilePath=''
180
+
181
+ tempFilePath1=''
182
+
183
+ }, 10000);
184
+
185
+ } else {
186
+
187
+ Taro.showToast({
188
+
189
+ title: '海报生成失败',
190
+
191
+ icon: 'none'
192
+
193
+ })
194
+
195
+ }
196
+
197
+ } else {
198
+
199
+ createImage(tempFilePath, showTips1)
200
+
201
+ }
202
+
203
+ tempFilePath1=filePath
204
+
205
+ // 创建图片预览弹窗
206
+
207
+ functioncreateImage(path:string, showTips1=false) {
208
+
209
+ constpreviewImage=document.createElement('div')
210
+
211
+ previewImage.style.cssText=`
212
+
213
+ position: fixed;
214
+
215
+ top: 0;
216
+
217
+ left: 0;
218
+
219
+ width: 100%;
220
+
221
+ height: 100%;
222
+
223
+ background: rgba(0,0,0,0.7);
224
+
225
+ z-index: 9999;
226
+
227
+ display: flex;
228
+
229
+ flex-direction: column;
230
+
231
+ align-items: center;
232
+
233
+ justify-content: center;
234
+
235
+ `
236
+
237
+ constimg=document.createElement('img')
238
+
239
+ img.src=path
240
+
241
+ img.style.cssText='max-width: 90%; max-height: 80%;'
242
+
243
+ consttips=document.createElement('div')
244
+
245
+ tips.innerText='长按转发或保存图片'
246
+
247
+ tips.style.cssText='color: #fff; margin-top: 15px; font-size: 16px;'
248
+
249
+ consttips1=document.createElement('div')
250
+
251
+ tips1.innerText='二维码 30 天有效'
252
+
253
+ tips1.style.cssText='color: #fff; margin-top: 5px; font-size: 12px;'
254
+
255
+ previewImage.appendChild(img)
256
+
257
+ previewImage.appendChild(tips)
258
+
259
+ showTips1&&previewImage.appendChild(tips1)
260
+
261
+ document.body.appendChild(previewImage)
262
+
263
+ // 点击空白处关闭
264
+
265
+ previewImage.onclick= () => {
266
+
267
+ document.body.removeChild(previewImage)
268
+
269
+ }
270
+
271
+ }
272
+
273
+ }
@@ -0,0 +1 @@
1
+ export * from './components'
@@ -0,0 +1,28 @@
1
+ import Taro from "@tarojs/taro"
2
+
3
+ // 工具函数:DataURL转Blob
4
+ export function dataURItoBlob(dataURI) {
5
+ const byteString = atob(dataURI.split(',')[1])
6
+ const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
7
+ const ab = new ArrayBuffer(byteString.length)
8
+ const ia = new Uint8Array(ab)
9
+ for (let i = 0; i < byteString.length; i++) {
10
+ ia[i] = byteString.charCodeAt(i)
11
+ }
12
+ return new Blob([ab], { type: mimeString })
13
+ }
14
+
15
+ // 是否H5页面
16
+ export function isWeb() {
17
+ const env = process.env.TARO_ENV || ''
18
+ return env === 'h5' || Taro.getEnv() === 'WEB'
19
+ }
20
+
21
+
22
+ // 使用时间戳生成唯一标识
23
+ export function generateUniqueId(pre?: string, delimiter = '-') {
24
+ return `${pre ? pre + delimiter : ''}${Date.now().toString(16)}${delimiter}${Math.random()
25
+ .toString(36)
26
+ .substr(2)}`
27
+ }
28
+