import colorModule from './modules/color.js' import regModule from './modules/regexValidate.js' export let color = colorModule; export let regexValidate = regModule; /* 生成随机uuid * n:uuid的长度 * type:类型(0-大小写字母+数字,1-小写字母+数字,2-纯数字,3-大小写字母,4-小写字母) */ export function uuid(n=6,type=0){ let res='', uType=0; const __uuidLetter = function(){ const __tempArr = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] return __tempArr[Math.floor(Math.random()*26)]; } for (let i=0;iitem.code==code) } return res.length>0?res[0]:[]; } /* 解析字典值 code:字典集合码 value:字典值 返回:字典值对应名称 */ export function parseDic(store,code,value){ let res = ''; let dicDataSource = store.getters['system/getEnum']; if (dicDataSource) { let _arr = dicDataSource.filter(item=>item.code==code) if (_arr.length>0) { res=_arr[0]?.sysDictDatas.filter(item=>item.code==value) res=res.length>0?res[0].value:'' if (!res) res = '无此字典' } else { res = '无此字典' } } else { res = 'Failed' } return res; }; /* 下载更新 */ export function downloadApk($config){ try{ const _downFun = function(){ try{ plus.runtime.openURL($config.downUrl, function(res) {console.log(res);}); }catch(ex){ console.log('_downFun Error!') console.log(ex) } setTimeout(()=>{ uni.hideLoading(); },10000) } uni.showLoading({ title: '开启下载...', mask:true }); if (plus.networkinfo.getCurrentType() != 3){ uni.hideLoading(); uni.showModal({ title:'系统提示', content:'当前非WIFI环境,确认继续下载吗?', success:(res)=>{ if (res.confirm) { uni.showLoading({ title: '开启下载...', mask:true }); _downFun() } } }) } else { _downFun() } } catch(e){ uni.hideLoading(); uni.showModal({ title:'系统提示', content:'下载失败', showCancel:false }) console.log('DownloadApk Error!') console.log(e) } }; export function getObjectType(obj){ if (typeof obj !== 'object') { return null; } else { let objTypeStr = Object.prototype.toString.call(obj).toLowerCase().trim(); objTypeStr = objTypeStr.substr(1,objTypeStr.length-2) let tempA = objTypeStr.split(" "); return tempA[1]; } } export function getUserDefaultArea($store,arr,valueField='code'){ let res = '' const _default = $store.getters['user/getUserInfo']['workShopType'] for (let i=0;i