学员端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
3.9 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <view class="main">
  3. <!-- <view class="u-back-top">
  4. <view class="backBox">
  5. <u-icon name="arrow-left" color="#333" size="28"></u-icon>
  6. </view>
  7. </view> -->
  8. <u-navbar title=" " @leftClick="leftClick" :bgColor="bgColor" :autoBack="true"></u-navbar>
  9. <view class="title">短信验证码登录</view>
  10. <view class="form">
  11. <view class="form-item">
  12. <view class="prefix">
  13. <view class="jia">+</view>
  14. <view class="num">86</view>
  15. <view class="" style="margin: 0 32rpx 0 12rpx;">
  16. <u-icon name="arrow-down" color="#333" size="16" ></u-icon>
  17. </view>
  18. </view>
  19. <view class="inputBox my">
  20. <u--input placeholder="请输入手机号" border="none" clearable type="number" maxlength="11" v-model="FormData.phone"></u--input>
  21. </view>
  22. </view>
  23. <view class="form-item">
  24. <view class="inputBox my">
  25. <u--input placeholder="请输入验证码" border="none" clearable style="height: 100%;" :clearable="false" v-model="FormData.code"></u--input>
  26. </view>
  27. <view class="code" @tap='goSms' :class="{active: isPhone&&!codeOn}">{{codeText}}</view>
  28. </view>
  29. <view class="loginBtn" :class="{active: btnHighlight}" @click="submitFn"> </view>
  30. <view style="margin-top: 40rpx;">
  31. <privacyRadion :isCheck="isCheck" @changeRadio="changeRadio"></privacyRadion>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { getLoginCode } from '@/config/api.js'
  38. export default {
  39. data() {
  40. return {
  41. isCheck: false,
  42. codeText: '获取验证码',
  43. FormData: {},
  44. codeOn: false,
  45. bgColor: 'transparent'
  46. }
  47. },
  48. onLoad() {
  49. },
  50. computed: {
  51. isPhone() {
  52. return uni.$u.test.mobile(this.FormData.phone)
  53. },
  54. btnHighlight() {
  55. return this.isPhone&&uni.$u.test.code(this.FormData.code, 4)
  56. }
  57. },
  58. methods: {
  59. leftClick() {
  60. console.log('leftClick');
  61. },
  62. // 是否选择协议
  63. changeRadio(val) {
  64. this.isCheck = val
  65. },
  66. // 发送短信验证码
  67. async goSms() {
  68. const {
  69. FormData
  70. } = this
  71. if (!FormData.phone) return this.$u.toast('请输入手机号');
  72. if (!this.isPhone) return this.$u.toast('手机号格式有误');
  73. if (this.codeOn) return
  74. const data = await getLoginCode({
  75. codeType: 1,
  76. phone: FormData.phone,
  77. })
  78. console.log(data)
  79. // 获取验证码
  80. var time = 60;
  81. var timer = setInterval(() => {
  82. time--;
  83. this.codeText = time + "秒后重新发送"
  84. this.codeOn = true;
  85. if (time == 0) {
  86. clearInterval(timer);
  87. this.codeText = "获取验证码";
  88. this.codeOn = false;
  89. }
  90. }, 1000);
  91. },
  92. submitFn() {
  93. uni.switchTab({
  94. url: '/pages/tabbar/index/index'
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .main {
  102. width: 100%;
  103. min-height: 100vh;
  104. background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
  105. background-size: 100% 360rpx;
  106. .u-back-top {
  107. padding: 32rpx 0 0 0;
  108. .backBox {
  109. padding: 24rpx;
  110. }
  111. }
  112. .title {
  113. font-size: 48rpx;
  114. color: #333;
  115. padding: 202rpx 0 80rpx 0;
  116. text-align: center;
  117. font-weight: 600;
  118. }
  119. .form {
  120. padding: 0 46rpx;
  121. .form-item {
  122. height: 112rpx;
  123. background: #F4F7FF;
  124. border-radius: 16rpx;
  125. width: 100%;
  126. line-height: 112rpx;
  127. display: flex;
  128. margin-bottom: 40rpx;
  129. padding: 0 40rpx;
  130. .prefix {
  131. display: flex;
  132. align-items: center;
  133. font-size: 32rpx;
  134. color: #333;
  135. font-weight: 600;
  136. }
  137. .inputBox {
  138. flex: 1;
  139. }
  140. .code {
  141. color: #BBBBBB;
  142. margin-left: 30rpx;
  143. &.active {
  144. color: $themC
  145. }
  146. }
  147. }
  148. .loginBtn {
  149. width: 100%;
  150. height: 112rpx;
  151. background: rgba(25,137,250,0.3);
  152. border-radius: 16rpx;
  153. text-align: center;
  154. line-height: 112rpx;
  155. font-size: 32rpx;
  156. font-weight: 600;
  157. color: #fff;
  158. margin-top: 100rpx;
  159. &.active {
  160. background: rgba(25,137,250,1);
  161. }
  162. }
  163. }
  164. }
  165. </style>