<template>
	<!-- 设置 -->
	<view class="container">
		<view @click="$wskj.to('/pages/my/setting/checkmobile')" class="item">
			<text>支付密码管理</text>
			<image src="@/static/right.png"></image>
		</view>
		<view @click="getXieyi('购买协议','gmxy')" class="item">
			<text>购买协议</text>
			<image src="@/static/right.png"></image>
		</view>
		<view @click="getXieyi('用户协议','yhxy')" class="item">
			<text>用户协议</text>
			<image src="@/static/right.png"></image>
		</view>
		<view @click="getXieyi('隐私政策','yszc')" class="item">
			<text>隐私政策</text>
			<image src="@/static/right.png"></image>
		</view>
		<view @click="$wskj.to('/pages/my/aboutme')" class="item">
			<text>关于我们</text>
			<image src="@/static/right.png"></image>
		</view>

		<view class="btn-group">
			<view @click="outlogin" class="fullscreen-btn">
				<text>退出登录</text>
			</view>
		</view>

		<!-- 退出弹窗 -->
		<wskj-modal :show="outloginShow" title="退出提醒" :showCancelButton="true" confirmText="确定" confirmColor="#EB7318"
			@close="outloginShow = false" @cancel="outloginShow = false" @confirm="onConfirmOutLogin">
			<view style="padding: 40rpx 0;">
				<view>
					<text style="font-size: 28rpx;">确定要退出当前账号？</text>
				</view>
			</view>
		</wskj-modal>
	</view>
</template>

<script>
	import { mapState } from "vuex"
	export default {
		data() {
			return {
				outloginShow: false,
				shopStatus: false
			}
		},
		onLoad(){
			this.getShopStatus()
		},
		computed: {
			...mapState(['user'])
		},
		methods: {
			getShopStatus(){
				const params = {
					url: '/api/userinfo/getopen',
					data: {
						shop_id: this.user.userInfo.shop_id
					}
				}
				this.$request(params).then(res => {
					// console.log(res)
					this.shopStatus = res.data == 1? true : false
				}).catch(err => {
					
				})
			},
			getXieyi(title, type){
				const params = {
					url: '/api/index/xieyi',
					loadingTip: '',
					data: {
						type
					}
				}
				this.$request(params).then(res => {
					// console.log(res)
					this.$wskj.to('/pages/xieyi?title=' + title + '&content=' + encodeURIComponent(res.data))
				}).catch(err => {
					
				})
			},
			outlogin() {
				this.outloginShow = true
			},
			// 退出登录确认
			onConfirmOutLogin() {
				this.outloginShow = false
				uni.showLoading({
					title: ''
				})
				const params = {
					url: '/api/userinfo/tuichu',
					data: {
						
					}
				}
				this.$request(params).then(res => {
					// console.log(res)
					uni.clearStorageSync();
					// 清除vuex用户信息数据
					this.$store.commit('user/outLogin')
					setTimeout(() => {
						uni.hideLoading()
						uni.reLaunch({
							url: '/pages/global'
						})
					}, 600)
				}).catch(err => {
					
				})
			}
		}
	}
</script>

<style scoped>
	.container {}

	.item {
		padding: 32rpx;
		display: flex;
		justify-content: space-between;
	}

	.item>image {
		width: 24rpx;
		height: 24rpx;
	}


	.btn-group {
		width: 90%;
		position: fixed;
		left: 50%;
		bottom: 100rpx;
		margin-left: -45%;
	}
</style>