综合办公系统
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

login.vue 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 class="copyright-info">©2025 CMC智联云枢办公系统 版权所有</view>
  34. </view>
  35. </template>
  36. <script>
  37. import { getCodeImg } from '@/api/login'
  38. export default {
  39. data() {
  40. return {
  41. codeUrl: "",
  42. captchaEnabled: true,
  43. globalConfig: getApp().globalData.config,
  44. loginForm: {
  45. username: "",
  46. password: "",
  47. code: "",
  48. uuid: ''
  49. }
  50. }
  51. },
  52. created() {
  53. this.getCode()
  54. },
  55. methods: {
  56. // 隐私协议
  57. handlePrivacy() {
  58. let site = this.globalConfig.appInfo.agreements[0]
  59. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  60. },
  61. // 用户协议
  62. handleUserAgrement() {
  63. let site = this.globalConfig.appInfo.agreements[1]
  64. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  65. },
  66. // 获取图形验证码
  67. getCode() {
  68. getCodeImg().then(res => {
  69. this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  70. if (this.captchaEnabled) {
  71. this.codeUrl = 'data:image/gif;base64,' + res.img
  72. this.loginForm.uuid = res.uuid
  73. }
  74. })
  75. },
  76. // 登录方法
  77. async handleLogin() {
  78. if (this.loginForm.username === "") {
  79. this.$modal.msgError("请输入您的账号")
  80. } else if (this.loginForm.password === "") {
  81. this.$modal.msgError("请输入您的密码")
  82. }
  83. // else if (this.loginForm.code === "" && this.captchaEnabled) {
  84. // this.$modal.msgError("请输入验证码")
  85. // }
  86. else {
  87. this.$modal.loading("登录中,请耐心等待...")
  88. this.pwdLogin()
  89. }
  90. },
  91. // 密码登录
  92. async pwdLogin() {
  93. this.$store.dispatch('Login', this.loginForm).then(() => {
  94. this.$modal.closeLoading()
  95. this.loginSuccess()
  96. }).catch(() => {
  97. if (this.captchaEnabled) {
  98. this.getCode()
  99. }
  100. })
  101. },
  102. // 登录成功后,处理函数
  103. loginSuccess(result) {
  104. // 设置用户信息
  105. this.$store.dispatch('GetInfo').then(res => {
  106. this.$tab.reLaunch('/pages/message/index')
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. page {
  114. background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
  115. min-height: 100vh;
  116. position: relative;
  117. overflow: hidden;
  118. &::before,
  119. &::after {
  120. content: '';
  121. position: absolute;
  122. width: 300px;
  123. height: 300px;
  124. border-radius: 50%;
  125. z-index: 0;
  126. }
  127. &::before {
  128. background: linear-gradient(45deg, rgba(33, 150, 243, 0.1), rgba(25, 118, 210, 0.1));
  129. top: -100px;
  130. right: -100px;
  131. animation: float 6s ease-in-out infinite;
  132. }
  133. &::after {
  134. background: linear-gradient(45deg, rgba(33, 150, 243, 0.08), rgba(25, 118, 210, 0.08));
  135. bottom: -150px;
  136. left: -150px;
  137. animation: float 8s ease-in-out infinite reverse;
  138. }
  139. }
  140. .normal-login-container {
  141. width: 100%;
  142. padding: 0 30rpx;
  143. box-sizing: border-box;
  144. position: relative;
  145. z-index: 1;
  146. min-height: 100vh;
  147. display: flex;
  148. flex-direction: column;
  149. &::before {
  150. content: '';
  151. position: absolute;
  152. top: 50%;
  153. left: 50%;
  154. transform: translate(-50%, -50%);
  155. width: 600px;
  156. height: 600px;
  157. background: radial-gradient(circle, rgba(33, 150, 243, 0.03) 0%, rgba(33, 150, 243, 0) 70%);
  158. z-index: -1;
  159. }
  160. .logo-content {
  161. width: 100%;
  162. font-size: 21px;
  163. text-align: center;
  164. padding-top: 25%;
  165. animation: fadeInDown 0.8s ease-out;
  166. image {
  167. border-radius: 12px;
  168. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  169. transition: transform 0.3s ease;
  170. &:hover {
  171. transform: scale(1.05);
  172. }
  173. }
  174. .title {
  175. margin-left: 10px;
  176. background: linear-gradient(45deg, #2196F3, #1976D2);
  177. -webkit-background-clip: text;
  178. color: transparent;
  179. font-weight: 600;
  180. }
  181. }
  182. .login-form-content {
  183. text-align: center;
  184. margin: 20px auto;
  185. margin-top: 10%;
  186. width: 90%;
  187. animation: fadeInUp 0.8s ease-out;
  188. .input-item {
  189. margin: 20px auto;
  190. background-color: rgba(255, 255, 255, 0.9);
  191. height: 45px;
  192. border-radius: 25px;
  193. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  194. transition: all 0.3s ease;
  195. border: 1px solid transparent;
  196. &:focus-within {
  197. border-color: #2196F3;
  198. box-shadow: 0 2px 12px rgba(33, 150, 243, 0.1);
  199. }
  200. .icon {
  201. font-size: 38rpx;
  202. margin-left: 20px;
  203. color: #2196F3;
  204. }
  205. .input {
  206. width: 100%;
  207. font-size: 14px;
  208. line-height: 20px;
  209. text-align: left;
  210. padding-left: 15px;
  211. color: #333;
  212. &::placeholder {
  213. color: #999;
  214. }
  215. }
  216. }
  217. .login-btn {
  218. margin-top: 40px;
  219. height: 45px;
  220. background: linear-gradient(45deg, #2196F3, #1976D2);
  221. border: none;
  222. font-weight: 600;
  223. letter-spacing: 1px;
  224. transition: all 0.3s ease;
  225. box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
  226. &:active {
  227. transform: translateY(2px);
  228. box-shadow: 0 2px 6px rgba(33, 150, 243, 0.2);
  229. }
  230. }
  231. }
  232. }
  233. .copyright-info {
  234. width: 100%;
  235. text-align: center;
  236. position: fixed;
  237. left: 0;
  238. bottom: 30rpx;
  239. color: #666;
  240. font-size: 22rpx;
  241. letter-spacing: 1rpx;
  242. z-index: 1;
  243. opacity: 0.8;
  244. }
  245. @keyframes float {
  246. 0%, 100% {
  247. transform: translateY(0) rotate(0deg);
  248. }
  249. 50% {
  250. transform: translateY(-20px) rotate(5deg);
  251. }
  252. }
  253. @keyframes fadeInDown {
  254. from {
  255. opacity: 0;
  256. transform: translateY(-20px);
  257. }
  258. to {
  259. opacity: 1;
  260. transform: translateY(0);
  261. }
  262. }
  263. @keyframes fadeInUp {
  264. from {
  265. opacity: 0;
  266. transform: translateY(20px);
  267. }
  268. to {
  269. opacity: 1;
  270. transform: translateY(0);
  271. }
  272. }
  273. </style>