logic.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. export default {
  2. data() {
  3. return {
  4. currentTab: 0, // 0: 免密, 1: 密码
  5. mobile: '',
  6. code: '',
  7. password: '',
  8. showPassword: false,
  9. isAgreed: false,
  10. countDown: 0,
  11. timer: null,
  12. showAgreementModal: false,
  13. agreementTitle: '',
  14. agreementContent: ''
  15. }
  16. },
  17. methods: {
  18. showAgreement(type) {
  19. this.agreementTitle = type === 1 ? '用户服务协议' : '隐私政策';
  20. if (type === 1) {
  21. this.agreementContent = '1. 服务条款\n欢迎使用宠宝平台。您在使用本服务时需遵守以下条款...\n\n2. 用户责任\n用户需对自己的行为负责...\n\n3. 账号管理\n请妥善保管您的账号密码...';
  22. } else {
  23. this.agreementContent = '1. 信息收集\n为了提供服务,我们需要收集您的手机号、地理位置、设备信息等必要数据。\n\n2. 信息使用\n您的位置信息将用于订单匹配和路径规划;您的联系方式将用于接单通知和客户沟通。\n\n3. 信息保护\n我们将采取严格的安全措施保护您的个人信息,未经授权不会向第三方披露。';
  24. }
  25. this.showAgreementModal = true;
  26. },
  27. getVerifyCode() {
  28. if (this.currentTab === 1) return; // 密码登录不需要验证码
  29. if (this.countDown > 0) return;
  30. if (!this.mobile || this.mobile.length !== 11) {
  31. uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
  32. return;
  33. }
  34. this.countDown = 60;
  35. this.timer = setInterval(() => {
  36. this.countDown--;
  37. if (this.countDown <= 0) {
  38. clearInterval(this.timer);
  39. }
  40. }, 1000);
  41. uni.showToast({ title: '验证码已发送', icon: 'none' });
  42. },
  43. handleLogin() {
  44. if (!this.isAgreed) {
  45. uni.showToast({ title: '请先同意用户协议', icon: 'none' });
  46. return;
  47. }
  48. if (!this.mobile) {
  49. uni.showToast({ title: '请输入手机号', icon: 'none' });
  50. return;
  51. }
  52. if (this.currentTab === 0) {
  53. // 免密登录
  54. if (!this.code) {
  55. uni.showToast({ title: '请输入验证码', icon: 'none' });
  56. return;
  57. }
  58. } else {
  59. // 密码登录
  60. if (!this.password) {
  61. uni.showToast({ title: '请输入密码', icon: 'none' });
  62. return;
  63. }
  64. }
  65. uni.showToast({ title: '登录成功', icon: 'success' });
  66. setTimeout(() => {
  67. uni.switchTab({
  68. url: '/pages/home/index'
  69. });
  70. }, 1000);
  71. },
  72. goToRecruit() {
  73. uni.navigateTo({
  74. url: '/pages/recruit/landing'
  75. });
  76. },
  77. goToForgotPwd() {
  78. uni.navigateTo({
  79. url: '/pages/login/reset-pwd-verify'
  80. });
  81. }
  82. }
  83. }