<template>
	<view class="page">
		
		<!-- 设置列表 -->
		<view class="setting-list">
			<view class="list" @click="onSetting('account')">
				<view class="title">
					<text>账户与安全</text>
				</view>
				<view class="more-content">
					<text class="iconfont icon-more more"></text>
				</view>
			</view>
			
			<view class="list" @click="goText(3)">
				<view class="title">
					<text>关于</text>
				</view>
				<view class="more-content">
					<text class="iconfont icon-more more"></text>
				</view>
			</view>
		</view>
		
		<!-- 退出 -->
		<view class="quit-login" @click="onQuitLogin">
			<text>退出登录</text>
		</view>
		<view class="agreeText">
			<view class="link" @click="goText(1)">
				《合之赢用户协议》
			</view><text>和</text><view class="link" @click="goText(2)">
				《合之赢隐私协议》
			</view>
		</view>
		<!-- 提示框 -->
		<DialogBox ref="DialogBox"></DialogBox>
	</view>
</template>

<script>
	import {removeAll} from '@/common/auth.js'
	import {logout} from '@/common/api.js'
	export default {
		data() {
			return {
				
			};
		},
		methods:{
			goText(id){
				uni.navigateTo({
					url:`/pages/my/richText?id=${id}`
				})
			},
			/**
			 * 用户信息点击
			 */
			onUserInfo(){
				uni.navigateTo({
					url: '/pages/Information/Information'
				})
			},
			/**
			 * 地址点击
			 */
			onAddress(){
				uni.navigateTo({
					url: '/pages/AddressList/AddressList',
				})
			},
			/**
			 * 设置列表点击
			 * @param {String} type
			 */
			onSetting(type){
				switch(type) {
					case 'account':
						uni.navigateTo({
							url: '/pages/AccountSecurity/AccountSecurity'
						})
						break;
					case 'pay':
						uni.navigateTo({
							url: '/pages/PaymentPassword/PaymentPassword'
						})
						break;
					case 'invoice':
						uni.navigateTo({
							url: '/pages/InvoiceList/InvoiceList'
						})
						break;
					case 'vip':
						uni.navigateTo({
							url: '/pages/MyMemberInterest/MyMemberInterest'
						})
						break;
					case 'common':
						uni.navigateTo({
							url: '/pages/SettingCommon/SettingCommon'
						})
						break;
					case 'about':
						uni.navigateTo({
							url: '/pages/AboutUs/AboutUs'
						})
						break;
				}
			},
			/**
			 * 退出点击
			 */
			onQuitLogin(){
				this.$refs['DialogBox'].confirm({
					title: '提示',
					content: '是否要退出登录?',
					DialogType: 'inquiry',
					animation: 0
				}).then(()=>{
					logout().then(res=>{
						if(res.code==1){
							removeAll()
							uni.switchTab({
								url:'/pages/home/home'
							})
						}
					})
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'Setting.scss';
</style>
