safety-verification.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view>
  3. <!-- 头部 -->
  4. <headContent>
  5. <template #left>
  6. <view class="head-revers-back iconfont" @click.stop="reversBackBtn()">&#xe604;</view>
  7. </template>
  8. <template #content>
  9. <view class="haed-title">安全验证</view>
  10. </template>
  11. </headContent>
  12. <view class="page-content">
  13. <text class="login-title">{{ title }}验证</text>
  14. <text class="login-content">验证码已发送至{{account}}</text>
  15. <view class="form-item">
  16. <input class="form-input" v-model="code" placeholder-class="form-input-place"
  17. :placeholder="`请输入您的${title}`" />
  18. <view class="form-code" @click.stop="getCode()">{{ codeText }}</view>
  19. </view>
  20. <view :class="['form-btn' , code ? '' : 'invalid-form-btn']" style="margin-top: 28rpx;"
  21. @click.stop="formSubmit">
  22. 下一步
  23. </view>
  24. <!-- <form class="login-form">
  25. <view class="form-item">
  26. <input class="form-input" placeholder-class="form-input-place" placeholder="请输入您的邮箱地址" />
  27. </view>
  28. <view class="form-btn" style="margin-top: 28rpx;" @click.stop="formSubmit">
  29. 下一步
  30. </view>
  31. </form> -->
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. reverseBack
  38. } from "@/utils/common.js"
  39. import {
  40. Api_getEmailCode,
  41. Api_getSmsSend
  42. } from "@/api/index.js"
  43. export default {
  44. name: 'safety-verification',
  45. data() {
  46. return {
  47. title: '',
  48. type: 0,
  49. account: '',
  50. code: '',
  51. codeText: '获取验证码',
  52. timeInterval: null
  53. };
  54. },
  55. onLoad(opt) {
  56. this.type = opt?.type;
  57. this.account = opt?.account;
  58. },
  59. watch: {
  60. account: {
  61. handler(newAccount) {
  62. if (['@'].includes(newAccount)) {
  63. // 邮箱
  64. this.title = '邮箱';
  65. } else {
  66. // 手机号
  67. this.title = '手机号';
  68. }
  69. }
  70. }
  71. },
  72. methods: {
  73. reversBackBtn() {
  74. reverseBack()
  75. },
  76. getCode() {
  77. if(this.codeText !=='获取验证码' ){
  78. return false
  79. }
  80. let Api_ = '',
  81. obj = {
  82. user_string: this.account
  83. }
  84. if (this.title === '邮箱') {
  85. Api_ = Api_getEmailCode;
  86. }
  87. if (this.title === '手机号') {
  88. Api_ = Api_getSmsSend;
  89. }
  90. if (Api_) {
  91. Api_(obj).then(res => {
  92. }).catch(err => {
  93. })
  94. let num = 60
  95. this.timeInterval = setInterval(() => {
  96. num--;
  97. if (num <= 0) {
  98. clearInterval(this.timeInterval);
  99. this.codeText = '获取验证码';
  100. return false
  101. };
  102. this.codeText = `${num}秒后重新发送`;
  103. 123456
  104. }, 1000)
  105. }
  106. },
  107. formSubmit() {
  108. // 安全验证
  109. if (this.code) {
  110. let path = ''
  111. switch (this.type) {
  112. case '1':
  113. path = `/pages/login/reset-pswd?account=${this.account}&code=${this.code}`;
  114. break
  115. }
  116. if (path) {
  117. uni.navigateTo({
  118. url: path
  119. })
  120. }
  121. }
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. @import "~./common.scss";
  128. // <view class="form-item">
  129. // <input class="form-input" placeholder-class="form-input-place" placeholder="请输入您的邮箱地址" />
  130. // <view class="form-code">52秒后重新发送</view>
  131. // </view>
  132. .login-title {
  133. font-size: 34rpx !important;
  134. }
  135. .login-content {
  136. padding-bottom: 0 !important;
  137. }
  138. .form-item {
  139. width: 100%;
  140. min-height: 100rpx;
  141. display: flex;
  142. justify-content: space-between;
  143. align-items: center;
  144. border-bottom: 1rpx solid $border-color4;
  145. .form-input {
  146. flex: 1;
  147. font-size: 26rpx;
  148. }
  149. .form-input-place {
  150. font-size: 26rpx;
  151. font-weight: 800;
  152. }
  153. .form-code {
  154. flex-shrink: 0;
  155. padding-left: 10rpx;
  156. font-size: 26rpx;
  157. color: $Theme-Color;
  158. }
  159. }
  160. .form-btn {
  161. margin-top: 80rpx !important;
  162. }
  163. </style>