forgot.vue 3.9 KB

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