你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

uni-app个人中心总汇(5)修改密码

2021/12/24 17:37:09
<template>
	<view>
		<view >
		<input style="border-bottom: 1rpx solid #eee;margin-top: 30rpx;" v-model="newPassword" placeholder="新密码" />
		<input style="border-bottom: 1rpx solid #eee;margin-top: 30rpx;" v-model="oldPassword" placeholder="旧密码" />
		</view>
		<button @click="getmima()" :style="[inputStyle]" class="getCaptcha">确定修改</button>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				newPassword:'',
				oldPassword:''
			}
		},
		computed: {
			inputStyle() {
				let style = {};
				if(this.newPassword&&this.oldPassword) {
					style.color = "#fff";
					style.backgroundColor = this.$u.color['warning'];
				}
				return style;
			}
		},
		methods: {
			getmima(){
				uni.request({
					url:'http://124.93.196.45:10091/prod-api/api/common/user/resetPwd',
					data:{
						newPassword:this.newPassword,
						oldPassword:this.oldPassword
					},
					method:"PUT",
					header:{
						Authorization:uni.getStorageSync('token')
					},
					success(res) {
						console.log(res)
						if(res.data.code==200){
							uni.showToast({
								title:res.data.msg
							})
							setTimeout(()=>{
								uni.switchTab({
									url:'index'
								})
							},1000)
						}
						if(res.data.code>=400){
							uni.showToast({
								title:res.data.msg
							})
						}
					}
				})
			}
		}
	}
</script>