RemarkPopup.js
3.97 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// components/RemarkPopup/RemarkPopup.js
import md5 from '~/utils/lib/md5.js'
import { performancePasswordUpdate, performancePasswordCheck } from '~/packageEquity/api'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
value: false,
observer: function (n) {
if (n) {
this.setData({
password: '',
repassword: ''
})
}
}
},
maxlength: Number,
title: {
type: String
},
btnName: {
type: String
},
isSetPassword: {
type: Boolean
// value: false
}
// isInt: {
// type: Boolean,
// value: false
// },
// required: {
// type: Boolean,
// value: false
// }
},
/**
* 组件的初始数据
*/
data: {
// inputValue: '',
// isEdit: false,
password: '',
repassword: ''
},
/**
* 组件的方法列表
*/
methods: {
input(e) {
let { value } = e.detail
console.log(e)
let { name } = e.currentTarget.dataset
this.setData({
[name]: value
})
},
noScroll() {},
blur(e) {
this.setData({
inputValue: e.detail.value,
isEdit: true
})
},
showPopup(e) {
// console.log()
let { name, btnName } = e.currentTarget.dataset
// if (btnName == 'cancel') {
// this.setData({
// value: ''
// })
// }
// console.log(name)
// 判断是不是来自组件 不是调用页面的数据修改
// 是用方法回传关闭
// let { isFormComponent } = this.data
// if (!isFormComponent) {
let thisPage = wx.$router.getPageInstance()
// console.log(thisPage)
console.log(thisPage)
thisPage.setData({
[name]: false
})
// 组件中使用
this.triggerEvent('cancel')
// this.setData({
// isEdit: false
// })
// } else {
// // console.log('tri')
// this.triggerEvent('closePop')
// }
},
remarkConfirm() {
// console.log('confirm')
let { isSetPassword, maxlength, password, repassword } = this.data
if (maxlength != password.length) {
return wx.$util.showToast('请输入4位数字密码')
}
// 判断 是设置密码还是输入密码
if (isSetPassword) {
if (maxlength != repassword.length) {
return wx.$util.showToast('请输入4位数字确认密码')
}
if (password != repassword) {
return wx.$util.showToast('两次密码输入不一致')
}
let params = {
passwordMd5: md5(password)
}
performancePasswordUpdate(params)
.then(res => {
console.log(res)
let { code, data, message } = res
if (code == 0 && data) {
this.triggerEvent('confirm')
this.showPopup({
currentTarget: {
dataset: {
name: 'passwordPop'
}
}
})
} else {
wx.$util.showToast(message)
}
})
.catch(err => {
console.log(err)
})
} else {
performancePasswordCheck({ passwordMd5: md5(password) })
.then(res => {
console.log(res)
let { code, data, message } = res
if (code == 0 && data) {
this.triggerEvent('confirm')
this.showPopup({
currentTarget: {
dataset: {
name: 'passwordPop'
}
}
})
} else {
wx.$util.showToast(message)
}
})
.catch(err => {
console.log(err)
})
// this.showPopup({
// currentTarget: {
// dataset: {
// name: 'passwordPop'
// }
// }
// })
}
}
}
})