login.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div class="login">
  3. <div class="logo">
  4. <img src="../assets/logo.png" style="width: 1.25rem;" alt="">
  5. </div>
  6. <div class="bandSection">
  7. <div class="school">
  8. {{ dataList.schoolName }}
  9. </div>
  10. <div class="phoneSection">
  11. <i class="man_icon"></i>
  12. <input type="number" @blur="codeBlur" v-model="dataList.phoneNumber" class="phone" pattern="[0-9]" placeholder="请输入手机号报名或查询进度">
  13. </div>
  14. </div>
  15. <div class="btn-group">
  16. <van-button size="large" :disabled="btnStatus" @click="onSubmit" class="btn">注册</van-button>
  17. </div>
  18. <van-popup class="popup" v-model="popupStatus">
  19. <div class="pContainer">
  20. <i class="message_icon"></i>
  21. <div class="content">
  22. <p class="status">{{ statusList(popupText) }}</p>
  23. <p class="dec" v-if="popupText == 0">请您耐心等待</p>
  24. </div>
  25. </div>
  26. <div class="pGroup">
  27. <van-button class="button" @click="popupStatus = false">取消</van-button>
  28. <van-button class="button" @click="popupStatus = false">确定</van-button>
  29. </div>
  30. </van-popup>
  31. <van-popup class="popup-code" v-model="popupCodeStatus" :close-on-click-overlay="false">
  32. <div class="code_section">
  33. <h2 class="code_title">输入短信验证码</h2>
  34. <div class="input-group">
  35. <input type="number" @blur="codeBlur" @keyup="checkCode()" v-model="dataList.code" class="phone" pattern="[0-9]" placeholder="请输入验证码">
  36. <span class="code_btn" :class="[codeStatus?'':'disable']" @click="sendCode">{{ smsText }}</span>
  37. </div>
  38. </div>
  39. </van-popup>
  40. </div>
  41. </template>
  42. <script>
  43. /* eslint-disable */
  44. import { Button, Popup, Toast, Dialog } from 'vant'
  45. import qs from 'qs'
  46. export default {
  47. name: 'login',
  48. components: { Button, Popup, Toast, Dialog },
  49. data() {
  50. return {
  51. popupStatus: false,
  52. popupCodeStatus: false, // 发送验证码弹窗
  53. smsText: '发送验证码',
  54. popupText: '',
  55. codeStatus: true, // 是否可以发送验证码
  56. btnStatus: true,
  57. dataList: {
  58. status: null,
  59. schoolName: '', // 乐团名称
  60. phoneNumber: '', // 手机号
  61. branchId: '', // 分部编号
  62. classId: '', // 乐团编号
  63. code: '', // 验证码
  64. }
  65. }
  66. },
  67. mounted() {
  68. let route = this.$route.query
  69. let params = {
  70. schoolId: route.schoolId
  71. }
  72. axios.post(`/user/getClassDetail`,qs.stringify(params)).then((response) => {
  73. let result = response.data
  74. if(result.data) {
  75. this.dataList = {
  76. status: result.data.status,
  77. schoolName: result.data.name,
  78. phoneNumber: '',
  79. code: '',
  80. branchId: result.data.branchId,
  81. classId: result.data.id
  82. }
  83. if(result.data.status == 5) {
  84. Dialog.alert({
  85. title: '提示',
  86. message: '该乐团已停止注册',
  87. confirmButtonColor: '#269a93'
  88. })
  89. } else {
  90. this.btnStatus = false
  91. }
  92. } else {
  93. Dialog.alert({
  94. title: '提示',
  95. message: '乐团建设中,请稍等',
  96. confirmButtonColor: '#269a93'
  97. })
  98. }
  99. })
  100. },
  101. methods: {
  102. codeBlur() {
  103. setTimeout(() => {
  104. const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
  105. window.scrollTo(0, Math.max(scrollHeight - 1, 0));
  106. }, 100);
  107. },
  108. onSubmit() {
  109. let dataStatus = this.dataList.status
  110. if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.dataList.phoneNumber))){
  111. Toast('手机号输入有误')
  112. return false;
  113. }
  114. let params = this.$route.query
  115. axios.get(`/user/getUserDetailByPhone?clazzId=${this.dataList.classId}&phone=${this.dataList.phoneNumber}&cityId=${params.cityId}`).then((res) => {
  116. let result = res.data
  117. // 判断是否有数据
  118. if(result.status) {
  119. if(result.data) {
  120. if(parseInt(result.data.pushStatus) == 1) {
  121. Dialog.alert({
  122. title: '提示',
  123. message: '恭喜您,报名成功',
  124. confirmButtonColor: '#269a93'
  125. })
  126. } else if(parseInt(result.data.pushStatus) == 2 && parseInt(result.data.status) == 0) {
  127. this.$router.push({
  128. path: 'home',
  129. query: {
  130. branchId: result.data.branchId,
  131. stuId: result.data.id,
  132. classId: result.data.classId
  133. }
  134. })
  135. } else if(parseInt(result.data.status) == 1) {
  136. Dialog.alert({
  137. title: '注册完成',
  138. message: '您已完成注册,欢迎加入管乐团开启您的器乐学习之旅,请等待开课通知!',
  139. confirmButtonColor: '#269a93'
  140. })
  141. }
  142. } else {
  143. this.sendCode() // 发送短信
  144. }
  145. } else {
  146. Dialog.alert({
  147. title: '提示',
  148. message: result.msg,
  149. confirmButtonColor: '#269a93'
  150. })
  151. }
  152. })
  153. },
  154. checkCode() {
  155. let params = this.$route.query
  156. let code = this.dataList.code
  157. if(code.length >= 6) {
  158. axios.post('/user/verifySmsCode', qs.stringify({
  159. smsCode: code,
  160. mobile: this.dataList.phoneNumber
  161. })).then(res => {
  162. let result = res.data
  163. if(result.status) {
  164. this.$router.push({
  165. path: 'register',
  166. query: {
  167. phone: this.dataList.phoneNumber,
  168. cityId: params.cityId,
  169. classId: this.dataList.classId,
  170. schoolId: params.schoolId,
  171. status: this.dataList.status, // 当前乐团状态
  172. schoolName: this.dataList.schoolName,
  173. branchId: this.dataList.branchId
  174. }
  175. })
  176. } else {
  177. Toast('验证码输入有误')
  178. this.dataList.code = ''
  179. }
  180. })
  181. }
  182. },
  183. sendCode() {
  184. // 发送短信验证码
  185. if(!this.codeStatus) {
  186. return false
  187. }
  188. axios.get('/user/sendSmsCode?mobile=' + this.dataList.phoneNumber).then(res => {
  189. this.popupCodeStatus = true // 开启弹窗
  190. let result = res.data
  191. this.codeStatus = false
  192. this.CountDown()
  193. })
  194. },
  195. CountDown() {
  196. let s = 120
  197. this.smsText = s + '秒'
  198. let timer = setInterval(() => {
  199. if(s <= 0) {
  200. this.codeStatus = true
  201. this.smsText = '发送验证码'
  202. clearInterval(timer)
  203. } else {
  204. s--
  205. this.smsText = s + '秒'
  206. }
  207. }, 1000);
  208. },
  209. statusList(index) {
  210. let statusText
  211. switch(index) {
  212. case 0:
  213. statusText = '报名中'
  214. break;
  215. case 1:
  216. statusText = '缴费中'
  217. break;
  218. }
  219. return statusText
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="less" scoped>
  225. .login {
  226. width: 100vw;
  227. height: 100vh;
  228. background: #14928A;
  229. }
  230. .logo {
  231. padding-top: .6rem;
  232. text-align: center
  233. }
  234. // 弹窗验证码
  235. .code_section {
  236. width: 90vw;
  237. border-radius: .08rem;
  238. padding-bottom: .15rem;
  239. .code_title {
  240. font-size: .16rem;
  241. text-align: center;
  242. padding: .1rem 0;
  243. color: #444;
  244. }
  245. .input-group {
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. }
  250. .phone {
  251. padding-left: .08rem;
  252. height: .48rem;
  253. line-height: .48rem;
  254. background:rgba(244,244,244,1);
  255. border: 1px solid #ccc;
  256. border-top-left-radius:5px;
  257. border-bottom-left-radius:5px;
  258. }
  259. .code_btn {
  260. color: #fff;
  261. font-size: .12rem;
  262. height: .48rem;
  263. line-height: .48rem;
  264. background: #14928A;
  265. // padding: .05rem .12rem;
  266. text-align: center;
  267. width: .84rem;
  268. border-top-right-radius:5px;
  269. border-bottom-right-radius:5px;
  270. &.disable {
  271. color: #fff;
  272. background: #aaa;
  273. }
  274. }
  275. }
  276. .bandSection {
  277. padding: .5rem .28rem 0;
  278. .school {
  279. color: #fff;
  280. font-size: .16rem;
  281. font-weight: bold;
  282. border-bottom: 2px solid #fff;
  283. padding-bottom: .08rem;
  284. margin-bottom: .2rem;
  285. }
  286. .phoneSection {
  287. background:rgba(0,0,0,0.25);
  288. border-radius:5px;
  289. display: flex;
  290. align-items: center;
  291. height: .45rem;
  292. }
  293. .man_icon {
  294. background: url('../assets/man_icon.png') no-repeat center;
  295. background-size: contain;
  296. width: .15rem;
  297. height: .21rem;
  298. margin-left: .15rem;
  299. }
  300. .phone {
  301. flex: 1;
  302. border: 0;
  303. background-color: transparent;
  304. color: #fff;
  305. padding-left: .12rem;
  306. font-size: .14rem;
  307. &::placeholder{
  308. color: #FFFFFF;
  309. }
  310. }
  311. }
  312. .btn-group {
  313. padding: .3rem .35rem 0;
  314. }
  315. .btn {
  316. border-radius: 1rem;
  317. background-color: #fff;
  318. color: #269a93;
  319. font-size: .16rem;
  320. margin-bottom: .2rem;
  321. }
  322. .popup {
  323. width: 75%;
  324. padding: .2rem .2rem .1rem;
  325. border-radius: .05rem;
  326. }
  327. .pContainer {
  328. display: flex;
  329. .message_icon {
  330. display: inline-block;
  331. background: url('../assets/message_icon.png') no-repeat center;
  332. background-size: contain;
  333. width: .32rem;
  334. height: .32rem;
  335. margin-top: .05rem;
  336. }
  337. .content {
  338. display: flex;
  339. color: #444;
  340. flex-direction: column;
  341. padding-left: .16rem;
  342. .status {
  343. font-size: .2rem;
  344. padding-bottom: .05rem;
  345. }
  346. .dec {
  347. font-size: .16rem;
  348. }
  349. }
  350. }
  351. .pGroup {
  352. display: flex;
  353. justify-content: space-between;
  354. padding-top: .15rem;
  355. .button {
  356. border: 0;
  357. color: #009688;
  358. font-size: .14rem;
  359. &:active::before {
  360. opacity: 0;
  361. }
  362. }
  363. }
  364. input, textarea {
  365. -webkit-user-select: auto!important;
  366. -khtml-user-select: auto!important;
  367. -moz-user-select: auto!important;
  368. -ms-user-select: auto!important;
  369. -o-user-select: auto!important;
  370. user-select: auto!important;
  371. }
  372. </style>