123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
-
- /*
- * 爽客邦公用方法
- */
- // 验证手机号码格式
- const verificationphonenumber = (phonenumber) =>{
- const reg = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/;
- return reg.test(phonenumber);
- };
- // 验证手机号码格式
- const verificationIdnumber = (idnumber) =>{
- const reg = /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/;
- return reg.test(idnumber);
- };
- // 验证手机号码格式
- const verificationbankcardId = (bankcardId) =>{
- const reg = /^[1-9]\d{9,29}$/;
- return reg.test(bankcardId);
- };
- // 提示函数
- const tips = (tips,position = "bottom") => {
- vant.Toast({message: tips,position});
- };
- //- 手机号码验证
- const verification = (mobilenumber) => {
- if(mobilenumber === '') {
- tips('请输入手机号码!');
- return true;
- }
- if(!verificationphonenumber(mobilenumber)){
- tips('手机号码格式错误!');
- return true;
- };
- };
- // 密码校验
- const verificationpassword = function(pwd){
- if(pwd.length < 6 || pwd.length > 16) {
- tips('密码长度应为6~16位');
- return true;
- }
- };
- // 验证码校验
- const verificationmobilecode = function(code){
- if(code.length !== 6) {
- tips('短信验证码长度应为6位');
- return true;
- }
- };
- // 按钮防抖
- const undebounce = function(func,delay = 300) {
- let timer;
- return function() {
- const args = arguments;
- const that = this;
- if (timer) clearTimeout(timer);
- timer = setTimeout(() => {
- func.apply(that,args)
- }, delay)
- }
- };
- // 保留两位小数
- Vue.filter('tofixed2', function (value) {
- return value.toFixed(2);
- });
- const tofixed2 = function (value) {
- return value.toFixed(2);
- };
- // 隐藏中间位
- const hidemiddlenum = function (str,frontLen,endLen = 0) {
- var len = str.length-frontLen-endLen;
- var xing = '';
- for (var i=0;i<len;i++) {
- xing+='*';
- }
- return str.substring(0,frontLen)+xing+str.substring(str.length-endLen);
- };
- // 模拟app方法接口
- // const PublicLib = {
- // Goto:function(urlobj){
- // window.open(`http://192.168.9.69:5757/${urlobj.Url}.html`,"_self");
- // },
- // putCookieInfo:function(name,val){
- // window.localStorage.setItem(name,val);
- // },
- // getCookieInfo:function(name){
- // return window.localStorage.getItem(name);
- // },
- // GoBack:function(num){
- // window.history.back(-num);
- // if(num === 0) {
- // PublicLib.Goto({Url:'user-center'});
- // }
- // },
- // ClearAppCache:function(){
- // vant.Toast('清除了缓存');
- // },
- // PhoneCall:function(phonenum){
- // window.location.href = 'tel:'+ phonenum;
- // },
- // GetAppVersion(){
- // return '1.1.4';
- // },
- // DataEncrypt({Content:val}){
- // return val
- // },
- // ShowLoading(){
- // console.log('等待。。。。。。')
- // },
- // HideLoading(){
- // console.log('隐藏等待。。。。。。')
- // },
- // };
- // PublicLib.Goto({Url:''});
- // PublicLib.putCookieInfo('userId', res.data.Id);
- // PublicLib.getCookieInfo('userId');
- // PublicLib.GoBack({Level:1});
- // 补零函数
- const fillzero = function(num) {
- if(num < 10) {
- return '0'+ num;
- }else{
- return num;
- };
- };
- const formatDate = function(year,mounth,daile = ''){
- year = fillzero(year);
- mounth = fillzero(mounth);
- daile = daile !== '' ? fillzero(daile) : ''
- return ''+year + mounth + daile;
- };
- // 底部导航栏是否显示
- const bottomtabisshow = true;
- // 顶部标题栏是否显示
- const toptitleisshow = true;
- /*判断访问终端*/
- const browsertype = {
- versions:function(){
- var u = navigator.userAgent, app = navigator.appVersion;
- return {
- trident: u.indexOf('Trident') > -1, /*IE内核*/
- presto: u.indexOf('Presto') > -1, /*opera内核*/
- webKit: u.indexOf('AppleWebKit') > -1, /*苹果、谷歌内核*/
- gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,/*火狐内核*/
- mobile: !!u.match(/AppleWebKit.*Mobile.*/), /*是否为移动终端*/
- ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), /*ios终端*/
- android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, /*android终端或者uc浏览器*/
- iPhone: u.indexOf('iPhone') > -1 , /*是否为iPhone或者QQHD浏览器*/
- iPad: u.indexOf('iPad') > -1, /*是否iPad*/
- webApp: u.indexOf('Safari') == -1, /*是否web应该程序,没有头部与底部*/
- weixin: u.toLowerCase().indexOf('micromessenger') > -1 /*是否是微信*/
- };
- }(),
- language:(navigator.browserLanguage || navigator.language).toLowerCase()
- };
- // 扫描二维码函数
- const scan = function (value,fn) {
- value = PublicLib.getCookieInfo("ScanContent") && JSON.parse(PublicLib.getCookieInfo("ScanContent")).scan
- if(value !== '') {
- fn();
- }
- PublicLib.putCookieInfo('ScanContent', '');
- };
- // 加密函数
- const encryption = function(val){
- return PublicLib.encryptByDES(val);
- };
- Host = 'http://test.bs.shuangkebang.com/';
- const showHost = 'http://test.bs.shuangkebang.com';
- // Host = '/';
- isWeb = true;
|