@10yun/cv-mobile-ui 0.5.57 → 0.5.59

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.
@@ -18,11 +18,11 @@
18
18
  :session-from="sessionFrom"
19
19
  :send-message-img="sendMessageImg"
20
20
  :show-message-card="showMessageCard"
21
- @getphonenumber="onGetPhoneNumber"
22
- @getuserinfo="onGetUserInfo"
23
- @error="onError"
24
- @opensetting="onOpenSetting"
25
- @launchapp="onLaunchApp"
21
+ @getphonenumber="getphonenumber"
22
+ @getuserinfo="getuserinfo"
23
+ @error="error"
24
+ @opensetting="opensetting"
25
+ @launchapp="launchapp"
26
26
  @contact="onContact"
27
27
  @chooseavatar="onChooseavatar"
28
28
  @addgroupapp="onAddgroupapp"
@@ -108,8 +108,8 @@
108
108
  !disabled && !loading && !color && (plain || type === 'info')
109
109
  ? 'u-button--active--plain'
110
110
  : !disabled && !loading && !plain
111
- ? 'u-button--active'
112
- : ''
111
+ ? 'u-button--active'
112
+ : ''
113
113
  "
114
114
  @tap="clickHandler"
115
115
  :class="bemClass"
@@ -157,6 +157,7 @@ import { props } from '../u-button/props.js';
157
157
  * button 按钮
158
158
  * @description Button 按钮
159
159
  * @tutorial https://uview-plus.jiangruyi.com/components/button.html
160
+ *
160
161
  * @property {Boolean} hairline 是否显示按钮的细边框 (默认 true )
161
162
  * @property {String} type 按钮的预置样式,info,primary,error,warning,success (默认 'info' )
162
163
  * @value info 默认按钮
@@ -168,7 +169,7 @@ import { props } from '../u-button/props.js';
168
169
  * @value large 超大尺寸
169
170
  * @value normal 普通尺寸
170
171
  * @value mini 迷你尺寸
171
- * @property {String} shape 按钮形状,circle(两边为半圆),square(带有一定的圆角) (默认 'square' )
172
+ * @property {String} shape 按钮形状,circle(两边为半圆),square(带圆角) (默认 'square' )
172
173
  * @value circle 两边为半圆
173
174
  * @value square 带有一定的圆角
174
175
  * @property {Boolean} plain 按钮是否镂空,背景色透明 (默认 false)
@@ -196,16 +197,18 @@ import { props } from '../u-button/props.js';
196
197
  * @property {String} iconColor 按钮图标颜色
197
198
  * @property {String} color 按钮颜色,支持传入linear-gradient渐变色
198
199
  * @property {Object} customStyle 定义需要用到的外部样式
200
+ *
199
201
  * @event {Function} click 非禁止并且非加载中,才能点击
200
202
  * @event {Function} getphonenumber open-type="getPhoneNumber"时有效
201
203
  * @event {Function} getuserinfo 用户点击该按钮时,会返回获取到的用户信息,从返回参数的detail中获取到的值同uni.getUserInfo
202
204
  * @event {Function} error 当使用开放能力时,发生错误的回调
203
205
  * @event {Function} opensetting 在打开授权设置页并关闭后回调
204
206
  * @event {Function} launchapp 打开 APP 成功的回调
205
- * @example <up-button>千金散尽还复来</up-button>
207
+ * @event {Function} agreeprivacyauthorization 用户同意隐私协议事件回调
208
+ * @example <up-button>月落</up-button>
206
209
  */
