my-resetpassword.vue 4.6 KB
Newer Older
M
m0_74163447 已提交
1 2
<template>
	<view class="main">
M
m0_74163447 已提交
3
		<view class="top">
Y
yyt 已提交
4
			<image @click="goBack" class="back" src="/static/discover/back.png"></image>
M
m0_74163447 已提交
5 6
			<view class="title">重置密码</view>
			<span class="empty"></span>
M
m0_74163447 已提交
7 8
		</view>
		<view class="content">
Y
yyt 已提交
9
			<view class="password">
M
m0_74163447 已提交
10
				<span>&ensp;&ensp;码:</span>
Y
布局  
yyt 已提交
11 12
				<input placeholder="请输入原密码" @input="bindPassword" type="text" :password="showPassword"
					name="input"></input>
Y
yyt 已提交
13 14
			</view>
			<view class="password">
M
m0_74163447 已提交
15
				<span>&ensp;&ensp;码:</span>
Y
yyt 已提交
16 17 18 19
				<input placeholder="请输入新密码" type="text" @input="bindNewPassword" :password="showPassword"
					name="input"></input>
			</view>
			<view class="password">
M
m0_74163447 已提交
20
				<span>确认密码:</span>
Y
yyt 已提交
21 22 23
				<input placeholder="请确认密码" type="text" @input="bindConfirmPassword" :password="showPassword"
					name="input"></input>
			</view>
M
m0_74163447 已提交
24 25 26 27
		</view>
		<view class="confirm">
			<button class="confirm-btn" @click="confirmModification()">确认修改</button>
		</view>
M
m0_74163447 已提交
28 29 30 31
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog cancelText="取消" confirmText="确定" title="提示" content="确定修改你的密码吗?"
				@confirm="dialogConfirm"></uni-popup-dialog>
		</uni-popup>
M
m0_74163447 已提交
32 33 34 35 36
	</view>
</template>

<script>
	export default {
M
m0_74163447 已提交
37 38 39
		data() {
			return {
				showPassword: true,
Y
布局  
yyt 已提交
40
				password: '',
Y
yyt 已提交
41 42
				newPassword: '',
				confirmPassword: '',
M
m0_74163447 已提交
43 44 45
			}
		},
		methods: {
M
m0_74163447 已提交
46 47 48
			bindPassword(e) {
				this.password = e.detail.value;
			},
Y
yyt 已提交
49 50 51 52 53 54
			bindNewPassword(e) {
				this.newPassword = e.detail.value;
			},
			bindConfirmPassword(e) {
				this.confirmPassword = e.detail.value;
			},
M
m0_74163447 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
			dialogConfirm() {
				let that = this;
				let password = that.password;
				let newPassword = that.newPassword;
				let confirmPassword = that.confirmPassword;
				let updata = {};
				if (!that.isPasswordAvailable(newPassword)) {
					uni.showToast({
						title: '密码长度在8-20位!',
						icon: 'none',
						duration: 2000
					});
					return;
				} else if (!that.isConfirmPasswordAvailable(newPassword, confirmPassword)) {
					uni.showToast({
						title: '两次密码不一致',
						icon: 'none',
						duration: 2000
					});
					return;
Y
结束  
yyt 已提交
75 76 77 78 79 80
				} else if (that.password == newPassword) {
					uni.showToast({
						title: '与原密码一致',
						icon: 'none',
						duration: 2000
					});
M
m0_74163447 已提交
81 82 83
				} else {
					updata.password = password;
					updata.newPassword = newPassword;
Y
结束  
yyt 已提交
84
					this.Upload(updata);
M
m0_74163447 已提交
85 86 87 88 89 90
				}
				this.$refs.alertDialog.close();
			},
			dialogClose() {
				this.$refsalertDialog.close();
			},
M
m0_74163447 已提交
91
			confirmModification() {
M
m0_74163447 已提交
92
				this.$refs.alertDialog.open();
M
m0_74163447 已提交
93
			},
Y
yyt 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107
			isPasswordAvailable(newPassword) {
				if (newPassword.length > 20 || newPassword.length < 8) {
					return false;
				} else {
					return true;
				}
			},
			isConfirmPasswordAvailable(newPassword, confirmPassword) {
				if (newPassword == confirmPassword) {
					return true;
				} else {
					return false;
				}
			},
M
m0_74163447 已提交
108 109 110 111
			goBack() {
				uni.navigateBack({
					delta: 1, //返回层数,2则上上页
				})
M
m0_74163447 已提交
112
			},
Y
yyt 已提交
113 114
			Upload(updata) {
				uniCloud.callFunction({
Y
布局  
yyt 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
						name: 'fe-my-resetpassword',
						data: {
							userId: getApp().globalData.userId,
							password: updata.password,
							newPassword: updata.newPassword
						},

					})
					.then(res => {
						uni.showToast({
							title: res.result.message,
							icon: 'none',
							duration: 2000
						});
						console.log(res);
M
m0_74163447 已提交
130
					});
Y
yyt 已提交
131 132
			},
			onload() {
M
m0_74163447 已提交
133 134
				plus.navigator.setStatusBarBackground('#EDEEF0');
			}
M
m0_74163447 已提交
135
		}
M
m0_74163447 已提交
136
	}
