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

220 lines
5.5 KiB

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