index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="title-content">
  4. <text class="title">哈密市重点项目<br>建设及工作可视<br>化管理平台</text>
  5. </view>
  6. <view class="login-form-content">
  7. <view class="welcome-text" @click="goToLogin()">
  8. <u-icon name="arrow-left" color="#C6C6CD" size="26"></u-icon>
  9. <text>找回密码</text>
  10. </view>
  11. <view class="item-text">电子邮箱验证</view>
  12. <view class="input-item flex align-center">
  13. <input v-model="emailAddress" class="input" type="text" placeholder="请输入您的电子邮件地址" maxlength="30" />
  14. </view>
  15. <button class="login-btn cu-btn block bg-blue lg round" @click="sendCode()">发送验证码</button>
  16. </view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import {
  21. getCodeImg,
  22. getCheckcode
  23. } from '@/api/login'
  24. import {
  25. ref
  26. } from "vue";
  27. import user from '@/store/modules/user'
  28. import config from '@/config.js'
  29. import store from '@/store'
  30. const codeUrl = ref("");
  31. const captchaEnabled = ref(false);
  32. const globalConfig = ref(config);
  33. const loginForm = ref({
  34. userName: "",
  35. password: ""
  36. });
  37. // 隐私协议
  38. function handlePrivacy() {
  39. let site = globalConfig.value.appInfo.agreements[0];
  40. uni.navigateTo({
  41. url: `/pages/common/webview/index?title=${site.title}&url=${site.url}`
  42. });
  43. };
  44. // 用户协议
  45. function handleUserAgrement() {
  46. let site = globalConfig.value.appInfo.agreements[1]
  47. uni.navigateTo({
  48. url: `/pages/common/webview/index?title=${site.title}&url=${site.url}`
  49. });
  50. };
  51. // 获取图形验证码
  52. function getCode() {
  53. getCodeImg().then(res => {
  54. captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
  55. if (captchaEnabled.value) {
  56. codeUrl.value = 'data:image/gif;base64,' + res.img
  57. loginForm.value.uuid = res.uuid
  58. }
  59. })
  60. };
  61. async function handleLogin() {
  62. if (loginForm.value.userName === "") {
  63. uni.showToast({
  64. title: '请输入您的账号',
  65. mask: false,
  66. duration: 1000
  67. });
  68. } else if (loginForm.value.password === "") {
  69. uni.showToast({
  70. title: '请输入您的密码',
  71. mask: false,
  72. duration: 1000
  73. });
  74. } else {
  75. uni.showToast({
  76. title: '登录中,请耐心等待...',
  77. mask: false,
  78. duration: 1000
  79. });
  80. pwdLogin()
  81. }
  82. };
  83. // 密码登录
  84. async function pwdLogin() {
  85. /* this.$modal.closeLoading() */
  86. store.dispatch('Login', loginForm.value).then(() => {
  87. loginSuccess()
  88. }).catch(() => {
  89. if (captchaEnabled.value) {
  90. getCode()
  91. }
  92. })
  93. };
  94. function loginSuccess(result) {
  95. // 设置用户信息
  96. store.dispatch('GetInfo').then(res => {
  97. uni.switchTab({
  98. url: '/pages/work/index'
  99. });
  100. })
  101. }
  102. function goToLogin() {
  103. uni.navigateBack({})
  104. }
  105. let emailAddress = ref(null)
  106. function sendCode() {
  107. let reg = /^([a-zA-Z\d][\w-]{2,})@(\w{2,})\.([a-z]{2,})(\.[a-z]{2,})?$/;
  108. let isValid = reg.test(emailAddress.value)
  109. if (!isValid) {
  110. return uni.showToast({
  111. title: "邮箱格式不正确",
  112. icon: "error",
  113. duration: 2000
  114. })
  115. }
  116. getCheckcode({
  117. email: emailAddress.value
  118. }).then(res => {
  119. if (res.code === 200) {
  120. uni.navigateTo({
  121. url: `/pages/login/changePass/index?login=none&email=${emailAddress.value}`
  122. })
  123. }
  124. })
  125. }
  126. </script>
  127. <style lang="scss">
  128. page {
  129. height: 100%;
  130. background-color: #EAF0FA;
  131. }
  132. .normal-login-container {
  133. position: relative;
  134. width: 100%;
  135. height: 100%;
  136. background: linear-gradient(108deg, #192DE8 0%, #1DA0FF 53%, #84D8FF 100%);
  137. .title-content {
  138. width: 100%;
  139. height: 46%;
  140. z-index: 1;
  141. background: url('@/static/login_bg.png');
  142. background-size: 100% 100%;
  143. .title {
  144. position: absolute;
  145. top: 8.5%;
  146. left: 7.4%;
  147. font-size: 52rpx;
  148. font-weight: 700;
  149. color: #FFFFFF;
  150. }
  151. }
  152. .login-form-content {
  153. position: absolute;
  154. top: 32%;
  155. left: 0;
  156. width: 100%;
  157. height: 68%;
  158. padding: 40rpx 7%;
  159. background-color: #fff;
  160. border-radius: 40rpx 40rpx 0rpx 0rpx;
  161. .welcome-text {
  162. display: flex;
  163. align-items: center;
  164. margin: 60rpx 0;
  165. font-size: 44rpx;
  166. font-weight: 700;
  167. color: #C6C6CD;
  168. text {
  169. margin-left: 20rpx;
  170. }
  171. }
  172. .item-text {
  173. font-size: 36rpx;
  174. font-weight: 400;
  175. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  176. color: #343437;
  177. }
  178. .input-item {
  179. height: 90rpx;
  180. margin: 20rpx auto 30rpx;
  181. font-size: 28rpx;
  182. background-color: #f5f6f7;
  183. border-radius: 16rpx;
  184. .input {
  185. width: 100%;
  186. font-size: 14px;
  187. line-height: 20px;
  188. text-align: left;
  189. padding-left: 15px;
  190. }
  191. }
  192. .forget-pass-item {
  193. text-align: right;
  194. }
  195. .forget-pass {
  196. color: #1869F6;
  197. border-bottom: 2rpx solid #1869F6;
  198. }
  199. .login-btn {
  200. margin-top: 50rpx;
  201. height: 45px;
  202. background: #1869F6;
  203. border-radius: 16rpx;
  204. }
  205. .xieyi {
  206. color: #333;
  207. margin-top: 20px;
  208. }
  209. .login-code {
  210. height: 38px;
  211. float: right;
  212. .login-code-img {
  213. height: 38px;
  214. position: absolute;
  215. margin-left: 10px;
  216. width: 200rpx;
  217. }
  218. }
  219. }
  220. }
  221. </style>