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

195 lines
4.8 KiB

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