You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
//需要验证的对象,验证对象
|
|
export function fromVaildUtil(param, vct) {
|
|
for (let key in vct) {
|
|
let data = (typeof vct[key] == 'object') ? vct[key][0] : vct[key]
|
|
let zeData = (typeof vct[key] == 'object') ? vct[key][1] : vct[key]
|
|
//验证表单
|
|
|
|
if (!(param[key] || (typeof param[key] == 'number' && param[key] != null))) {
|
|
uni.$u.toast(data)
|
|
return false;
|
|
}
|
|
if (typeof vct[key] == 'object') {
|
|
//判断正则
|
|
let ze = zeData.ze
|
|
if (!ze.test(param[key])) {
|
|
uni.$u.toast(zeData.tip)
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
//转换对象为?拼接
|
|
export function addQueryString(params) {
|
|
if (!params) return ''
|
|
var str = '';
|
|
for (var Key in params) {
|
|
str += Key + '=' + params[Key] + '&';
|
|
}
|
|
return '?' + str.substr(0, str.length - 1)
|
|
}
|
|
|
|
//判断平台
|
|
export function platCom(code) {
|
|
//app App web Web mp-weixin 微信小程序
|
|
return this.environment.systemInfo.uniPlatform && (this.environment.systemInfo.uniPlatform == code);
|
|
}
|
|
|
|
|
|
//图片返回全地址接口
|
|
export function getImgUrlPath(data, type) {
|
|
let url = ''
|
|
if (type == 'file') {
|
|
url = this.environment.fileUrl
|
|
} else {
|
|
url = this.environment.appImageUrl
|
|
}
|
|
return url + data
|
|
}
|
|
|