smsCode.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="tab-page">
  3. <view class="backimage">
  4. <image class="back" src="/static/image/login/back.png" mode=""></image>
  5. <image class="title-img" src="/static/image/login/code.png" mode=""></image>
  6. <text class="title">验证码已发送至:+86 {{this.info.userName}}</text>
  7. </view>
  8. <view class="info">
  9. <u--input v-model="info.smsCode" border="bottom" clearable maxlength="6" placeholderStyle="color:#999"
  10. style="padding: 34rpx 0;box-sizing: border-box;" :focus="true">
  11. <template slot="suffix">
  12. <u-code ref="uCode2" @change="codeChange2" keep-running start-text="发送验证码"
  13. style="color: #F9E000;"></u-code>
  14. <view @tap="getCode2" :text="tips2" class="u-page__code-text">{{tips2}}</view>
  15. </template>
  16. </u--input>
  17. </view>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. isHidePassword: true, //是否隐藏密码
  25. tips2: '',
  26. info: {
  27. userName: "", //账号
  28. system: "APP", //系统code
  29. captcha: "", //验证码
  30. captchaId: "", //验证码id
  31. smsCode: "", //手机验证码
  32. }
  33. }
  34. },
  35. onLoad(options) {
  36. let info = JSON.parse(options.info);
  37. this.info.userName = info.userName;
  38. this.info.captcha = info.captcha;
  39. this.info.captchaId = info.captchaId;
  40. },
  41. watch: {
  42. "info.smsCode": {
  43. handler(val) {
  44. if (val.length == 6) {
  45. console.log(this.info);
  46. uni.showLoading({
  47. title: '请求登录'
  48. })
  49. setTimeout(() => {
  50. uni.hideLoading();
  51. this.$login({
  52. url: "/auth/login",
  53. data: this.info,
  54. }).then(res => {
  55. if (res) {
  56. return uni.showToast({
  57. title: res.msg,
  58. icon: 'none'
  59. });
  60. }
  61. return;
  62. })
  63. }, 1000);
  64. }
  65. },
  66. deep: true
  67. },
  68. },
  69. onShow() {},
  70. methods: {
  71. //修改密码
  72. confirm() {
  73. //重置密码逻辑
  74. uni.navigateTo({
  75. url: '/pages/login/login'
  76. })
  77. },
  78. codeChange2(text) {
  79. this.tips2 = text;
  80. },
  81. getCode2() {
  82. if (!this.info.userName) {
  83. uni.showToast({
  84. title: '手机号为空',
  85. icon: 'none'
  86. });
  87. return;
  88. }
  89. if (this.$refs.uCode2.canGetCode) {
  90. this.smsCode();
  91. // 模拟向后端请求验证码
  92. uni.showLoading({
  93. title: '正在获取验证码'
  94. })
  95. setTimeout(() => {
  96. uni.hideLoading();
  97. // 这里此提示会被this.start()方法中的提示覆盖
  98. uni.$u.toast('验证码已发送');
  99. // 通知验证码组件内部开始倒计时
  100. this.$refs.uCode2.start();
  101. }, 1000);
  102. } else {
  103. uni.$u.toast('倒计时结束后再发送');
  104. }
  105. },
  106. async smsCode() {
  107. let res = await this.$http.get('/auth/sendSmsCode?mobile=' + this.info.userName);
  108. },
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. page {
  114. background-color: #fff;
  115. }
  116. .backimage {
  117. width: 100%;
  118. height: 503rpx;
  119. background-color: #fff;
  120. position: relative;
  121. .back {
  122. width: 100%;
  123. height: 100%;
  124. }
  125. .title-img {
  126. position: absolute;
  127. top: 247rpx;
  128. left: 60rpx;
  129. width: 387rpx;
  130. height: 91rpx;
  131. }
  132. .title {
  133. position: absolute;
  134. top: 347rpx;
  135. left: 60rpx;
  136. font-size: 36rpx;
  137. color: #1f1f1f;
  138. }
  139. }
  140. .info {
  141. padding: 0 75rpx;
  142. box-sizing: border-box;
  143. .icon-img {
  144. width: 30rpx;
  145. height: 30rpx;
  146. }
  147. }
  148. //登录
  149. .performLogin {
  150. margin-top: 100rpx;
  151. .buttom {
  152. width: 100%;
  153. padding: 19rpx;
  154. box-sizing: border-box;
  155. background-color: #FDE935;
  156. border-radius: 45rpx;
  157. font-weight: bold;
  158. font-size: 36rpx;
  159. color: #1f1f1f;
  160. }
  161. .arigon {
  162. font-size: 28rpx;
  163. color: #666;
  164. padding: 0 30rpx;
  165. box-sizing: border-box;
  166. }
  167. }
  168. .footer {
  169. position: fixed;
  170. left: 0;
  171. right: 0;
  172. bottom: 62rpx;
  173. text {
  174. font-size: 26rpx;
  175. color: #999;
  176. }
  177. }
  178. .codemodal {
  179. padding: 40rpx;
  180. box-sizing: border-box;
  181. .buttom {
  182. width: 100%;
  183. padding: 19rpx;
  184. box-sizing: border-box;
  185. background-color: #FDE935;
  186. border-radius: 45rpx;
  187. font-weight: bold;
  188. font-size: 36rpx;
  189. color: #1f1f1f;
  190. }
  191. }
  192. .sendcode {
  193. font-size: 28rpx;
  194. color: #F9E000;
  195. }
  196. .u-page__code-text {
  197. padding: 4rpx 18rpx;
  198. background: rgba(253, 233, 53, 0.2);
  199. border-radius: 6rpx 6rpx 6rpx 6rpx;
  200. border: 1rpx solid #FDE935;
  201. color: #333333;
  202. font-size: 26rpx;
  203. }
  204. </style>