sadais-piui 1.2.7-beta103 → 1.2.7-beta104

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,7 +1,7 @@
1
1
  <!--
2
2
  * @Author: zhangzhenfei
3
3
  * @Date: 2021-08-13 11:31:57
4
- * @LastEditTime: 2024-05-20 12:18:03
4
+ * @LastEditTime: 2024-05-24 15:19:19
5
5
  * @LastEditors: zhangzhenfei
6
6
  * @Description: 图片上传组件
7
7
  * @FilePath: /piui-awesome/src/piui/components/pi-upload-img/index.vue
@@ -37,7 +37,11 @@
37
37
  >
38
38
  <view class="file-mask">
39
39
  <pi-icon
40
- :name="type === 'video' ? 'videofill' : 'activity-fill'"
40
+ :name="
41
+ isVideoFilename(imgField ? img[imgField] : img)
42
+ ? 'videofill'
43
+ : 'activity-fill'
44
+ "
41
45
  size="48"
42
46
  color="#0C6DF4"
43
47
  />
@@ -445,20 +449,26 @@ export default {
445
449
  uploadImg.chooseImageOpts,
446
450
  this.chooseImageOpts,
447
451
  {
448
- arrayMerge: (target, source) => source
452
+ arrayMerge: (_target, source) => source
449
453
  }
450
454
  )
451
455
  },
452
456
  getChooseFileOpts() {
453
457
  return this.$pi.lang.mergeDeep(
454
458
  uploadImg.chooseFileOpts,
455
- this.chooseFileOpts
459
+ this.chooseFileOpts,
460
+ {
461
+ arrayMerge: (_target, source) => source
462
+ }
456
463
  )
457
464
  },
458
465
  getChooseVideoOpts() {
459
466
  return this.$pi.lang.mergeDeep(
460
467
  uploadImg.chooseVideoOpts,
461
- this.chooseVideoOpts
468
+ this.chooseVideoOpts,
469
+ {
470
+ arrayMerge: (_target, source) => source
471
+ }
462
472
  )
463
473
  },
464
474
  getUploadMaxCount() {
@@ -474,6 +484,7 @@ export default {
474
484
  },
475
485
  methods: {
476
486
  isImageFilename,
487
+ isVideoFilename,
477
488
  getFileType(file) {
478
489
  if (!file) return ''
479
490
  const ext = file.split('.').pop()
@@ -678,7 +689,12 @@ export default {
678
689
  // #endif
679
690
 
680
691
  // #ifdef MP-WEIXIN
681
- this.showActionSheet = true
692
+ const { fromWxMessage } = this.getChooseFileOpts
693
+ if (fromWxMessage) {
694
+ this.showActionSheet = true
695
+ } else {
696
+ this.handleChooseMedia()
697
+ }
682
698
  // #endif
683
699
 
684
700
  return
@@ -809,12 +825,13 @@ export default {
809
825
  }
810
826
  },
811
827
  async handleChooseMedia() {
812
- const { sourceType, maxDuration, camera } =
828
+ const { sourceType, extension, maxDuration, camera } =
813
829
  this.type === 'video' ? this.getChooseVideoOpts : this.getChooseFileOpts
814
830
  try {
815
831
  const [, result] = await uni.chooseMedia({
816
832
  count: this.getUploadMaxCount,
817
- mediaType: this.type === 'video' ? ['video'] : ['video', 'image'],
833
+ mediaType: this.type === 'video' ? ['video'] : ['mix'],
834
+ extension,
818
835
  sourceType,
819
836
  maxDuration,
820
837
  camera
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: zhangzhenfei
3
3
  * @Date: 2021-08-13 11:29:02
4
- * @LastEditTime: 2024-05-20 12:11:59
4
+ * @LastEditTime: 2024-05-24 15:18:10
5
5
  * @LastEditors: zhangzhenfei
6
6
  * @Description: 图片上传
7
7
  * @FilePath: /piui-awesome/src/piui/config/uploadImg.js
@@ -43,20 +43,21 @@ export default {
43
43
  type: 'image', // 上传文件类型,可选值为image、video、all
44
44
  // 当type为 "all"时生效,调用uni.chooseFile参数
45
45
  chooseFileOpts: {
46
- sourceType: [], // (仅在type为image或video时可用)album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
46
+ sourceType: ['album', 'camera'], // (仅在type为image或video时可用)album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
47
47
  extension: [], // 允许上传的文件类型,不填则不限制
48
48
  maxDuration: 60, // 拍摄视频最长拍摄时间,单位秒,默认60
49
- camera: 'back' // 前置或后置摄像头,默认back
49
+ camera: 'back', // 前置或后置摄像头,默认back
50
+ fromWxMessage: true // 是否来自微信消息
50
51
  },
51
52
  // 当type为 "image"时生效,调用uni.chooseImage参数
52
53
  chooseImageOpts: {
53
- sourceType: [], // album 从相册选图,camera 使用相机,默认album
54
+ sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认album
54
55
  sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认compressed
55
56
  crop: {} // 图像裁剪参数,设置后 sizeType 失效
56
57
  },
57
58
  // 当type为 "video"时生效,调用uniapp.chooseVideo参数
58
59
  chooseVideoOpts: {
59
- sourceType: [], // album 从相册选视频,camera 使用相机拍摄,默认二者都有
60
+ sourceType: ['album', 'camera'], // album 从相册选视频,camera 使用相机拍摄,默认二者都有
60
61
  compressed: true, // 是否压缩视频,默认true
61
62
  maxDuration: 60, // 拍摄视频最长拍摄时间,单位秒,默认60
62
63
  camera: 'back', // 前置或后置摄像头,默认back
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta103",
3
+ "version": "1.2.7-beta104",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {