sadais-piui 1.2.7-beta156 → 1.2.7-beta158

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.
@@ -40,7 +40,7 @@
40
40
  'pi-solid-bottom-1': showItemBottomBorder,
41
41
  'pi-disabled': item.disabled
42
42
  }"
43
- class="pi-align-center pi-fz-30 pi-pd-lr-32"
43
+ class="pi-align-center pi-fz-32 pi-pd-lr-32"
44
44
  hover-class="pi-hover-class"
45
45
  @tap.stop="handleSelectItem(item)"
46
46
  >
@@ -56,7 +56,7 @@
56
56
  <template v-if="cancelText">
57
57
  <pi-gap height="20" />
58
58
  <view
59
- class="pi-align-center pi-fz-30 pi-pd-32 pi-light-gray"
59
+ class="pi-align-center pi-fz-32 pi-pd-32 pi-light-gray"
60
60
  hover-class="pi-hover-class"
61
61
  :style="[getItemAlignStyle]"
62
62
  @tap="handleCancel"
@@ -461,17 +461,9 @@ export default {
461
461
  )
462
462
  },
463
463
  getFieldValue(obj, keypath) {
464
- if (obj) {
465
- return keypath.split('-').reduce((prev, key) => {
466
- let tmpKey = key
467
- if (/^\[\d+\]$/.test(key)) {
468
- tmpKey = tmpKey.slice(1, -1)
469
- }
470
- prev = prev && prev[tmpKey]
471
- return prev
472
- }, obj)
473
- }
474
- return undefined
464
+ // 使用工具函数中的 getFieldValue 方法
465
+ // 支持嵌套对象和数组访问,如: a.b.c, items[0].name, users[0].addresses[1].city
466
+ return this.$pi.lang.getFieldValue(obj, keypath)
475
467
  },
476
468
  // 校验数据
477
469
  validation(trigger) {
@@ -145,23 +145,13 @@
145
145
  />
146
146
 
147
147
  <!-- 自定义拍照操作面板(小程序专用) -->
148
- <pi-select
148
+ <pi-action-sheet
149
149
  v-model="showCustomTakePhoto"
150
150
  :items="customTakePhotoItems"
151
- :single-cancel="false"
152
- single-confirm
153
- :item-style="{
154
- padding: '32rpx'
155
- }"
156
151
  :popup="{
157
152
  borderRadius: 0
158
153
  }"
159
- :popup-select="{
160
- showTitle: true,
161
- title: '请选择拍摄方式'
162
- }"
163
- item-height="auto"
164
- @confirm="handleCustomTakePhotoSelect"
154
+ @select="handleCustomTakePhotoSelect"
165
155
  />
166
156
  </view>
167
157
  </template>
@@ -457,8 +447,7 @@ export default {
457
447
  cropPic: '', // 需要剪裁的图片
458
448
  cropedPic: '', // 剪裁后的图片
459
449
  showActionSheet: false, // 是否显示上传视频操作面板
460
- showCustomTakePhoto: false, // 是否显示自定义拍照操作面板
461
- currentSourceType: ['camera', 'album'] // 当前选择的拍照方式
450
+ showCustomTakePhoto: false // 是否显示自定义拍照操作面板
462
451
  }
463
452
  },
464
453
  computed: {
@@ -487,8 +476,16 @@ export default {
487
476
  }
488
477
  ]
489
478
  },
