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

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