logout.vue 2.2 KB
<template>
	<view style="padding-left: 4%; padding-right: 4%; padding-top: 4%;">
		<view style="display: flex; ">
			<text space="emsp" style="font-size: 35rpx;">手机号</text>
			<text style="margin-left: 25rpx; font-size: 35rpx;">{{phoneNume}}</text>
		</view>
		<view style="height: 2rpx; background-color: #eeeeee; margin-top: 5rpx; margin-bottom: 20rpx;"></view>
		<view style="display: flex; align-items: center;">
			<text space="emsp" style="font-size: 35rpx;">密 码</text>
			<input style="font-size: 35rpx; margin-left: 25rpx;" password type="text" v-model="pwd"
				placeholder="请输入密码" />
		</view>
		<view style="height: 2rpx; background-color: #eeeeee; margin-top: 5rpx; margin-bottom: 20rpx;"></view>
		<view style="align-content: center; width: 100%;">
			<text style="color: #D4383D; font-size: 22rpx;">账号注销后该账户下所有信息将被清除</text>
		</view>
		<button style="margin-top: 8%; background-color: #2a0d5c; border-radius: 13rpx; color: white;"
			@click="bindLogout()">确实注销</button>
	</view>
</template>

<script>

	import http from "@/utils/http";
	import loginHelper from '../../utils/loginHelper.js'
	export default {
		data() {
			return {
				pwd: "",
				phoneNume: ""
			}
		},

		onLoad: function(){
			console.info("onLoad")
			this.phoneNume = "******" + loginHelper.getUserInfo().Mobile.substring(7);
		},

		methods: {
			bindLogout() {
				{
					this.logoutLogin();
				}
			},
			async logoutLogin() {
				if (this.pwd.length <= 0) {
					uni.showToast({
						icon: "none",
						title: "请输入密码",
					});
					return;
				}

				let query_data = `mutation{
					info_update_user(user:{	user_status:"-1"})
					{      
						error       
						success       
						error_type
					}
				}`;
				console.info(query_data);
				let result = await http.gql({
					query: query_data
				})
				this.loginBtnLoading = false;
				console.info(result);
				//处理返回请求
				if (result && result.data && result.data.info_update_user &&
					!result.data.info_update_user.error) {
					loginHelper.logout();
					uni.navigateBack();
				} else {
					uni.showToast({
						icon: "none",
						title: "注销异常",
					});
					return;
				}
			}
		}
	}
</script>

<style>

</style>