@10yun/cv-mobile-ui 0.5.34 → 0.5.36

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.
@@ -1,147 +1,168 @@
1
1
  function getLocalFilePath(path) {
2
- if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path.indexOf('_downloads') === 0) {
3
- return path
2
+ if (
3
+ path.indexOf('_www') === 0 ||
4
+ path.indexOf('_doc') === 0 ||
5
+ path.indexOf('_documents') === 0 ||
6
+ path.indexOf('_downloads') === 0
7
+ ) {
8
+ return path;
9
+ }
10
+ if (path.indexOf('file://') === 0) {
11
+ return path;
12
+ }
13
+ if (path.indexOf('/storage/emulated/0/') === 0) {
14
+ return path;
15
+ }
16
+ if (path.indexOf('/') === 0) {
17
+ var localFilePath = plus.io.convertAbsoluteFileSystem(path);
18
+ if (localFilePath !== path) {
19
+ return localFilePath;
20
+ } else {
21
+ path = path.substr(1);
4
22
  }
5
- if (path.indexOf('file://') === 0) {
6
- return path
7
- }
8
- if (path.indexOf('/storage/emulated/0/') === 0) {
9
- return path
10
- }
11
- if (path.indexOf('/') === 0) {
12
- var localFilePath = plus.io.convertAbsoluteFileSystem(path)
13
- if (localFilePath !== path) {
14
- return localFilePath
15
- } else {
16
- path = path.substr(1)
17
- }
18
- }
19
- return '_www/' + path
23
+ }
24
+ return '_www/' + path;
20
25
  }
21
26
 
22
27
  export function pathToBase64(path) {
23
- return new Promise(function (resolve, reject) {
24
- if (typeof window === 'object' && 'document' in window) {
25
- if (typeof FileReader === 'function') {
26
- var xhr = new XMLHttpRequest()
27
- xhr.open('GET', path, true)
28
- xhr.responseType = 'blob'
29
- xhr.onload = function () {
30
- if (this.status === 200) {
31
- let fileReader = new FileReader()
32
- fileReader.onload = function (e) {
33
- resolve(e.target.result)
34
- }
35
- fileReader.onerror = reject
36
- fileReader.readAsDataURL(this.response)
37
- }
38
- }
39
- xhr.onerror = reject
40
- xhr.send()
41
- return
42
- }
43
- var canvas = document.createElement('canvas')
44
- var c2x = canvas.getContext('2d')
45
- var img = new Image
46
- img.onload = function () {
47
- canvas.width = img.width
48
- canvas.height = img.height
49
- c2x.drawImage(img, 0, 0)
50
- resolve(canvas.toDataURL())
51
- canvas.height = canvas.width = 0
28
+ return new Promise(function (resolve, reject) {
29
+ if (typeof window === 'object' && 'document' in window) {
30
+ if (typeof FileReader === 'function') {
31
+ var xhr = new XMLHttpRequest();
32
+ xhr.open('GET', path, true);
33
+ xhr.responseType = 'blob';
34
+ xhr.onload = function () {
35
+ if (this.status === 200) {
36
+ let fileReader = new FileReader();
37
+ fileReader.onload = function (e) {
38
+ resolve(e.target.result);
39
+ };
40
+ fileReader.onerror = reject;
41
+ fileReader.readAsDataURL(this.response);
42
+ }
43
+ };
44
+ xhr.onerror = reject;
45
+ xhr.send();
46
+ return;
47
+ }
48
+ var canvas = document.createElement('canvas');
49
+ var c2x = canvas.getContext('2d');
50
+ var img = new Image();
51
+ img.onload = function () {
52
+ canvas.width = img.width;
53
+ canvas.height = img.height;
54
+ c2x.drawImage(img, 0, 0);
55
+ resolve(canvas.toDataURL());
56
+ canvas.height = canvas.width = 0;
57
+ };
58
+ img.onerror = reject;
59
+ img.src = path;
60
+ return;
61
+ }
62
+ if (typeof plus === 'object') {
63
+ plus.io.resolveLocalFileSystemURL(
64
+ getLocalFilePath(path),
65
+ function (entry) {
66
+ entry.file(
67
+ function (file) {
68
+ var fileReader = new plus.io.FileReader();
69
+ fileReader.onload = function (data) {
70
+ resolve(data.target.result);
71
+ };
72
+ fileReader.onerror = function (error) {
73
+ reject(error);
74
+ };
75
+ fileReader.readAsDataURL(file);
76
+ },
77
+ function (error) {
78
+ reject(error);
52
79
  }
53
- img.onerror = reject
54
- img.src = path
55
- return
80
+ );
81
+ },
82
+ function (error) {
83
+ reject(error);
56
84
  }
57
- if (typeof plus === 'object') {
58
- plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), function (entry) {
59
- entry.file(function (file) {
60
- var fileReader = new plus.io.FileReader()
61
- fileReader.onload = function (data) {
62
- resolve(data.target.result)
63
- }
64
- fileReader.onerror = function (error) {
65
- reject(error)
66
- }
67
- fileReader.readAsDataURL(file)
68
- }, function (error) {
69
- reject(error)
70
- })
71
- }, function (error) {
72
- reject(error)
73
- })
74
- return
75
- }
76
- if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
77
- wx.getFileSystemManager().readFile({
78
- filePath: path,
79
- encoding: 'base64',
80
- success: function (res) {
81
- resolve('data:image/png;base64,' + res.data)
82
- },
83
- fail: function (error) {
84
- reject(error)
85
- }
86
- })
87
- return
85
+ );
86
+ return;
87
+ }
88
+ if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
89
+ wx.getFileSystemManager().readFile({
90
+ filePath: path,
91
+ encoding: 'base64',
92
+ success: function (res) {
93
+ resolve('data:image/png;base64,' + res.data);
94
+ },
95
+ fail: function (error) {
96
+ reject(error);
88
97
  }
89
- reject(new Error('not support'))
90
- })
98
+ });
99
+ return;
100
+ }
101
+ reject(new Error('not support'));
102
+ });
91
103
  }
