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
| let $api = require('../../utils/ajaxFn.js')
| let md5 = require('../../utils/md5.js')
| let validator = require('../../utils/validator.js')
| const app = getApp()
| Page({
| data: {
| userStyle: {},
| newTwo: "",
| info: {
| newPwd: "",
| oldPwd: ""
| },
| userInfo: {}
| },
| onLoad() {
| this.setData({
| userStyle: app.userStyle,
| userInfo: app.userInfo
| })
| },
| getOld(e) {
| this.setData({
| 'info.oldPwd': e.detail.value
| })
| },
| getNem(e) {
| this.setData({
| 'info.newPwd': e.detail.value
| })
| },
| getNemTwo(e) {
| this.setData({
| newTwo: e.detail.value
| })
| },
| save() {
| let self = this
| console.log(this.data.userInfo.mblNo, this.data.newTwo, this.data.info)
| if (validator.checkValEmpty(this.data.info.oldPwd)) {
| my.showToast({
| content: '请输入原密码',
| duration: 2000,
| });
| return
| }
| if (validator.checkValEmpty(this.data.info.newPwd)) {
| my.showToast({
| content: '请输入新密码',
| duration: 2000,
| });
| return
| }
| if (!validator.checkPassword(this.data.info.newPwd)) {
| my.showToast({
| content: '新密码格式有误,应为8-16位字母数字组合',
| duration: 2000,
| });
| return
| }
| if (this.data.newTwo != this.data.info.newPwd) {
| my.showToast({
| content: '两次新密码不一致,请确认',
| duration: 2000,
| });
| return
| }
| let p = new Promise(function (re, rej) {
| $api.ajax(
| '/sib/user/updatePwd',
| 'POST',
| (res) => {
| my.showToast({
| content:'修改成功',
| duration:3000,
| success:()=>{
| re()
| }
| })
| },
| (err) => {
|
| },
| true,
| {
| newPwd: md5.hex_md5(self.data.userInfo.mblNo + self.data.info.newPwd),
| oldPwd: md5.hex_md5(self.data.userInfo.mblNo + self.data.info.oldPwd)
| }
| )
|
| })
| p.then(() => {
| $api.ajax(
| '/sib/xcx/login/logout',
| 'POST',
| res => {
| my.removeStorageSync({
| key: 'sessionId',
| });
| my.navigateTo({
| url: '/pages/index/index'
| });
| },
| err => {
|
| },
| true
| )
| })
|
| }
| });
|
|