1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
| <template>
| <view>
| <u-toast ref="uToast" /><u-no-network></u-no-network>
| <u-navbar title="设置密码" safeAreaInsetTop fixed placeholder>
| <view class="coreshop-navbar-left-slot" slot="left">
| <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
| <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
| <u-icon name="home" size="22" @click="goHome"></u-icon>
| </view>
| <view slot="right">
| </view>
| </u-navbar>
| <view class="coreshop-padding-15 coreshop-bg-white">
| <u--form :model="model" :rules="rules" ref="uForm" errorType="message" labelPosition="left" labelWidth="80">
| <u-form-item label="旧密码" prop="pwd" v-if="oldpassWord" borderBottom>
| <u--input border="none" :password-icon="true" type="password" v-model="model.pwd" placeholder="请输入密码"></u--input>
| </u-form-item>
| <u-form-item label="新密码" prop="newPwd" borderBottom>
| <u--input border="none" :password-icon="true" type="password" v-model="model.newPwd" placeholder="请输入密码"></u--input>
| </u-form-item>
| <u-form-item label="确认密码" prop="rePwd" borderBottom>
| <u--input border="none" :password-icon="true" type="password" v-model="model.rePwd" placeholder="请确认密码"></u--input>
| </u-form-item>
| </u--form>
| </view>
|
| <!--按钮-->
| <view class="coreshop-bg-white coreshop-footer-fixed coreshop-foot-padding-bottom">
| <u-button type="error" size="normal" @click="submitHandler" :disabled='submitStatus' :loading='submitStatus'>保存</u-button>
| </view>
| </view>
| </template>
| <script>
| export default {
| data() {
| return {
| model: {
| pwd: '',
| newPwd: '',
| rePwd: '',
| },
| submitStatus: false,
| oldpassWord: true,
| rules: {
| pwd: [
| {
| type: 'string',
| required: true,
| message: '请输入密码',
| trigger: ['change', 'blur'],
| }
| ],
| newPwd: [
| {
| type: 'string',
| required: true,
| message: '请输入密码',
| trigger: ['change', 'blur'],
| }
| ],
| rePwd: [
| {
| type: 'string',
| required: true,
| message: '请重新输入密码',
| trigger: ['change', 'blur'],
| },
| {
| validator: (rule, value, callback) => {
| return value === this.model.newPwd;
| },
| message: '两次输入的密码不相等',
| trigger: ['change', 'blur'],
| }
| ],
| },
| }
| },
| computed: {},
| onReady() {
| this.$refs.uForm.setRules(this.rules);
| },
| methods: {
| // 保存资料
| submitHandler() {
| this.submitStatus = true;
|
| this.$refs.uForm.validate().then(res => {
|
| this.$u.api.editPwd({
| pwd: this.model.pwd,
| newpwd: this.model.newPwd,
| repwd: this.model.rePwd
| }).then(res => {
| this.submitStatus = false;
| if (res.status) {
| this.$refs.uToast.show({message: res.msg, type: 'success', complete: function () {
| uni.navigateBack({
| delta: 1
| });
| }
| })
|
| } else {
| this.$u.toast(res.msg)
| }
| });
| }).catch(errors => {
| uni.$u.toast('您输入的内容校验失败。')
| })
| }
| },
| onLoad: function () {
| var _this = this;
| _this.$u.api.userInfo().then(res => {
| if (res.status) {
| _this.oldpassWord = res.data.passWord ? true : false;;
| } else {
| //报错了
| _this.$u.toast(res.msg);
| }
| });
| }
| }
| </script>
|
| <style lang="scss">
| </style>
|
|