<template>
	<view class="container">
		  <uni-group mode="card">
			<uni-list>
			 	<uni-list-item title="艺术家合作协议" :show-extra-icon="true" :extra-icon="compoSign" link to="/pages-userInfo/setting/compoSign"></uni-list-item>
				<uni-list-item title="艺术家隐私协议" :show-extra-icon="true" :extra-icon="secretSign" link to="/pages-userInfo/setting/secretSign"></uni-list-item>
				<uni-list-item title="注销登录" :show-extra-icon="true" :extra-icon="logout" clickable showArrow @click="logoutUser"></uni-list-item>
			</uni-list>
		  </uni-group>
	</view>
</template>

<script>
	import {
		logout
	} from '@/api/auth.js'
	export default {
		data() {
			return {
				clearCache: {
					color:'#0000ff',
					size: '22',
					type: 'refresh'
				},
				compoSign: {
					color:'#0000ff',
					size: '22',
					type: 'compose'
				},
				secretSign: {
					color:'#0000ff',
					size: '22',
					type: 'eye-slash'
				},
				logout: {
					color:'#0000ff',
					size: '22',
					type: 'redo'
				},
				userInfo:{}
			}
		},
		created() {
			const userInfo = uni.getStorageSync('userInfo')
			if (!userInfo) {
				console.log('havent userInfo')
				uni.showModal({
					content: '艺术家账户过期,请重新登录！',
					showCancel: false,
					success() {
						//没有缓存则跳转登录页面
						uni.reLaunch({
							url: '/pages/login/login'
						});
					}
				});
			} else {
				this.userInfo = userInfo;
				console.log('have userInfo')
			}
		},
		// // 下拉刷新
		// onPullDownRefresh() {
		// 	this.pageNum = 1
		// 	this.inviteLogList = []
		// 	this.getInviteLog();
		// 	uni.stopPullDownRefresh()
		// },
		// // 上划加载更多
		// onReachBottom() {
		// 	if (this.inviteLogList.length > this.pageSize*this.pageNum-1) {
		// 		this.flag = false;
		// 		this.pageNum += 1
		// 		this.getInviteLog();
		// 	}else{
		// 		this.flag = true;
		// 	}
		// },
		methods: {
			//注销
			logoutUser(){
				let that = this;
				uni.showModal({
				  title: "提示",
				  content: "确定注销吗！",
				  showCancel: true,
				  success: function(ress){
					  if(ress.confirm){
						 const param = {
						 	phone: that.userInfo.phone
						 }
						 logout(param).then(res => {
						 	 if (res.data.data === true) {
						 	   uni.reLaunch({
						 	   	url: '/pages/login/login',
								success() {
									uni.clearStorage();
									uni.showToast({
										title: '注销成功!',
										duration: 2000
									});
								}
						 	   });
						 	 } else {
						 	   uni.showModal({
						 	     content: "注销失败，请联系管理员!",
						 	     showCancel: false,
						 	   });
						 	 }
						 }); 
					  }
				  }
				});
			}
		}
	}
</script>

<style lang="scss">
	.ivOver{
		width: 100%;
		height:100rpx;
		line-height: 100rpx;
		text-align: center;
		background: #fff;
		font-size: 20rpx;
	}


</style>
