@10yun/cv-mobile-ui 0.5.51 → 0.5.52
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/build/common_func.js +3 -1
- package/build/parse-create.js +17 -8
- package/build/parse-pages-pkg.js +10 -4
- package/empty-devtools.js +3 -0
- package/libs/aes.js +50 -0
- package/libs/bledefine/bledefine.js +51 -0
- package/libs/bledefine/ios-ble-statuscode.js +97 -0
- package/libs/nfc/hexiii-nfc.js +236 -0
- package/libs/nfc.js +179 -0
- package/libs/sdk/html2canvas.js +8 -0
- package/libs/sdk/sdk-h5.js +585 -0
- package/{plugins → libs}/storage2.js +0 -5
- package/{plugins → libs}/storage3.js +0 -4
- package/libs/validators/index.js +438 -0
- package/libs/weapp-qrcode.js +1108 -0
- package/package.json +2 -3
- package/ui-cv/components/cv-dialog-share/tui-share.vue +16 -16
- package/ui-fireui/components/{fui-actionsheet/fui-actionsheet.vue → u-action-sheet/u-action-sheet.vue} +21 -21
- package/ui-fireui/components/{fui-alert/fui-alert.vue → u-alert/u-alert.vue} +13 -13
- package/ui-fireui/components/{fui-badge/fui-badge.vue → u-badge/u-badge.vue} +16 -16
- package/ui-fireui/components/{fui-bottom-navigation/fui-bottom-navigation.vue → u-bottom-navigation/u-bottom-navigation.vue} +47 -46
- package/ui-fireui/components/{fui-bottom-popup/fui-bottom-popup.vue → u-bottom-popup/u-bottom-popup.vue} +9 -8
- package/ui-fireui/components/{fui-bubble-popup/fui-bubble-popup.vue → u-bubble-popup/u-bubble-popup.vue} +19 -15
- package/ui-fireui/components/{fui-button/fui-button.vue → u-button/u-button.vue} +69 -69
- package/ui-fireui/components/u-button/u-button2.vue +553 -0
- package/ui-fireui/components/{fui-calendar/fui-calendar.vue → u-calendar/u-calendar.vue} +78 -78
- package/ui-fireui/components/u-calendar/u-calendar2.vue +801 -0
- package/ui-fireui/components/{fui-card/fui-card.vue → u-card/u-card.vue} +24 -24
- package/ui-fireui/components/{fui-cascade-selection/fui-cascade-selection.vue → u-cascade-selection/u-cascade-selection.vue} +32 -32
- package/ui-fireui/components/{fui-circular-progress/fui-circular-progress.vue → u-circular-progress/u-circular-progress.vue} +14 -6
- package/ui-fireui/components/{fui-collapse/fui-collapse.vue → u-collapse/u-collapse.vue} +19 -19
- package/ui-fireui/components/{fui-countdown/fui-countdown.vue → u-countdown/u-countdown.vue} +28 -28
- package/ui-fireui/components/{fui-datetime/fui-datetime.vue → u-datetime/u-datetime.vue} +51 -51
- package/ui-fireui/components/{fui-divider/fui-divider.vue → u-divider/u-divider.vue} +6 -6
- package/ui-fireui/components/{fui-drawer/fui-drawer.vue → u-drawer/u-drawer.vue} +11 -11
- package/ui-fireui/components/{fui-dropdown-list/fui-dropdown-list.vue → u-dropdown-list/u-dropdown-list.vue} +11 -6
- package/ui-fireui/components/{fui-fab/fui-fab.vue → u-fab/u-fab.vue} +30 -30
- package/ui-fireui/components/{fui-footer/fui-footer.vue → u-footer/u-footer.vue} +19 -15
- package/ui-fireui/components/{fui-grid/fui-grid.vue → u-grid/u-grid.vue} +13 -5
- package/ui-fireui/components/{fui-grid-item/fui-grid-item.vue → u-grid-item/u-grid-item.vue} +19 -19
- package/ui-fireui/components/{fui-icon/fui-icon.vue → u-icon/u-icon.vue} +191 -191
- package/ui-fireui/components/{fui-image-cropper/fui-image-cropper.vue → u-image-cropper/u-image-cropper.vue} +44 -44
- package/ui-fireui/components/{fui-image-group/fui-image-group.vue → u-image-group/u-image-group.vue} +7 -7
- package/ui-fireui/components/{fui-keyboard/fui-keyboard.vue → u-keyboard/u-keyboard.vue} +29 -32
- package/ui-fireui/components/{fui-keyboard-input/fui-keyboard-input.vue → u-keyboard-input/u-keyboard-input.vue} +9 -9
- package/ui-fireui/components/{fui-list-cell/fui-list-cell.vue → u-list-cell/u-list-cell.vue} +23 -23
- package/ui-fireui/components/{fui-list-view/fui-list-view.vue → u-list-view/u-list-view.vue} +11 -11
- package/ui-fireui/components/{fui-loading/fui-loading.vue → u-loading/u-loading.vue} +6 -6
- package/ui-fireui/components/{fui-loadmore/fui-loadmore.vue → u-loadmore/u-loadmore.vue} +15 -15
- package/ui-fireui/components/{fui-modal/fui-modal.vue → u-modal/u-modal.vue} +58 -58
- package/ui-fireui/components/{fui-navigation-bar/fui-navigation-bar.vue → u-navigation-bar/u-navigation-bar.vue} +11 -10
- package/ui-fireui/components/{fui-no-data/fui-no-data.vue → u-no-data/u-no-data.vue} +11 -11
- package/ui-fireui/components/{fui-nomore/fui-nomore.vue → u-nomore/u-nomore.vue} +10 -10
- package/ui-fireui/components/{fui-numberbox/fui-numberbox.vue → u-numberbox/u-numberbox.vue} +12 -12
- package/ui-fireui/components/{fui-numberbox-border/fui-numberbox-border.vue → u-numberbox-border/u-numberbox-border.vue} +10 -10
- package/ui-fireui/components/{fui-picture-cropper/fui-picture-cropper.vue → u-picture-cropper/u-picture-cropper.vue} +42 -42
- package/ui-fireui/components/u-picture-cropper/u-picture-cropper.wxs +582 -0
- package/ui-fireui/components/{fui-round-progress/fui-round-progress.vue → u-round-progress/u-round-progress.vue} +2 -2
- package/ui-fireui/components/{fui-scroll-top/fui-scroll-top.vue → u-scroll-top/u-scroll-top.vue} +21 -21
- package/ui-fireui/components/{fui-sharemodel/fui-sharemodel.vue → u-share-model/u-share-model.vue} +24 -24
- package/ui-fireui/components/{fui-skeleton/fui-skeleton.vue → u-skeleton/u-skeleton.vue} +22 -22
- package/ui-fireui/components/{fui-steps/fui-steps.vue → u-steps/u-steps.vue} +27 -27
- package/ui-fireui/components/{fui-sticky/fui-sticky.vue → u-sticky/u-sticky.vue} +4 -4
- package/ui-fireui/components/{fui-sticky-wxs/fui-sticky-wxs.vue → u-sticky-wxs/u-sticky-wxs.vue} +7 -7
- package/ui-fireui/components/u-sticky-wxs/u-sticky.wxs +46 -0
- package/ui-fireui/components/{fui-swipe-action/fui-swipe-action.vue → u-swipe-action/u-swipe-action.vue} +11 -11
- package/ui-fireui/components/{fui-tabbar/fui-tabbar.vue → u-tabbar/u-tabbar.vue} +26 -30
- package/ui-fireui/components/{fui-tabs/fui-tabs.vue → u-tabs/u-tabs.vue} +17 -17
- package/ui-fireui/components/{fui-tabs2/fui-tabs2.vue → u-tabs2/u-tabs2.vue} +17 -17
- package/ui-fireui/components/{fui-tag/fui-tag.vue → u-tag/u-tag.vue} +362 -374
- package/ui-fireui/components/{fui-time-axis/fui-time-axis.vue → u-time-axis/u-time-axis.vue} +3 -3
- package/ui-fireui/components/{fui-timeaxis-item/fui-timeaxis-item.vue → u-timeaxis-item/u-timeaxis-item.vue} +4 -4
- package/ui-fireui/components/{fui-tips/fui-tips.vue → u-tips/u-tips.vue} +20 -20
- package/ui-fireui/components/{fui-toast/fui-toast.vue → u-toast/u-toast.vue} +13 -13
- package/ui-fireui/components/{fui-top-dropdown/fui-top-dropdown.vue → u-top-dropdown/u-top-dropdown.vue} +8 -8
- package/ui-fireui/components/{fui-upload/fui-upload.vue → u-upload/u-upload.vue} +30 -30
- package/ui-fireui/components/u-upload2/u-upload.vue +464 -0
- package/ui-fireui/components/{fui-uploadsamll/fui-uploadsamll.vue → u-uploadsamll/u-uploadsamll.vue} +34 -34
- package/ui-fireui/css/thorui.css +589 -0
- package/ui-fireui/{fireui.css → index.css} +306 -268
- package/ui-fireui/nvue/u-circular-progress/gcanvas/bridge/bridge-weex.js +241 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/RenderingContext.js +666 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Buffer.js +21 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLenum.js +298 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLmethod.js +142 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLtype.js +23 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Program.js +21 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Shader.js +22 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Texture.js +22 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/classUtils.js +3 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/env/canvas.js +74 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/env/image.js +96 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/env/tool.js +24 -0
- package/ui-fireui/nvue/u-circular-progress/gcanvas/index.js +47 -0
- package/ui-fireui/nvue/u-circular-progress/u-circular-progress.nvue +203 -0
- package/ui-fireui/nvue/u-icon/icons.js +188 -0
- package/ui-fireui/nvue/u-icon/u-icon.vue +78 -0
- package/ui-fireui/components/fui-picture-cropper/fui-picture-cropper.wxs +0 -560
- package/ui-fireui/components/fui-rate/fui-rate.vue +0 -167
- package/ui-fireui/components/fui-sticky-wxs/fui-sticky.wxs +0 -44
- /package/ui-fireui/components/{fui-calendar/fui-calendar.js → u-calendar/u-calendar.js} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {getTransferedObjectUUID} from './classUtils';
|
|
2
|
+
|
|
3
|
+
const name = 'WebGLShader';
|
|
4
|
+
|
|
5
|
+
function uuid(id) {
|
|
6
|
+
return getTransferedObjectUUID(name, id);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class WebGLShader {
|
|
10
|
+
className = name;
|
|
11
|
+
|
|
12
|
+
constructor(id, type) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.type = type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static uuid = uuid;
|
|
18
|
+
|
|
19
|
+
uuid() {
|
|
20
|
+
return uuid(this.id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {getTransferedObjectUUID} from './classUtils';
|
|
2
|
+
|
|
3
|
+
const name = 'WebGLTexture';
|
|
4
|
+
|
|
5
|
+
function uuid(id) {
|
|
6
|
+
return getTransferedObjectUUID(name, id);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class WebGLTexture {
|
|
10
|
+
className = name;
|
|
11
|
+
|
|
12
|
+
constructor(id, type) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.type = type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static uuid = uuid;
|
|
18
|
+
|
|
19
|
+
uuid() {
|
|
20
|
+
return uuid(this.id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {getTransferedObjectUUID} from './classUtils';
|
|
2
|
+
|
|
3
|
+
const name = 'WebGLUniformLocation';
|
|
4
|
+
|
|
5
|
+
function uuid(id) {
|
|
6
|
+
return getTransferedObjectUUID(name, id);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class WebGLUniformLocation {
|
|
10
|
+
className = name;
|
|
11
|
+
|
|
12
|
+
constructor(id, type) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.type = type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static uuid = uuid;
|
|
18
|
+
|
|
19
|
+
uuid() {
|
|
20
|
+
return uuid(this.id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import GContext2D from '../context-2d/RenderingContext';
|
|
2
|
+
import GContextWebGL from '../context-webgl/RenderingContext';
|
|
3
|
+
|
|
4
|
+
export default class GCanvas {
|
|
5
|
+
|
|
6
|
+
// static GBridge = null;
|
|
7
|
+
|
|
8
|
+
id = null;
|
|
9
|
+
|
|
10
|
+
_needRender = true;
|
|
11
|
+
|
|
12
|
+
constructor(id, { disableAutoSwap }) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
|
|
15
|
+
this._disableAutoSwap = disableAutoSwap;
|
|
16
|
+
if (disableAutoSwap) {
|
|
17
|
+
this._swapBuffers = () => {
|
|
18
|
+
GCanvas.GBridge.render(this.id);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getContext(type) {
|
|
24
|
+
|
|
25
|
+
let context = null;
|
|
26
|
+
|
|
27
|
+
if (type.match(/webgl/i)) {
|
|
28
|
+
context = new GContextWebGL(this);
|
|
29
|
+
|
|
30
|
+
context.componentId = this.id;
|
|
31
|
+
|
|
32
|
+
if (!this._disableAutoSwap) {
|
|
33
|
+
const render = () => {
|
|
34
|
+
if (this._needRender) {
|
|
35
|
+
GCanvas.GBridge.render(this.id);
|
|
36
|
+
this._needRender = false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
setInterval(render, 16);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
GCanvas.GBridge.callSetContextType(this.id, 1); // 0 for 2d; 1 for webgl
|
|
43
|
+
} else if (type.match(/2d/i)) {
|
|
44
|
+
context = new GContext2D(this);
|
|
45
|
+
|
|
46
|
+
context.componentId = this.id;
|
|
47
|
+
|
|
48
|
+
// const render = ( callback ) => {
|
|
49
|
+
//
|
|
50
|
+
// const commands = context._drawCommands;
|
|
51
|
+
// context._drawCommands = '';
|
|
52
|
+
//
|
|
53
|
+
// GCanvas.GBridge.render2d(this.id, commands, callback);
|
|
54
|
+
// this._needRender = false;
|
|
55
|
+
// }
|
|
56
|
+
// //draw方法触发
|
|
57
|
+
// context._flush = render;
|
|
58
|
+
// //setInterval(render, 16);
|
|
59
|
+
|
|
60
|
+
GCanvas.GBridge.callSetContextType(this.id, 0);
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error('not supported context ' + type);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return context;
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
reset() {
|
|
70
|
+
GCanvas.GBridge.callReset(this.id);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
let incId = 1;
|
|
2
|
+
|
|
3
|
+
const noop = function () { };
|
|
4
|
+
|
|
5
|
+
class GImage {
|
|
6
|
+
|
|
7
|
+
static GBridge = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
this._id = incId++;
|
|
11
|
+
this._width = 0;
|
|
12
|
+
this._height = 0;
|
|
13
|
+
this._src = undefined;
|
|
14
|
+
this._onload = noop;
|
|
15
|
+
this._onerror = noop;
|
|
16
|
+
this.complete = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get width() {
|
|
20
|
+
return this._width;
|
|
21
|
+
}
|
|
22
|
+
set width(v) {
|
|
23
|
+
this._width = v;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get height() {
|
|
27
|
+
return this._height;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
set height(v) {
|
|
31
|
+
this._height = v;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get src() {
|
|
35
|
+
return this._src;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
set src(v) {
|
|
39
|
+
|
|
40
|
+
if (v.startsWith('//')) {
|
|
41
|
+
v = 'http:' + v;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this._src = v;
|
|
45
|
+
|
|
46
|
+
GImage.GBridge.perloadImage([this._src, this._id], (data) => {
|
|
47
|
+
if (typeof data === 'string') {
|
|
48
|
+
data = JSON.parse(data);
|
|
49
|
+
}
|
|
50
|
+
if (data.error) {
|
|
51
|
+
var evt = { type: 'error', target: this };
|
|
52
|
+
this.onerror(evt);
|
|
53
|
+
} else {
|
|
54
|
+
this.complete = true;
|
|
55
|
+
this.width = typeof data.width === 'number' ? data.width : 0;
|
|
56
|
+
this.height = typeof data.height === 'number' ? data.height : 0;
|
|
57
|
+
var evt = { type: 'load', target: this };
|
|
58
|
+
this.onload(evt);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
addEventListener(name, listener) {
|
|
64
|
+
if (name === 'load') {
|
|
65
|
+
this.onload = listener;
|
|
66
|
+
} else if (name === 'error') {
|
|
67
|
+
this.onerror = listener;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
removeEventListener(name, listener) {
|
|
72
|
+
if (name === 'load') {
|
|
73
|
+
this.onload = noop;
|
|
74
|
+
} else if (name === 'error') {
|
|
75
|
+
this.onerror = noop;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get onload() {
|
|
80
|
+
return this._onload;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
set onload(v) {
|
|
84
|
+
this._onload = v;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get onerror() {
|
|
88
|
+
return this._onerror;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
set onerror(v) {
|
|
92
|
+
this._onerror = v;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default GImage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
export function ArrayBufferToBase64 (buffer) {
|
|
3
|
+
var binary = '';
|
|
4
|
+
var bytes = new Uint8ClampedArray(buffer);
|
|
5
|
+
for (var len = bytes.byteLength, i = 0; i < len; i++) {
|
|
6
|
+
binary += String.fromCharCode(bytes[i]);
|
|
7
|
+
}
|
|
8
|
+
return btoa(binary);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Base64ToUint8ClampedArray(base64String) {
|
|
12
|
+
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
|
13
|
+
const base64 = (base64String + padding)
|
|
14
|
+
.replace(/\-/g, '+')
|
|
15
|
+
.replace(/_/g, '/');
|
|
16
|
+
|
|
17
|
+
const rawData = atob(base64);
|
|
18
|
+
const outputArray = new Uint8ClampedArray(rawData.length);
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < rawData.length; ++i) {
|
|
21
|
+
outputArray[i] = rawData.charCodeAt(i);
|
|
22
|
+
}
|
|
23
|
+
return outputArray;
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import GCanvas from './env/canvas';
|
|
2
|
+
import GImage from './env/image';
|
|
3
|
+
|
|
4
|
+
import GWebGLRenderingContext from './context-webgl/RenderingContext';
|
|
5
|
+
import GContext2D from './context-2d/RenderingContext';
|
|
6
|
+
|
|
7
|
+
import GBridgeWeex from './bridge/bridge-weex';
|
|
8
|
+
|
|
9
|
+
export let Image = GImage;
|
|
10
|
+
|
|
11
|
+
export let WeexBridge = GBridgeWeex;
|
|
12
|
+
|
|
13
|
+
export function enable(el, {
|
|
14
|
+
bridge,
|
|
15
|
+
debug,
|
|
16
|
+
disableAutoSwap,
|
|
17
|
+
disableComboCommands
|
|
18
|
+
} = {}) {
|
|
19
|
+
|
|
20
|
+
const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge;
|
|
21
|
+
|
|
22
|
+
GBridge.callEnable(el.ref, [
|
|
23
|
+
0, // renderMode: 0--RENDERMODE_WHEN_DIRTY, 1--RENDERMODE_CONTINUOUSLY
|
|
24
|
+
-1, // hybridLayerType: 0--LAYER_TYPE_NONE 1--LAYER_TYPE_SOFTWARE 2--LAYER_TYPE_HARDWARE
|
|
25
|
+
false, // supportScroll
|
|
26
|
+
false, // newCanvasMode
|
|
27
|
+
1, // compatible
|
|
28
|
+
'white', // clearColor
|
|
29
|
+
false // sameLevel: newCanvasMode = true && true => GCanvasView and Webview is same level
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
if (debug === true) {
|
|
33
|
+
GBridge.callEnableDebug();
|
|
34
|
+
}
|
|
35
|
+
if (disableComboCommands) {
|
|
36
|
+
GBridge.callEnableDisableCombo();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var canvas = new GCanvas(el.ref, {
|
|
40
|
+
disableAutoSwap
|
|
41
|
+
});
|
|
42
|
+
let pixelRatio = uni.getSystemInfoSync().pixelRatio;
|
|
43
|
+
canvas.width = el.style.width * pixelRatio;
|
|
44
|
+
canvas.height = el.style.height * pixelRatio;
|
|
45
|
+
|
|
46
|
+
return canvas;
|
|
47
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="up-circular-container" :style="{ width: diam + 'px', height: (height || diam) + 'px' }">
|
|
3
|
+
<gcanvas :ref="progressCanvasId" :style="{ width: diam + 'px', height: (height || diam) + 'px' }"></gcanvas>
|
|
4
|
+
<slot />
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
//nuve 专用
|
|
10
|
+
import { enable, WeexBridge } from './gcanvas/index.js';
|
|
11
|
+
export default {
|
|
12
|
+
name: 'thorCircularProgress',
|
|
13
|
+
props: {
|
|
14
|
+
/*
|
|
15
|
+
传值需使用rpx进行转换保证各终端兼容
|
|
16
|
+
px = rpx / 750 * uni.getSystemInfoSync().windowWidth
|
|
17
|
+
圆形进度条(画布)宽度,直径 [px]
|
|
18
|
+
*/
|
|
19
|
+
diam: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 60
|
|
22
|
+
},
|
|
23
|
+
//圆形进度条(画布)高度,默认取diam值[当画半弧时可传值,height有值时则取height]
|
|
24
|
+
height: {
|
|
25
|
+
type: Number,
|
|
26
|
+
default: 60
|
|
27
|
+
},
|
|
28
|
+
//进度条线条宽度[px]
|
|
29
|
+
lineWidth: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 4
|
|
32
|
+
},
|
|
33
|
+
/*
|
|
34
|
+
线条的端点样式
|
|
35
|
+
butt:向线条的每个末端添加平直的边缘
|
|
36
|
+
round 向线条的每个末端添加圆形线帽
|
|
37
|
+
square 向线条的每个末端添加正方形线帽
|
|
38
|
+
*/
|
|
39
|
+
lineCap: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: 'round'
|
|
42
|
+
},
|
|
43
|
+
//圆环进度字体大小 [px]
|
|
44
|
+
fontSize: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 26
|
|
47
|
+
},
|
|
48
|
+
//圆环进度字体颜色
|
|
49
|
+
fontColor: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: '#16b999'
|
|
52
|
+
},
|
|
53
|
+
//是否显示进度文字
|
|
54
|
+
fontShow: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true
|
|
57
|
+
},
|
|
58
|
+
/*
|
|
59
|
+
自定义显示文字[默认为空,显示百分比,fontShow=true时生效]
|
|
60
|
+
可以使用 slot自定义显示内容
|
|
61
|
+
*/
|
|
62
|
+
percentText: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: ''
|
|
65
|
+
},
|
|
66
|
+
//进度条颜色
|
|
67
|
+
progressColor: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: '#16b999'
|
|
70
|
+
},
|
|
71
|
+
//起始弧度,单位弧度
|
|
72
|
+
sAngle: {
|
|
73
|
+
type: Number,
|
|
74
|
+
default: -Math.PI / 2
|
|
75
|
+
},
|
|
76
|
+
//指定弧度的方向是逆时针还是顺时针。默认是false,即顺时针
|
|
77
|
+
counterclockwise: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false
|
|
80
|
+
},
|
|
81
|
+
//进度百分比 [10% 传值 10]
|
|
82
|
+
percentage: {
|
|
83
|
+
type: Number,
|
|
84
|
+
default: 0
|
|
85
|
+
},
|
|
86
|
+
//进度百分比缩放倍数[使用半弧为100%时,则可传2]
|
|
87
|
+
multiple: {
|
|
88
|
+
type: Number,
|
|
89
|
+
default: 1
|
|
90
|
+
},
|
|
91
|
+
//动画执行时间[单位毫秒,低于50无动画]
|
|
92
|
+
duration: {
|
|
93
|
+
type: Number,
|
|
94
|
+
default: 800
|
|
95
|
+
},
|
|
96
|
+
//backwards: 动画从头播;forwards:动画从上次结束点接着播
|
|
97
|
+
activeMode: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: 'backwards'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
computed: {
|
|
103
|
+
canvasChange() {
|
|
104
|
+
return `${this.diam},${this.height},${this.lineWidth}`;
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
watch: {
|
|
108
|
+
percentage(val) {
|
|
109
|
+
this.initDraw();
|
|
110
|
+
},
|
|
111
|
+
canvasChange() {
|
|
112
|
+
this.initDraw(true);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
data() {
|
|
116
|
+
return {
|
|
117
|
+
progressCanvasId: this.getCanvasId(),
|
|
118
|
+
progressContext: null,
|
|
119
|
+
canvasObj: null,
|
|
120
|
+
//起始百分比
|
|
121
|
+
startPercentage: 0,
|
|
122
|
+
// dpi
|
|
123
|
+
pixelRatio: uni.getSystemInfoSync().pixelRatio
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
mounted() {
|
|
127
|
+
this.initDraw(true);
|
|
128
|
+
},
|
|
129
|
+
methods: {
|
|
130
|
+
//初始化绘制
|
|
131
|
+
initDraw(init) {
|
|
132
|
+
let start = this.activeMode === 'backwards' ? 0 : this.startPercentage;
|
|
133
|
+
this.drawProgressCircular(start);
|
|
134
|
+
},
|
|
135
|
+
//进度圆环
|
|
136
|
+
drawProgressCircular(startPercentage) {
|
|
137
|
+
let ctx = this.progressContext;
|
|
138
|
+
if (!ctx) {
|
|
139
|
+
let ganvas = this.$refs[this.progressCanvasId];
|
|
140
|
+
/*通过元素引用获取canvas对象*/
|
|
141
|
+
this.canvasObj = enable(ganvas, {
|
|
142
|
+
bridge: WeexBridge
|
|
143
|
+
});
|
|
144
|
+
/*获取绘图所需的上下文,目前不支持3d*/
|
|
145
|
+
ctx = this.canvasObj.getContext('2d');
|
|
146
|
+
this.progressContext = ctx;
|
|
147
|
+
}
|
|
148
|
+
ctx.setLineWidth(this.lineWidth);
|
|
149
|
+
ctx.setStrokeStyle(this.progressColor);
|
|
150
|
+
let time = this.duration / this.percentage;
|
|
151
|
+
startPercentage = this.duration < 50 ? this.percentage - 1 : startPercentage;
|
|
152
|
+
startPercentage++;
|
|
153
|
+
if (startPercentage > this.percentage) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (this.fontShow) {
|
|
157
|
+
ctx.setFontSize(this.fontSize);
|
|
158
|
+
ctx.setFillStyle(this.fontColor);
|
|
159
|
+
ctx.setTextAlign('center');
|
|
160
|
+
ctx.setTextBaseline('middle');
|
|
161
|
+
let percentage = this.percentText;
|
|
162
|
+
if (!percentage) {
|
|
163
|
+
percentage = this.counterclockwise ? 100 - startPercentage * this.multiple : startPercentage * this.multiple;
|
|
164
|
+
percentage = `${percentage}%`;
|
|
165
|
+
}
|
|
166
|
+
let radius = this.diam / 2;
|
|
167
|
+
ctx.fillText(percentage, radius, radius);
|
|
168
|
+
}
|
|
169
|
+
let eAngle = ((2 * Math.PI) / 100) * startPercentage + this.sAngle;
|
|
170
|
+
this.drawArc(ctx, eAngle);
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
this.startPercentage = startPercentage;
|
|
173
|
+
this.drawProgressCircular(startPercentage);
|
|
174
|
+
this.$emit('change', {
|
|
175
|
+
percentage: startPercentage
|
|
176
|
+
});
|
|
177
|
+
}, time);
|
|
178
|
+
},
|
|
179
|
+
//创建弧线
|
|
180
|
+
drawArc(ctx, eAngle) {
|
|
181
|
+
ctx.setLineCap(this.lineCap);
|
|
182
|
+
ctx.beginPath();
|
|
183
|
+
let radius = this.diam / 2; //x=y
|
|
184
|
+
ctx.arc(radius, radius, radius - this.lineWidth, this.sAngle, eAngle, this.counterclockwise);
|
|
185
|
+
ctx.stroke();
|
|
186
|
+
ctx.draw();
|
|
187
|
+
},
|
|
188
|
+
//生成canvasId
|
|
189
|
+
getCanvasId() {
|
|
190
|
+
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
191
|
+
return (c === 'x' ? (Math.random() * 16) | 0 : 'r&0x3' | '0x8').toString(16);
|
|
192
|
+
});
|
|
193
|
+
return uuid;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
</script>
|
|
198
|
+
|
|
199
|
+
<style scoped>
|
|
200
|
+
.up-circular-container {
|
|
201
|
+
position: relative;
|
|
202
|
+
}
|
|
203
|
+
</style>
|