login_new.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="login-page">
  3. <view class="login-hero"></view>
  4. <view class="login-content">
  5. <view class="status-bar"></view>
  6. <view class="header">
  7. <text class="header-title">登录律师账号</text>
  8. <text class="header-subtitle">请使用手机号接收验证码进行登录</text>
  9. </view>
  10. <view class="form-card">
  11. <view class="field">
  12. <text class="field-label">手机号码</text>
  13. <input class="field-input" type="number" :value="phoneDisplay" placeholder="请输入手机号" maxlength="13"
  14. @input="handlePhoneInput" />
  15. </view>
  16. <button @click="handleLogin" class="primary-btn">获取验证码</button>
  17. <view class="agreement-row" @click="toggleAgreement">
  18. <view :class="['agreement-checkbox', { checked: agreementChecked }]">
  19. <view class="checkbox-inner"></view>
  20. </view>
  21. <text class="agreement-text">
  22. 我已阅读并同意
  23. <text class="link" @click.stop="handleUserAgrement">《用户协议》</text>
  24. <text class="link" @click.stop="handlePrivacy">《隐私政策》</text>
  25. </text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { getToken } from '@/utils/auth'
  33. export default {
  34. data() {
  35. return {
  36. codeUrl: "",
  37. captchaEnabled: true,
  38. register: false,
  39. agreementChecked: true,
  40. phoneDisplay: "",
  41. globalConfig: getApp().globalData.config,
  42. loginForm: {
  43. username: "",
  44. password: "admin123",
  45. code: "",
  46. uuid: ""
  47. }
  48. }
  49. },
  50. onLoad() {
  51. //#ifdef H5
  52. if (getToken()) {
  53. this.$tab.reLaunch('/pages/index')
  54. }
  55. //#endif
  56. },
  57. methods: {
  58. handlePhoneInput(e) {
  59. const raw = (e.detail.value || '').replace(/\D/g, '').slice(0, 11)
  60. this.loginForm.username = raw
  61. if (raw.length > 7) {
  62. this.phoneDisplay = raw.replace(/(\d{3})(\d{4})(\d{0,4})/, '$1 $2 $3').trim()
  63. } else if (raw.length > 3) {
  64. this.phoneDisplay = raw.replace(/(\d{3})(\d{0,4})/, '$1 $2').trim()
  65. } else {
  66. this.phoneDisplay = raw
  67. }
  68. },
  69. toggleAgreement() {
  70. this.agreementChecked = !this.agreementChecked
  71. },
  72. handleUserRegister() {
  73. this.$tab.redirectTo(`/pages/register`)
  74. },
  75. handlePrivacy() {
  76. let site = this.globalConfig.appInfo.agreements[0]
  77. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  78. },
  79. handleUserAgrement() {
  80. let site = this.globalConfig.appInfo.agreements[1]
  81. this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
  82. },
  83. getCode() {
  84. getCodeImg().then(res => {
  85. this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  86. if (this.captchaEnabled) {
  87. this.codeUrl = 'data:image/gif;base64,' + res.img
  88. this.loginForm.uuid = res.uuid
  89. }
  90. })
  91. },
  92. handleLogin() {
  93. uni.reLaunch({
  94. url: '/pages/index',
  95. success: () => {
  96. console.log('跳转成功')
  97. },
  98. fail: (err) => {
  99. console.error('跳转失败:', err)
  100. // 如果 reLaunch 失败,尝试使用 navigateTo
  101. uni.navigateTo({
  102. url: '/pages/index',
  103. fail: (err2) => {
  104. console.error('navigateTo 也失败:', err2)
  105. }
  106. })
  107. }
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. page {
  115. background-color: #eaf3ff;
  116. }
  117. .login-page {
  118. position: relative;
  119. min-height: 100vh;
  120. width: 100%;
  121. overflow: hidden;
  122. background: url('../static/login/login-bg.png') no-repeat center center;
  123. }
  124. .login-bg {
  125. position: absolute;
  126. right: 0;
  127. top: 0;
  128. width: 100%;
  129. height: 100%;
  130. z-index: 0;
  131. }
  132. .login-hero {
  133. position: absolute;
  134. width: 360px;
  135. height: 580px;
  136. background: url('../static/login/login-illustration.png') no-repeat;
  137. background-size: 100% 100%;
  138. right: 0rpx;
  139. top: 40rpx;
  140. }
  141. .login-content {
  142. padding: 470rpx 40rpx 0;
  143. display: flex;
  144. flex-direction: column;
  145. box-sizing: border-box;
  146. }
  147. .status-bar {
  148. height: var(--status-bar-height, 0px);
  149. }
  150. .header {
  151. display: flex;
  152. flex-direction: column;
  153. }
  154. .header-title {
  155. font-size: 50rpx;
  156. font-weight: 600;
  157. color: #19274b;
  158. line-height: 1.2;
  159. }
  160. .header-subtitle {
  161. margin-top: 24rpx;
  162. font-size: 26rpx;
  163. color: rgba(25, 39, 75, 0.68);
  164. line-height: 1.6;
  165. }
  166. .form-card {
  167. z-index: 9;
  168. margin-top: 160rpx;
  169. width: 100%;
  170. box-sizing: border-box;
  171. }
  172. .field {
  173. width: 100%;
  174. display: flex;
  175. flex-direction: column;
  176. }
  177. .field-label {
  178. font-size: 26rpx;
  179. color: #151515;
  180. font-size: 28rpx;
  181. margin-bottom: 18rpx;
  182. }
  183. .field-input {
  184. text-align: center;
  185. width: 100%;
  186. height: 102rpx;
  187. border-radius: 28rpx;
  188. background: rgba(255, 255, 255, 0.7);
  189. border: 1px solid rgba(47, 94, 187, 0.08);
  190. box-shadow: inset 0 4rpx 12rpx rgba(41, 94, 187, 0.06);
  191. padding: 0 36rpx;
  192. box-sizing: border-box;
  193. font-size: 28rpx;
  194. color: #AAA;
  195. letter-spacing: 6rpx;
  196. }
  197. .field-input::placeholder {
  198. color: #AAA;
  199. letter-spacing: 6rpx;
  200. opacity: 0.7;
  201. }
  202. .primary-btn {
  203. margin-top: 44rpx;
  204. width: 100%;
  205. height: 100rpx;
  206. border-radius: 28rpx;
  207. background: linear-gradient(90deg, #3677E9 0%, #2856C7 100%);
  208. color: #ffffff;
  209. font-size: 28rpx;
  210. font-weight: 500;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. border: none;
  215. box-shadow: 0 20rpx 40rpx rgba(38, 104, 255, 0.35);
  216. }
  217. .agreement-row {
  218. position: fixed;
  219. bottom: 100rpx;
  220. left: 0;
  221. width: 100%;
  222. box-sizing: border-box;
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. }
  227. .agreement-checkbox {
  228. width: 30rpx;
  229. height: 30rpx;
  230. margin-right: 8rpx;
  231. border-radius: 50%;
  232. border: 1px solid rgba(35, 96, 255, 0.5);
  233. background: rgba(250, 252, 255, 0.8);
  234. display: flex;
  235. align-items: center;
  236. justify-content: center;
  237. }
  238. .agreement-checkbox.checked {
  239. background: linear-gradient(140deg, #3c7dff 0%, #235aff 100%);
  240. border: none;
  241. }
  242. .checkbox-inner {
  243. width: 16rpx;
  244. height: 16rpx;
  245. border-radius: 50%;
  246. background: #ffffff;
  247. opacity: 0;
  248. }
  249. .agreement-checkbox.checked .checkbox-inner {
  250. opacity: 1;
  251. }
  252. .agreement-text {
  253. font-size: 24rpx;
  254. color: rgba(34, 52, 91, 0.75);
  255. line-height: 1.5;
  256. }
  257. .agreement-text .link {
  258. color: #2360ff;
  259. margin: 0 6rpx;
  260. }
  261. </style>