@tplc/business 0.2.40 → 0.2.42
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.
- package/CHANGELOG.md +17 -0
- package/components/lcb-calendar-search/lcb-calendar-search.vue +3 -11
- package/components/lcb-calendar-search/types.ts +3 -0
- package/components/lcb-map/lcb-map.vue +41 -28
- package/components/lcb-map/types.ts +4 -0
- package/components/lcb-poster/common/relation.js +150 -0
- package/components/lcb-poster/hybrid/html/index.html +119 -0
- package/components/lcb-poster/hybrid/html/painter.js +1 -0
- package/components/lcb-poster/hybrid/html/uni.webview.1.5.3.js +1 -0
- package/components/lcb-poster/lcb-poster.vue +494 -0
- package/components/lcb-poster/nvue.js +214 -0
- package/components/lcb-poster/painter.js +1 -0
- package/components/lcb-poster/props.js +56 -0
- package/components/lcb-poster/single.js +1 -0
- package/components/lcb-poster/types.ts +26 -0
- package/components/lcb-poster/utils.js +368 -0
- package/global.d.ts +2 -0
- package/package.json +1 -1
- package/types/components/lcb-calendar-search/lcb-calendar-search.vue.d.ts +1 -0
- package/types/components/lcb-calendar-search/types.d.ts +3 -0
- package/types/components/lcb-map/types.d.ts +3 -0
- package/types/components/lcb-poster/lcb-poster.vue.d.ts +50 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
export const networkReg = /^(http|\/\/)/;
|
|
2
|
+
export const isBase64 = (path) => /^data:image\/(\w+);base64/.test(path);
|
|
3
|
+
export function sleep(delay) {
|
|
4
|
+
return new Promise(resolve => setTimeout(resolve, delay))
|
|
5
|
+
}
|
|
6
|
+
let {platform, SDKVersion} = uni.getSystemInfoSync()
|
|
7
|
+
export const isPC = /windows|mac/.test(platform)
|
|
8
|
+
// 缓存图片
|
|
9
|
+
let cache = {}
|
|
10
|
+
export function isNumber(value) {
|
|
11
|
+
return /^-?\d+(\.\d+)?$/.test(value);
|
|
12
|
+
}
|
|
13
|
+
export function toPx(value, baseSize, isDecimal = false) {
|
|
14
|
+
// 如果是数字
|
|
15
|
+
if (typeof value === 'number') {
|
|
16
|
+
return value
|
|
17
|
+
}
|
|
18
|
+
// 如果是字符串数字
|
|
19
|
+
if (isNumber(value)) {
|
|
20
|
+
return value * 1
|
|
21
|
+
}
|
|
22
|
+
// 如果有单位
|
|
23
|
+
if (typeof value === 'string') {
|
|
24
|
+
const reg = /^-?([0-9]+)?([.]{1}[0-9]+){0,1}(em|rpx|px|%)$/g
|
|
25
|
+
const results = reg.exec(value);
|
|
26
|
+
if (!value || !results) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
const unit = results[3];
|
|
30
|
+
value = parseFloat(value);
|
|
31
|
+
let res = 0;
|
|
32
|
+
if (unit === 'rpx') {
|
|
33
|
+
res = uni.upx2px(value);
|
|
34
|
+
} else if (unit === 'px') {
|
|
35
|
+
res = value * 1;
|
|
36
|
+
} else if (unit === '%') {
|
|
37
|
+
res = value * toPx(baseSize) / 100;
|
|
38
|
+
} else if (unit === 'em') {
|
|
39
|
+
res = value * toPx(baseSize || 14);
|
|
40
|
+
}
|
|
41
|
+
return isDecimal ? res.toFixed(2) * 1 : Math.round(res);
|
|
42
|
+
}
|
|
43
|
+
return 0
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 计算版本
|
|
47
|
+
export function compareVersion(v1, v2) {
|
|
48
|
+
v1 = v1.split('.')
|
|
49
|
+
v2 = v2.split('.')
|
|
50
|
+
const len = Math.max(v1.length, v2.length)
|
|
51
|
+
while (v1.length < len) {
|
|
52
|
+
v1.push('0')
|
|
53
|
+
}
|
|
54
|
+
while (v2.length < len) {
|
|
55
|
+
v2.push('0')
|
|
56
|
+
}
|
|
57
|
+
for (let i = 0; i < len; i++) {
|
|
58
|
+
const num1 = parseInt(v1[i], 10)
|
|
59
|
+
const num2 = parseInt(v2[i], 10)
|
|
60
|
+
|
|
61
|
+
if (num1 > num2) {
|
|
62
|
+
return 1
|
|
63
|
+
} else if (num1 < num2) {
|
|
64
|
+
return -1
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return 0
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function gte(version) {
|
|
71
|
+
// #ifdef MP-ALIPAY
|
|
72
|
+
SDKVersion = my.SDKVersion
|
|
73
|
+
// #endif
|
|
74
|
+
return compareVersion(SDKVersion, version) >= 0;
|
|
75
|
+
}
|
|
76
|
+
export function canIUseCanvas2d() {
|
|
77
|
+
// #ifdef MP-WEIXIN
|
|
78
|
+
return gte('2.9.2');
|
|
79
|
+
// #endif
|
|
80
|
+
// #ifdef MP-ALIPAY
|
|
81
|
+
return gte('2.7.15');
|
|
82
|
+
// #endif
|
|
83
|
+
// #ifdef MP-TOUTIAO
|
|
84
|
+
return gte('1.78.0');
|
|
85
|
+
// #endif
|
|
86
|
+
return false
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// #ifdef MP
|
|
90
|
+
export const prefix = () => {
|
|
91
|
+
// #ifdef MP-TOUTIAO
|
|
92
|
+
return tt
|
|
93
|
+
// #endif
|
|
94
|
+
// #ifdef MP-WEIXIN
|
|
95
|
+
return wx
|
|
96
|
+
// #endif
|
|
97
|
+
// #ifdef MP-BAIDU
|
|
98
|
+
return swan
|
|
99
|
+
// #endif
|
|
100
|
+
// #ifdef MP-ALIPAY
|
|
101
|
+
return my
|
|
102
|
+
// #endif
|
|
103
|
+
// #ifdef MP-QQ
|
|
104
|
+
return qq
|
|
105
|
+
// #endif
|
|
106
|
+
// #ifdef MP-360
|
|
107
|
+
return qh
|
|
108
|
+
// #endif
|
|
109
|
+
}
|
|
110
|
+
// #endif
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* base64转路径
|
|
116
|
+
* @param {Object} base64
|
|
117
|
+
*/
|
|
118
|
+
export function base64ToPath(base64) {
|
|
119
|
+
const [, format] = /^data:image\/(\w+);base64,/.exec(base64) || [];
|
|
120
|
+
|
|
121
|
+
return new Promise((resolve, reject) => {
|
|
122
|
+
// #ifdef MP
|
|
123
|
+
const fs = uni.getFileSystemManager()
|
|
124
|
+
//自定义文件名
|
|
125
|
+
if (!format) {
|
|
126
|
+
reject(new Error('ERROR_BASE64SRC_PARSE'))
|
|
127
|
+
}
|
|
128
|
+
const time = new Date().getTime();
|
|
129
|
+
let pre = prefix()
|
|
130
|
+
// #ifdef MP-TOUTIAO
|
|
131
|
+
const filePath = `${pre.getEnvInfoSync().common.USER_DATA_PATH}/${time}.${format}`
|
|
132
|
+
// #endif
|
|
133
|
+
// #ifndef MP-TOUTIAO
|
|
134
|
+
const filePath = `${pre.env.USER_DATA_PATH}/${time}.${format}`
|
|
135
|
+
// #endif
|
|
136
|
+
fs.writeFile({
|
|
137
|
+
filePath,
|
|
138
|
+
data: base64.split(',')[1],
|
|
139
|
+
encoding: 'base64',
|
|
140
|
+
success() {
|
|
141
|
+
resolve(filePath)
|
|
142
|
+
},
|
|
143
|
+
fail(err) {
|
|
144
|
+
console.error(err)
|
|
145
|
+
reject(err)
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
// #endif
|
|
149
|
+
|
|
150
|
+
// #ifdef H5
|
|
151
|
+
// mime类型
|
|
152
|
+
let mimeString = base64.split(',')[0].split(':')[1].split(';')[0];
|
|
153
|
+
//base64 解码
|
|
154
|
+
let byteString = atob(base64.split(',')[1]);
|
|
155
|
+
//创建缓冲数组
|
|
156
|
+
let arrayBuffer = new ArrayBuffer(byteString.length);
|
|
157
|
+
//创建视图
|
|
158
|
+
let intArray = new Uint8Array(arrayBuffer);
|
|
159
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
160
|
+
intArray[i] = byteString.charCodeAt(i);
|
|
161
|
+
}
|
|
162
|
+
resolve(URL.createObjectURL(new Blob([intArray], {
|
|
163
|
+
type: mimeString
|
|
164
|
+
})))
|
|
165
|
+
// #endif
|
|
166
|
+
|
|
167
|
+
// #ifdef APP-PLUS
|
|
168
|
+
const bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now())
|
|
169
|
+
bitmap.loadBase64Data(base64, () => {
|
|
170
|
+
if (!format) {
|
|
171
|
+
reject(new Error('ERROR_BASE64SRC_PARSE'))
|
|
172
|
+
}
|
|
173
|
+
const time = new Date().getTime();
|
|
174
|
+
const filePath = `_doc/uniapp_temp/${time}.${format}`
|
|
175
|
+
bitmap.save(filePath, {},
|
|
176
|
+
() => {
|
|
177
|
+
bitmap.clear()
|
|
178
|
+
resolve(filePath)
|
|
179
|
+
},
|
|
180
|
+
(error) => {
|
|
181
|
+
bitmap.clear()
|
|
182
|
+
reject(error)
|
|
183
|
+
})
|
|
184
|
+
}, (error) => {
|
|
185
|
+
bitmap.clear()
|
|
186
|
+
reject(error)
|
|
187
|
+
})
|
|
188
|
+
// #endif
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 路径转base64
|
|
194
|
+
* @param {Object} string
|
|
195
|
+
*/
|
|
196
|
+
export function pathToBase64(path) {
|
|
197
|
+
if (/^data:/.test(path)) return path
|
|
198
|
+
return new Promise((resolve, reject) => {
|
|
199
|
+
// #ifdef H5
|
|
200
|
+
let image = new Image();
|
|
201
|
+
image.setAttribute("crossOrigin", 'Anonymous');
|
|
202
|
+
image.onload = function() {
|
|
203
|
+
let canvas = document.createElement('canvas');
|
|
204
|
+
canvas.width = this.naturalWidth;
|
|
205
|
+
canvas.height = this.naturalHeight;
|
|
206
|
+
canvas.getContext('2d').drawImage(image, 0, 0);
|
|
207
|
+
let result = canvas.toDataURL('image/png')
|
|
208
|
+
resolve(result);
|
|
209
|
+
canvas.height = canvas.width = 0
|
|
210
|
+
}
|
|
211
|
+
image.src = path + '?v=' + Math.random()
|
|
212
|
+
image.onerror = (error) => {
|
|
213
|
+
reject(error);
|
|
214
|
+
};
|
|
215
|
+
// #endif
|
|
216
|
+
|
|
217
|
+
// #ifdef MP
|
|
218
|
+
if (uni.canIUse('getFileSystemManager')) {
|
|
219
|
+
uni.getFileSystemManager().readFile({
|
|
220
|
+
filePath: path,
|
|
221
|
+
encoding: 'base64',
|
|
222
|
+
success: (res) => {
|
|
223
|
+
resolve('data:image/png;base64,' + res.data)
|
|
224
|
+
},
|
|
225
|
+
fail: (error) => {
|
|
226
|
+
console.error({error, path})
|
|
227
|
+
reject(error)
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
// #endif
|
|
232
|
+
|
|
233
|
+
// #ifdef APP-PLUS
|
|
234
|
+
plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), (entry) => {
|
|
235
|
+
entry.file((file) => {
|
|
236
|
+
const fileReader = new plus.io.FileReader()
|
|
237
|
+
fileReader.onload = (data) => {
|
|
238
|
+
resolve(data.target.result)
|
|
239
|
+
}
|
|
240
|
+
fileReader.onerror = (error) => {
|
|
241
|
+
reject(error)
|
|
242
|
+
}
|
|
243
|
+
fileReader.readAsDataURL(file)
|
|
244
|
+
}, reject)
|
|
245
|
+
}, reject)
|
|
246
|
+
// #endif
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
export function getImageInfo(path, useCORS) {
|
|
253
|
+
const isCanvas2D = this && this.canvas && this.canvas.createImage
|
|
254
|
+
return new Promise(async (resolve, reject) => {
|
|
255
|
+
// let time = +new Date()
|
|
256
|
+
let src = path.replace(/^@\//,'/')
|
|
257
|
+
if (cache[path] && cache[path].errMsg) {
|
|
258
|
+
resolve(cache[path])
|
|
259
|
+
} else {
|
|
260
|
+
try {
|
|
261
|
+
// #ifdef MP || APP-PLUS
|
|
262
|
+
if (isBase64(path) && (isCanvas2D ? isPC : true)) {
|
|
263
|
+
src = await base64ToPath(path)
|
|
264
|
+
}
|
|
265
|
+
// #endif
|
|
266
|
+
// #ifdef H5
|
|
267
|
+
if(useCORS) {
|
|
268
|
+
src = await pathToBase64(path)
|
|
269
|
+
}
|
|
270
|
+
// #endif
|
|
271
|
+
} catch (error) {
|
|
272
|
+
reject({
|
|
273
|
+
...error,
|
|
274
|
+
src
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
// #ifndef APP-NVUE
|
|
278
|
+
if(isCanvas2D && !isPC) {
|
|
279
|
+
const img = this.canvas.createImage()
|
|
280
|
+
img.onload = function() {
|
|
281
|
+
const image = {
|
|
282
|
+
path: img,
|
|
283
|
+
width: img.width,
|
|
284
|
+
height: img.height
|
|
285
|
+
}
|
|
286
|
+
cache[path] = image
|
|
287
|
+
resolve(cache[path])
|
|
288
|
+
}
|
|
289
|
+
img.onerror = function(err) {
|
|
290
|
+
reject({err,path})
|
|
291
|
+
}
|
|
292
|
+
img.src = src
|
|
293
|
+
return
|
|
294
|
+
}
|
|
295
|
+
// #endif
|
|
296
|
+
uni.getImageInfo({
|
|
297
|
+
src,
|
|
298
|
+
success: (image) => {
|
|
299
|
+
const localReg = /^\.|^\/(?=[^\/])/;
|
|
300
|
+
// #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-TOUTIAO
|
|
301
|
+
image.path = localReg.test(src) ? `/${image.path}` : image.path;
|
|
302
|
+
// #endif
|
|
303
|
+
if(isCanvas2D) {
|
|
304
|
+
const img = this.canvas.createImage()
|
|
305
|
+
img.onload = function() {
|
|
306
|
+
image.path = img
|
|
307
|
+
cache[path] = image
|
|
308
|
+
resolve(cache[path])
|
|
309
|
+
}
|
|
310
|
+
img.onerror = function(err) {
|
|
311
|
+
reject({err,path})
|
|
312
|
+
}
|
|
313
|
+
img.src = src
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
// #ifdef APP-PLUS
|
|
317
|
+
// console.log('getImageInfo', +new Date() - time)
|
|
318
|
+
// ios 比较严格 可能需要设置跨域
|
|
319
|
+
if(uni.getSystemInfoSync().osName == 'ios' && useCORS) {
|
|
320
|
+
pathToBase64(image.path).then(base64 => {
|
|
321
|
+
image.path = base64
|
|
322
|
+
cache[path] = image
|
|
323
|
+
resolve(cache[path])
|
|
324
|
+
}).catch(err => {
|
|
325
|
+
console.error({err, path})
|
|
326
|
+
reject({err,path})
|
|
327
|
+
})
|
|
328
|
+
return
|
|
329
|
+
}
|
|
330
|
+
// #endif
|
|
331
|
+
cache[path] = image
|
|
332
|
+
resolve(cache[path])
|
|
333
|
+
},
|
|
334
|
+
fail(err) {
|
|
335
|
+
console.error({err, path})
|
|
336
|
+
reject({err,path})
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
})
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
// #ifdef APP-PLUS
|
|
345
|
+
const getLocalFilePath = (path) => {
|
|
346
|
+
if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path
|
|
347
|
+
.indexOf('_downloads') === 0) {
|
|
348
|
+
return path
|
|
349
|
+
}
|
|
350
|
+
if (path.indexOf('file://') === 0) {
|
|
351
|
+
return path
|
|
352
|
+
}
|
|
353
|
+
if (path.indexOf('/storage/emulated/0/') === 0) {
|
|
354
|
+
return path
|
|
355
|
+
}
|
|
356
|
+
if (path.indexOf('/') === 0) {
|
|
357
|
+
const localFilePath = plus.io.convertAbsoluteFileSystem(path)
|
|
358
|
+
if (localFilePath !== path) {
|
|
359
|
+
return localFilePath
|
|
360
|
+
} else {
|
|
361
|
+
path = path.substr(1)
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return '_www/' + path
|
|
365
|
+
}
|
|
366
|
+
// #endif
|
|
367
|
+
|
|
368
|
+
|
package/global.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ declare module 'vue' {
|
|
|
22
22
|
'lcb-map': (typeof import('./types/components/lcb-map/lcb-map.vue'))['default']
|
|
23
23
|
'lcb-nav': (typeof import('./types/components/lcb-nav/lcb-nav.vue'))['default']
|
|
24
24
|
'lcb-notice': (typeof import('./types/components/lcb-notice/lcb-notice.vue'))['default']
|
|
25
|
+
'lcb-poster': (typeof import('./types/components/lcb-poster/lcb-poster.vue'))['default']
|
|
25
26
|
'lcb-product': (typeof import('./types/components/lcb-product/lcb-product.vue'))['default']
|
|
26
27
|
'lcb-product-item': (typeof import('./types/components/lcb-product-item/lcb-product-item.vue'))['default']
|
|
27
28
|
'lcb-rich-text': (typeof import('./types/components/lcb-rich-text/lcb-rich-text.vue'))['default']
|
|
@@ -33,6 +34,7 @@ declare module 'vue' {
|
|
|
33
34
|
'lcb-user-top': (typeof import('./types/components/lcb-user-top/lcb-user-top.vue'))['default']
|
|
34
35
|
'lcb-video': (typeof import('./types/components/lcb-video/lcb-video.vue'))['default']
|
|
35
36
|
'lcb-vip': (typeof import('./types/components/lcb-vip/lcb-vip.vue'))['default']
|
|
37
|
+
'lcb-waterfall-item': (typeof import('./types/components/lcb-waterfall/lcb-waterfall-item.vue'))['default']
|
|
36
38
|
'lcb-waterfall': (typeof import('./types/components/lcb-waterfall/lcb-waterfall.vue'))['default']
|
|
37
39
|
}
|
|
38
40
|
}
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LcbActionViewProps } from '../lcb-action-view/types'
|
|
1
2
|
export interface MapMarker {
|
|
2
3
|
id: number
|
|
3
4
|
name?: string
|
|
@@ -11,6 +12,7 @@ export interface MapMarker {
|
|
|
11
12
|
x: number
|
|
12
13
|
y: number
|
|
13
14
|
}
|
|
15
|
+
alpha?: number
|
|
14
16
|
callout: {
|
|
15
17
|
textAlign: string
|
|
16
18
|
borderWidth: number
|
|
@@ -30,4 +32,5 @@ export interface MapItem {
|
|
|
30
32
|
latitude: number
|
|
31
33
|
longitude: number
|
|
32
34
|
productId: string
|
|
35
|
+
link: LcbActionViewProps
|
|
33
36
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<
|
|
2
|
+
{},
|
|
3
|
+
{},
|
|
4
|
+
{
|
|
5
|
+
use2dCanvas: boolean
|
|
6
|
+
canvasHeight: number
|
|
7
|
+
canvasWidth: null
|
|
8
|
+
parentWidth: number
|
|
9
|
+
inited: boolean
|
|
10
|
+
progress: number
|
|
11
|
+
firstRender: number
|
|
12
|
+
done: boolean
|
|
13
|
+
tasks: never[]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
styles(): string
|
|
17
|
+
canvasId(): string
|
|
18
|
+
size(): string | undefined
|
|
19
|
+
dpr(): any
|
|
20
|
+
boardWidth(): any
|
|
21
|
+
boardHeight(): any
|
|
22
|
+
hasBoard(): any
|
|
23
|
+
elements(): any
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
watchRender(val: any, old: any): Promise<void>
|
|
27
|
+
setFilePath(path: any, param: any): Promise<any>
|
|
28
|
+
getSize(args: any): Promise<void>
|
|
29
|
+
canvasToTempFilePathSync(args: any): void
|
|
30
|
+
runTask(): void
|
|
31
|
+
getParentWeith(): Promise<any>
|
|
32
|
+
render(args?: {}): Promise<void | {
|
|
33
|
+
ctx: any
|
|
34
|
+
draw: any
|
|
35
|
+
node: any
|
|
36
|
+
}>
|
|
37
|
+
canvasDraw(flag?: boolean): Promise<any>
|
|
38
|
+
getContext(): Promise<any>
|
|
39
|
+
canvasToTempFilePath(args?: {}): Promise<any>
|
|
40
|
+
},
|
|
41
|
+
any,
|
|
42
|
+
import('vue').ComponentOptionsMixin,
|
|
43
|
+
{},
|
|
44
|
+
string,
|
|
45
|
+
import('vue').PublicProps,
|
|
46
|
+
Readonly<import('vue').ExtractPropTypes<{}>>,
|
|
47
|
+
{},
|
|
48
|
+
{}
|
|
49
|
+
>
|
|
50
|
+
export default _default
|