index.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <app-statusbar class="login">
  3. <div class="login-logo">铁合金掌上行</div>
  4. <Form class="login-form" @submit="formSubmit">
  5. <CellGroup>
  6. <Field v-model="user.LoginID" name="account" label="用户名" size="large" placeholder="请输入用户名"
  7. :rules="[{ required: true, message: '请输入用户名' }]" />
  8. <Field v-model="user.LoginPWD" name="password" type="password" label="密码" size="large" placeholder="请输入密码"
  9. :rules="[{ required: true, message: '请输入密码' }]" autocomplete="off" />
  10. </CellGroup>
  11. <div class="button-link">
  12. <span @click="navigationTo('register')">用户注册</span>
  13. <span @click="navigationTo('forget')">忘记密码</span>
  14. </div>
  15. <div class="button-submit">
  16. <Button type="primary" native-type="submit" round block>登录</Button>
  17. </div>
  18. </Form>
  19. <div class="login-footer">
  20. <Checkbox shape="square" icon-size=".32rem" v-model="checked">我已阅读并同意</Checkbox>
  21. <span @click="routerTo('rules-zcxy')" style="color:#E92020">《用户注册协议》</span>
  22. <span>和</span>
  23. <span @click="routerTo('rules-yhkhfxgzs')" style="color:#E92020">《用户开户风险告知书》</span>
  24. <span>和</span>
  25. <span @click="routerTo('rules-yszc')" style="color:#E92020">《隐私政策》</span>
  26. </div>
  27. </app-statusbar>
  28. </template>
  29. <script lang="ts" setup>
  30. import { shallowRef } from 'vue'
  31. import { useRoute, useRouter } from 'vue-router'
  32. import { Button, Field, CellGroup, Form, Checkbox, Toast } from 'vant'
  33. import { fullloading } from '@/utils/vant'
  34. import { useAuth } from '@/business/auth'
  35. import { useNavigation } from '@/hooks/navigation'
  36. import service from '@/services'
  37. const { routerTo } = useNavigation()
  38. const { user, login } = useAuth()
  39. const route = useRoute()
  40. const router = useRouter()
  41. const checked = shallowRef(false) // 是否同意协议管理
  42. // 导航跳转
  43. const navigationTo = (name: string) => {
  44. fullloading((hideLoading) => {
  45. service.onReady().then(() => {
  46. hideLoading()
  47. routerTo(name)
  48. }).catch(() => {
  49. Toast.fail('初始化失败')
  50. })
  51. }, '加载中...')
  52. }
  53. const formSubmit = () => {
  54. if (checked.value) {
  55. fullloading((hideLoading) => {
  56. login().then(() => {
  57. hideLoading()
  58. const redirect = route.query.redirect
  59. if (redirect) {
  60. router.replace(redirect.toString())
  61. } else {
  62. router.replace('/')
  63. }
  64. }).catch((err) => {
  65. Toast.fail(err)
  66. })
  67. }, '登录中...')
  68. } else {
  69. Toast('请先同意使用条款')
  70. }
  71. }
  72. </script>
  73. <style lang="less" scoped>
  74. @import './index.less';
  75. </style>