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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export default class Verify {
  2. //验证表单是否包含
  3. indexOfs(name: string, data: string[]): Boolean {
  4. let start = false
  5. for (let item of data) {
  6. if (name.indexOf(item) != -1) {
  7. start = true
  8. break
  9. }
  10. }
  11. return start
  12. }
  13. //TAG log
  14. TAGLog(tag: string, msg: string) {
  15. console.log(tag + ":", msg)
  16. }
  17. //表单输入校验
  18. verify(data, hint, type) {
  19. if (data) {
  20. showDialog(hint)
  21. return true
  22. }
  23. let reg: string = ''
  24. switch (type) {
  25. case 'email': //邮箱校验
  26. reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
  27. return reg.test(data)
  28. case 'phoneno': //手机号码校验
  29. reg = /^1[0-9]{10,10}$/;
  30. return reg.test(data)
  31. case 'plate': //车牌号校验
  32. reg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
  33. return reg.test(data)
  34. }
  35. }
  36. showDialog(hint: string) {
  37. uni.showModal({
  38. title: "提示",
  39. content: hint,
  40. showCancel: false,
  41. confirmText: "确定"
  42. })
  43. }
  44. }