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

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