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.

230 lines
5.9 KiB

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