@10yun/cv-mobile-ui 0.3.24 → 0.3.25

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 (77) hide show
  1. package/package.json +5 -2
  2. package/plugins/request.js +14 -1
  3. package/ui-cv/cv-banner/cv-banner.vue +23 -14
  4. package/ui-cv/cv-banner-card/cv-banner-card.vue +24 -16
  5. package/ui-cv/cv-block/cv-block.vue +6 -6
  6. package/ui-cv/cv-box/cv-box.vue +6 -7
  7. package/ui-cv/cv-button/cv-button.vue +32 -13
  8. package/ui-cv/cv-cell/cv-cell.vue +21 -25
  9. package/ui-cv/cv-checkbox/cv-checkbox.vue +22 -22
  10. package/ui-cv/cv-checkbox-tag/cv-checkbox-tag.vue +30 -25
  11. package/ui-cv/cv-code-sms/cv-code-sms.vue +60 -38
  12. package/ui-cv/cv-dialog-bottom/cv-dialog-bottom.vue +14 -18
  13. package/ui-cv/cv-dialog-full/cv-dialog-full.vue +14 -18
  14. package/ui-cv/cv-dialog-loading/cv-dialog-loading.vue +10 -17
  15. package/ui-cv/cv-dialog-share/cv-dialog-share.vue +4 -5
  16. package/ui-cv/cv-draw-barcode/cv-draw-barcode.vue +54 -51
  17. package/ui-cv/cv-draw-posters/cv-draw-posters.vue +53 -71
  18. package/ui-cv/cv-draw-progress/cv-draw-progress.vue +44 -39
  19. package/ui-cv/cv-draw-qrcode/cv-draw-qrcode.vue +48 -45
  20. package/ui-cv/cv-editor/compressImage.vue +47 -40
  21. package/ui-cv/cv-editor/cv-editor.vue +234 -124
  22. package/ui-cv/cv-editor-parse/cv-editor-parse.vue +21 -30
  23. package/ui-cv/cv-editor-parse/u-parse.vue +21 -30
  24. package/ui-cv/cv-filter-hm/cv-filter-hm.vue +140 -74
  25. package/ui-cv/cv-form-group/cv-form-group.vue +11 -13
  26. package/ui-cv/cv-form-item/cv-form-item.vue +35 -20
  27. package/ui-cv/cv-form-merge/cv-form-merge.vue +5 -10
  28. package/ui-cv/cv-geo-local/cv-geo-local.vue +50 -27
  29. package/ui-cv/cv-icons/cv-icons.vue +24 -19
  30. package/ui-cv/cv-info/cv-info.vue +9 -11
  31. package/ui-cv/cv-input-btn/cv-input-btn.vue +34 -13
  32. package/ui-cv/cv-input-digit/cv-input-digit.vue +31 -18
  33. package/ui-cv/cv-input-idcard/cv-input-idcard.vue +31 -21
  34. package/ui-cv/cv-input-number/cv-input-number.vue +29 -14
  35. package/ui-cv/cv-input-password/cv-input-password.vue +31 -20
  36. package/ui-cv/cv-input-text/cv-input-text.vue +32 -17
  37. package/ui-cv/cv-link/cv-link.vue +7 -7
  38. package/ui-cv/cv-lists-base/cv-lists-base.vue +148 -114
  39. package/ui-cv/cv-lists-swiper/cv-lists-swipe2r.vue +24 -15
  40. package/ui-cv/cv-lists-swiper/cv-lists-swiper.vue +85 -63
  41. package/ui-cv/cv-load-more/cv-load-more.vue +60 -28
  42. package/ui-cv/cv-message/cv-message.vue +5 -6
  43. package/ui-cv/cv-nav-col/cv-nav-col.vue +9 -13
  44. package/ui-cv/cv-nav-group/cv-nav-group.vue +6 -8
  45. package/ui-cv/cv-nav-row/cv-nav-row.vue +21 -25
  46. package/ui-cv/cv-picker-date/cv-picker-date.vue +28 -12
  47. package/ui-cv/cv-picker-datetime/cv-picker-datetime.vue +43 -21
  48. package/ui-cv/cv-picker-datetime5/cv-picker-datetime5.vue +108 -60
  49. package/ui-cv/cv-picker-region/cv-picker-region.vue +46 -32
  50. package/ui-cv/cv-picker-time/cv-picker-time.vue +26 -11
  51. package/ui-cv/cv-picker1/cv-picker1.vue +32 -17
  52. package/ui-cv/cv-picker2/cv-picker2.vue +46 -28
  53. package/ui-cv/cv-picker3/cv-picker3.vue +77 -44
  54. package/ui-cv/cv-radio/cv-radio.vue +17 -10
  55. package/ui-cv/cv-radio-sex/cv-radio-sex.vue +20 -21
  56. package/ui-cv/cv-radio-tag/cv-radio-tag.vue +22 -11
  57. package/ui-cv/cv-rate/cv-rate.vue +17 -13
  58. package/ui-cv/cv-search/cv-search.vue +17 -12
  59. package/ui-cv/cv-skeleton/cv-skeleton.vue +32 -27
  60. package/ui-cv/cv-skeleton/cv-skeleton2.vue +56 -33
  61. package/ui-cv/cv-skeleton-group/cv-skeleton-group.vue +4 -6
  62. package/ui-cv/cv-specs/cv-specs.vue +31 -30
  63. package/ui-cv/cv-switch/cv-switch.vue +4 -5
  64. package/ui-cv/cv-tab-lists/cv-tab-lists.vue +189 -128
  65. package/ui-cv/cv-textarea/cv-textarea.vue +31 -13
  66. package/ui-cv/cv-treaty/cv-treaty.vue +8 -8
  67. package/ui-cv/cv-update-app/cv-update-app.vue +68 -53
  68. package/ui-cv/cv-upload-avatar/cv-upload-avatar.vue +33 -31
  69. package/ui-cv/cv-upload-img/cv-upload-img.vue +97 -70
  70. package/ui-cv/dict/area-city.js +612 -612
  71. package/ui-cv/dict/area-county.js +3392 -3392
  72. package/ui-cv/dict/area-province.js +35 -35
  73. package/ui-cv/mixins/mixins-checkbox.js +9 -15
  74. package/ui-cv/mixins/mixins-common.js +7 -7
  75. package/ui-cv/mixins/mixins-input.js +11 -12
  76. package/ui-cv/mixins/mixins-picker.js +9 -13
  77. package/ui-cv/mixins/mixins-radio.js +10 -14
