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

210 lines
5.3 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
8 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. console.log('login_front')
  115. console.log(login_front)
  116. if(login_front) {
  117. let switchBar = ['/pages/tabbar/index/index', '/pages/tabbar/learnCar/index', '/pages/tabbar/mine/index']
  118. if(switchBar.includes(login_front)) {
  119. uni.reLaunch({
  120. url: login_front
  121. })
  122. }else {
  123. // this.$goPage(login_front)
  124. uni.navigateBack()
  125. }
  126. }else {
  127. uni.switchTab({
  128. url: '/pages/tabbar/index/index'
  129. })
  130. }
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .main {
  137. width: 100%;
  138. min-height: 100vh;
  139. // background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
  140. // background-size: 100% 360rpx;
  141. .u-back-top {
  142. padding: 32rpx 0 0 0;
  143. .backBox {
  144. padding: 24rpx;
  145. }
  146. }
  147. .title {
  148. font-size: 48rpx;
  149. color: #333;
  150. padding: 202rpx 0 80rpx 0;
  151. text-align: center;
  152. font-weight: 600;
  153. }
  154. .form {
  155. padding: 0 46rpx;
  156. .form-item {
  157. height: 112rpx;
  158. background: #F4F7FF;
  159. border-radius: 16rpx;
  160. width: 100%;
  161. line-height: 112rpx;
  162. display: flex;
  163. margin-bottom: 40rpx;
  164. padding: 0 40rpx;
  165. .prefix {
  166. display: flex;
  167. align-items: center;
  168. font-size: 32rpx;
  169. color: #333;
  170. font-weight: 600;
  171. }
  172. .inputBox {
  173. flex: 1;
  174. }
  175. .code {
  176. color: #BBBBBB;
  177. margin-left: 30rpx;
  178. &.active {
  179. color: $themC
  180. }
  181. }
  182. }
  183. .loginBtn {
  184. width: 100%;
  185. height: 112rpx;
  186. background: rgba(25,137,250,0.3);
  187. border-radius: 16rpx;
  188. text-align: center;
  189. line-height: 112rpx;
  190. font-size: 32rpx;
  191. font-weight: 600;
  192. color: #fff;
  193. margin-top: 100rpx;
  194. &.active {
  195. background: rgba(25,137,250,1);
  196. }
  197. }
  198. }
  199. }
  200. </style>