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

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