my-resetpassword.vue 4.4 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 75 76 77 78 79 80 81 82 83 84
			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;
				} else {
					updata.password = password;
					updata.newPassword = newPassword;
				}
				this.Upload(updata);
				this.$refs.alertDialog.close();
			},
			dialogClose() {
				this.$refsalertDialog.close();
			},
M
m0_74163447 已提交
85
			confirmModification() {
M
m0_74163447 已提交
86
				this.$refs.alertDialog.open();
M
m0_74163447 已提交
87
			},
Y
yyt 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100 101
			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 已提交
102 103 104 105
			goBack() {
				uni.navigateBack({
					delta: 1, //返回层数,2则上上页
				})
M
m0_74163447 已提交
106
			},
Y
yyt 已提交
107 108
			Upload(updata) {
				uniCloud.callFunction({
Y
布局  
yyt 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
						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 已提交
124
					});
Y
yyt 已提交
125 126
			},
			onload() {
M
m0_74163447 已提交
127 128
				plus.navigator.setStatusBarBackground('#EDEEF0');
			}
M
m0_74163447 已提交
129
		}
M
m0_74163447 已提交
130
	}
M
m0_74163447 已提交
131 132 133 134 135 136 137
</script>

<style>
	.main {
		position: absolute;
		width: 100%;
		height: 100%;
M
m0_74163447 已提交
138 139 140 141 142
	}

	.top {
		width: 100%;
		height: 50px;
M
m0_74163447 已提交
143
		background-color: #EDEEF0;
M
m0_74163447 已提交
144
		text-align: center;
M
m0_74163447 已提交
145
	}
M
m0_74163447 已提交
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

	.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 已提交
167
		margin-top: 15px;
M
m0_74163447 已提交
168 169 170
		font-weight: bold;
		color: #f1992d;
		display: inline-block;
M
m0_74163447 已提交
171
	}
M
m0_74163447 已提交
172 173 174 175

	.content {

		width: 80%;
M
m0_74163447 已提交
176 177 178 179
		margin-top: 50%;
		margin-left: auto;
		margin-right: auto;
	}
M
m0_74163447 已提交
180 181 182

	.password {

M
m0_74163447 已提交
183
		margin-top: 50rpx;
M
m0_74163447 已提交
184
		height: 20%;
M
m0_74163447 已提交
185 186
		display: flex;
		align-items: center;
M
m0_74163447 已提交
187

M
m0_74163447 已提交
188 189
		/* border-bottom: 1px solid #ccc; */
	}
M
m0_74163447 已提交
190 191

	.password span {
M
m0_74163447 已提交
192 193
		font-size: 35rpx;
	}
M
m0_74163447 已提交
194 195

	.password input {
M
m0_74163447 已提交
196 197
		border-bottom: 1px solid #ccc;
	}
M
m0_74163447 已提交
198 199

	.confirm {
M
m0_74163447 已提交
200 201 202
		height: 20%;
		margin-top: 20%;
	}
M
m0_74163447 已提交
203 204 205

	.confirm-btn {
		background-color: #F1992D;
M
m0_74163447 已提交
206
		color: #FFFFFF;
M
m0_74163447 已提交
207
		width: 70%;
M
m0_74163447 已提交
208
		height: 85rpx;
M
m0_74163447 已提交
209
		line-height: 85rpx;
M
m0_74163447 已提交
210 211 212 213 214 215
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		border-radius: 20rpx;
	}
</style>