479
+ currentSourceType() {
480
+ if (this.type === 'video') {
481
+ return this.getChooseVideoOpts.sourceType
482
+ }
483
+ if (this.type === 'image') {
484
+ return this.getChooseImageOpts.sourceType
485
+ }
486
+ return this.getChooseFileOpts.sourceType
487
+ },
490
488
  customTakePhotoItems() {
491
- // currentSourceType 当前选择的拍照方式 ['camera', 'album']
492
489
  let sourceType = this.currentSourceType || ['camera', 'album']
493
490
  if (sourceType.length === 0) {
494
491
  sourceType = ['camera', 'album']
@@ -497,12 +494,16 @@ export default {
497
494
  {
498
495
  id: 'takePhoto',
499
496
  text: '拍照',
500
- show: sourceType.includes('camera')
497
+ show:
498
+ sourceType.includes('camera') &&
499
+ ['all', 'image'].includes(this.type)
501
500
  },
502
501
  {
503
502
  id: 'takeVideo',
504
503
  text: '录像',
505
- show: sourceType.includes('camera')
504
+ show:
505
+ sourceType.includes('camera') &&
506
+ ['all', 'video'].includes(this.type)
506
507
  },
507
508
  // {
508
509
  // id: 'takePhotoOffline',
@@ -511,9 +512,16 @@ export default {
511
512
  // show: sourceType.includes('camera')
512
513
  // },
513
514
  {
514
- id: 'chooseFromAlbum',
515
- text: '从手机相册选择',
516
- show: sourceType.includes('album')
515
+ id: 'chooseImageFromAlbum',
516
+ text: '从手机相册选择图片',
517
+ show:
518
+ sourceType.includes('album') && ['all', 'image'].includes(this.type)
519
+ },
520
+ {
521
+ id: 'chooseVideoFromAlbum',
522
+ text: '从手机相册选择视频',
523
+ show:
524
+ sourceType.includes('album') && ['all', 'video'].includes(this.type)
517
525
  }
518
526
  // {
519
527
  // id: 'chooseFromCacheAlbum',
@@ -910,12 +918,20 @@ export default {
910
918
  this.$emit('show-actions')
911
919
  this.showActionSheet = true
912
920
  } else {
921
+ if (this.customTakePhoto) {
922
+ this.handleOpenCustomTakePhoto()
923
+ return
924
+ }
913
925
  this.handleChooseMedia()
914
926
  }
915
927
  // #endif
916
928
 
917
929
  return
918
930
  }
931
+ if (this.customTakePhoto) {
932
+ this.handleOpenCustomTakePhoto()
933
+ return
934
+ }
919
935
  if (this.type === 'image') {
920
936
  this.handleChooseImage()
921
937
  return
@@ -932,6 +948,13 @@ export default {
932
948
  return
933
949
  }
934
950
  },
951
+ handleOpenCustomTakePhoto() {
952
+ if (this.customTakePhotoItems.length === 1) {
953
+ this.handleCustomTakePhotoSelect(this.customTakePhotoItems[0])
954
+ return
955
+ }
956
+ this.showCustomTakePhoto = true
957
+ },
935
958
  async handleChooseFile() {
936
959
  const { sizeType, sourceType, crop } = this.getChooseFileOpts
937
960
  try {
@@ -1010,13 +1033,6 @@ export default {
1010
1033
  async handleChooseImage() {
1011
1034
  const { sizeType, sourceType, crop } = this.getChooseImageOpts
1012
1035
 
1013
- this.currentSourceType = sourceType
1014
-
1015
- if (this.customTakePhoto) {
1016
- this.showCustomTakePhoto = true
1017
- return
1018
- }
1019
-
1020
1036
  this.handleUniChooseImage(sizeType, sourceType, crop)
1021
1037
  },
1022
1038
  async handleUniChooseImage(sizeType, sourceType, crop) {
@@ -1075,14 +1091,11 @@ export default {
1075
1091
  }
1076
1092
  },
1077
1093
  async handleChooseVideo() {
1078
- const { sourceType, maxDuration, camera } = this.getChooseVideoOpts
1079
-
1080
- this.currentSourceType = sourceType
1081
-
1082
- if (this.customTakePhoto) {
1083
- this.showCustomTakePhoto = true
1084
- return
1085
- }
1094
+ const { sourceType } = this.getChooseVideoOpts
1095
+ this.handleUniChooseVideo(sourceType)
1096
+ },
1097
+ async handleUniChooseVideo(sourceType) {
1098
+ const { maxDuration, camera } = this.getChooseVideoOpts
1086
1099
 
1087
1100
  try {
1088
1101
  const [cancel, result] = await uni.chooseVideo({
@@ -1114,20 +1127,22 @@ export default {
1114
1127
  }
1115
1128
  },
1116
1129
  async handleChooseMedia() {
1117
- const { sourceType, maxDuration, camera } =
1130
+ const { sourceType } =
1118
1131
  this.type === 'video' ? this.getChooseVideoOpts : this.getChooseFileOpts
1119
1132
 
1120
- this.currentSourceType = sourceType
1121
-
1122
- if (this.customTakePhoto) {
1123
- this.showCustomTakePhoto = true
1124
- return
1125
- }
1133
+ this.handleUniChooseMedia(
1134
+ this.type === 'video' ? ['video'] : ['mix'],
1135
+ sourceType
1136
+ )
1137
+ },
1138
+ async handleUniChooseMedia(mediaType, sourceType) {
1139
+ const { maxDuration, camera } =
1140
+ this.type === 'video' ? this.getChooseVideoOpts : this.getChooseFileOpts
1126
1141
 
1127
1142
  try {
1128
1143
  const [cancel, result] = await uni.chooseMedia({
1129
1144
  count: this.getUploadMaxCount,
1130
- mediaType: this.type === 'video' ? ['video'] : ['mix'],
1145
+ mediaType,
1131
1146
  extension: this.getExtension,
1132
1147
  sourceType,
1133
1148
  maxDuration,
@@ -1216,10 +1231,30 @@ export default {
1216
1231
  })
1217
1232
  },
1218
1233
  handleCustomTakePhotoSelect(type) {
1219
- if (type.id === 'chooseFromAlbum') {
1234
+ if (type.id === 'takeVideo') {
1235
+ // #ifndef MP-WEIXIN
1236
+ this.handleUniChooseVideo(['camera'])
1237
+ // #endif
1238
+
1239
+ // #ifdef MP-WEIXIN
1240
+ this.handleUniChooseMedia(['video'], ['camera'])
1241
+ // #endif
1242
+ return
1243
+ }
1244
+ if (type.id === 'chooseImageFromAlbum') {
1220
1245
  // 从手机相册选择
1221
1246
  const { sizeType, crop } = this.getChooseImageOpts
1222
1247
  this.handleUniChooseImage(sizeType, ['album'], crop)
1248
+ return
1249
+ } else if (type.id === 'chooseVideoFromAlbum') {
1250
+ // #ifndef MP-WEIXIN
1251
+ this.handleUniChooseVideo(['album'])
1252
+ // #endif
1253
+
1254
+ // #ifdef MP-WEIXIN
1255
+ this.handleUniChooseMedia(['video'], ['album'])
1256
+ // #endif
1257
+ return
1223
1258
  } else {
1224
1259
  this.handleEmitTakePhoto(type.id)
1225
1260
  }
@@ -6,7 +6,7 @@ export default {
6
6
  items: [], // 选项列表,默认([])
7
7
  keyField: 'id', // 选项id字段,默认为id
8
8
  displayField: 'text', // 选项显示字段,默认为text
9
- itemHeight: 110, // 行高(默认:'110rpx')
9
+ itemHeight: 120, // 行高(默认:'120rpx')
10
10
  itemStyle: {}, // 行样式(默认:{})
11
11
  itemAlign: 'center', // 行对齐方式,默认值:'center'
12
12
  showItemBottomBorder: true, // 是否显示底部边线
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta156",
3
+ "version": "1.2.7-beta158",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {