my-resetpassword.vue 4.8 KB
Newer Older
M
m0_74163447 已提交
1 2
<template>
	<view class="main">
M
m0_74163447 已提交
3
		<!-- <view class="return">
M
m0_74163447 已提交
4
			<view class="return-btn" @click="goBack"></view>
M
m0_74163447 已提交
5 6 7 8 9 10
			<text>重置密码</text>
		</view> -->
		<view class="top">
			<image @click="goBack" class="back" :src="'/static/my/exit-icon.png'"></image>
			<view class="title">重置密码</view>
			<span class="empty"></span>
M
m0_74163447 已提交
11 12
		</view>
		<view class="content">
Y
yyt 已提交
13
			<view class="password">
M
m0_74163447 已提交
14 15 16 17
				<span>&ensp;&ensp;码:</span>
				<input placeholder="请输入原密码" type="text" :password="showPassword" name="input"></input>
				<!-- <text :class="[!showPassword ?'cuIcon-attentionfill' : 'cuIcon-attentionforbidfill']" class="text-gray"  @click="showPwd" ></text> -->
				<!-- <input type="safe-password" :value="originalPassword" :valplaceholder='请输入原密码'></input> -->
Y
yyt 已提交
18 19
			</view>
			<view class="password">
M
m0_74163447 已提交
20
				<span>&ensp;&ensp;码:</span>
Y
yyt 已提交
21 22 23 24
				<input placeholder="请输入新密码" type="text" @input="bindNewPassword" :password="showPassword"
					name="input"></input>
			</view>
			<view class="password">
M
m0_74163447 已提交
25
				<span>确认密码:</span>
Y
yyt 已提交
26 27 28
				<input placeholder="请确认密码" type="text" @input="bindConfirmPassword" :password="showPassword"
					name="input"></input>
			</view>
M
m0_74163447 已提交
29 30 31 32 33 34 35 36 37
		</view>
		<view class="confirm">
			<button class="confirm-btn" @click="confirmModification()">确认修改</button>
		</view>
	</view>
</template>

<script>
	export default {
M
m0_74163447 已提交
38 39 40
		data() {
			return {
				showPassword: true,
Y
yyt 已提交
41 42 43
				password:'1223',
				newPassword: '',
				confirmPassword: '',
M
m0_74163447 已提交
44 45 46
			}
		},
		methods: {
Y
yyt 已提交
47 48 49 50 51 52
			bindNewPassword(e) {
				this.newPassword = e.detail.value;
			},
			bindConfirmPassword(e) {
				this.confirmPassword = e.detail.value;
			},
M
m0_74163447 已提交
53 54 55 56 57 58 59 60 61
			// showPwd: function() {
			//           this.showPassword = !this.showPassword;
			//            },
			confirmModification() {

				uni.showModal({
					title: '温馨提示', //提示标题
					content: '确认修改密码吗', //提示内容
					showCancel: true, //是否显示取消按钮
Y
yyt 已提交
62
					success: res => {
M
m0_74163447 已提交
63
						if (res.confirm) { //confirm为ture,代表用户点击确定
Y
yyt 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
							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);
M
m0_74163447 已提交
88 89 90 91 92 93
						} else if (res.cancel) { //cancel为ture,代表用户点击取消
							console.log('点击了取消按钮');
						}
					}
				})
			},
Y
yyt 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110

			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 已提交
111 112 113 114
			goBack() {
				uni.navigateBack({
					delta: 1, //返回层数,2则上上页
				})
M
m0_74163447 已提交
115
			},
Y
yyt 已提交
116 117 118 119 120 121 122 123 124 125 126 127
			Upload(updata) {
				
				uniCloud.callFunction({
					name: 'fe-my-resetpassword',
					
					data: {userId:'6450da43e1a35c371b3699cc',password:updata.password,newPassword:updata.newPassword}
				})
				.then(res => {
					console.log(res);
				});						
			},
			onload() {
M
m0_74163447 已提交
128 129
				plus.navigator.setStatusBarBackground('#EDEEF0');
			}
M
m0_74163447 已提交
130
		}
M
m0_74163447 已提交
131
	}
M
m0_74163447 已提交
132 133 134 135 136 137 138
</script>

<style>
	.main {
		position: absolute;
		width: 100%;
		height: 100%;
M
m0_74163447 已提交
139 140 141 142 143 144
		/* background-color: #EDEEF0; */
	}

	.top {
		width: 100%;
		height: 50px;
M
m0_74163447 已提交
145
		background-color: #EDEEF0;
M
m0_74163447 已提交
146
		text-align: center;
M
m0_74163447 已提交
147
	}
M
m0_74163447 已提交
148 149 150 151 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;
		margin-top: 10px;
		font-weight: bold;
		color: #f1992d;
		display: inline-block;
M
m0_74163447 已提交
173
	}
M
m0_74163447 已提交
174 175 176 177

	.content {

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

	.password {

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

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

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

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

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

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