mali-applet-ui 1.1.95 → 1.1.97
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.
- package/lib/components/ml-list-item-title/ml-list-item-title.vue +2 -0
- package/lib/components/ml-upload/ml-upload.vue +1 -1
- package/package.json +1 -1
- package/types/utils/index.d.ts +5 -0
- package/utils/applet.js +14 -0
- package/utils/file.js +3 -2
- package/utils/index.js +2 -0
- package/utils/scan.js +23 -0
|
@@ -413,7 +413,7 @@ export default {
|
|
|
413
413
|
return this.imgTypes.includes(XEUtils.toValueString(item[this.typeField]).toLowerCase())
|
|
414
414
|
},
|
|
415
415
|
removeEvent (item) {
|
|
416
|
-
this.fileList = this.fileList.filter(obj => obj.
|
|
416
|
+
this.fileList = this.fileList.filter(obj => obj[this.urlField] !== item[this.urlField])
|
|
417
417
|
const removeMethod = this.removeFile ? this.removeFile : (globalStore.upload ? globalStore.upload.removeFile : null)
|
|
418
418
|
if (!item) {
|
|
419
419
|
console.error('删除出错!!!')
|
package/package.json
CHANGED
package/types/utils/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import 'xe-utils'
|
|
|
2
2
|
import { XEUtilsMethods } from 'xe-utils/ctor'
|
|
3
3
|
|
|
4
4
|
export interface MlUtilsCore extends XEUtilsMethods {
|
|
5
|
+
scanQRCode (options?: {
|
|
6
|
+
success?: (e: any) => void
|
|
7
|
+
fail?: (e: any) => void
|
|
8
|
+
}): Promise<any>
|
|
9
|
+
|
|
5
10
|
toDateString (date: any, format?: string): string
|
|
6
11
|
toStringDate (value: any): Date
|
|
7
12
|
|
package/utils/applet.js
CHANGED
|
@@ -102,3 +102,17 @@ export function getAppDpr () {
|
|
|
102
102
|
ratio = info.pixelRatio || 2
|
|
103
103
|
return ratio
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
export function getUserDataPath () {
|
|
107
|
+
let udPath = ''
|
|
108
|
+
|
|
109
|
+
// #ifdef MP-WEIXIN
|
|
110
|
+
udPath = wx.env.USER_DATA_PATH
|
|
111
|
+
// #endif
|
|
112
|
+
|
|
113
|
+
// #ifdef MP-DINGTALK
|
|
114
|
+
udPath = dd.env.USER_DATA_PATH
|
|
115
|
+
// #endif
|
|
116
|
+
|
|
117
|
+
return udPath
|
|
118
|
+
}
|
package/utils/file.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils'
|
|
2
|
+
import { getUserDataPath } from './applet'
|
|
2
3
|
|
|
3
4
|
export function getFileSuffix (filename) {
|
|
4
5
|
const pos = filename.lastIndexOf('.')
|
|
@@ -41,7 +42,7 @@ export function openFileByUrl (fileUrl, fileName, options) {
|
|
|
41
42
|
const fileType = opts.type || getFileSuffix(name || getFileName(url)).toLowerCase()
|
|
42
43
|
uni.downloadFile({
|
|
43
44
|
url,
|
|
44
|
-
filePath: name ? `${
|
|
45
|
+
filePath: name ? `${getUserDataPath()}/${name.indexOf('.') === -1 ? `${name}.${fileType}` : name}` : '',
|
|
45
46
|
success: (downRes) => {
|
|
46
47
|
if (getFilePreviewTypes().includes(fileType)) {
|
|
47
48
|
uni.openDocument({
|
|
@@ -98,7 +99,7 @@ export function saveFileByUrl (fileUrl, fileName, options) {
|
|
|
98
99
|
const fileType = opts.type || getFileSuffix(name || getFileName(url)).toLowerCase()
|
|
99
100
|
uni.downloadFile({
|
|
100
101
|
url,
|
|
101
|
-
filePath: name ? `${
|
|
102
|
+
filePath: name ? `${getUserDataPath()}/${name.indexOf('.') === -1 ? `${name}.${fileType}` : name}` : '',
|
|
102
103
|
success: (downRes) => {
|
|
103
104
|
uni.saveFile({
|
|
104
105
|
tempFilePath: downRes.filePath || downRes.tempFilePath,
|
package/utils/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import urlMethods from 'xe-utils/url'
|
|
|
9
9
|
import webMethods from 'xe-utils/web'
|
|
10
10
|
|
|
11
11
|
import * as appletFns from './applet'
|
|
12
|
+
import * as scanFns from './scan'
|
|
12
13
|
import * as dateFns from './date'
|
|
13
14
|
import * as numberFns from './number'
|
|
14
15
|
import * as fileFns from './file'
|
|
@@ -34,6 +35,7 @@ const MaliUtils = {
|
|
|
34
35
|
...webMethods,
|
|
35
36
|
|
|
36
37
|
...appletFns,
|
|
38
|
+
...scanFns,
|
|
37
39
|
...dateFns,
|
|
38
40
|
...numberFns,
|
|
39
41
|
...fileFns
|
package/utils/scan.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 扫码
|
|
3
|
+
*/
|
|
4
|
+
export function scanQRCode (options) {
|
|
5
|
+
const opts = Object.assign({}, options)
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
uni.scanCode({
|
|
8
|
+
scanType: 'qrCode',
|
|
9
|
+
success (res) {
|
|
10
|
+
if (opts.success) {
|
|
11
|
+
opts.success(res)
|
|
12
|
+
}
|
|
13
|
+
resolve(res)
|
|
14
|
+
},
|
|
15
|
+
fail (e) {
|
|
16
|
+
if (opts.fail) {
|
|
17
|
+
opts.fail(e)
|
|
18
|
+
}
|
|
19
|
+
reject(e)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
}
|