@@ -1,36 +1,36 @@
1
1
  <template>
2
2
  <view class="cv-draw-barcode">
3
3
  <!-- #ifndef MP-ALIPAY -->
4
- <canvas class="cv-draw-barcode_canvas" :canvas-id="cid" :style="{width:canvasWidth+'px',height:canvasHeight+'px'}" />
4
+ <canvas class="cv-draw-barcode_canvas" :canvas-id="cid" :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }" />
5
5
  <!-- #endif -->
6
6
  <!-- #ifdef MP-ALIPAY -->
7
7
  <canvas :id="cid" :width="canvasWidth" :height="canvasHeight" class="cv-draw-barcode_canvas" />
8
8
  <!-- #endif -->
9
- <image v-show="show" :src="result" :style="{width:canvasWidth+'px',height:canvasHeight+'px'}" />
9
+ <image v-show="show" :src="result" :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }" />
10
10
  </view>
11
11
  </template>
12
12
 
13
13
  <script>
14
- import barCode from "./barcode.js"
14
+ import barCode from './barcode.js';
15
15
  const opations = {
16
16
  // format: "CODE128",//选择要使用的条形码类型 微信支持的条码类型有 code128\code39\ena13\ean8\upc\itf14\
17
17
  width: 2, //设置条之间的宽度
18
18
  height: 60, //高度
19
19
  displayValue: true, //是否在条形码下方显示文字
20
20
  // text: "1234567890",//覆盖显示的文本
21
- textAlign: "center", //设置文本的水平对齐方式
22
- textPosition: "bottom", //设置文本的垂直位置
21
+ textAlign: 'center', //设置文本的水平对齐方式
22
+ textPosition: 'bottom', //设置文本的垂直位置
23
23
  textMargin: 5, //设置条形码和文本之间的间距
24
24
  fontSize: 16, //设置文本的大小
25
- fontColor: "#000000", //设置文本的颜色
26
- lineColor: "#000000", //设置条形码的颜色
27
- background: "#FFFFFF", //设置条形码的背景色
25
+ fontColor: '#000000', //设置文本的颜色
26
+ lineColor: '#000000', //设置条形码的颜色
27
+ background: '#FFFFFF', //设置条形码的背景色
28
28
  margin: 10, //设置条形码周围的空白边距
29
29
  marginTop: undefined, //设置条形码周围的上边距
30
30
  marginBottom: undefined, //设置条形码周围的下边距
31
31
  marginLeft: undefined, //设置条形码周围的左边距
32
- marginRight: undefined, //设置条形码周围的右边距
33
- }
32
+ marginRight: undefined //设置条形码周围的右边距
33
+ };
34
34
  export default {
35
35
  name: 'cvDrawBarcode',
36
36
  props: {
@@ -57,7 +57,7 @@ export default {
57
57
  opations: {
58
58
  type: Object,
59
59
  default: function () {
60
- return {}
60
+ return {};
61
61
  }
62
62
  },
63
63
  onval: {
@@ -67,7 +67,7 @@ export default {
67
67
  loadMake: {
68
68
  type: Boolean,
69
69
  default: true
70
- },
70
+ }
71
71
  },
72
72
  data() {
73
73
  return {
@@ -75,55 +75,58 @@ export default {
75
75
  canvasWidth: 0,
76
76
  canvasHeight: 0,
77
77
  defaultOpations: Object.assign({}, opations)
78
- }
79
- },
80
- onUnload() {
81
-
78
+ };
82
79
  },
80
+ onUnload() {},
83
81
  methods: {
84
82
  _makeCode() {
85
- let that = this
83
+ let that = this;
86
84
  // 合并参数
87
- Object.assign(this.defaultOpations, this.opations)
88
- if (that.unit == "upx") {
85
+ Object.assign(this.defaultOpations, this.opations);
86
+ if (that.unit == 'upx') {
89
87
  if (that.defaultOpations.width) {
90
- that.defaultOpations.width = uni.upx2px(that.defaultOpations.width)
91
- that.defaultOpations.width = uni.upx2px(that.defaultOpations.width)
88
+ that.defaultOpations.width = uni.upx2px(that.defaultOpations.width);
89
+ that.defaultOpations.width = uni.upx2px(that.defaultOpations.width);
92
90
  }
93
91
  if (that.defaultOpations.height) {
94
- that.defaultOpations.height = uni.upx2px(that.defaultOpations.height)
92
+ that.defaultOpations.height = uni.upx2px(that.defaultOpations.height);
95
93
  }
96
94
  if (that.defaultOpations.fontSize) {
97
- that.defaultOpations.fontSize = uni.upx2px(that.defaultOpations.fontSize)
95
+ that.defaultOpations.fontSize = uni.upx2px(that.defaultOpations.fontSize);
98
96
  }
99
97
  }
100
98
 
101
99
  if (that._empty(that.defaultOpations.text)) {
102
- that.defaultOpations.text = that.val
100
+ that.defaultOpations.text = that.val;
103
101
  }
104
102
  if (that._empty(that.defaultOpations.format)) {
105
- that.defaultOpations.format = that.format
103
+ that.defaultOpations.format = that.format;
106
104
  }
107
105
 
108
- new barCode(that, that.cid, that.defaultOpations,
109
- function (res) { // 生成条形码宽高回调
110
- that.canvasWidth = res.width
111
- that.canvasHeight = res.height
106
+ new barCode(
107
+ that,
108
+ that.cid,
109
+ that.defaultOpations,
110
+ function (res) {
111
+ // 生成条形码宽高回调
112
+ that.canvasWidth = res.width;
113
+ that.canvasHeight = res.height;
112
114
  },
113
- function (res) { // 生成条形码的回调
115
+ function (res) {
116
+ // 生成条形码的回调
114
117
  // 返回值
115
- that._result(res)
118
+ that._result(res);
116
119
  // 重置默认参数
117
- that.defaultOpations = { ...opations }
118
- },
120
+ that.defaultOpations = { ...opations };
121
+ }
119
122
  );
120
123
  },
121
124
  _clearCode() {
122
- this._result('')
125
+ this._result('');
123
126
  },
124
127
  _saveCode() {
125
128
  let that = this;
126
- if (this.result != "") {
129
+ if (this.result != '') {
127
130
  uni.saveImageToPhotosAlbum({
128
131
  filePath: that.result,
129
132
  success: function () {
@@ -138,23 +141,23 @@ export default {
138
141
  },
139
142
  _result(res) {
140
143
  this.result = res;
141
- this.$emit('result', res)
144
+ this.$emit('result', res);
142
145
  },
143
146
  _empty(v) {
144
147
  let tp = typeof v,
145
148
  rt = false;
146
- if (tp == "number" && String(v) == "") {
147
- rt = true
148
- } else if (tp == "undefined") {
149
- rt = true
150
- } else if (tp == "object") {
151
- if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null) rt = true
152
- } else if (tp == "string") {
153
- if (v == "" || v == "undefined" || v == "null" || v == "{}" || v == "[]") rt = true
154
- } else if (tp == "function") {
155
- rt = false
149
+ if (tp == 'number' && String(v) == '') {
150
+ rt = true;
151
+ } else if (tp == 'undefined') {
152
+ rt = true;
153
+ } else if (tp == 'object') {
154
+ if (JSON.stringify(v) == '{}' || JSON.stringify(v) == '[]' || v == null) rt = true;
155
+ } else if (tp == 'string') {
156
+ if (v == '' || v == 'undefined' || v == 'null' || v == '{}' || v == '[]') rt = true;
157
+ } else if (tp == 'function') {
158
+ rt = false;
156
159
  }
157
- return rt
160
+ return rt;
158
161
  }
159
162
  },
160
163
  watch: {
@@ -162,7 +165,7 @@ export default {
162
165
  if (this.onval) {
163
166
  if (n != o && !this._empty(n)) {
164
167
  setTimeout(() => {
165
- this._makeCode()
168
+ this._makeCode();
166
169
  }, 0);
167
170
  }
168
171
  }
@@ -172,7 +175,7 @@ export default {
172
175
  if (this.onval) {
173
176
  if (!this._empty(n)) {
174
177
  setTimeout(() => {
175
- this._makeCode()
178
+ this._makeCode();
176
179
  }, 0);
177
180
  }
178
181
  }
@@ -184,12 +187,12 @@ export default {
184
187
  if (this.loadMake) {
185
188
  if (!this._empty(this.val)) {
186
189
  setTimeout(() => {
187
- this._makeCode()
190
+ this._makeCode();
188
191
  }, 0);
189
192
  }
190
193
  }
191
194
  }
192
- }
195
+ };
193
196
  </script>
194
197
 
195
198
  <style>
@@ -1,6 +1,5 @@
1
1
  <template>
2
- <canvas canvas-id="canvasdrawer" :style="{width: width + 'px', height: height + 'px'}" class="posters-layer">
3
- </canvas>
2
+ <canvas canvas-id="canvasdrawer" :style="{ width: width + 'px', height: height + 'px' }" class="posters-layer"></canvas>
4
3
  </template>
5
4
  <script>
6
5
  const CACHE_KEYS = 'cv_draw_posters_cache';
@@ -30,8 +29,8 @@ export default {
30
29
  tempFileList: [],
31
30
  isPainting: false,
32
31
  ctx: null,
33
- cache: {},
34
- }
32
+ cache: {}
33
+ };
35
34
  },
36
35
  mounted() {
37
36
  uni.removeStorageSync(CACHE_KEYS);
@@ -43,10 +42,10 @@ export default {
43
42
  createPosters(newVal) {
44
43
  if (!newVal.width || !newVal.height) {
45
44
  return;
46
- };
45
+ }
47
46
  // newVal = newVal || { views: [] };
48
47
  newVal.views = newVal.views || [];
49
- uni.removeStorageSync(CACHE_KEYS)
48
+ uni.removeStorageSync(CACHE_KEYS);
50
49
  this.paintingData = newVal;
51
50
  this.ctx && this.ctx.clearActions();
52
51
  if (!this.isPainting) {
@@ -54,8 +53,7 @@ export default {
54
53
  this.isPainting = true;
55
54
  try {
56
55
  this.readyPigment();
57
- }
58
- catch (err) {
56
+ } catch (err) {
59
57
  this.$emit('error');
60
58
  }
61
59
  }
@@ -80,7 +78,7 @@ export default {
80
78
  radius,
81
79
  width,
82
80
  height
83
- })
81
+ });
84
82
  this.getImageList(views);
85
83
  this.downLoadImages(0);
86
84
  }
@@ -100,11 +98,11 @@ export default {
100
98
  const tempFileList = this.tempFileList;
101
99
  if (index < imageList.length) {
102
100
  // console.log(imageList[index])
103
- this.getImageInfo(imageList[index]).then(imgInfo => {
104
- tempFileList.push(imgInfo)
101
+ this.getImageInfo(imageList[index]).then((imgInfo) => {
102
+ tempFileList.push(imgInfo);
105
103
  this.tempFileList = tempFileList;
106
104
  this.downLoadImages(index + 1);
107
- })
105
+ });
108
106
  } else {
109
107
  this.startPainting();
110
108
  }
@@ -144,7 +142,10 @@ export default {
144
142
  return data;
145
143
  },
146
144
  async startPainting() {
147
- const { tempFileList, paintingData: { views } } = this;
145
+ const {
146
+ tempFileList,
147
+ paintingData: { views }
148
+ } = this;
148
149
  for (let i = 0, imageIndex = 0; i < views.length; i++) {
149
150
  if (views[i].type === 'image') {
150
151
  let _img = tempFileList[imageIndex];
@@ -175,36 +176,23 @@ export default {
175
176
  }
176
177
  } else if (views[i].type === 'rect') {
177
178
  this.drawRect(views[i]);
178
- }
179
- else if (views[i].type === 'round') {
179
+ } else if (views[i].type === 'round') {
180
180
  this.drawRound(views[i]);
181
181
  }
182
182
  }
183
183
  this.ctx.draw(true, () => {
184
184
  uni.setStorageSync(CACHE_KEYS, this.cache);
185
185
  this.saveImageToLocal();
186
- })
186
+ });
187
187
  },
188
188
  old_drawImage(params) {
189
189
  // console.log(params)
190
- const {
191
- url,
192
- top = 0,
193
- left = 0,
194
- width = 0,
195
- height = 0,
196
- sx = 0,
197
- sy = 0,
198
- ex = 0,
199
- ey = 0
200
- } = params;
190
+ const { url, top = 0, left = 0, width = 0, height = 0, sx = 0, sy = 0, ex = 0, ey = 0 } = params;
201
191
  if ('tailor' in params) {
202
192
  this.ctx.drawImage(url, sx, sy, ex, ey, left, top, width, height);
203
- }
204
- else if (params.round === true) {
193
+ } else if (params.round === true) {
205
194
  this.drawRoundImage(params);
206
- }
207
- else {
195
+ } else {
208
196
  this.ctx.drawImage(url, left, top, width, height);
209
197
  }
210
198
  },
@@ -227,13 +215,7 @@ export default {
227
215
  ctx.restore();
228
216
  },
229
217
  _drawRadiusRect(params) {
230
- const {
231
- top = 0,
232
- left = 0,
233
- width = 0,
234
- height = 0,
235
- radius = 0,
236
- } = params;
218
+ const { top = 0, left = 0, width = 0, height = 0, radius = 0 } = params;
237
219
  let x = left;
238
220
  let y = top;
239
221
  let w = width;
@@ -242,14 +224,14 @@ export default {
242
224
  let r = radius;
243
225
  // let br = radius;
244
226
  this.ctx.beginPath();
245
- this.ctx.moveTo(x + r, y); // 移动到左上角的点
227
+ this.ctx.moveTo(x + r, y); // 移动到左上角的点
246
228
  this.ctx.lineTo(x + w - r, y);
247
229
  this.ctx.arc(x + w - r, y + r, r, 2 * Math.PI * (3 / 4), 2 * Math.PI * (4 / 4));
248
230
  this.ctx.lineTo(x + w, y + h - r);
249
231
  this.ctx.arc(x + w - r, y + h - r, r, 0, 2 * Math.PI * (1 / 4));
250
232
  this.ctx.lineTo(x + r, y + h);
251
233
  this.ctx.arc(x + r, y + h - r, r, 2 * Math.PI * (1 / 4), 2 * Math.PI * (2 / 4));
252
- this.ctx.lineTo((x), (y + r));
234
+ this.ctx.lineTo(x, y + r);
253
235
  this.ctx.arc(x + r, y + r, r, 2 * Math.PI * (2 / 4), 2 * Math.PI * (3 / 4));
254
236
 
255
237
  // this.ctx.moveTo(x + r, y);
@@ -282,7 +264,6 @@ export default {
282
264
  if (radius) {
283
265
  this.ctx.beginPath();
284
266
 
285
-
286
267
  // if (radius === parseInt(width / 2)) {
287
268
  // console.log('圆');
288
269
  // this.ctx.beginPath();
@@ -300,8 +281,7 @@ export default {
300
281
  }
301
282
  if ('tailor' in params) {
302
283
  this.ctx.drawImage(url, sx, sy, ex, ey, left, top, width, height);
303
- }
304
- else {
284
+ } else {
305
285
  this.ctx.drawImage(url, left, top, width, height);
306
286
  }
307
287
  // this.drawImage(params);
@@ -352,7 +332,7 @@ export default {
352
332
  this.ctx.setFillStyle(color);
353
333
  this.ctx.setFontSize(fontSize);
354
334
  this.ctx.setTextAlign(textAlign);
355
- }
335
+ };
356
336
  _setStyle();
357
337
  if (!breakWord) {
358
338
  this.ctx.fillText(content, left, top);
@@ -419,14 +399,13 @@ export default {
419
399
  },
420
400
  drawRect(params) {
421
401
  // console.log(params)
422
- const { background, top = 0, left = 0, width = 0, height = 0 } = params
402
+ const { background, top = 0, left = 0, width = 0, height = 0 } = params;
423
403
  this.ctx.save();
424
404
  this.ctx.setFillStyle(background);
425
405
  if (params.radius) {
426
406
  this._drawRadiusRect(params);
427
407
  this.ctx.fill();
428
- }
429
- else {
408
+ } else {
430
409
  this.ctx.setFillStyle(background);
431
410
  this.ctx.fillRect(left, top, width, height);
432
411
  }
@@ -443,7 +422,7 @@ export default {
443
422
  if (objExp.test(url)) {
444
423
  uni.getImageInfo({
445
424
  src: url,
446
- complete: res => {
425
+ complete: (res) => {
447
426
  if (res.errMsg === 'getImageInfo:ok') {
448
427
  const img = {
449
428
  url,
@@ -470,35 +449,38 @@ export default {
470
449
  resolve(url);
471
450
  }
472
451
  }
473
- })
452
+ });
474
453
  },
475
454
  saveImageToLocal() {
476
455
  const { width, height } = this;
477
- uni.canvasToTempFilePath({
478
- destWidth: width,
479
- destHeight: height,
480
- canvasId: 'canvasdrawer',
481
- success: res => {
482
- if (res.errMsg === 'canvasToTempFilePath:ok') {
483
- this.isPainting = false;
484
- this.imageList = [];
485
- this.tempFileList = [];
486
- this.$emit('success', {
487
- width,
488
- height,
489
- path: res.tempFilePath
490
- });
456
+ uni.canvasToTempFilePath(
457
+ {
458
+ destWidth: width,
459
+ destHeight: height,
460
+ canvasId: 'canvasdrawer',
461
+ success: (res) => {
462
+ if (res.errMsg === 'canvasToTempFilePath:ok') {
463
+ this.isPainting = false;
464
+ this.imageList = [];
465
+ this.tempFileList = [];
466
+ this.$emit('success', {
467
+ width,
468
+ height,
469
+ path: res.tempFilePath
470
+ });
471
+ }
472
+ },
473
+ fail: (error) => {
474
+ this.$emit('error', error);
491
475
  }
492
- }, fail: (error) => {
493
- this.$emit('error', error);
494
- }
495
- }, this);
476
+ },
477
+ this
478
+ );
496
479
  }
497
-
498
480
  }
499
- }
481
+ };
500
482
  </script>
501
- <style >
483
+ <style>
502
484
  .posters-layer {
503
485
  position: fixed;
504
486
  top: -5000rpx;
@@ -506,4 +488,4 @@ export default {
506
488
  /* top: 0;
507
489
  left: 0; */
508
490
  }
509
- </style>
491
+ </style>
@@ -1,11 +1,11 @@
1
1
  <template>
2
2
  <view class="de-re-frame">
3
- <canvas :canvas-id="canvasId" :style="'height:'+cSize+'px;width:'+cSize+'px;'"></canvas>
4
- <view class="de-re-place" :style="'height:'+cSize+'px;width:'+cSize+'px;'">
3
+ <canvas :canvas-id="canvasId" :style="'height:' + cSize + 'px;width:' + cSize + 'px;'"></canvas>
4
+ <view class="de-re-place" :style="'height:' + cSize + 'px;width:' + cSize + 'px;'">
5
5
  <template v-if="cPlaceContent">
6
- <view class="de-re-progress de-re-progress_1" v-if="cBili<100">
6
+ <view class="de-re-progress de-re-progress_1" v-if="cBili < 100">
7
7
  <view class="de-re-progress_yi">已抢</view>
8
- <view class="de-re-progress_zhi">{{cBili}}%</view>
8
+ <view class="de-re-progress_zhi">{{ cBili }}%</view>
9
9
  </view>
10
10
  <view class="de-re-progress de-re-progress_2" v-else>已抢光</view>
11
11
  </template>
@@ -18,85 +18,90 @@
18
18
 
19
19
  <script>
20
20
  export default {
21
- name: "cvDrawProgress",
21
+ name: 'cvDrawProgress',
22
22
  props: {
23
- canvasId: { //画布的id 同个页面需要多个画布需要定义不同id
23
+ canvasId: {
24
+ //画布的id 同个页面需要多个画布需要定义不同id
24
25
  type: String,
25
- default: 'cv-draw-progress-canvas',
26
+ default: 'cv-draw-progress-canvas'
26
27
  },
27
- cSize: { //圆的大小 单位px 取偶数
28
+ cSize: {
29
+ //圆的大小 单位px 取偶数
28
30
  type: Number,
29
31
  default: 80
30
32
  },
31
- cBackground: { //进度条背景底色
33
+ cBackground: {
34
+ //进度条背景底色
32
35
  type: String,
33
36
  default: '#f4f4f4'
34
37
  },
35
- cColor: { //进度条颜色
38
+ cColor: {
39
+ //进度条颜色
36
40
  type: String,
37
41
  default: '#fe9b25'
38
42
  },
39
- lineWidth: { //进度条线的宽度 注意:因为圆的半径设置为画布大小的一半-2 所以注意进度条线的粗细会不会超过圆的大小
43
+ lineWidth: {
44
+ //进度条线的宽度 注意:因为圆的半径设置为画布大小的一半-2 所以注意进度条线的粗细会不会超过圆的大小
40
45
  type: Number,
41
46
  default: 8
42
47
  },
43
- cBili: { //进度条的占比
48
+ cBili: {
49
+ //进度条的占比
44
50
  type: [Number, String],
45
- validator: function (val) { //验证器
46
- return val >= 0 && val <= 100
51
+ validator: function (val) {
52
+ //验证器
53
+ return val >= 0 && val <= 100;
47
54
  },
48
55
  default: 100
49
56
  },
50
- cPlaceContent: { //是否显示默认提示内容
57
+ cPlaceContent: {
58
+ //是否显示默认提示内容
51
59
  type: Boolean,
52
60
  default: true
53
61
  }
54
62
  },
55
63
  data() {
56
- return {
57
-
58
- }
64
+ return {};
59
65
  },
60
66
  watch: {
61
- cBili(val) { //监听比例数值的改变
67
+ cBili(val) {
68
+ //监听比例数值的改变
62
69
  this.drawProgress();
63
70
  }
64
71
  },
65
72
  created() {
66
73
  this.drawProgress();
67
74
  },
68
- mounted() {
69
-
70
- },
75
+ mounted() {},
71
76
  methods: {
72
77
  drawProgress() {
73
- let yX = this.cSize / 2; //圆心 x坐标
74
- let yY = this.cSize / 2; //圆心 y坐标
75
- let yBanJ = this.cSize / 2 - 4; //圆的半径 减2是因为有线条宽度
78
+ let yX = this.cSize / 2; //圆心 x坐标
79
+ let yY = this.cSize / 2; //圆心 y坐标
80
+ let yBanJ = this.cSize / 2 - 4; //圆的半径 减2是因为有线条宽度
76
81
 
77
- const ctx = uni.createCanvasContext(this.canvasId, this)
82
+ const ctx = uni.createCanvasContext(this.canvasId, this);
78
83
 
79
- ctx.beginPath(); //画背景
80
- ctx.arc(yX, yY, yBanJ, 0.7 * Math.PI, 2.3 * Math.PI);//坐标40,40 半径38
81
- ctx.setStrokeStyle(this.cBackground); //画颜色
84
+ ctx.beginPath(); //画背景
85
+ ctx.arc(yX, yY, yBanJ, 0.7 * Math.PI, 2.3 * Math.PI); //坐标40,40 半径38
86
+ ctx.setStrokeStyle(this.cBackground); //画颜色
82
87
  ctx.setLineWidth(this.lineWidth);
83
- ctx.stroke(); //填充 画弧线
88
+ ctx.stroke(); //填充 画弧线
84
89
 
85
- let value = (this.cBili / 100).toFixed(4)
86
- let bX = 0.70 * Math.PI; //进度条开始的位置 一直都是0.7
87
- let eX = (0.70 + (1.6 * value)) * Math.PI; //进度条结束的位置 100%是2.3
90
+ let value = (this.cBili / 100).toFixed(4);
91
+ let bX = 0.7 * Math.PI; //进度条开始的位置 一直都是0.7
92
+ let eX = (0.7 + 1.6 * value) * Math.PI; //进度条结束的位置 100%是2.3
88
93
  ctx.beginPath();
89
- ctx.arc(yX, yY, yBanJ, bX, eX); //范围是0.7-2.3之间是百分百
94
+ ctx.arc(yX, yY, yBanJ, bX, eX); //范围是0.7-2.3之间是百分百
90
95
  ctx.setStrokeStyle(this.cColor);
91
96
  ctx.stroke();
92
97
 
93
- setTimeout(() => { //必须延迟执行 不然H5不显示
94
- ctx.draw(); //画在画布上
95
- }, 20)
96
-
98
+ setTimeout(() => {
99
+ //必须延迟执行 不然H5不显示
100
+ ctx.draw(); //画在画布上
101
+ }, 20);
97
102
  }
98
103
  }
99
- }
104
+ };
100
105
  </script>
101
106
 
102
107
  <style>