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

207 lines
5.2 KiB

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