login.27932eb5.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. import { c as h, R as r, C as i, I as c } from './validate.598a2b58.js'
  2. import {
  3. d as f,
  4. s,
  5. f as g,
  6. g as d,
  7. h as C,
  8. i as T,
  9. j as y,
  10. k as t,
  11. l as a,
  12. B as m
  13. } from './index.879f7421.js'
  14. import { C as S } from './index.4aec72fa.js'
  15. import { C as D } from './index.fe392820.js'
  16. import { F as u } from './index.00975bf6.js'
  17. import './index.c463dbd0.js'
  18. import './index.9a3a3b84.js'
  19. const w = '_login_y7mb5_1',
  20. _ = '_loginTitle_y7mb5_7',
  21. b = '_codeText_y7mb5_15',
  22. F = '_margin34_y7mb5_18',
  23. x = '_formTitle_y7mb5_21'
  24. var o = { login: w, loginTitle: _, codeText: b, margin34: F, formTitle: x },
  25. N = f({
  26. name: 'login',
  27. data() {
  28. return {
  29. loginType: 'SMS',
  30. username: '',
  31. password: '',
  32. smsCode: '',
  33. countDownStatus: !0,
  34. countDownTime: 1e3 * 120,
  35. imgCodeStatus: !1
  36. }
  37. },
  38. computed: {
  39. codeDisable() {
  40. let e = !0
  41. return (
  42. this.loginType === 'PWD'
  43. ? this.username && this.password && (e = !1)
  44. : this.username && this.smsCode && (e = !1),
  45. e
  46. )
  47. },
  48. appName() {
  49. return {
  50. STUDENT: '\u5B66\u751F\u7AEF',
  51. TEACHER: '\u8001\u5E08\u7AEF',
  52. SCHOOL: '\u7BA1\u7406\u7AEF'
  53. }[s.platformType]
  54. }
  55. },
  56. mounted() {
  57. g(), this.directNext()
  58. },
  59. methods: {
  60. directNext() {
  61. if (s.user.status === 'login' || s.user.status === 'error') {
  62. const { returnUrl: e, isRegister: l, ...n } = this.$route.query
  63. this.$router.replace({ path: e, query: { ...n } })
  64. }
  65. },
  66. async onLogin() {
  67. try {
  68. const e = {
  69. username: this.username,
  70. client_id: s.clientId[s.platformType],
  71. client_secret: s.clientId[s.platformType]
  72. }
  73. this.loginType === 'PWD'
  74. ? ((e.password = this.password),
  75. (e.loginType = 'PASSWORD'),
  76. (e.grant_type = 'PASSWORD'))
  77. : ((e.password = this.smsCode), (e.loginType = 'SMS'), (e.grant_type = 'SMS'))
  78. const { data: l } = await d.post('/api-oauth/userlogin', {
  79. requestType: 'form',
  80. data: { ...e }
  81. })
  82. C(l.token_type + ' ' + l.access_token)
  83. const n = await d.get(s.platformApi + '/user/getUserInfo', { initRequest: !0 })
  84. if (s.platformType === 'SCHOOL') {
  85. const p = n.data.schoolInfos ? n.data.schoolInfos[0] : {}
  86. n.data.school = p
  87. }
  88. T(n.data), this.directNext()
  89. } catch {}
  90. },
  91. async onSendCode() {
  92. if (!h(this.username))
  93. return y('\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u7801')
  94. this.imgCodeStatus = !0
  95. },
  96. onCodeSend() {
  97. ;(this.countDownStatus = !1),
  98. this.$nextTick(() => {
  99. this.$refs.countDownRef.start()
  100. })
  101. },
  102. onFinished() {
  103. ;(this.countDownStatus = !0), this.$refs.countDownRef.reset()
  104. },
  105. onChange() {
  106. this.loginType === 'PWD'
  107. ? (this.loginType = 'SMS')
  108. : this.loginType === 'SMS' && (this.loginType = 'PWD')
  109. }
  110. },
  111. render() {
  112. return t('div', { class: o.login }, [
  113. t('div', { class: o.loginTitle }, [
  114. a('\u60A8\u597D\uFF0C'),
  115. t('br', null, null),
  116. a(' \u6B22\u8FCE\u4F7F\u7528\u7BA1\u4E50\u56E2'),
  117. this.appName
  118. ]),
  119. t(
  120. S,
  121. { class: o.margin34, border: !1 },
  122. {
  123. default: () => [
  124. t(
  125. r,
  126. { style: { marginBottom: '16px' } },
  127. {
  128. default: () => [
  129. t(
  130. i,
  131. { span: 24, class: o.formTitle },
  132. { default: () => [a('\u624B\u673A\u53F7')] }
  133. ),
  134. t(
  135. i,
  136. { span: 24, class: 'van-hairline--bottom' },
  137. {
  138. default: () => [
  139. t(
  140. u,
  141. {
  142. modelValue: this.username,
  143. 'onUpdate:modelValue': (e) => (this.username = e),
  144. name: '\u624B\u673A\u53F7',
  145. placeholder: '\u8BF7\u8F93\u5165\u60A8\u7684\u624B\u673A\u53F7',
  146. type: 'tel',
  147. maxlength: 11
  148. },
  149. null
  150. )
  151. ]
  152. }
  153. )
  154. ]
  155. }
  156. ),
  157. this.loginType === 'PWD'
  158. ? t(r, null, {
  159. default: () => [
  160. t(
  161. i,
  162. { span: 24, class: o.formTitle },
  163. { default: () => [a('\u5BC6\u7801')] }
  164. ),
  165. t(
  166. i,
  167. { span: 24, class: 'van-hairline--bottom' },
  168. {
  169. default: () => [
  170. t(
  171. u,
  172. {
  173. modelValue: this.password,
  174. 'onUpdate:modelValue': (e) => (this.password = e),
  175. type: 'password',
  176. name: '\u5BC6\u7801',
  177. placeholder: '\u8BF7\u8F93\u5165\u5BC6\u7801'
  178. },
  179. null
  180. )
  181. ]
  182. }
  183. )
  184. ]
  185. })
  186. : t(r, null, {
  187. default: () => [
  188. t(
  189. i,
  190. { span: 24, class: o.formTitle },
  191. { default: () => [a('\u9A8C\u8BC1\u7801')] }
  192. ),
  193. t(
  194. i,
  195. { span: 24, class: 'van-hairline--bottom' },
  196. {
  197. default: () => [
  198. t(
  199. u,
  200. {
  201. modelValue: this.smsCode,
  202. 'onUpdate:modelValue': (e) => (this.smsCode = e),
  203. name: '\u9A8C\u8BC1\u7801',
  204. placeholder: '\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801',
  205. type: 'tel',
  206. maxlength: 6
  207. },
  208. {
  209. button: () =>
  210. this.countDownStatus
  211. ? t('span', { class: o.codeText, onClick: this.onSendCode }, [
  212. a('\u83B7\u53D6\u9A8C\u8BC1\u7801')
  213. ])
  214. : t(
  215. D,
  216. {
  217. ref: 'countDownRef',
  218. 'auto-start': !1,
  219. time: this.countDownTime,
  220. onFinish: this.onFinished,
  221. format: 'ss\u79D2'
  222. },
  223. null
  224. )
  225. }
  226. )
  227. ]
  228. }
  229. )
  230. ]
  231. })
  232. ]
  233. }
  234. ),
  235. t('div', { class: o.margin34 }, [
  236. t(
  237. m,
  238. {
  239. round: !0,
  240. block: !0,
  241. type: 'primary',
  242. disabled: this.codeDisable,
  243. onClick: this.onLogin
  244. },
  245. { default: () => [a('\u63D0\u4EA4')] }
  246. ),
  247. t(
  248. m,
  249. { block: !0, round: !0, color: '#F5F7FB', onClick: this.onChange },
  250. {
  251. default: () => [
  252. this.loginType === 'PWD'
  253. ? '\u9A8C\u8BC1\u7801\u767B\u5F55'
  254. : '\u5BC6\u7801\u767B\u5F55'
  255. ]
  256. }
  257. )
  258. ]),
  259. this.imgCodeStatus
  260. ? t(
  261. c,
  262. {
  263. value: this.imgCodeStatus,
  264. 'onUpdate:value': (e) => (this.imgCodeStatus = e),
  265. phone: this.username,
  266. onClose: () => {
  267. this.imgCodeStatus = !1
  268. },
  269. onSendCode: this.onCodeSend
  270. },
  271. null
  272. )
  273. : null
  274. ])
  275. }
  276. })
  277. export { N as default }