江西小程序管理端
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.

186 lines
4.1 KiB

1 year ago
  1. <template>
  2. <view class="main">
  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. <view class="title">短信验证码登录</view>
  9. <view class="form">
  10. <view class="form-item">
  11. <view class="prefix">
  12. <view class="jia">+</view>
  13. <view class="num">86</view>
  14. <view class="" style="margin: 0 32rpx 0 12rpx;">
  15. <u-icon name="arrow-down" color="#333" size="16" ></u-icon>
  16. </view>
  17. </view>
  18. <view class="inputBox my">
  19. <u--input placeholder="请输入手机号" border="none" clearable type="number" maxlength="11" v-model="FormData.phone"></u--input>
  20. </view>
  21. </view>
  22. <view class="form-item">
  23. <view class="inputBox my">
  24. <u--input placeholder="请输入验证码" border="none" clearable style="height: 100%;" :clearable="false" v-model="FormData.code"></u--input>
  25. </view>
  26. <view class="code" @tap='goSms' :class="{active: isPhone&&!codeOn}">{{codeText}}</view>
  27. </view>
  28. <view class="loginBtn" :class="{active: btnHighlight}" @click="submitFn"> </view>
  29. <view class="radioWrap">
  30. <u-checkbox-group >
  31. <u-checkbox v-model="isCheck" shape="circle" label="已阅读并同意" :labelSize="12" ></u-checkbox>
  32. </u-checkbox-group>
  33. <view class="privacyText">
  34. <text>用户协议</text> <text>隐私协议</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { getLoginCode } from '@/config/api.js'
  42. export default {
  43. data() {
  44. return {
  45. isCheck: false,
  46. codeText: '获取验证码',
  47. FormData: {},
  48. codeOn: false
  49. }
  50. },
  51. onLoad() {
  52. },
  53. computed: {
  54. isPhone() {
  55. return uni.$u.test.mobile(this.FormData.phone)
  56. },
  57. btnHighlight() {
  58. return this.isPhone&&uni.$u.test.code(this.FormData.code, 4)
  59. }
  60. },
  61. methods: {
  62. // 是否选择协议
  63. groupChangeEnvnt(e) {
  64. this.isCheck = e.value
  65. console.log('是否选择协议', this.isCheck)
  66. },
  67. // 发送短信验证码
  68. async goSms() {
  69. const {
  70. FormData
  71. } = this
  72. if (!FormData.phone) return this.$u.toast('请输入手机号');
  73. if (!this.isPhone) return this.$u.toast('手机号格式有误');
  74. if (this.codeOn) return
  75. const data = await getLoginCode({
  76. codeType: 1,
  77. phone: FormData.phone,
  78. })
  79. console.log(data)
  80. // 获取验证码
  81. var time = 60;
  82. var timer = setInterval(() => {
  83. time--;
  84. this.codeText = time + "秒后重新发送"
  85. this.codeOn = true;
  86. if (time == 0) {
  87. clearInterval(timer);
  88. this.codeText = "获取验证码";
  89. this.codeOn = false;
  90. }
  91. }, 1000);
  92. },
  93. submitFn() {
  94. uni.switchTab({
  95. url: '/pages/tabbar/index/index'
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .main {
  103. width: 100%;
  104. min-height: 100vh;
  105. background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
  106. background-size: 100% 360rpx;
  107. .u-back-top {
  108. padding: 32rpx 0 0 0;
  109. .backBox {
  110. padding: 24rpx;
  111. }
  112. }
  113. .title {
  114. font-size: 48rpx;
  115. color: #333;
  116. padding: 92rpx 0;
  117. text-align: center;
  118. font-weight: 600;
  119. }
  120. .form {
  121. padding: 0 46rpx;
  122. .form-item {
  123. height: 112rpx;
  124. background: #F4F7FF;
  125. border-radius: 16rpx;
  126. width: 100%;
  127. line-height: 112rpx;
  128. display: flex;
  129. margin-bottom: 40rpx;
  130. padding: 0 40rpx;
  131. .prefix {
  132. display: flex;
  133. align-items: center;
  134. font-size: 32rpx;
  135. color: #333;
  136. font-weight: 600;
  137. }
  138. .inputBox {
  139. flex: 1;
  140. }
  141. .code {
  142. color: #BBBBBB;
  143. margin-left: 30rpx;
  144. &.active {
  145. color: $themC
  146. }
  147. }
  148. }
  149. .loginBtn {
  150. width: 100%;
  151. height: 112rpx;
  152. background: rgba(25,137,250,0.3);
  153. border-radius: 16rpx;
  154. text-align: center;
  155. line-height: 112rpx;
  156. font-size: 32rpx;
  157. font-weight: 600;
  158. color: #fff;
  159. margin-top: 100rpx;
  160. &.active {
  161. background: rgba(25,137,250,1);
  162. }
  163. }
  164. .radioWrap {
  165. display: flex;
  166. align-items: center;
  167. margin-top: 40rpx;
  168. .privacyText {
  169. font-size: 24rpx;
  170. color: #888E94;
  171. text {
  172. color: $themC;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. </style>