M
m0_74163447 已提交
137 138 139 140 141 142 143
</script>

<style>
	.main {
		position: absolute;
		width: 100%;
		height: 100%;
M
m0_74163447 已提交
144 145 146 147 148
	}

	.top {
		width: 100%;
		height: 50px;
M
m0_74163447 已提交
149
		background-color: #EDEEF0;
M
m0_74163447 已提交
150
		text-align: center;
M
m0_74163447 已提交
151
	}
M
m0_74163447 已提交
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172

	.back {
		width: 40px;
		height: 30px;
		margin-top: 10px;
		margin-bottom: 10px;
		float: left;
		margin-left: 10px;
	}

	.empty {
		width: 40px;
		height: 30px;
		margin-top: 10px;
		margin-bottom: 10px;
		float: right;
		margin-right: 10px;
	}

	.title {
		font-size: 20px;
Y
yyt 已提交
173
		margin-top: 15px;
M
m0_74163447 已提交
174 175 176
		font-weight: bold;
		color: #f1992d;
		display: inline-block;
M
m0_74163447 已提交
177
	}
M
m0_74163447 已提交
178 179 180 181

	.content {

		width: 80%;
M
m0_74163447 已提交
182 183 184 185
		margin-top: 50%;
		margin-left: auto;
		margin-right: auto;
	}
M
m0_74163447 已提交
186 187 188

	.password {

M
m0_74163447 已提交
189
		margin-top: 50rpx;
M
m0_74163447 已提交
190
		height: 20%;
M
m0_74163447 已提交
191 192
		display: flex;
		align-items: center;
M
m0_74163447 已提交
193

M
m0_74163447 已提交
194 195
		/* border-bottom: 1px solid #ccc; */
	}
M
m0_74163447 已提交
196 197

	.password span {
M
m0_74163447 已提交
198 199
		font-size: 35rpx;
	}
M
m0_74163447 已提交
200 201

	.password input {
M
m0_74163447 已提交
202 203
		border-bottom: 1px solid #ccc;
	}
M
m0_74163447 已提交
204 205

	.confirm {
M
m0_74163447 已提交
206 207 208
		height: 20%;
		margin-top: 20%;
	}
M
m0_74163447 已提交
209 210 211

	.confirm-btn {
		background-color: #F1992D;
M
m0_74163447 已提交
212
		color: #FFFFFF;
M
m0_74163447 已提交
213
		width: 70%;
M
m0_74163447 已提交
214
		height: 85rpx;
M
m0_74163447 已提交
215
		line-height: 85rpx;
M
m0_74163447 已提交
216 217 218 219 220 221
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		border-radius: 20rpx;
	}
</style>