洛阳学员端
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.

191 lines
4.7 KiB

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