guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="findPayPwd"> |
| 3 | <view class="findPayPwd-list"> |
| 4 | <u-field v-model="tel" label="手机号" placeholder="请输入手机号" placeholder-style="color:#999999;font-family:PingFang-SC-Regular" |
| 5 | label-width="160" maxlength="11" type="number" clear-size="40"></u-field> |
| 6 | <u-field v-model="code" label="验证码" placeholder="请输入验证码" clear-size="40" placeholder-style="color:#999999" label-width="160" maxlength="6" type="number"> |
| 7 | <u-button size="mini" slot="right" type="primary" @click="getCode" shape="circle" :custom-style="btn" :disabled="isChecked">{{codeText}}</u-button> |
| 8 | </u-field> |
| 9 | <u-field v-model="pwd" label="新密码" placeholder="请输入6位密码" clear-size="40" placeholder-style="color:#999999" label-width="160" maxlength="6" :password="true" type="number"></u-field> |
| 10 | <u-field v-model="repwd" label="确认新密码" placeholder="请确认密码" clear-size="40" placeholder-style="color:#999999" label-width="160" maxlength="6" :password="true" type="number"></u-field> |
| 11 | </view> |
| 12 | <u-button class="findPayPwd-btn" @click="findPayPwd" :custom-style="findPayPwdBtn">确认</u-button> |
| 13 | </view> |
| 14 | </template> |
| 15 | |
| 16 | <script> |
| 17 | export default { |
| 18 | data() { |
| 19 | return { |
| 20 | codeText: "获取验证码", |
| 21 | tel: "", |
| 22 | code: "", |
| 23 | pwd: "", |
| 24 | repwd: "", |
| 25 | isChecked:false, |
| 26 | btn:{ |
| 27 | color: '#2FA8E1', |
| 28 | backgroundColor: '#FFFFFF', |
| 29 | borderColor:'#2FA8E1', |
| 30 | borderWidth: '1rpx', |
| 31 | borderStyle: 'solid', |
| 32 | fontFamily: "PingFang-SC-Regular" |
| 33 | }, |
| 34 | findPayPwdBtn:{ |
| 35 | width: '600rpx', |
| 36 | backgroundColor: '#2FA8E1', |
| 37 | color: '#FFFFFF', |
| 38 | fontFamily: "PingFang-SC-Medium", |
| 39 | fontSize: '30rpx', |
| 40 | marginTop: '100rpx', |
| 41 | padding: '50rpx 0' |
| 42 | } |
| 43 | } |
| 44 | }, |
| 45 | methods: { |
| 46 | getCode() { |
| 47 | let that = this |
| 48 | let tel = that.tel |
| 49 | if (tel == "") { |
| 50 | uni.showToast({ |
| 51 | title: "请输入正确手机号", |
| 52 | icon: "none", |
| 53 | duration: 800 |
| 54 | }) |
| 55 | return false |
| 56 | } |
| 57 | that.$u.post('/v1/code', {}).then(res => { |
| 58 | uni.showToast({ |
| 59 | title: res.msg, |
| 60 | icon: "none", |
| 61 | duration: 800 |
| 62 | }) |
| 63 | let i = 60 |
| 64 | that.isChecked = true |
| 65 | that.timer = setInterval(() => { |
| 66 | if (i != 0) { |
| 67 | i-- |
| 68 | that.codeText = i + "s" |
| 69 | } else { |
| 70 | clearInterval(that.timer) |
| 71 | that.codeText = "重新获取" |
| 72 | that.isChecked = false |
| 73 | } |
| 74 | }, 1000) |
| 75 | }) |
| 76 | }, |
| 77 | async findPayPwd() { |
| 78 | let that = this |
| 79 | let { |
| 80 | tel, |
| 81 | pwd, |
| 82 | code, |
| 83 | repwd |
| 84 | } = that |
| 85 | if (tel == "") { |
| 86 | uni.showToast({ |
| 87 | title: "请输入正确手机号", |
| 88 | icon: "none", |
| 89 | duration: 800 |
| 90 | }) |
| 91 | return false |
| 92 | } |
| 93 | if (code == "") { |
| 94 | uni.showToast({ |
| 95 | title: "请输入验证码", |
| 96 | icon: "none", |
| 97 | duration: 800 |
| 98 | }) |
| 99 | return false |
| 100 | } |
| 101 | if (pwd == "") { |
| 102 | uni.showToast({ |
| 103 | title: "请设置您的密码", |
| 104 | icon: "none", |
| 105 | duration: 800 |
| 106 | }) |
| 107 | return false |
| 108 | } |
| 109 | if (pwd != repwd) { |
| 110 | uni.showToast({ |
| 111 | title: "二次输入密码不一致,请确认后重新输入", |
| 112 | icon: "none", |
| 113 | duration: 800 |
| 114 | }) |
| 115 | return false |
| 116 | } |
| 117 | let param = { |
| 118 | code: code, |
| 119 | } |
| 120 | let ret = await that.$u.post("/v1/checkcode", param) |
| 121 | if (ret.code === 200) { |
| 122 | let { |
| 123 | randcode |
| 124 | } = ret |
| 125 | let param = { |
| 126 | "pwd": pwd, |
| 127 | "repwd": repwd, |
| 128 | "type": "find", |
| 129 | "randcode": randcode |
| 130 | } |
| 131 | that.$u.post("/v1/paypwd", param).then((res) => { |
| 132 | uni.showToast({ |
| 133 | title: "密码重置成功", |
| 134 | icon: "none", |
| 135 | duration: 800, |
| 136 | complete(res){ |
| 137 | setTimeout(() => { |
| 138 | uni.reLaunch({ |
| 139 | url: "/pages/sub_tabbar/index" |
| 140 | }) |
| 141 | }, 1500) |
| 142 | } |
| 143 | }) |
| 144 | }) |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | </script> |
| 150 | |
| 151 | <style lang="scss" scoped> |
| 152 | .findPayPwd { |
| 153 | width: 100vw; |
| 154 | // height: 100vh; |
| 155 | background-color: #F3F3F3; |
| 156 | overflow: hidden; |
| 157 | padding-bottom: 30rpx; |
| 158 | |
| 159 | &-list { |
| 160 | margin-top: 30rpx; |
| 161 | background-color: #FFFFFF; |
| 162 | } |
| 163 | |
| 164 | &-btn { |
| 165 | width: 600rpx; |
| 166 | background-color: #2FA8E1; |
| 167 | color: #FFFFFF; |
| 168 | font-family: "PingFang-SC-Medium"; |
| 169 | font-size: 30rpx; |
| 170 | margin-top: 100rpx; |
| 171 | padding: 50rpx 0; |
| 172 | } |
| 173 | |
| 174 | } |
| 175 | |
| 176 | .btn { |
| 177 | color: #2FA8E1; |
| 178 | background-color: #FFFFFF; |
| 179 | border-color: #2FA8E1; |
| 180 | border-width: 1rpx; |
| 181 | border-style: solid; |
| 182 | font-family: "PingFang-SC-Regular"; |
| 183 | } |
| 184 | </style> |