zartui 2.0.83 → 2.0.85

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.
@@ -7,6 +7,7 @@ var _createNamespace = createNamespace('back-top'),
7
7
  import scrollTo from '../utils/scrollTo';
8
8
  import getScroll from '../utils/getScroll';
9
9
  import { preventDefault } from '../utils/dom/event';
10
+ import TopImage from './images/top.png';
10
11
  export default createComponent({
11
12
  props: {
12
13
  disableMove: {
@@ -199,7 +200,7 @@ export default createComponent({
199
200
  "style": this.blurStyle
200
201
  }, [h("img", {
201
202
  "attrs": {
202
- "src": require('./images/top.png')
203
+ "src": TopImage
203
204
  }
204
205
  })]);
205
206
  }
package/es/index.js CHANGED
@@ -75,7 +75,7 @@ import TextEllipsis from './text-ellipsis';
75
75
  import Timeline from './timeline';
76
76
  import Toast from './toast';
77
77
  import Uploader from './uploader';
78
- var version = '2.0.83';
78
+ var version = '2.0.85';
79
79
 
80
80
  function install(Vue) {
81
81
  var components = [ActionSheet, Area, Avatar, BackTop, Badge, Button, Calendar, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, FoldDialog, Form, Grid, GridItem, HierarchySelect, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, Lazyload, List, Loading, Locale, MediaPicker, MediaPlayer, MultiplePicker, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, Picker, Popover, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Table, Tabs, Tag, TextEllipsis, Timeline, Toast, Uploader];
@@ -30,7 +30,9 @@ import DefaultPdfIcon from "./image/DefaultPdfIcon";
30
30
  import DefaultPptIcon from "./image/DefaultPptIcon";
31
31
  import DefaultTextIcon from "./image/DefaultTextIcon";
32
32
  import { FRAME_CONTAINER, CERTIFICATE_BACKGROUND, CERTIFICATE_BUTTON } from './image/Img64';
33
- import { getFileUniqueCode, getUniqueFileName, isAudioType, isImageType, isVideoType, isPdfType, isDocType, isTextType, isPptType, isExcelType } from "./media-util"; // 单个文件最大限制,单位为M(目前限制是100M)
33
+ import { getFileUniqueCode, getUniqueFileName, isAudioType, isImageType, isVideoType, isPdfType, isDocType, isTextType, isPptType, isExcelType } from "./media-util";
34
+ import { isWeixin } from '../utils/device';
35
+ import { wxUploadImage } from './wx-util'; // 单个文件最大限制,单位为M(目前限制是100M)
34
36
 
35
37
  var FILE_SIZE_LIMIT = 100;
36
38
 
@@ -161,6 +163,10 @@ export default createComponent({
161
163
  reUploadText: {
162
164
  type: String,
163
165
  default: '重新拍摄'
166
+ },
167
+ useWx: {
168
+ type: Boolean,
169
+ default: false
164
170
  }
165
171
  },
166
172
  model: {
@@ -214,6 +220,8 @@ export default createComponent({
214
220
  },
215
221
  methods: {
216
222
  mediaPick: function mediaPick(mediaType, mediaAddType) {
223
+ var _this2 = this;
224
+
217
225
  if (this.disabled) {
218
226
  return;
219
227
  }
@@ -236,10 +244,17 @@ export default createComponent({
236
244
  fileInput = _this$$refs.fileInput;
237
245
 
238
246
  if (mediaType === MediaType.PHOTO) {
239
- if (mediaAddType === MediaAddType.TAKE) {
240
- this.triggerHiddenInput(cameraInput);
241
- } else if (mediaAddType === MediaAddType.PICK) {
242
- this.triggerHiddenInput(imageInput);
247
+ if (this.useWx && isWeixin() && window.wx) {
248
+ var type = mediaAddType === MediaAddType.TAKE ? 'camera' : 'album';
249
+ wxUploadImage(type).then(function (newMedias) {
250
+ _this2.$emit('input', [].concat(_this2.mediaList, newMedias));
251
+ });
252
+ } else {
253
+ if (mediaAddType === MediaAddType.TAKE) {
254
+ this.triggerHiddenInput(cameraInput);
255
+ } else if (mediaAddType === MediaAddType.PICK) {
256
+ this.triggerHiddenInput(imageInput);
257
+ }
243
258
  }
244
259
  } else if (mediaType === MediaType.VIDEO) {
245
260
  if (mediaAddType === MediaAddType.TAKE) {
@@ -309,7 +324,7 @@ export default createComponent({
309
324
  }
310
325
  },
311
326
  handleInputFiles: function handleInputFiles(event) {
312
- var _this2 = this;
327
+ var _this3 = this;
313
328
 
314
329
  var files = event.target.files;
315
330
 
@@ -341,9 +356,9 @@ export default createComponent({
341
356
  if (isPromise(response)) {
342
357
  response.then(function (data) {
343
358
  if (data) {
344
- _this2.readFiles(data);
359
+ _this3.readFiles(data);
345
360
  } else {
346
- _this2.readFiles(files);
361
+ _this3.readFiles(files);
347
362
  }
348
363
  });
349
364
  return;
@@ -353,13 +368,13 @@ export default createComponent({
353
368
  this.readFiles(files);
354
369
  },
355
370
  readFiles: function readFiles(files) {
356
- var _this3 = this;
371
+ var _this4 = this;
357
372
 
358
373
  // 处理非图片
359
374
  var notImages = files.filter(function (f) {
360
375
  return !isImageType(f);
361
376
  }).map(function (f) {
362
- return _this3.transformNotImageFile(f);
377
+ return _this4.transformNotImageFile(f);
363
378
  });
364
379
  var newMedias = [];
365
380
 
@@ -384,14 +399,14 @@ export default createComponent({
384
399
  newMedias = newMedias.concat(medias);
385
400
  }
386
401
  }).finally(function () {
387
- if (_this3.pickerMode === "certificate") {
388
- _this3.$emit('input', [].concat(newMedias));
402
+ if (_this4.pickerMode === "certificate") {
403
+ _this4.$emit('input', [].concat(newMedias));
389
404
  } else {
390
- _this3.$emit('input', [].concat(_this3.mediaList, newMedias));
405
+ _this4.$emit('input', [].concat(_this4.mediaList, newMedias));
391
406
  }
392
407
 
393
- if (_this3.afterRead) {
394
- _this3.afterRead(newMedias);
408
+ if (_this4.afterRead) {
409
+ _this4.afterRead(newMedias);
395
410
  }
396
411
  });
397
412
  },
@@ -495,7 +510,7 @@ export default createComponent({
495
510
  * @return {Promise<[Media]>}
496
511
  */
497
512
  transformImageFiles: function transformImageFiles(files) {
498
- var _this4 = this;
513
+ var _this5 = this;
499
514
 
500
515
  var promisesTodo = [];
501
516
  var resizeOptions = new ResizeOptions(this.maxImageSideLength);
@@ -503,19 +518,19 @@ export default createComponent({
503
518
 
504
519
  var _loop = function _loop(i) {
505
520
  var file = files[i];
506
- var watermarkEnabled = _this4.watermarkOptions && _this4.watermarkOptions.watermarkConfigString && checkWatermarkConfigSupported(_this4.watermarkOptions.watermarkConfigString);
521
+ var watermarkEnabled = _this5.watermarkOptions && _this5.watermarkOptions.watermarkConfigString && checkWatermarkConfigSupported(_this5.watermarkOptions.watermarkConfigString);
507
522
  var watermarkOpt = void 0;
508
523
 
509
524
  if (watermarkEnabled) {
510
525
  watermarkOpt = new WatermarkOptions({
511
526
  enabled: true,
512
- watermarkConfigString: watermarkEnabled ? _this4.watermarkOptions.watermarkConfigString : '',
527
+ watermarkConfigString: watermarkEnabled ? _this5.watermarkOptions.watermarkConfigString : '',
513
528
  context: {
514
- address: _this4.watermarkOptions.address || "",
515
- humanName: _this4.watermarkOptions.humanName || _this4.watermarkOptions.humanname || "",
516
- projectName: _this4.watermarkOptions.projectName || "",
517
- logo: _this4.watermarkOptions.logo || "",
518
- applicationName: _this4.watermarkOptions.applicationName || "",
529
+ address: _this5.watermarkOptions.address || "",
530
+ humanName: _this5.watermarkOptions.humanName || _this5.watermarkOptions.humanname || "",
531
+ projectName: _this5.watermarkOptions.projectName || "",
532
+ logo: _this5.watermarkOptions.logo || "",
533
+ applicationName: _this5.watermarkOptions.applicationName || "",
519
534
  watermarkTime: new Date()
520
535
  }
521
536
  });
@@ -666,7 +681,7 @@ export default createComponent({
666
681
  }
667
682
  },
668
683
  onDelete: function onDelete(media, index) {
669
- var _this5 = this;
684
+ var _this6 = this;
670
685
 
671
686
  if (this.beforeDelete) {
672
687
  var response = this.beforeDelete(media);
@@ -677,7 +692,7 @@ export default createComponent({
677
692
 
678
693
  if (isPromise(response)) {
679
694
  response.then(function () {
680
- _this5.deleteMedia(media, index);
695
+ _this6.deleteMedia(media, index);
681
696
  });
682
697
  return;
683
698
  }
@@ -692,7 +707,7 @@ export default createComponent({
692
707
  this.$emit('delete', media, index);
693
708
  },
694
709
  hiddenInput: function hiddenInput() {
695
- var _this6 = this;
710
+ var _this7 = this;
696
711
 
697
712
  var h = this.$createElement;
698
713
  return [h("input", {
@@ -706,7 +721,7 @@ export default createComponent({
706
721
  "on": {
707
722
  "change": this.handleInputFiles,
708
723
  "click": function click() {
709
- return _this6.resetInput(MediaType.PHOTO, MediaAddType.TAKE);
724
+ return _this7.resetInput(MediaType.PHOTO, MediaAddType.TAKE);
710
725
  }
711
726
  },
712
727
  "class": bem('hidden')
@@ -720,7 +735,7 @@ export default createComponent({
720
735
  "on": {
721
736
  "change": this.handleInputFiles,
722
737
  "click": function click() {
723
- return _this6.resetInput(MediaType.PHOTO, MediaAddType.PICK);
738
+ return _this7.resetInput(MediaType.PHOTO, MediaAddType.PICK);
724
739
  }
725
740
  },
726
741
  "class": bem('hidden')
@@ -734,7 +749,7 @@ export default createComponent({
734
749
  "on": {
735
750
  "change": this.handleInputFiles,
736
751
  "click": function click() {
737
- return _this6.resetInput(MediaType.VIDEO, MediaAddType.TAKE);
752
+ return _this7.resetInput(MediaType.VIDEO, MediaAddType.TAKE);
738
753
  }
739
754
  },
740
755
  "class": bem('hidden')
@@ -747,7 +762,7 @@ export default createComponent({
747
762
  "on": {
748
763
  "change": this.handleInputFiles,
749
764
  "click": function click() {
750
- return _this6.resetInput(MediaType.VIDEO, MediaAddType.PICK);
765
+ return _this7.resetInput(MediaType.VIDEO, MediaAddType.PICK);
751
766
  }
752
767
  },
753
768
  "class": bem('hidden')
@@ -761,7 +776,7 @@ export default createComponent({
761
776
  "on": {
762
777
  "change": this.handleInputFiles,
763
778
  "click": function click() {
764
- return _this6.resetInput(MediaType.AUDIO, MediaAddType.TAKE);
779
+ return _this7.resetInput(MediaType.AUDIO, MediaAddType.TAKE);
765
780
  }
766
781
  },
767
782
  "class": bem('hidden')
@@ -774,7 +789,7 @@ export default createComponent({
774
789
  "on": {
775
790
  "change": this.handleInputFiles,
776
791
  "click": function click() {
777
- return _this6.resetInput(MediaType.AUDIO, MediaAddType.PICK);
792
+ return _this7.resetInput(MediaType.AUDIO, MediaAddType.PICK);
778
793
  }
779
794
  },
780
795
  "class": bem('hidden')
@@ -787,14 +802,14 @@ export default createComponent({
787
802
  "on": {
788
803
  "change": this.handleInputFiles,
789
804
  "click": function click() {
790
- return _this6.resetInput(MediaType.FILE, MediaAddType.PICK);
805
+ return _this7.resetInput(MediaType.FILE, MediaAddType.PICK);
791
806
  }
792
807
  },
793
808
  "class": bem('hidden')
794
809
  })];
795
810
  },
796
811
  renderIcon: function renderIcon(mediaType, mediaAddType) {
797
- var _this7 = this;
812
+ var _this8 = this;
798
813
 
799
814
  var h = this.$createElement;
800
815
 
@@ -804,7 +819,7 @@ export default createComponent({
804
819
  "class": bem('button'),
805
820
  "on": {
806
821
  "click": function click() {
807
- return _this7.mediaPick(mediaType, mediaAddType);
822
+ return _this8.mediaPick(mediaType, mediaAddType);
808
823
  }
809
824
  }
810
825
  });
@@ -813,7 +828,7 @@ export default createComponent({
813
828
  "class": bem('button'),
814
829
  "on": {
815
830
  "click": function click() {
816
- return _this7.mediaPick(mediaType, mediaAddType);
831
+ return _this8.mediaPick(mediaType, mediaAddType);
817
832
  }
818
833
  }
819
834
  });
@@ -823,7 +838,7 @@ export default createComponent({
823
838
  "class": bem('button'),
824
839
  "on": {
825
840
  "click": function click() {
826
- return _this7.mediaPick(mediaType, mediaAddType);
841
+ return _this8.mediaPick(mediaType, mediaAddType);
827
842
  }
828
843
  }
829
844
  });
@@ -832,7 +847,7 @@ export default createComponent({
832
847
  "class": bem('button'),
833
848
  "on": {
834
849
  "click": function click() {
835
- return _this7.mediaPick(mediaType, mediaAddType);
850
+ return _this8.mediaPick(mediaType, mediaAddType);
836
851
  }
837
852
  }
838
853
  });
@@ -841,7 +856,7 @@ export default createComponent({
841
856
  "class": bem('button'),
842
857
  "on": {
843
858
  "click": function click() {
844
- return _this7.mediaPick(mediaType, mediaAddType);
859
+ return _this8.mediaPick(mediaType, mediaAddType);
845
860
  }
846
861
  }
847
862
  });
@@ -872,7 +887,7 @@ export default createComponent({
872
887
  }, [label])]);
873
888
  },
874
889
  renderCertificates: function renderCertificates() {
875
- var _this8 = this;
890
+ var _this9 = this;
876
891
 
877
892
  var h = this.$createElement;
878
893
 
@@ -885,9 +900,9 @@ export default createComponent({
885
900
  "click": function click(event) {
886
901
  event.stopPropagation();
887
902
 
888
- _this8.onDelete(media, 0);
903
+ _this9.onDelete(media, 0);
889
904
 
890
- _this8.mediaPick(MediaType.PHOTO, MediaAddType.PICK);
905
+ _this9.mediaPick(MediaType.PHOTO, MediaAddType.PICK);
891
906
  }
892
907
  }
893
908
  }, [h(ReUploadIcon, {
@@ -905,7 +920,7 @@ export default createComponent({
905
920
  "click": function click(event) {
906
921
  event.stopPropagation(); // 证件照模式只有一张图片
907
922
 
908
- _this8.previewMedia(media, 0);
923
+ _this9.previewMedia(media, 0);
909
924
  }
910
925
  }
911
926
  }, [reUpload]);
@@ -922,7 +937,7 @@ export default createComponent({
922
937
  },
923
938
  "on": {
924
939
  "click": function click() {
925
- _this8.mediaPick(MediaType.PHOTO, MediaAddType.PICK);
940
+ _this9.mediaPick(MediaType.PHOTO, MediaAddType.PICK);
926
941
  }
927
942
  }
928
943
  }), h("span", {
@@ -1056,7 +1071,7 @@ export default createComponent({
1056
1071
  }
1057
1072
  },
1058
1073
  renderMediaList: function renderMediaList() {
1059
- var _this9 = this;
1074
+ var _this10 = this;
1060
1075
 
1061
1076
  var h = this.$createElement;
1062
1077
  return this.mediaList.map(function (media, index) {
@@ -1067,7 +1082,7 @@ export default createComponent({
1067
1082
  "click": function click(event) {
1068
1083
  event.stopPropagation();
1069
1084
 
1070
- _this9.onDelete(media, index);
1085
+ _this10.onDelete(media, index);
1071
1086
  }
1072
1087
  }
1073
1088
  });
@@ -1077,10 +1092,10 @@ export default createComponent({
1077
1092
  "click": function click(event) {
1078
1093
  event.stopPropagation();
1079
1094
 
1080
- _this9.previewMedia(media, index);
1095
+ _this10.previewMedia(media, index);
1081
1096
  }
1082
1097
  }
1083
- }, [_this9.renderMediaBox(media), _this9.genThumbnailMask(media), deleteIcon]);
1098
+ }, [_this10.renderMediaBox(media), _this10.genThumbnailMask(media), deleteIcon]);
1084
1099
  });
1085
1100
  },
1086
1101
  selectAction: function selectAction(action) {
@@ -1089,7 +1104,7 @@ export default createComponent({
1089
1104
  }
1090
1105
  },
1091
1106
  render: function render() {
1092
- var _this10 = this;
1107
+ var _this11 = this;
1093
1108
 
1094
1109
  var h = arguments[0];
1095
1110
  var title = this.showTitle && h("div", {
@@ -1103,9 +1118,9 @@ export default createComponent({
1103
1118
  "mediaUrl": this.mediaUrlToPlay
1104
1119
  },
1105
1120
  "model": {
1106
- value: _this10.mediaPlayerVisible,
1121
+ value: _this11.mediaPlayerVisible,
1107
1122
  callback: function callback($$v) {
1108
- _this10.mediaPlayerVisible = $$v;
1123
+ _this11.mediaPlayerVisible = $$v;
1109
1124
  }
1110
1125
  }
1111
1126
  }), h(ZtActionSheet, {
@@ -1119,9 +1134,9 @@ export default createComponent({
1119
1134
  "select": this.selectAction
1120
1135
  },
1121
1136
  "model": {
1122
- value: _this10.actionVisible,
1137
+ value: _this11.actionVisible,
1123
1138
  callback: function callback($$v) {
1124
- _this10.actionVisible = $$v;
1139
+ _this11.actionVisible = $$v;
1125
1140
  }
1126
1141
  }
1127
1142
  }), this.pickerMode === "certificate" ? h("div", {
@@ -0,0 +1,64 @@
1
+ import { MediaType, MediaUploadStatus } from './type';
2
+ export var chooseImage = function chooseImage(type) {
3
+ return new Promise(function (resolve, reject) {
4
+ window.wx.chooseImage({
5
+ count: 1,
6
+ sizeType: ['original', 'compressed'],
7
+ // 可以指定是原图还是压缩图,默认二者都有
8
+ sourceType: [type],
9
+ // 可以指定来源是相册还是相机,默认二者都有
10
+ success: function success(_ref) {
11
+ var localIds = _ref.localIds;
12
+ resolve(localIds);
13
+ },
14
+ fail: function fail(res) {
15
+ reject(res);
16
+ }
17
+ });
18
+ });
19
+ };
20
+ export var uploadImage = function uploadImage(localId) {
21
+ return new Promise(function (resolve, reject) {
22
+ window.wx.uploadImage({
23
+ localId: localId,
24
+ // 需要上传的图片的本地ID,由chooseImage接口获得
25
+ isShowProgressTips: 1,
26
+ // 默认为1,显示进度提示
27
+ success: function success(_ref2) {
28
+ var serverId = _ref2.serverId;
29
+ resolve(serverId);
30
+ },
31
+ fail: function fail(res) {
32
+ reject(res);
33
+ }
34
+ });
35
+ });
36
+ };
37
+ export var wxUploadImage = function wxUploadImage(type) {
38
+ return new Promise(function (resolve) {
39
+ var newMedias = [];
40
+ chooseImage(type).then(function (localIds) {
41
+ var time = new Date().getTime().toString();
42
+ var media = {
43
+ type: MediaType.PHOTO,
44
+ uniqueCode: time,
45
+ fileSize: 0,
46
+ lastModified: 0,
47
+ deletable: true,
48
+ status: MediaUploadStatus.DONE
49
+ };
50
+ localIds.forEach(function (localId) {
51
+ media.showSrc = localId;
52
+ media.url = localId;
53
+ uploadImage(localId).then(function (serverId) {
54
+ media.wxServerId = serverId;
55
+ newMedias.push(media);
56
+
57
+ if (newMedias.length === localIds.length) {
58
+ resolve(newMedias);
59
+ }
60
+ });
61
+ });
62
+ });
63
+ });
64
+ };
@@ -13,6 +13,8 @@ var _getScroll = _interopRequireDefault(require("../utils/getScroll"));
13
13
 
14
14
  var _event = require("../utils/dom/event");
15
15
 
16
+ var _top = _interopRequireDefault(require("./images/top.png"));
17
+
16
18
  var _createNamespace = (0, _utils.createNamespace)('back-top'),
17
19
  createComponent = _createNamespace[0],
18
20
  bem = _createNamespace[1];
@@ -209,7 +211,7 @@ var _default2 = createComponent({
209
211
  "style": this.blurStyle
210
212
  }, [h("img", {
211
213
  "attrs": {
212
- "src": require('./images/top.png')
214
+ "src": _top.default
213
215
  }
214
216
  })]);
215
217
  }
package/lib/index.js CHANGED
@@ -313,7 +313,7 @@ exports.Toast = _toast.default;
313
313
  var _uploader = _interopRequireDefault(require("./uploader"));
314
314
 
315
315
  exports.Uploader = _uploader.default;
316
- var version = '2.0.83';
316
+ var version = '2.0.85';
317
317
  exports.version = version;
318
318
 
319
319
  function install(Vue) {