changePayPass.vue 3.32 KB
Newer Older
王建威's avatar
王建威 committed
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
<template>
	<view class="main">
		<TopBar title="修改支付密码"/>
		<view>
			<view class="set_title" style="margin-top: 40rpx;">请完成以下认证</view>
			<view class="set_tip">验证后更换支付密码</view>
			<input password class="set_input" v-model="old_password" placeholder="请输入旧支付密码">
			<view class="set_title" style="margin-top: 40rpx;">设置新的支付密码</view>
			<input password class="set_input" v-model="new_password" placeholder="设置6位支付密码">
			<input password class="set_input" v-model="new_password_repeat" placeholder="再一次输入支付密码">
			<view class="btn" style="margin-top: 80rpx;" @click="checkPass()">确认</view>
		</view>
		<view class="success_page" v-if="changeSuccess">
			<image src="../../../static/common/icon_chenggong@2x.png"></image>
			<text>修改成功!</text>
			<view class="btn" @click="returnHome()">确认</view>
		</view>
	</view>
</template>

<script>
	import TopBar from '@/components/TopBar/TopBar';
	import md5 from 'md5';
	export default {
		data() {
			return {
				old_password: '',
				new_password: '',
				new_password_repeat: '',
				changeSuccess: false
			}
		},
		methods: {
			checkPass() {
				if(this.new_password !== this.new_password_repeat) {
					uni.showToast({
						title: '两次密码输入不一致',
						icon: 'none'
					});
					return
				}
王建威's avatar
王建威 committed
42
				if(!/^[0-9a-zA-Z_]{6}$/.test(this.new_password)) {
王建威's avatar
王建威 committed
43
					uni.showToast({
王建威's avatar
王建威 committed
44
						title: '请设置6位支付密码,可以是字母、数字或下划线',
王建威's avatar
王建威 committed
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
						icon: 'none',
						duration: 2000
					});
					return
				}
				uni.request({
					url: '/uni/api/member/change_payword',
					method: 'POST',
					data: {
						old_password: md5(this.old_password),
						newpassword: md5(this.new_password),
						confirm_password: md5(this.new_password_repeat)
					},
					dataType: 'json',
					success: (res) => {
						if(res.data.code === 0) {
							this.changeSuccess = true;
						} else {
							uni.showToast({
								title: res.data.message,
								icon: 'none'
							});
						}
					}
				})
			},
			returnHome() {
				this.$jump('/pages/setaccount/setaccount', 2);
			}
		},
		components: {
			TopBar
		}
	}
</script>

<style lang="less" scoped>
	.main {
		padding: 80rpx 40rpx 0;
		.set_title {
			font-size: 32rpx;
			color: #212121;
			line-height: 44rpx;
			margin-top: 24rpx;
		}
		.set_tip {
			color: #7C7C7C;
			font-size: 26rpx;
			line-height: 36rpx;
			margin-top: 4rpx;
		}
		.set_input {
			width: 670rpx;
			height: 88rpx;
			line-height: 88rpx;
			background-color: #f5f5f5;
			padding-left: 20rpx;
			box-sizing: border-box;
			border-radius: 8rpx;
			margin-top: 20rpx;
		}
		.set_input::placeholder {
			color: #aeaeae;
		}
		.btn {
			background-color: #FFCD00;
			border-radius: 16rpx;
			text-align: center;
			width: 670rpx;
			height: 88rpx;
			line-height: 88rpx;
			margin: 162rpx auto 0;
			font-size: 30rpx;
		}
		.success_page {
			display: flex;
			flex-direction: column;
			align-items: center;
			position: absolute;
			left: 0;
			top: 0;
			z-index: 10;
			width: 100%;
			height: 100vh;
			background-color: #fff;
			image {
				width: 152rpx;
				height: 152rpx;
				margin-top: 282rpx;
			}
			text {
				font-size: 32rpx;
				font-family:PingFangSC-Medium,PingFang SC;
				font-weight:500;
				line-height: 44rpx;
				margin: 16rpx auto 78rpx;
			}
		}
	}
</style>