account-login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!-- 账号密码登录 accountLogin -->
  2. <template>
  3. <view>
  4. <!-- 表单项 -->
  5. <u-form
  6. ref="accountLoginRef"
  7. labelWidth="140"
  8. labelAlign="left"
  9. labelPosition="top"
  10. >
  11. <u-form-item prop="mobile" label="手机号">
  12. <view class="input-line">
  13. <u-input
  14. placeholder="请输入手机号"
  15. v-model="model.mobile"
  16. border="none"
  17. type="number"
  18. maxlength="11"
  19. ></u-input>
  20. </view>
  21. </u-form-item>
  22. <u-form-item prop="password" label="密码">
  23. <view class="input-line">
  24. <u-input
  25. type="password"
  26. placeholder="请输入密码"
  27. v-model="model.password"
  28. border="none"
  29. ></u-input>
  30. </view>
  31. </u-form-item>
  32. </u-form>
  33. </view>
  34. </template>
  35. <script>
  36. export default{
  37. data() {
  38. return {
  39. model:{
  40. mobile:'',
  41. password:''
  42. },
  43. rules:{
  44. mobile: [
  45. {
  46. required: true,
  47. errorMessage: '请输入手机号',
  48. },
  49. {
  50. validateFunction: function (rule, value, data, callback) {
  51. if (!test.mobile(value)) {
  52. callback('手机号码格式不正确');
  53. }
  54. return true;
  55. },
  56. },
  57. ],
  58. password: [
  59. {
  60. required: true,
  61. errorMessage: '请输入密码',
  62. },
  63. ],
  64. }
  65. }
  66. },
  67. methods:{
  68. accountLoginSubmit() {
  69. if(!uni.$u.test.mobile(this.model.mobile)){
  70. return uni.$u.toast("请输入正确手机号");
  71. }
  72. if(!this.model.password) {
  73. return uni.$u.toast("请输入密码");
  74. }
  75. uni.$u.toast("登录成功!");
  76. setTimeout(()=>{
  77. uni.redirectTo({
  78. url:'/pages/index/index'
  79. })
  80. },1000)
  81. }
  82. }
  83. }
  84. // import { computed, watch, ref, reactive, unref } from "vue";
  85. // import sheep from "@/sheep";
  86. // import { mobile, password } from "@/sheep/validate/form";
  87. // import { showAuthModal, closeAuthModal } from "@/sheep/hooks/useModal";
  88. // import { Base64 } from "js-base64";
  89. // const accountLoginRef = ref(null);
  90. // const props = defineProps({
  91. // agreeStatus: {
  92. // type: Boolean,
  93. // default: false,
  94. // },
  95. // });
  96. // // 数据
  97. // const state = reactive({
  98. // model: {
  99. // mobile: "", // 账号
  100. // password: "", // 密码
  101. // },
  102. // rules: {
  103. // mobile,
  104. // password,
  105. // },
  106. // });
  107. // defineExpose({
  108. // accountLoginSubmit,
  109. // });
  110. </script>
  111. <style lang="scss" scoped>
  112. // @import "../index.scss";
  113. .input-line {
  114. display: flex;
  115. align-items: center;
  116. width: 100%;
  117. background-color: #f5f7fb;
  118. border-radius: 16rpx;
  119. padding-left: 30rpx;
  120. height: 88rpx;
  121. box-sizing: border-box;
  122. }
  123. </style>