6 changed files with 119 additions and 8 deletions
-
11common/http.interceptor.js
-
10common/http.js
-
100common/mixin.js
-
2main.js
-
2manifest.json
-
2pages/index/index.vue
@ -0,0 +1,100 @@ |
|||
export default{ |
|||
data(){ |
|||
return { |
|||
// 返回顶部
|
|||
needToTop: false |
|||
} |
|||
}, |
|||
onLoad(option){ |
|||
|
|||
}, |
|||
onPageScroll(res) { |
|||
if(res.scrollTop > 1000){ |
|||
this.needToTop = true; |
|||
} |
|||
this.needToTop = false; |
|||
}, |
|||
// 页面转发分享
|
|||
async onShareAppMessage(res) { |
|||
|
|||
}, |
|||
methods: { |
|||
$check(str, type) { |
|||
switch (type) { |
|||
case 'mobile': //手机号码
|
|||
return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(str); |
|||
case 'tel': //座机
|
|||
return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(str); |
|||
case 'card': //身份证
|
|||
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(str); |
|||
case 'mobileCode': //6位数字验证码
|
|||
return /^[0-9]{6}$/.test(str) |
|||
case 'pwd': //密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线
|
|||
return /^([a-zA-Z0-9_]){6,20}$/.test(str) |
|||
case 'payPwd': //支付密码 6位纯数字
|
|||
return /^[0-9]{6}$/.test(str) |
|||
case 'postal': //邮政编码
|
|||
return /[1-9]\d{5}(?!\d)/.test(str); |
|||
case 'QQ': //QQ号
|
|||
return /^[1-9][0-9]{4,9}$/.test(str); |
|||
case 'email': //邮箱
|
|||
return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(str); |
|||
case 'money': //金额(小数点2位)
|
|||
return /^\d*(?:\.\d{0,2})?$/.test(str); |
|||
case 'URL': //网址
|
|||
return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(str) |
|||
case 'IP': //IP
|
|||
return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(str); |
|||
case 'date': //日期时间
|
|||
return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(str) || /^(\d{4})\-(\d{2})\-(\d{2})$/ |
|||
.test(str) |
|||
case 'number': //数字
|
|||
return /^[0-9]$/.test(str); |
|||
case 'english': //英文
|
|||
return /^[a-zA-Z]+$/.test(str); |
|||
case 'chinese': //中文
|
|||
return /^[\\u4E00-\\u9FA5]+$/.test(str); |
|||
case 'lower': //小写
|
|||
return /^[a-z]+$/.test(str); |
|||
case 'upper': //大写
|
|||
return /^[A-Z]+$/.test(str); |
|||
case 'HTML': //HTML标记
|
|||
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(str); |
|||
default: |
|||
return true; |
|||
} |
|||
}, |
|||
$msg(title = '', param = {}) { |
|||
if(!title) return; |
|||
uni.showToast({ |
|||
title, |
|||
duration: param.duration || 1500, |
|||
mask: param.mask || true, // 默认应该加mask 禁止提示时操作
|
|||
icon: param.icon || 'none' |
|||
}); |
|||
}, |
|||
$url(url, options = {}){ |
|||
// TODO 判断登录逻辑;防抖
|
|||
if(options.type && options.type !== ''){ |
|||
if(options.type === 'redirect'){ // 关闭当前,跳转
|
|||
uni.redirectTo({ url }) |
|||
}else if(options.type === 'switch'){ // 跳转
|
|||
uni.switchTab({ url }) |
|||
}else if(options.type === 'launch'){ // 关闭所有,跳转
|
|||
uni.reLaunch({ url }) |
|||
} |
|||
}else{ |
|||
uni.navigateTo({ url }) // 跳转
|
|||
} |
|||
}, |
|||
$toBack(){ |
|||
let pages = getCurrentPages(); // 当前页
|
|||
let beforePage = pages[pages.length - 2]; // 上个页面
|
|||
if(beforePage && beforePage.route){ |
|||
uni.navigateBack(); |
|||
}else{ |
|||
uni.switchTab({url:'/pages/index/index'}); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue