index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!-- 蓝色简洁登录页面 -->
  2. <template class="denglu">
  3. <view class="t-login">
  4. <!-- 标题 -->
  5. <view class="t-b">
  6. <image class="logo" src="~@/static/img/logo.png"></image>
  7. </view>
  8. <view class="t-b2">{{ subTitle }}</view>
  9. <form>
  10. <!-- 登录账号 -->
  11. <view class="login-form-item">
  12. <u-input v-model="username" placeholder="请输入登录用户名" maxlength="30">
  13. <u-icon color="#E60012" slot="prefix" name="account" size="25px"></u-icon>
  14. </u-input>
  15. </view>
  16. <!-- 登录密码 -->
  17. <view class="login-form-item">
  18. <u-input v-model="password" type="password" placeholder="请输入登录密码" maxlength="16">
  19. <u-icon color="#E60012" slot="prefix" name="lock" size="25px"></u-icon>
  20. </u-input>
  21. </view>
  22. <!-- 图形验证码 -->
  23. <view class="login-form-item t-captcha" v-if="false">
  24. <u-input v-model="captchaCode" type="number" placeholder="请输入验证码" maxlength="4">
  25. <u-icon slot="prefix" name="fingerprint" size="35px"></u-icon>
  26. </u-input>
  27. <image :src="captcha" @click="getCaptcha" class="t-captcha-img"></image>
  28. </view>
  29. <button class="login-button" @tap="login()">登 录</button>
  30. </form>
  31. </view>
  32. </template>
  33. <script>
  34. import * as CaptchaApi from '@/api/captcha'
  35. import {
  36. isEmpty
  37. } from '@/utils/verify.js'
  38. export default {
  39. data() {
  40. return {
  41. // subTitle: 'Global Project Management Syste',
  42. subTitle: '全球项目管理平台',
  43. // 图形验证码信息
  44. captcha: null,
  45. // 登录账号
  46. username: 'admin',
  47. // 密码
  48. password: 'admin123',
  49. // 图形验证码
  50. captchaCode: '',
  51. uuid: '',
  52. //是否开启验证码
  53. captchaEnabled: false
  54. };
  55. },
  56. created() {
  57. // 获取图形验证码
  58. this.getCaptcha()
  59. },
  60. methods: {
  61. // 获取图形验证码
  62. getCaptcha() {
  63. const app = this
  64. CaptchaApi.image().then(result => {
  65. let {
  66. captchaEnabled
  67. } = result
  68. app.captchaEnabled = captchaEnabled
  69. if (captchaEnabled) {
  70. app.captcha = 'data:image/gif;base64,' + result.img
  71. app.uuid = result.uuid
  72. }
  73. })
  74. },
  75. // 验证表单内容
  76. validItem() {
  77. const app = this
  78. if (isEmpty(app.username)) {
  79. uni.$u.toast('请输入登录用户名')
  80. return false
  81. }
  82. if (isEmpty(app.password)) {
  83. uni.$u.toast('请输入登录密码')
  84. return false
  85. }
  86. return true
  87. },
  88. // 确认登录
  89. login() {
  90. const app = this
  91. let valid = app.validItem();
  92. if (valid) {
  93. app.isLoading = true
  94. app.$store.dispatch('Login', {
  95. username: app.username,
  96. password: app.password,
  97. code: app.captchaCode,
  98. uuid: app.uuid
  99. }).then(result => {
  100. // uni.switchTab({
  101. // url: '/pages/work/index',
  102. // fail(err) {
  103. // console.log(err)
  104. // }
  105. // })
  106. // 直接跳转审批页面
  107. uni.navigateTo({
  108. url: '/pages/work/approve/list',
  109. fail(err) {
  110. console.log(err)
  111. }
  112. })
  113. })
  114. .catch(err => {
  115. app.captchaCode = ''
  116. app.getCaptcha()
  117. })
  118. .finally(() => app.isLoading = false)
  119. }
  120. },
  121. }
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. @import 'index.scss';
  126. page {
  127. background: linear-gradient(181deg, rgba(255, 224, 224, 0.17) 0%, rgba(252, 247, 247, 0.84) 18%, #FFFFFF 100%);
  128. overflow-y: hidden;
  129. }
  130. </style>