Skip to content

Commit 750aeeb

Browse files
committed
Merge branch 'develop' of github.com:supervons/react-native-adaptive-utils into develop
2 parents ec0ed32 + 237396c commit 750aeeb

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

common/helper.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* @Descripttion:
3+
* @Author: liujing
4+
* @Date: 2022-02-15 11:22:59
5+
* @LastEditTime: 2022-02-21 16:53:47
6+
*/
17
/**
28
* Helper tool,Improve and optimize development efficiency.
39
*/
@@ -48,6 +54,23 @@ export function randomString(len = 32) {
4854
}
4955
return pwd;
5056
}
57+
58+
/**
59+
* Object array sort.
60+
* * @param arr
61+
* @type {boolean}
62+
*/
63+
export function sortFun(arr, props, type) {
64+
if (type == 1) {
65+
return arr.sort(function (a, b) {
66+
return a[props] - b[props];
67+
});
68+
} else if (type == 0) {
69+
return arr.sort(function (a, b) {
70+
return b[props] - a[props];
71+
});
72+
}
73+
}
5174
/**
5275
* integer decimals thousands format show
5376
* @type {boolean}
@@ -60,14 +83,14 @@ export function integerDecimalsFormat(num) {
6083
let intPart = num.substring(0, pointIndex);
6184
let pointPart = num.substring(pointIndex + 1, num.length);
6285
intPart = intPart + "";
63-
var re = /(-?\d+)(\d{3})/;
86+
let re = /(-?\d+)(\d{3})/;
6487
while (re.test(intPart)) {
6588
intPart = intPart.replace(re, "$1,$2");
6689
}
6790
num = intPart + "." + pointPart;
6891
} else {
6992
num = num + "";
70-
var re = /(-?\d+)(\d{3})/;
93+
let re = /(-?\d+)(\d{3})/;
7194
while (re.test(num)) {
7295
num = num.replace(re, "$1,$2");
7396
}

common/validator.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,9 @@ export function limitStr(val, strNum) {
6666
*/
6767
export function isImg(target) {
6868
let file = target.value();
69-
if (file == "") {
70-
alert("Please upload pictures");
69+
if (file === "") {
7170
return false;
7271
} else {
73-
if (!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(file)) {
74-
alert("The image type must be One of the .gif,jpeg,jpg,png");
75-
return false;
76-
}
72+
return /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(file);
7773
}
7874
}

0 commit comments

Comments
 (0)