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

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