forgot.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="page" :style="{'height':h+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="忘记密码" :showHome="false"></c-nav-bar>
  4. <view class="box">
  5. <view class="b_item">
  6. <text>手机号码</text>
  7. <input type="tel" placeholder="请输入手机号" placeholder-style="{color:#999999}" v-model="phone" @blur="setPhone" @confirm="setPhone">
  8. </view>
  9. <view class="b_item b_item_code">
  10. <text>验证码</text>
  11. <input type="tel" placeholder="请输入验证码" placeholder-style="{color:#999999}" v-model="code" @blur="setCode" @confirm="setCode">
  12. <view class="bi_code" @tap="sendCode" v-if="text=='获取验证码'">{{text}}</view>
  13. <view class="bi_code" v-else>{{text}} {{time}}S</view>
  14. </view>
  15. <view class="b_item">
  16. <text>新密码</text>
  17. <input type="tel" placeholder="请输入新密码" placeholder-style="{color:#999999}" v-model="password" @blur="setPassword" @confirm="setPassword">
  18. </view>
  19. <view class="b_item">
  20. <text>确认密码</text>
  21. <input type="tel" placeholder="请再次输入新密码" placeholder-style="{color:#999999}" v-model="surePassword" @blur="setSurePassword" @confirm="setSurePassword">
  22. </view>
  23. </view>
  24. <view class="btn" @tap="toSure">确定</view>
  25. </view>
  26. </template>
  27. <script>
  28. var timer;
  29. export default {
  30. data() {
  31. return {
  32. h:this.$h,
  33. mt:this.$mt,
  34. phone:'',
  35. time:59,
  36. text:'获取验证码',
  37. phone:'',
  38. code:'',
  39. password:'',
  40. surePassword:''
  41. }
  42. },
  43. methods: {
  44. setPhone(e){
  45. this.phone = e.target.value;
  46. },
  47. setCode(e){
  48. this.code = e.target.value;
  49. },
  50. setPassword(e){
  51. this.password = e.target.value;
  52. },
  53. setSurePassword(e){
  54. this.surePassword = e.target.value;
  55. },
  56. sendCode(){
  57. if(this.text!='获取验证码') return;
  58. this.text = '重新发送';
  59. timer = setInterval(()=>{
  60. this.time--;
  61. if(this.time==0){
  62. this.text = '获取验证码';
  63. this.time = 59;
  64. clearInterval(timer);
  65. }
  66. },1000)
  67. },
  68. toSure(){
  69. if(!/^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(this.phone)) return this.$showToast('请输入正确的手机号');
  70. if(!this.code) return this.$showToast('请输入验证码');
  71. if(!this.password) return this.$showToast('请输入新密码');
  72. if(!this.surePassword) return this.$showToast('两次密码不一致');
  73. this.$showToast('修改成功');
  74. setTimeout(()=>{
  75. uni.navigateBack();
  76. },1500);
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="less">
  82. .page{
  83. width: 100%;
  84. padding: 0 30rpx 40rpx;
  85. box-sizing: border-box;
  86. background: #F3F4F4;
  87. .box{
  88. margin-top: 20rpx;
  89. width: 100%;
  90. padding: 0 30rpx;
  91. box-sizing: border-box;
  92. background: #FFFFFF;
  93. border-radius: 10rpx 10rpx 10rpx 10rpx;
  94. .b_item{
  95. display: flex;
  96. align-items: center;
  97. padding: 30rpx 0;
  98. border-bottom: 1rpx solid #E1E1E1;
  99. position: relative;
  100. text{
  101. font-size: 30rpx;
  102. font-family: PingFang SC, PingFang SC;
  103. font-weight: 400;
  104. color: #333333;
  105. width: 120rpx;
  106. }
  107. input{
  108. border: none;
  109. width: calc(100% - 120rpx);
  110. padding-left: 22rpx;
  111. box-sizing: border-box;
  112. font-size: 30rpx;
  113. font-family: PingFang SC, PingFang SC;
  114. font-weight: 400;
  115. color: #333333;
  116. }
  117. &:last-child{
  118. border-bottom: none;
  119. }
  120. &.b_item_code{
  121. input{
  122. width: calc(100% - 400rpx);
  123. }
  124. }
  125. .bi_code{
  126. position: absolute;
  127. right: 0;
  128. top: 50%;
  129. margin-top: -21rpx;
  130. font-size: 30rpx;
  131. font-family: PingFang SC, PingFang SC;
  132. font-weight: 400;
  133. color: #1372FF;
  134. }
  135. }
  136. }
  137. .btn{
  138. width: calc(100% - 60rpx);
  139. height: 96rpx;
  140. background: #1372FF;
  141. border-radius: 48rpx 48rpx 48rpx 48rpx;
  142. line-height: 96rpx;
  143. text-align: center;
  144. font-size: 34rpx;
  145. font-family: PingFang SC, PingFang SC;
  146. font-weight: 400;
  147. color: #FFFFFF;
  148. letter-spacing: 2rpx;
  149. position: fixed;
  150. bottom: 40rpx;
  151. left: 30rpx;
  152. }
  153. }
  154. </style>