updatePass.vue 2.4 KB
<template>
	<view class="content">
		<view style="padding-top: 16px;">
			<view class="inputC">
				<input type="text" value="" placeholder="当前密码" @input="oldPassInput" password="true" />
			</view>
			<view class="inputC">
				<input type="text" value="" placeholder="新密码" @input="newPassInput" password="true" />
			</view>
			<view class="inputC">
				<input type="text" value="" placeholder="确认密码" @input="confrimPassInput" password="true" />
			</view>
		</view>

		<view style="margin: 90px 16px;" @click="saves">
			<view class="saveBox"><text class="save">保存</text></view>
		</view>
	</view>
</template>

<script>
	import request from '../../utils/request.js'
	export default {
		data() {
			return {
				oldPass: '',
				newPass: '',
				confrim: '',
			}
		},
		methods: {
			oldPassInput(e) {
				this.oldPass = e.detail.value
			},
			newPassInput(e) {
				this.newPass = e.detail.value
			},
			confrimPassInput(e) {
				this.confrim = e.detail.value
			},
			saves() {
				if (this.oldPass == '') {
					uni.showToast({
						title: '请输入原始密码',
						icon: 'none'
					})
				} else if (this.newPass == '') {
					uni.showToast({
						title: '请输入新密码',
						icon: 'none'
					})
				} else if (this.confrim == '') {
					uni.showToast({
						title: '请确认新密码',
						icon: 'none'
					})
				} else if (this.newPass != this.confrim) {
					uni.showToast({
						title: '密码不一致',
						icon: 'none'
					})
				} else {
					request.post('/api/index/save_pass', {
						password1: this.oldPass,
						password2: this.newPass,
						password3: this.confrim,
					}).then(res => {
						if (res.code == 1) {
							uni.showToast({
								title: '修改成功',
								icon: 'none'
							})
							setTimeout(() => {
								uni.redirectTo({
									url: '/pages/index/me'
								})
							}, 1000)

						} else {
							uni.showToast({
								title: err.msg,
								icon: 'none'
							})
						}
					}).catch(err => {

					})
				}

			}
		}
	}
</script>

<style>
	.inputC {
		background: #ffffff;
		height: 46px;
		display: flex;
		align-items: center;
		margin-bottom: 16px;
		padding: 0 16px;
	}

	.saveBox {
		background: #4674c9;
		border-radius: 8rpx;
		height: 96rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.save {
		color: #FFFFFF;
		font-size: 32rpx;
	}

	.content {
		background-color: #F2F3F5;
		height: 100vh;
	}
</style>