92
104
 
93
105
  export function base64ToPath(base64) {
94
- return new Promise(function (resolve, reject) {
95
- if (typeof window === 'object' && 'document' in window) {
96
- base64 = base64.split(',')
97
- var type = base64[0].match(/:(.*?);/)[1]
98
- var str = atob(base64[1])
99
- var n = str.length
100
- var array = new Uint8Array(n)
101
- while (n--) {
102
- array[n] = str.charCodeAt(n)
106
+ return new Promise(function (resolve, reject) {
107
+ if (typeof window === 'object' && 'document' in window) {
108
+ base64 = base64.split(',');
109
+ var type = base64[0].match(/:(.*?);/)[1];
110
+ var str = atob(base64[1]);
111
+ var n = str.length;
112
+ var array = new Uint8Array(n);
113
+ while (n--) {
114
+ array[n] = str.charCodeAt(n);
115
+ }
116
+ return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], { type: type })));
117
+ }
118
+ var extName = base64.match(/data\:\S+\/(\S+);/);
119
+ if (extName) {
120
+ extName = extName[1];
121
+ } else {
122
+ reject(new Error('base64 error'));
123
+ }
124
+ var fileName = Date.now() + '.' + extName;
125
+ if (typeof plus === 'object') {
126
+ var bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now());
127
+ bitmap.loadBase64Data(
128
+ base64,
129
+ function () {
130
+ var filePath = '_doc/uniapp_temp/' + fileName;
131
+ bitmap.save(
132
+ filePath,
133
+ {},
134
+ function () {
135
+ bitmap.clear();
136
+ resolve(filePath);
137
+ },
138
+ function (error) {
139
+ bitmap.clear();
140
+ reject(error);
103
141
  }
104
- return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], { type: type })))
105
- }
106
- var extName = base64.match(/data\:\S+\/(\S+);/)
107
- if (extName) {
108
- extName = extName[1]
109
- } else {
110
- reject(new Error('base64 error'))
142
+ );
143
+ },
144
+ function (error) {
145
+ bitmap.clear();
146
+ reject(error);
111
147
  }
112
- var fileName = Date.now() + '.' + extName
113
- if (typeof plus === 'object') {
114
- var bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now())
115
- bitmap.loadBase64Data(base64, function () {
116
- var filePath = '_doc/uniapp_temp/' + fileName
117
- bitmap.save(filePath, {}, function () {
118
- bitmap.clear()
119
- resolve(filePath)
120
- }, function (error) {
121
- bitmap.clear()
122
- reject(error)
123
- })
124
- }, function (error) {
125
- bitmap.clear()
126
- reject(error)
127
- })
128
- return
129
- }
130
- if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
131
- var filePath = wx.env.USER_DATA_PATH + '/' + fileName
132
- wx.getFileSystemManager().writeFile({
133
- filePath: filePath,
134
- data: base64.replace(/^data:\S+\/\S+;base64,/, ''),
135
- encoding: 'base64',
136
- success: function () {
137
- resolve(filePath)
138
- },
139
- fail: function (error) {
140
- reject(error)
141
- }
142
- })
143
- return
148
+ );
149
+ return;
150
+ }
151
+ if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
152
+ var filePath = wx.env.USER_DATA_PATH + '/' + fileName;
153
+ wx.getFileSystemManager().writeFile({
154
+ filePath: filePath,
155
+ data: base64.replace(/^data:\S+\/\S+;base64,/, ''),
156
+ encoding: 'base64',
157
+ success: function () {
158
+ resolve(filePath);
159
+ },
160
+ fail: function (error) {
161
+ reject(error);
144
162
  }
145
- reject(new Error('not support'))
146
- })
147
- }
163
+ });
164
+ return;
165
+ }
166
+ reject(new Error('not support'));
167
+ });
168
+ }
@@ -12,7 +12,9 @@
12
12
  * @description 数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景
13
13
  * @tutorial https://ext.dcloud.net.cn/plugin?id=21
14
14
  * @property {String} text 角标内容
15
- * @property {String} size = [normal|small] 角标内容
15
+ * @property {String} size = [normal|small] Badge 大小
16
+ * @value normal 一般尺寸
17
+ * @value small 小尺寸
16
18
  * @property {String} type = [info|primary|success|warning|error] 颜色类型
17
19
  * @value info 灰色
18
20
  * @value primary 蓝色
@@ -79,7 +79,7 @@ function propObserver(newValue, oldValue, instance) {
79
79
  pullDown = newValue;
80
80
  }
81
81
 
82
- module.exports = {
82
+ export default {
83
83
  touchmove: touchMove,
84
84
  touchstart: touchStart,
85
85
  touchend: touchEnd,
@@ -110,6 +110,9 @@ export default {
110
110
  type: Object,
111
111
  default() {
112
112
  return {
113
+ //contentdown: '上拉显示更多',
114
+ //contentrefresh: '正在加载...',
115
+ //contentnomore: '没有更多数据了'
113
116
  contentdown: '',
114
117
  contentrefresh: '',
115
118
  contentnomore: ''