login.vue 11 KB

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