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

235 lines
6.0 KiB

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