forgetPassword.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="page">
  3. <view class="title">身份验证</view>
  4. <view class="input u-flex" style="margin-top: 28rpx;">
  5. <u-input placeholder-style='font-size: 32rpx;
  6. font-family: PingFangSC, PingFang SC;
  7. font-weight: 400;
  8. color: #222222;opacity: 0.5;' placeholder='手机号' v-model="resultPhone" type="text" :border="false"
  9. :clearable='false' />
  10. </view>
  11. <view class="input u-flex">
  12. <u-input placeholder-style='font-size: 32rpx;
  13. font-family: PingFangSC, PingFang SC;
  14. font-weight: 400;
  15. color: #222222;opacity: 0.5;' placeholder='请输入验证码' v-model="code" type="text" :border="false" :clearable='false' />
  16. <view class="code" @click="getCode">
  17. {{tips}}
  18. </view>
  19. </view>
  20. <view class="button" @click="changePasswoed">
  21. 确认
  22. </view>
  23. <u-verification-code :seconds="seconds" ref="uCode" @change="codeChange"></u-verification-code>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. code: '',
  31. phone: '',
  32. resultPhone: '',
  33. tips: '',
  34. seconds: ''
  35. };
  36. },
  37. onLoad() {
  38. if (uni.getStorageSync('token')) {
  39. this.getUserinfo()
  40. }
  41. },
  42. methods: {
  43. codeChange(text) {
  44. this.tips = text;
  45. },
  46. changePasswoed() {
  47. uni.navigateTo({
  48. url: '/pages/login/changePasswoed?mobile=' + this.phone
  49. })
  50. },
  51. getUserinfo() {
  52. this.$u.post('api/user/getUserinfo').then(res => {
  53. this.phone = res.mobile
  54. this.resultPhone = res.phone_r
  55. })
  56. },
  57. getCode() {
  58. if (this.$refs.uCode.canGetCode) {
  59. // 模拟向后端请求验证码
  60. uni.showLoading({
  61. title: '正在获取验证码',
  62. mask: true
  63. })
  64. this.$u.post('/api/sms/send', {
  65. mobile: this.phone,
  66. password: this.password
  67. }).then(res => {
  68. if (res.code == 1) {
  69. uni.hideLoading();
  70. // 这里此提示会被this.start()方法中的提示覆盖
  71. this.$u.toast('验证码已发送');
  72. // 通知验证码组件内部开始倒计时
  73. this.$refs.uCode.start();
  74. } else {
  75. this.$u.toast(res.msg)
  76. }
  77. })
  78. } else {
  79. this.$u.toast('倒计时结束后再发送');
  80. }
  81. },
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. .page {
  87. padding: 52rpx 36rpx 0;
  88. border-top: 2rpx solid rgba(235, 235, 235, 1);
  89. }
  90. .code {
  91. font-size: 32rpx;
  92. font-family: PingFangSC, PingFang SC;
  93. font-weight: 400;
  94. color: #06A971;
  95. }
  96. .button {
  97. width: 678rpx;
  98. height: 84rpx;
  99. background: #06A971;
  100. border-radius: 8rpx;
  101. // opacity: 0.5;
  102. text-align: center;
  103. margin-top: 46rpx;
  104. line-height: 84rpx;
  105. font-size: 32rpx;
  106. font-family: PingFangSC, PingFang SC;
  107. font-weight: 400;
  108. color: #FFFFFF;
  109. }
  110. .title {
  111. height: 74rpx;
  112. font-size: 52rpx;
  113. font-family: PingFangSC, PingFang SC;
  114. font-weight: 500;
  115. color: #222222;
  116. line-height: 74rpx;
  117. }
  118. .input {
  119. height: 122rpx;
  120. display: flex;
  121. align-items: center;
  122. border-bottom: 2rpx solid rgba(0, 0, 0, 0.14);
  123. }
  124. </style>