合同小程序前端代码仓库
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.

104 lines
2.2 KiB

2 weeks ago
  1. <template>
  2. <view class="container">
  3. <view class="form">
  4. <input class="input" type="text" placeholder="请输入您的账号" v-model="username" />
  5. <input class="input" type="password" placeholder="请输入您的密码" v-model="password" />
  6. <view class="agreement">
  7. <checkbox-group @change="handleAgreementChange">
  8. <label>
  9. <checkbox value="agree" /> 阅读并同意《用户协议》和《隐私政策》
  10. </label>
  11. </checkbox-group>
  12. </view>
  13. <button class="button" @click="handleLogin">登录</button>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. username: '',
  22. password: '',
  23. agreed: false
  24. };
  25. },
  26. methods: {
  27. handleAgreementChange(e) {
  28. this.agreed = e.detail.value.includes('agree');
  29. },
  30. handleLogin() {
  31. if (!this.agreed) {
  32. uni.showToast({
  33. title: '请先同意用户协议和隐私政策',
  34. icon: 'none'
  35. });
  36. return;
  37. }
  38. // 简单的登录验证逻辑
  39. if (this.username === 'admin' && this.password === '123456') {
  40. uni.showToast({
  41. title: '登录成功',
  42. icon: 'success',
  43. duration: 1500, // 提示持续时间
  44. success: () => {
  45. // 延迟跳转,确保用户看到提示
  46. setTimeout(() => {
  47. uni.navigateTo({
  48. url: '/pages/home/home' // 跳转到首页或其他页面
  49. });
  50. }, 1500);
  51. }
  52. });
  53. } else {
  54. uni.showToast({
  55. title: '账号或密码错误',
  56. icon: 'none'
  57. });
  58. }
  59. }
  60. }
  61. };
  62. </script>
  63. <style>
  64. .container {
  65. display: flex;
  66. justify-content: center;
  67. align-items: center;
  68. height: 100vh;
  69. background-color: #f5f5f5;
  70. }
  71. .form {
  72. width: 80%;
  73. background-color: #fff;
  74. padding: 20px;
  75. border-radius: 8px;
  76. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  77. }
  78. .input {
  79. width: 100%;
  80. height: 40px;
  81. margin-bottom: 15px;
  82. padding: 10px;
  83. border: 1px solid #ccc;
  84. border-radius: 4px;
  85. }
  86. .agreement {
  87. margin-bottom: 15px;
  88. }
  89. .button {
  90. width: 100%;
  91. height: 40px;
  92. background-color: #007aff;
  93. color: #fff;
  94. border: none;
  95. border-radius: 4px;
  96. font-size: 16px;
  97. }
  98. </style>