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.

207 lines
5.2 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
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
  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" ></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. <u-action-sheet :actions="list" title="请选择您要登录的角色" :show="showRole" @select="selectClick" ></u-action-sheet>
  36. </view>
  37. </template>
  38. <script>
  39. import { getLoginCode, loginSMS, coachSmsLogin } from '@/config/api.js'
  40. import privacyRadion from './comp/privacyRadion.vue'
  41. import { imgUrl } from '@/config/site.config'
  42. export default {
  43. components: {privacyRadion},
  44. data() {
  45. return {
  46. imgUrl: imgUrl+'loginTopBg.png',
  47. backgroundSize: '100% 360rpx',
  48. isCheck:false,
  49. codeText: '获取验证码',
  50. FormData: {},
  51. codeOn: false,
  52. bgColor: 'transparent',
  53. list: [{name: '实操教练', id: 3}, {name: '校长', id: 4}],
  54. showRole: false,
  55. }
  56. },
  57. onLoad(options) {
  58. },
  59. computed: {
  60. isPhone() {
  61. return uni.$u.test.mobile(this.FormData.phone)
  62. },
  63. btnHighlight() {
  64. return this.isPhone&&uni.$u.test.code(this.FormData.code, 4)
  65. }
  66. },
  67. methods: {
  68. // 是否选择协议
  69. changeRadio(val) {
  70. this.isCheck = val
  71. },
  72. // 发送短信验证码
  73. goSms() {
  74. const {
  75. FormData
  76. } = this
  77. if (!FormData.phone) return this.$u.toast('请输入手机号');
  78. if (!this.isPhone) return this.$u.toast('手机号格式有误');
  79. if (this.codeOn) return
  80. this.codeOn = true;
  81. getLoginCode({
  82. scene: 11,
  83. mobile: FormData.phone,
  84. }).then(()=>{
  85. var time = 60;
  86. this.codeText = time + "秒后重新发送"
  87. var timer = setInterval(() => {
  88. time--;
  89. this.codeText = time + "秒后重新发送"
  90. if (time == 0) {
  91. clearInterval(timer);
  92. this.codeText = "获取验证码";
  93. this.codeOn = false;
  94. }
  95. }, 1000);
  96. }).catch(()=>{
  97. this.codeOn = false;
  98. })
  99. // 获取验证码
  100. },
  101. async submitFn() {
  102. if(!this.btnHighlight) return
  103. if(!this.isCheck) return this.$u.toast('请勾选产品协议与隐私政策');
  104. let obj = {
  105. mobile: this.FormData.phone,
  106. code: this.FormData.code
  107. }
  108. const res = await coachSmsLogin(obj)
  109. this.$store.commit('update_vuex_loginInfo',res.data)
  110. await this.$store.dispatch('getUserInfo')
  111. if(res.userType==5) {
  112. uni.switchTab({
  113. url: '/pages/tabbar/statistics/index'
  114. })
  115. }else {
  116. this.showRole = true
  117. }
  118. },
  119. selectClick(item) {
  120. this.showRole = false
  121. this.$store.commit('upDateIdentity', item.name)
  122. uni.switchTab({
  123. url: '/pages/tabbar/statistics/index'
  124. })
  125. // alert(item.name)
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .main {
  132. width: 100%;
  133. min-height: 100vh;
  134. // background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
  135. // background-size: 100% 360rpx;
  136. .u-back-top {
  137. padding: 32rpx 0 0 0;
  138. .backBox {
  139. padding: 24rpx;
  140. }
  141. }
  142. .title {
  143. font-size: 48rpx;
  144. color: #333;
  145. padding: 202rpx 0 80rpx 0;
  146. text-align: center;
  147. font-weight: 600;
  148. }
  149. .form {
  150. padding: 0 46rpx;
  151. .form-item {
  152. height: 112rpx;
  153. background: #F4F7FF;
  154. border-radius: 16rpx;
  155. width: 100%;
  156. line-height: 112rpx;
  157. display: flex;
  158. margin-bottom: 40rpx;
  159. padding: 0 40rpx;
  160. .prefix {
  161. display: flex;
  162. align-items: center;
  163. font-size: 32rpx;
  164. color: #333;
  165. font-weight: 600;
  166. }
  167. .inputBox {
  168. flex: 1;
  169. }
  170. .code {
  171. color: #BBBBBB;
  172. margin-left: 30rpx;
  173. &.active {
  174. color: $themC
  175. }
  176. }
  177. }
  178. .loginBtn {
  179. width: 100%;
  180. height: 112rpx;
  181. background: rgba(25,137,250,0.3);
  182. border-radius: 16rpx;
  183. text-align: center;
  184. line-height: 112rpx;
  185. font-size: 32rpx;
  186. font-weight: 600;
  187. color: #fff;
  188. margin-top: 100rpx;
  189. &.active {
  190. background: rgba(25,137,250,1);
  191. }
  192. }
  193. }
  194. }
  195. </style>