综合办公系统
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

login.vue 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content align-center justify-center flex">
  4. <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
  5. </image>
  6. <text class="title">CMC综合办公系统</text>
  7. </view>
  8. <view class="login-form-content">
  9. <view class="input-item flex align-center">
  10. <view class="iconfont icon-user icon"></view>
  11. <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
  12. </view>
  13. <view class="input-item flex align-center">
  14. <view class="iconfont icon-password icon"></view>
  15. <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
  16. </view>
  17. <!-- <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
  18. <view class="iconfont icon-code icon"></view>
  19. <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
  20. <view class="login-code">
  21. <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
  22. </view >
  23. </view> -->
  24. <view class="action-btn">
  25. <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
  26. </view>
  27. </view>
  28. <!-- <view class="xieyi text-center">
  29. <text class="text-grey1">登录即代表同意</text>
  30. <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
  31. <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
  32. </view> -->
  33. </view>
  34. </template>
  35. <script>
  36. import { getCodeImg } from '@/api/login'
  37. export default {
  38. data() {
  39. return {
  40. codeUrl: "",
  41. captchaEnabled: true,
  42. globalConfig: getApp().globalData.config,
  43. loginForm: {
  44. username: "admin",
  45. password: "admin123",
  46. code: "",
  47. uuid: ''
  48. }
  49. }
  50. },
  51. created() {
  52. this.getCode()
  53. },
  54. methods: {
  55. // 隐私协议
  56. handlePrivacy() {
  57. let site = this.globalConfig.appInfo.agreements[0]
  58. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  59. },
  60. // 用户协议
  61. handleUserAgrement() {
  62. let site = this.globalConfig.appInfo.agreements[1]
  63. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  64. },
  65. // 获取图形验证码
  66. getCode() {
  67. getCodeImg().then(res => {
  68. this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  69. if (this.captchaEnabled) {
  70. this.codeUrl = 'data:image/gif;base64,' + res.img
  71. this.loginForm.uuid = res.uuid
  72. }
  73. })
  74. },
  75. // 登录方法
  76. async handleLogin() {
  77. if (this.loginForm.username === "") {
  78. this.$modal.msgError("请输入您的账号")
  79. } else if (this.loginForm.password === "") {
  80. this.$modal.msgError("请输入您的密码")
  81. }
  82. // else if (this.loginForm.code === "" && this.captchaEnabled) {
  83. // this.$modal.msgError("请输入验证码")
  84. // }
  85. else {
  86. this.$modal.loading("登录中,请耐心等待...")
  87. this.pwdLogin()
  88. }
  89. },
  90. // 密码登录
  91. async pwdLogin() {
  92. this.$store.dispatch('Login', this.loginForm).then(() => {
  93. this.$modal.closeLoading()
  94. this.loginSuccess()
  95. }).catch(() => {
  96. if (this.captchaEnabled) {
  97. this.getCode()
  98. }
  99. })
  100. },
  101. // 登录成功后,处理函数
  102. loginSuccess(result) {
  103. // 设置用户信息
  104. this.$store.dispatch('GetInfo').then(res => {
  105. this.$tab.reLaunch('/pages/message/index')
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. page {
  113. background-color: #ffffff;
  114. }
  115. .normal-login-container {
  116. width: 100%;
  117. .logo-content {
  118. width: 100%;
  119. font-size: 21px;
  120. text-align: center;
  121. padding-top: 15%;
  122. image {
  123. border-radius: 4px;
  124. }
  125. .title {
  126. margin-left: 10px;
  127. }
  128. }
  129. .login-form-content {
  130. text-align: center;
  131. margin: 20px auto;
  132. margin-top: 15%;
  133. width: 80%;
  134. .input-item {
  135. margin: 20px auto;
  136. background-color: #f5f6f7;
  137. height: 45px;
  138. border-radius: 20px;
  139. .icon {
  140. font-size: 38rpx;
  141. margin-left: 10px;
  142. color: #999;
  143. }
  144. .input {
  145. width: 100%;
  146. font-size: 14px;
  147. line-height: 20px;
  148. text-align: left;
  149. padding-left: 15px;
  150. }
  151. }
  152. .login-btn {
  153. margin-top: 40px;
  154. height: 45px;
  155. }
  156. .xieyi {
  157. color: #333;
  158. margin-top: 20px;
  159. }
  160. .login-code {
  161. height: 38px;
  162. float: right;
  163. .login-code-img {
  164. height: 38px;
  165. position: absolute;
  166. margin-left: 10px;
  167. width: 200rpx;
  168. }
  169. }
  170. }
  171. }
  172. </style>