loginActive.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="login" :style="{ minHeight: bodyHeight + 'px' }">
  3. <div class="section">
  4. <h2>手机号</h2>
  5. <van-cell-group class="form-container top">
  6. <van-field v-model="form.phone"
  7. center
  8. clearable
  9. placeholder="请输入手机号" >
  10. </van-field>
  11. </van-cell-group>
  12. <h2>验证码</h2>
  13. <van-cell-group class="form-container">
  14. <van-field v-model="form.code" center
  15. clearable
  16. placeholder="请输入短信验证码" >
  17. <van-button slot="button" @click="sendCode" size="small" type="primary">{{ smsText }}</van-button>
  18. </van-field>
  19. </van-cell-group>
  20. <div class="btn-group">
  21. <van-button size="large" @click="onSubmit" class="btn">登录</van-button>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. /* eslint-disable */
  28. import qs from 'qs'
  29. export default {
  30. name: 'login',
  31. data() {
  32. return {
  33. bodyHeight: 0,
  34. popupStatus: false,
  35. popupCodeStatus: false, // 发送验证码弹窗
  36. smsText: '发送验证码',
  37. popupText: '',
  38. codeStatus: true, // 是否可以发送验证码
  39. btnStatus: true,
  40. form: {
  41. phone: null,
  42. code: null
  43. }
  44. }
  45. },
  46. created() {
  47. this.bodyHeight = document.documentElement.clientHeight
  48. },
  49. mounted() {
  50. },
  51. methods: {
  52. codeBlur() {
  53. setTimeout(() => {
  54. const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
  55. window.scrollTo(0, Math.max(scrollHeight - 1, 0));
  56. }, 100);
  57. },
  58. onSubmit() {
  59. let form = this.form
  60. if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(form.phone))){
  61. this.$toast('手机号输入有误')
  62. return false;
  63. }
  64. this.$axios.get(`/user/getMecUser?phone=${form.phone}&smsCode=${form.code}`).then((response) => {
  65. let result = response.data
  66. console.log(result)
  67. if(result.code == 200) {
  68. this.$router.push({
  69. path: '/activePay/' + new Date().getTime(),
  70. query: {
  71. userId: result.data.userId,
  72. branchId: result.data.branchId
  73. }
  74. })
  75. } else {
  76. this.$toast(result.msg)
  77. }
  78. })
  79. },
  80. checkCode() {
  81. let params = this.$route.query
  82. let code = this.form.code
  83. if(code.length >= 6) {
  84. this.$axios.post('/user/verifySmsCode', qs.stringify({
  85. smsCode: code,
  86. mobile: this.form.phone
  87. })).then(res => {
  88. let result = res.data
  89. if(result.status) {
  90. this.$router.push({
  91. path: 'register',
  92. query: {
  93. phone: this.form.phone,
  94. cityId: params.cityId,
  95. classId: this.dataList.classId,
  96. schoolId: params.schoolId,
  97. status: this.dataList.status, // 当前乐团状态
  98. schoolName: this.dataList.schoolName,
  99. branchId: this.dataList.branchId
  100. }
  101. })
  102. } else {
  103. this.$toast('验证码输入有误')
  104. this.form.code = ''
  105. }
  106. })
  107. }
  108. },
  109. sendCode() {
  110. if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.form.phone))){
  111. this.$toast('手机号输入有误')
  112. return false;
  113. }
  114. // 发送短信验证码
  115. if(!this.codeStatus) {
  116. return false
  117. }
  118. this.$axios.get('/user/sendSmsCode?mobile=' + this.form.phone).then(res => {
  119. let result = res.data
  120. this.codeStatus = false
  121. this.CountDown()
  122. })
  123. },
  124. CountDown() {
  125. let s = 120
  126. this.smsText = s + '秒'
  127. let timer = setInterval(() => {
  128. if(s <= 0) {
  129. this.codeStatus = true
  130. this.smsText = '发送验证码'
  131. clearInterval(timer)
  132. } else {
  133. s--
  134. this.smsText = s + '秒'
  135. }
  136. }, 1000)
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="less" scoped>
  142. .login {
  143. width: 100vw;
  144. height: 100vh;
  145. background: url('../assets/bg1.png') no-repeat left top;
  146. background-size: cover;
  147. overflow: hidden;
  148. position: relative;
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. }
  153. .section {
  154. padding: 0 .25rem;
  155. transform: translateY(.7rem);
  156. h2 {
  157. font-size: .16rem;
  158. color: #FFFFFF;
  159. }
  160. }
  161. .form-container {
  162. background: transparent;
  163. &.top {
  164. margin-bottom: .3rem;
  165. }
  166. .van-cell {
  167. background: transparent;
  168. padding-left: 0;
  169. border-bottom: 1px solid #fff;
  170. /deep/.van-field__control {
  171. font-size: .16rem;
  172. color: #fff;
  173. }
  174. }
  175. }
  176. /deep/.van-hairline--top-bottom::after, /deep/.van-hairline-unset--top-bottom::after {
  177. border-width: 0;
  178. }
  179. /deep/.van-button--primary {
  180. background: transparent;
  181. border: 1px solid #fff;
  182. border-radius: 30px;
  183. }
  184. .btn {
  185. margin-top: .3rem;
  186. margin-bottom: .2rem;
  187. border-radius: 1rem;
  188. background:linear-gradient(270deg,rgba(242,209,163,1) 0%,rgba(188,130,76,1) 100%);
  189. border: 0;
  190. color: #fff;
  191. font-size: .18rem;
  192. }
  193. input, textarea {
  194. -webkit-user-select: auto!important;
  195. -khtml-user-select: auto!important;
  196. -moz-user-select: auto!important;
  197. -ms-user-select: auto!important;
  198. -o-user-select: auto!important;
  199. user-select: auto!important;
  200. }
  201. </style>