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

236 lines
6.0 KiB

10 months ago
9 months ago
9 months ago
10 months ago
9 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
9 months ago
9 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 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
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
9 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" :holdKeyboard="true" :adjustPosition="false"></u--input> -->
  21. <input v-model="FormData.phone" placeholder="请输入手机号" type="number" maxlength="11" >
  22. </view>
  23. </view>
  24. <view class="form-item">
  25. <view class="inputBox my">
  26. <!-- <u--input placeholder="请输入验证码" border="none" clearable style="height: 100%;" :clearable="false" v-model="FormData.code"></u--input> -->
  27. <input type="text" placeholder="请输入验证码" v-model="FormData.code">
  28. </view>
  29. <view class="code" @click.stop='goSms' :class="{active: isPhone&&!codeOn}">{{codeText}}</view>
  30. </view>
  31. <view class="loginBtn" :class="{active: btnHighlight}" @click="submitFn"> </view>
  32. <view style="margin-top: 40rpx;">
  33. <privacyRadion :isCheck="isCheck" @changeRadio="changeRadio"></privacyRadion>
  34. </view>
  35. <!-- <button @click="$goPage('/pages/userCenter/login/face')">进入人脸识别</button> -->
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import { getLoginCode, loginSMS } from '@/config/api.js'
  41. import privacyRadion from './comp/privacyRadion.vue'
  42. import { imgUrl } from '@/config/site.config'
  43. export default {
  44. components: {privacyRadion},
  45. data() {
  46. return {
  47. imgUrl: imgUrl+'loginTopBg.png',
  48. backgroundSize: '100% 360rpx',
  49. isCheck:false,
  50. codeText: '获取验证码',
  51. FormData: {},
  52. codeOn: false,
  53. bgColor: 'transparent',
  54. autoBack:'arrow-left',
  55. redirect: ''
  56. }
  57. },
  58. onLoad(options) {
  59. if(options.redirect) this.redirect = options.redirect
  60. this.isCheck = options.isCheck=='true'?true:false
  61. // alert(options.autoBack)
  62. if(options.autoBack) this.autoBack = ''
  63. console.log(this.autoBack)
  64. },
  65. computed: {
  66. isPhone() {
  67. return uni.$u.test.mobile(this.FormData.phone)
  68. },
  69. btnHighlight() {
  70. return this.isPhone&&this.FormData.code*1>999
  71. }
  72. },
  73. methods: {
  74. // 是否选择协议
  75. changeRadio(val) {
  76. uni.hideKeyboard();
  77. this.isCheck = val
  78. },
  79. // 发送短信验证码
  80. goSms() {
  81. uni.hideKeyboard();
  82. const {
  83. FormData
  84. } = this
  85. if (!FormData.phone) return this.$u.toast('请输入手机号');
  86. if (!this.isPhone) return this.$u.toast('手机号格式有误');
  87. if (this.codeOn) return
  88. this.codeOn = true;
  89. getLoginCode({
  90. scene: 1,
  91. mobile: FormData.phone,
  92. }).then(()=>{
  93. var time = 60;
  94. this.codeText = time + "秒后重新发送"
  95. var timer = setInterval(() => {
  96. time--;
  97. this.codeText = time + "秒后重新发送"
  98. if (time == 0) {
  99. clearInterval(timer);
  100. this.codeText = "获取验证码";
  101. this.codeOn = false;
  102. }
  103. }, 1000);
  104. }).catch(()=>{
  105. this.codeOn = false;
  106. })
  107. // 获取验证码
  108. },
  109. async submitFn() {
  110. uni.hideKeyboard();
  111. if(!this.btnHighlight) return
  112. if(!this.isCheck) return this.$u.toast('请勾选产品协议与隐私政策');
  113. let obj = {
  114. mobile: this.FormData.phone,
  115. code: this.FormData.code
  116. }
  117. const res = await loginSMS(obj)
  118. this.$store.commit('update_vuex_loginInfo',res.data)
  119. await this.$store.dispatch('getUserInfo')
  120. if(this.redirect) {
  121. let switchBar = ['/pages/tabbar/index/index', '/pages/tabbar/learnCar/index', '/pages/tabbar/mine/index']
  122. if(switchBar.includes(this.redirect)) {
  123. uni.reLaunch({
  124. url: this.redirect
  125. })
  126. }else {
  127. const pages = getCurrentPages();
  128. console.log('有几个pages')
  129. console.log(pages)
  130. if(pages.length<1) {
  131. console.log('走首页')
  132. uni.switchTab({
  133. url: '/pages/tabbar/index/index'
  134. })
  135. }
  136. console.log('走返回')
  137. uni.navigateBack()
  138. }
  139. }else {
  140. uni.switchTab({
  141. url: '/pages/tabbar/index/index'
  142. })
  143. }
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .main {
  150. width: 100%;
  151. min-height: 100vh;
  152. // background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
  153. // background-size: 100% 360rpx;
  154. .uni-input-placeholder {
  155. color: #BBBBBB !important;
  156. }
  157. .u-back-top {
  158. padding: 32rpx 0 0 0;
  159. .backBox {
  160. padding: 24rpx;
  161. }
  162. }
  163. .title {
  164. font-size: 48rpx;
  165. color: #333;
  166. padding: 202rpx 0 80rpx 0;
  167. text-align: center;
  168. font-weight: 600;
  169. }
  170. .form {
  171. padding: 0 46rpx;
  172. .form-item {
  173. height: 112rpx;
  174. background: #F4F7FF;
  175. border-radius: 16rpx;
  176. width: 100%;
  177. line-height: 112rpx;
  178. display: flex;
  179. margin-bottom: 40rpx;
  180. padding: 0 40rpx;
  181. .prefix {
  182. display: flex;
  183. align-items: center;
  184. font-size: 32rpx;
  185. color: #333;
  186. font-weight: 600;
  187. }
  188. .inputBox {
  189. flex: 1;
  190. input {
  191. display: block;
  192. width: 100%;
  193. height: 100%;
  194. display: block;
  195. line-height: 112rpx;
  196. font-size: 30rpx;
  197. }
  198. }
  199. .code {
  200. color: #BBBBBB;
  201. margin-left: 30rpx;
  202. font-size: 30rpx;
  203. &.active {
  204. color: $themC
  205. }
  206. }
  207. }
  208. .loginBtn {
  209. width: 100%;
  210. height: 112rpx;
  211. background: rgba(25,137,250,0.3);
  212. border-radius: 16rpx;
  213. text-align: center;
  214. line-height: 112rpx;
  215. font-size: 32rpx;
  216. font-weight: 600;
  217. color: #fff;
  218. margin-top: 100rpx;
  219. &.active {
  220. background: rgba(25,137,250,1);
  221. }
  222. }
  223. }
  224. }
  225. </style>