123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <template>
- <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
- <view class="main">
- <view class="one">
- <uni-forms ref="form" :modelValue="form" :rules="rules" label-width="auto">
- <uni-forms-item label="账号" name="phone">
- <uni-easyinput type="text" v-model="form.phone" placeholder="请输入账号" disabled />
- </uni-forms-item>
- <uni-forms-item label="新密码" name="password">
- <uni-easyinput type="password" v-model="form.password" placeholder="请输入新密码" />
- </uni-forms-item>
- <uni-forms-item label="确认密码" name="is_password">
- <uni-easyinput type="is_password" v-model="form.is_password" placeholder="请输入确认密码" />
- </uni-forms-item>
- </uni-forms>
- <view class="btn">
- <button type="primary" @click="onSubmit('form')" size="small">提交</button>
- <view class="name">提示:为了您的账户安全,建议定期修改密码</view>
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- frameStyle: {
- useBar: false
- },
- form: {},
- rules: {
- password: {
- rules: [{
- required: true,
- errorMessage: '请输入新密码',
- }]
- },
- },
- };
- },
- onLoad: function(e) {
- const that = this;
- that.watchLogin();
- },
- methods: {
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: (res) => {
- let user = that.$jwt(res.data);
- if (user) {
- that.$set(that, `form`, {
- id: user.id,
- phone: user.phone
- })
- }
- },
- fail: (err) => {}
- })
- },
- toPath(e) {
- if (e && e.route) uni.redirectTo({
- url: `/${e.route}`
- })
- },
- // 提交保存
- onSubmit(ref) {
- const that = this;
- that.$refs[ref].validate().then(async params => {
- if (params.password == params.is_password) {
- const arr = await that.$api(`/user/resetPwd/${that.form.id}`, 'POST', params);
- if (arr.errcode == '0') {
- uni.showToast({
- title: `密码修改成功`,
- icon: 'success',
- });
- uni.clearStorage();
- uni.redirectTo({
- url: '/pages/login/index'
- })
- } else {
- uni.showToast({
- title: arr.errmsg,
- })
- }
- } else {
- uni.showToast({
- title: `密码不一致`,
- });
- }
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- padding: 2vw;
- .uni-input {
- border: #f1f1ff 1px solid;
- padding: 2vw 2vw;
- border-radius: 1vw;
- }
- .btn {
- text-align: center;
- button {
- margin: 0 2vw 2vw 2vw;
- background-color:var(--fFB1Color);
- color: var(--fffColor);
- }
- .name {
- color: var(--f85Color);
- font-size: var(--font14Size);
- }
- }
- }
- }
- .uni-forms-item {
- margin-bottom: 6vw !important;
- display: flex;
- flex-direction: row;
- }
- </style>
|