<template>
	<view class="content">
		<view class="shezhi-title">
			<image @click="backImg" src="../../static/fanhui.png" mode="widthFix"></image>
			<span>设置中心</span>
		</view>
		<view class="shezhi-list" v-for="(item,index) in list" :key="index" @click="goNav(item)">
			<view class="shezhi-list-left">
				<image class="shezhi-list-img-icon" :src="item.imgUrl" mode=""></image>
				<view class="shezhi-list-img-text">{{item.text}}</view>
			</view>
			<image class="shezhi-list-img-jiantou" src="../../static/images/my/right.png" mode=""></image>
		</view>
		<view style="position: fixed;bottom: 0rpx;left: 0;right: 0;height: 110rpx;line-height: 110rpx;z-index: 999;">
			<view v-if="isShow" class="btn" @click="TuiLogin">退出登录</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				version: '',
				isShow: false,
				list:[
					{url:'/pages/public/pwd',text:'修改密码',imgUrl:'../../static/shezhi1.png'},
					{url:'/my/help/feedbackIndex',text:'帮助中心',imgUrl:'../../static/shezhi3.png'},
					{url:'/my/feedback/index',text:'意见反馈',imgUrl:'../../static/shezhi4.png'},
					{url:'/my/setting/xieyi',text:'用户协议',imgUrl:'../../static/shezhi5.png'},
					{url:'/my/setting/mimi',text:'隐私政策',imgUrl:'../../static/shezhi6.png'},
					{url:'/my/setting/about',text:'关于我们',imgUrl:'../../static/shezhi8.png'},
				]
			}
		},
		onShow() {
			let token = this.$queue.getData('token');
			if (token) {
				this.isShow = true;
			}
		},
		onLoad() {
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
				this.version = widgetInfo.version;
			});
			// #endif
		},
		methods: {
			backImg(){//返回上一页
				uni.reLaunch({
					url:'/pages/my/index'
				})
			},
			//退出登录
			TuiLogin() {
				let that = this
				let userId = this.$queue.getData('userId');
				if (userId) {
					uni.showModal({
						title: '提示',
						content: '确定退出登录吗？',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.removeStorageSync('userName')
								uni.removeStorageSync('avatar')
								uni.removeStorageSync('userId')
								uni.removeStorageSync('token')
								uni.removeStorageSync('phone')
								uni.removeStorageSync('zhiFuBaoName')
								uni.removeStorageSync('zhiFuBao')
								uni.removeStorageSync('invitationCode')
								uni.removeStorageSync('unionId')
								uni.removeStorageSync('openId')
								uni.removeStorageSync('isVIP')
								uni.showToast({
									title: '退出成功！',
									icon: 'none'
								})
								uni.reLaunch({
									url:'/pages/my/index?money=0&couponnum=0'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/public/login'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			goNav(item) {
				uni.navigateTo({
					url: item.url
				})
			},
			goOut() {
				uni.showModal({
					title: '提示',
					content: '确定退出登录吗？',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							uni.removeStorageSync('userName')
							uni.removeStorageSync('avatar')
							uni.removeStorageSync('userId')
							uni.removeStorageSync('token')
							uni.removeStorageSync('phone')
							uni.removeStorageSync('zhiFuBaoName')
							uni.removeStorageSync('zhiFuBao')
							uni.removeStorageSync('invitationCode')
							uni.removeStorageSync('unionId')
							uni.removeStorageSync('openId')
							uni.removeStorageSync('isVIP')
							uni.removeStorageSync("artificerId")
							uni.removeStorageSync("onlineStatus")
							uni.showToast({
								title: '退出成功！',
								icon: 'none'
							})
							setTimeout(function() {
								uni.navigateBack()
							}, 1000)
							uni.$emit("exitLoginStatus", false);
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			}
		}

	}
</script>

<style scoped>
	.content {
		width: 100%;
		height: 100vh;
		background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #f7f7f7), url('../../static/background-img.png');
		background-position: center center;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		overflow: auto;
	}
	.shezhi-list-img-text{
		font-weight: 400;
		font-size: 32rpx;
		color: #202020;
	}
	.shezhi-list-left{
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
	.shezhi-list{
		width: 95%;
		padding: 0px 15px;
		height: 108rpx;
		background: #FFFFFF;
		border-radius: 14rpx;
		margin: 10px auto;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
	.shezhi-list-img-icon{
		width: 39.58rpx;
		height: 40.28rpx;
		margin-right: 5px;
	}
	.shezhi-list-img-jiantou{
		width: 10.76rpx;
		height: 18.19rpx;
	}
	
	.shezhi-title{
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		position: relative;
		margin: 10px 0px;
	}
	.shezhi-title span{
		font-weight: bold;
		font-size: 38rpx;
		color: #17181C;
	}
	.shezhi-title image{
		width: 25px;
		height: 30rpx;
		margin-right: 10px;
		position: absolute;
		left: 0;
	}
	.btn {
		background: linear-gradient(90deg, #019C88, #0FA78B, #35C495);
		color: #FFFFFF;
		margin: 16rpx 30upx;
		position: fixed;
		bottom: 0upx;
		width: 90%;
		border-radius: 50rpx;
		height: 78rpx;
		line-height: 78rpx;
		font-size: 32rpx;
		text-align: center;
	}
	.xian{
		width: 100%;
		height: 1px;
		background-color: #f7f7f7;
	}
</style>
