学员端小程序
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.

184 lines
4.3 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 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 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" @click='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, loginSMS } 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. // this.$store.dispatch('getUserInfo')
  50. },
  51. computed: {
  52. isPhone() {
  53. return uni.$u.test.mobile(this.FormData.phone)
  54. },
  55. btnHighlight() {
  56. return this.isPhone&&uni.$u.test.code(this.FormData.code, 4)
  57. }
  58. },
  59. methods: {
  60. leftClick() {
  61. console.log('leftClick');
  62. },
  63. // 是否选择协议
  64. changeRadio(val) {
  65. this.isCheck = val
  66. },
  67. // 发送短信验证码
  68. async goSms() {
  69. const {
  70. FormData
  71. } = this
  72. if (!FormData.phone) return this.$u.toast('请输入手机号');
  73. if (!this.isPhone) return this.$u.toast('手机号格式有误');
  74. if (this.codeOn) return
  75. const data = await getLoginCode({
  76. scene: 1,
  77. mobile: FormData.phone,
  78. })
  79. console.log(data)
  80. // 获取验证码
  81. var time = 60;
  82. var timer = setInterval(() => {
  83. time--;
  84. this.codeText = time + "秒后重新发送"
  85. this.codeOn = true;
  86. if (time == 0) {
  87. clearInterval(timer);
  88. this.codeText = "获取验证码";
  89. this.codeOn = false;
  90. }
  91. }, 1000);
  92. },
  93. async submitFn() {
  94. if(!this.btnHighlight) return
  95. if(!this.isCheck) return this.$u.toast('请勾选产品协议与隐私政策');
  96. let obj = {
  97. mobile: this.FormData.phone,
  98. code: this.FormData.code
  99. }
  100. const res = await loginSMS(obj)
  101. this.$store.commit('update_vuex_loginInfo',res.data)
  102. this.$store.dispatch('getUserInfo')
  103. uni.switchTab({
  104. url: '/pages/tabbar/index/index'
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .main {
  112. width: 100%;
  113. min-height: 100vh;
  114. background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
  115. background-size: 100% 360rpx;
  116. .u-back-top {
  117. padding: 32rpx 0 0 0;
  118. .backBox {
  119. padding: 24rpx;
  120. }
  121. }
  122. .title {
  123. font-size: 48rpx;
  124. color: #333;
  125. padding: 202rpx 0 80rpx 0;
  126. text-align: center;
  127. font-weight: 600;
  128. }
  129. .form {
  130. padding: 0 46rpx;
  131. .form-item {
  132. height: 112rpx;
  133. background: #F4F7FF;
  134. border-radius: 16rpx;
  135. width: 100%;
  136. line-height: 112rpx;
  137. display: flex;
  138. margin-bottom: 40rpx;
  139. padding: 0 40rpx;
  140. .prefix {
  141. display: flex;
  142. align-items: center;
  143. font-size: 32rpx;
  144. color: #333;
  145. font-weight: 600;
  146. }
  147. .inputBox {
  148. flex: 1;
  149. }
  150. .code {
  151. color: #BBBBBB;
  152. margin-left: 30rpx;
  153. &.active {
  154. color: $themC
  155. }
  156. }
  157. }
  158. .loginBtn {
  159. width: 100%;
  160. height: 112rpx;
  161. background: rgba(25,137,250,0.3);
  162. border-radius: 16rpx;
  163. text-align: center;
  164. line-height: 112rpx;
  165. font-size: 32rpx;
  166. font-weight: 600;
  167. color: #fff;
  168. margin-top: 100rpx;
  169. &.active {
  170. background: rgba(25,137,250,1);
  171. }
  172. }
  173. }
  174. }
  175. </style>