207
210
  export default {
208
- name: 'u-button-wu',
211
+ name: 'u-button',
209
212
  // #ifdef MP
210
213
  mixins: [mpMixin, mixin, buttonMixin, openType, props],
211
214
  // #endif
@@ -20,13 +20,13 @@
20
20
  @opensetting="opensetting"
21
21
  @launchapp="launchapp"
22
22
  @agreeprivacyauthorization="agreeprivacyauthorization"
23
- :hover-class="!disabled && !loading ? 'u-button--active' : ''"
23
+ :hover-class="!disabled && !localLoading ? 'u-button--active' : ''"
24
24
  class="u-button u-reset-button"
25
25
  :style="[baseColor, addStyle(customStyle)]"
26
26
  @tap="clickHandler"
27
27
  :class="bemClass"
28
28
  >
29
- <template v-if="loading">
29
+ <template v-if="localLoading">
30
30
  <up-loading-icon :mode="loadingMode" :size="loadingSize * 1.15" :color="loadingColor"></up-loading-icon>
31
31
  <text class="u-button__loading-text" :style="[{ fontSize: textSize + 'px' }]">{{ loadingText || text }}</text>
32
32
  </template>
@@ -50,9 +50,9 @@
50
50
  :hover-stay-time="Number(hoverStayTime)"
51
51
  class="u-button"
52
52
  :hover-class="
53
- !disabled && !loading && !color && (plain || type === 'info')
53
+ !disabled && !localLoading && !color && (plain || type === 'info')
54
54
  ? 'u-button--active--plain'
55
- : !disabled && !loading && !plain
55
+ : !disabled && !localLoading && !plain
56
56
  ? 'u-button--active'
57
57
  : ''
58
58
  "
@@ -60,7 +60,7 @@
60
60
  :class="bemClass"
61
61
  :style="[baseColor, addStyle(customStyle)]"
62
62
  >
63
- <template v-if="loading">
63
+ <template v-if="localLoading">
64
64
  <up-loading-icon :mode="loadingMode" :size="loadingSize * 1.15" :color="loadingColor"></up-loading-icon>
65
65
  <text class="u-button__loading-text" :style="[nvueTextStyle]" :class="[plain && `u-button__text--plain--${type}`]">
66
66
  {{ loadingText || text }}
@@ -100,8 +100,18 @@ import color from '../../libs/config/color';
100
100
  *
101
101
  * @property {Boolean} hairline 是否显示按钮的细边框 (默认 true )
102
102
  * @property {String} type 按钮的预置样式,info,primary,error,warning,success (默认 'info' )
103
+ * @value info 默认按钮
104
+ * @value primary 主题按钮
105
+ * @value error 危险按钮
106
+ * @value warning 警告按钮
107
+ * @value success 成功按钮
103
108
  * @property {String} size 按钮尺寸,large,normal,mini (默认 normal)
109
+ * @value large 超大尺寸
110
+ * @value normal 普通尺寸
111
+ * @value mini 迷你尺寸
104
112
  * @property {String} shape 按钮形状,circle(两边为半圆),square(带圆角) (默认 'square' )
113
+ * @value circle 两边为半圆
114
+ * @value square 带有一定的圆角
105
115
  * @property {Boolean} plain 按钮是否镂空,背景色透明 (默认 false)
106
116
  * @property {Boolean} disabled 是否禁用 (默认 false)
107
117
  * @property {Boolean} loading 按钮名称前是否带 loading 图标(App-nvue 平台,在 ios 上为雪花,Android上为圆圈) (默认 false)
@@ -146,9 +156,14 @@ export default {
146
156
  mixins: [mpMixin, mixin, props],
147
157
  // #endif
148
158
  data() {
149
- return {};
159
+ return {
160
+ loadingStatus: false
161
+ };
150
162
  },
151
163
  computed: {
164
+ localLoading() {
165
+ return this.loadingStatus || this.loading;
166
+ },
152
167
  // 生成bem风格的类名
153
168
  bemClass() {
154
169
  // this.bem为一个computed变量,在mixin中
@@ -236,15 +251,33 @@ export default {
236
251
  methods: {
237
252
  addStyle,
238
253
  clickHandler(e) {
239
- // 非禁止并且非加载中,才能点击
240
- if (!this.disabled && !this.loading) {
241
- // 进行节流控制,每this.throttle毫秒内,只在开始处执行
242
- throttle(() => {
243
- this.$emit('click', e);
244
- }, this.throttleTime);
254
+ if (this.autoLoading) {
255
+ if (!this.loadingStatus) {
256
+ this.loadingStatus = true;
257
+ // 进行节流控制,每this.throttle毫秒内,只在开始处执行
258
+ throttle(() => {
259
+ this.$emit(
260
+ 'click',
261
+ () => {
262
+ this.loadingStatus = false;
263
+ },
264
+ e
265
+ );
266
+ }, this.throttleTime);
267
+ // 是否阻止事件传播
268
+ this.stop && this.preventEvent(e);
269
+ }
270
+ } else {
271
+ // 非禁止并且非加载中,才能点击
272
+ if (!this.disabled && !this.loading) {
273
+ // 进行节流控制,每this.throttle毫秒内,只在开始处执行
274
+ throttle(() => {
275
+ this.$emit('click', e);
276
+ }, this.throttleTime);
277
+ }
278
+ // 是否阻止事件传播
279
+ this.stop && this.preventEvent(e);
245
280
  }
246
- // 是否阻止事件传播
247
- this.stop && this.preventEvent(e);
248
281
  },
249
282
  // 下面为对接uniapp官方按钮开放能力事件回调的对接
250
283
  getphonenumber(res) {
@@ -0,0 +1,186 @@
1
+ // 重构数据结构为双向映射,便于快速查找
2
+ const MIME_MAPPINGS = (() => {
3
+ const mappings = {
4
+ // 图片格式
5
+ svg: ['image/svg+xml', 'image/svg'],
6
+ jpg: ['image/jpeg', 'image/jpg'],
7
+ jpeg: ['image/jpeg'],
8
+ png: ['image/png'],
9
+ gif: ['image/gif'],
10
+ webp: ['image/webp'],
11
+ bmp: ['image/bmp', 'image/x-bmp', 'image/x-ms-bmp'],
12
+ ico: ['image/x-icon', 'image/vnd.microsoft.icon'],
13
+ tiff: ['image/tiff', 'image/tif', 'image/x-tiff'],
14
+ apng: ['image/apng'],
15
+ avif: ['image/avif'],
16
+ heic: ['image/heic'],
17
+
18
+ // 文档格式
19
+ pdf: ['application/pdf'],
20
+ txt: ['text/plain'],
21
+ csv: ['text/csv'],
22
+ json: ['application/json'],
23
+ xml: ['application/xml'],
24
+
25
+ // Office 文档
26
+ doc: ['application/msword'],
27
+ docx: ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
28
+ xls: ['application/vnd.ms-excel'],
29
+ xlsx: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
30
+ ppt: ['application/vnd.ms-powerpoint'],
31
+ pptx: ['application/vnd.openxmlformats-officedocument.presentationml.presentation'],
32
+
33
+ // 压缩文件
34
+ zip: ['application/zip'],
35
+ rar: ['application/x-rar-compressed'],
36
+ '7z': ['application/x-7z-compressed'],
37
+
38
+ // 音频/视频
39
+ mp3: ['audio/mpeg'],
40
+ mp4: ['video/mp4'],
41
+ mov: ['video/quicktime'],
42
+ avi: ['video/x-msvideo'],
43
+ wav: ['audio/wav']
44
+ };
45
+
46
+ // 创建双向映射
47
+ const extensionToMime = {};
48
+ const mimeToExtension = {};
49
+
50
+ for (const [ext, mimes] of Object.entries(mappings)) {
51
+ extensionToMime[ext] = mimes[0]; // 每个扩展名映射到第一个MIME类型
52
+
53
+ for (const mime of mimes) {
54
+ mimeToExtension[mime] = ext;
55
+ }
56
+ }
57
+ return { extensionToMime, mimeToExtension };
58
+ })();
59
+ /**
60
+ * 根据MIME类型获取文件扩展名
61
+ * @param {string} type - MIME类型(如 'image/jpeg')
62
+ * @returns {string} 对应的文件扩展名(默认返回'jpg')
63
+ */
64
+ export function fileMimeToExtension(type) {
65
+ if (!type) return 'jpg';
66
+
67
+ const normalizedType = type.toLowerCase().trim();
68
+ return MIME_MAPPINGS.mimeToExtension[normalizedType] || 'jpg';
69
+ }
70
+ /**
71
+ * 根据文件扩展名获取MIME类型
72
+ * @param {string} ext - 文件扩展名(如 'jpg')
73
+ * @returns {string} 对应的MIME类型(默认返回空字符串)
74
+ */
75
+ export function fileExtensionToMime(ext) {
76
+ if (!ext) return '';
77
+ // 处理带点的情况(如 '.jpg')
78
+ const normalizedExt = ext.replace(/^\./, '').toLowerCase();
79
+ return MIME_MAPPINGS.extensionToMime[normalizedExt] || '';
80
+ }
81
+
82
+ export function generateUniqidName() {
83
+ // 获取当前日期时间,格式化为 YYYYMMDDHHmmss
84
+ const now = new Date();
85
+ const datePart = [
86
+ now.getFullYear(),
87
+ String(now.getMonth() + 1).padStart(2, '0'),
88
+ String(now.getDate()).padStart(2, '0'),
89
+ String(now.getHours()).padStart(2, '0'),
90
+ String(now.getMinutes()).padStart(2, '0'),
91
+ String(now.getSeconds()).padStart(2, '0')
92
+ ].join('');
93
+
94
+ // 生成唯一ID部分(类似PHP的uniqid)
95
+ const uniquePart = Math.random().toString(36).substring(2, 10);
96
+
97
+ return datePart + uniquePart;
98
+ }
99
+ export function checkIsObject(value) {
100
+ return Object.prototype.toString.call(value) === '[object Object]';
101
+ }
102
+ export function parseJsonSafe(str) {
103
+ if (typeof str !== 'string') return {};
104
+ try {
105
+ const obj = JSON.parse(str);
106
+ return typeof obj === 'object' && obj !== null ? obj : {};
107
+ } catch {
108
+ return {};
109
+ }
110
+ }
111
+
112
+ export function parseFormData(data) {
113
+ let formData = {};
114
+ // let formData = new FormData();
115
+ formData['success_action_status'] = data.success_action_status || '200';
116
+ // formData['OSSAccessKeyId']= data.accessid;
117
+ formData['policy'] = data.policy;
118
+ formData['signature'] = data.signature;
119
+ formData['x-oss-signature'] = data.signature;
120
+ formData['x-oss-signature-version'] = 'OSS4-HMAC-SHA256';
121
+ formData['x-oss-credential'] = data.x_oss_credential;
122
+ formData['x-oss-date'] = data.x_oss_date;
123
+ formData['x-oss-security-token'] = data.security_token;
124
+ let full_key = data.key;
125
+ if (!data.key) {
126
+ full_key = data.dir + '/' + file.name;
127
+ }
128
+ formData['key'] = full_key; // 文件名
129
+ if (data.callback) {
130
+ // 添加回调参数
131
+ formData['callback'] = data.callback;
132
+ }
133
+ if (data.callback_var && checkIsObject(data.callback_var)) {
134
+ // headers['x-oss-callback-var'] = data.callback_var;
135
+ // 在POST请求的Body中使用表单域来携带参数
136
+
137
+ for (const key in data.callback_var) {
138
+ if (data.callback_var.hasOwnProperty(key)) {
139
+ // 确保是对象自身的属性,而非继承的
140
+ formData[key] = data.callback_var[key];
141
+ }
142
+ }
143
+ // formData['callback-var', data.callback_var);
144
+ }
145
+ // formData['file']= file; // file 必须为最后一个表单域
146
+ return formData;
147
+ }
148
+ export function getFileInfo(imgStr) {
149
+ let index = imgStr.lastIndexOf('/');
150
+ let strName = imgStr.substring(index + 1, imgStr.length);
151
+ let strType = '';
152
+ if (strName.lastIndexOf('.') > -1) {
153
+ strType = strName.slice(strName.lastIndexOf('.') + 1);
154
+ strType = 'image/' + strType;
155
+ }
156
+ return {
157
+ name: strName,
158
+ url: imgStr,
159
+ type: strType,
160
+ status: 'success'
161
+ };
162
+ }
163
+ export function content_to_array(valDef) {
164
+ let existList = [];
165
+ let value_type1 = Object.prototype.toString.call(valDef);
166
+ if (value_type1 === '[object String]') {
167
+ existList.push(getFileInfo(valDef));
168
+ } else if (value_type1 === '[object Object]') {
169
+ if (valDef.name && valDef.url) {
170
+ existList.push(valDef);
171
+ }
172
+ } else if (value_type1 === '[object Array]') {
173
+ for (let i in valDef) {
174
+ let itemDef = valDef[i];
175
+ let value_type2 = Object.prototype.toString.call(itemDef);
176
+ if (value_type2 === '[object String]') {
177
+ existList.push(getFileInfo(itemDef));
178
+ } else if (value_type2 === '[object Object]') {
179
+ if (itemDef.name && itemDef.url) {
180
+ existList.push(itemDef);
181
+ }
182
+ }
183
+ }
184
+ }
185
+ return existList;
186
+ }
@@ -0,0 +1,176 @@
1
+ import { defineMixin } from '../../libs/vue';
2
+ import defProps from '../../libs/config/props.js';
3
+ export const props = defineMixin({
4
+ props: {
5
+ // 接受的文件类型, 可选值为all media image file video
6
+ accept: {
7
+ type: String,
8
+ default: () => defProps.upload.accept
9
+ },
10
+ extension: {
11
+ type: Array,
12
+ default: () => defProps.upload.extension
13
+ },
14
+ // 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头
15
+ capture: {
16
+ type: [String, Array],
17
+ default: () => defProps.upload.capture
18
+ },
19
+ // 当accept为video时生效,是否压缩视频,默认为true
20
+ compressed: {
21
+ type: Boolean,
22
+ default: () => defProps.upload.compressed
23
+ },
24
+ // 当accept为video时生效,可选值为back或front
25
+ camera: {
26
+ type: String,
27
+ default: () => defProps.upload.camera
28
+ },
29
+ // 当accept为video时生效,拍摄视频最长拍摄时间,单位秒
30
+ maxDuration: {
31
+ type: Number,
32
+ default: () => defProps.upload.maxDuration
33
+ },
34
+ // 上传区域的图标,只能内置图标
35
+ uploadIcon: {
36
+ type: String,
37
+ default: () => defProps.upload.uploadIcon
38
+ },
39
+ // 上传区域的图标的颜色,默认
40
+ uploadIconColor: {
41
+ type: String,
42
+ default: () => defProps.upload.uploadIconColor
43
+ },
44
+ // 是否开启文件读取前事件
45
+ useBeforeRead: {
46
+ type: Boolean,
47
+ default: () => defProps.upload.useBeforeRead
48
+ },
49
+ // 读取后的处理函数
50
+ afterRead: {
51
+ type: Function,
52
+ default: null
53
+ },
54
+ // 读取前的处理函数
55
+ beforeRead: {
56
+ type: Function,
57
+ default: null
58
+ },
59
+ // 是否显示组件自带的图片&视频预览功能
60
+ previewFullImage: {
61
+ type: Boolean,
62
+ default: () => defProps.upload.previewFullImage
63
+ },
64
+ // 最大上传数量
65
+ maxCount: {
66
+ type: [String, Number],
67
+ default: () => defProps.upload.maxCount
68
+ },
69
+ // 是否启用
70
+ disabled: {
71
+ type: Boolean,
72
+ default: () => defProps.upload.disabled
73
+ },
74
+ // 预览上传的图片时的裁剪模式,和image组件mode属性一致
75
+ imageMode: {
76
+ type: String,
77
+ default: () => defProps.upload.imageMode
78
+ },
79
+ // 标识符,可以在回调函数的第二项参数中获取
80
+ name: {
81
+ type: String,
82
+ default: () => defProps.upload.name
83
+ },
84
+ // 所选的图片的尺寸, 可选值为original compressed
85
+ sizeType: {
86
+ type: Array,
87
+ default: () => defProps.upload.sizeType
88
+ },
89
+ // 是否开启图片多选,部分安卓机型不支持
90
+ multiple: {
91
+ type: Boolean,
92
+ default: () => defProps.upload.multiple
93
+ },
94
+ // 是否展示删除按钮
95
+ deletable: {
96
+ type: Boolean,
97
+ default: () => defProps.upload.deletable
98
+ },
99
+ // 文件大小限制,单位为byte
100
+ maxSize: {
101
+ type: [String, Number],
102
+ default: () => defProps.upload.maxSize
103
+ },
104
+ // 显示已上传的文件列表
105
+ fileList: {
106
+ type: Array,
107
+ default: () => defProps.upload.fileList
108
+ },
109
+ // 上传区域的提示文字
110
+ uploadText: {
111
+ type: String,
112
+ default: () => defProps.upload.uploadText
113
+ },
114
+ // 内部预览图片区域和选择图片按钮的区域宽度
115
+ width: {
116
+ type: [String, Number],
117
+ default: () => defProps.upload.width
118
+ },
119
+ // 内部预览图片区域和选择图片按钮的区域高度
120
+ height: {
121
+ type: [String, Number],
122
+ default: () => defProps.upload.height
123
+ },
124
+ // 是否在上传完成后展示预览图
125
+ previewImage: {
126
+ type: Boolean,
127
+ default: () => defProps.upload.previewImage
128
+ },
129
+ // 是否自动删除
130
+ autoDelete: {
131
+ type: Boolean,
132
+ default: () => defProps.upload.autoDelete
133
+ },
134
+ // 是否自动上传需要传递action指定地址
135
+ autoUpload: {
136
+ type: Boolean,
137
+ default: () => defProps.upload.autoUpload
138
+ },
139
+ // 自动上传接口地址
140
+ autoUploadApi: {
141
+ type: String,
142
+ default: () => defProps.upload.autoUploadApi
143
+ },
144
+ // 自动上传驱动,local/oss/cos/kodo
145
+ autoUploadDriver: {
146
+ type: String,
147
+ default: () => defProps.upload.autoUploadDriver
148
+ },
149
+ // 自动上传授权接口,比如oss的签名接口。
150
+ autoUploadAuthUrl: {
151
+ type: String,
152
+ default: () => defProps.upload.autoUploadAuthUrl
153
+ },
154
+ // 自动上传携带的header
155
+ autoUploadHeader: {
156
+ type: Object,
157
+ default: () => {
158
+ return defProps.upload.autoUploadHeader;
159
+ }
160
+ },
161
+ // 本地计算视频封面
162
+ getVideoThumb: {
163
+ type: Boolean,
164
+ default: () => defProps.upload.getVideoThumb
165
+ },
166
+ // 自定义自动上传后处理
167
+ customAfterAutoUpload: {
168
+ type: Boolean,
169
+ default: () => defProps.upload.customAfterAutoUpload
170
+ },
171
+ videoPreviewObjectFit: {
172
+ type: String,
173
+ default: () => defProps.upload.videoPreviewObjectFit
174
+ }
175
+ }
176
+ });
@@ -2,6 +2,18 @@ import { defineMixin } from '../../libs/vue';
2
2
  import defProps from '../../libs/config/props.js';
3
3
  export const props = defineMixin({
4
4
  props: {
5
+ modelValue: {
6
+ type: [Number, String, Array],
7
+ default: ''
8
+ },
9
+ initValue: {
10
+ type: [String, Array],
11
+ default: ''
12
+ },
13
+ iconSize: {
14
+ type: [String, Number],
15
+ default: 12
16
+ },
5
17
  // 接受的文件类型, 可选值为all media image file video
6
18
  accept: {
7
19
  type: String,