<template>
	<view class="page">
		<view class="list_info">
			<view class="item" v-for="(item,index) in list" :key="index">
				<text>{{item.name}}</text>

				<image v-if="item.desc == '' && item.switch != 1" class="arrow"
					src="../../static/me/arrow_right_gray.png" mode="widthFix">
				</image>
				<text class="desc" v-else>{{item.desc}}</text>
				<switch v-if="item.switch == 1" checked color="#FFCC33" style="transform:scale(0.7)" />

			</view>


			<view class="blankHeight"></view>
		</view>

		<view class="btn_submit">退出登录</view>


		<!-- 提示框 -->
		<DialogBox ref="DialogBox"></DialogBox>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				title: '',
				sel: 1,
				list: [{
						name: '实名认证',
						'desc': '',
						'path': ''
					},
					{
						name: '修改密码',
						'desc': '',
						'path': ''
					},
					{
						name: '修改手机号',
						'desc': '',
						'path': ''
					},
					{
						name: '打赏设置',
						'desc': '',
						'path': ''
					},
					{
						name: '收款账户设置',
						'desc': '',
						'path': ''
					},
					{
						name: '收货地址设置',
						'desc': '',
						'path': ''
					},
					{
						name: '举报记录',
						'desc': '',
						'path': ''
					},
					{
						name: '用户协议',
						'desc': '',
						'path': ''
					},
					{
						name: '隐私政策',
						'desc': '',
						'path': ''
					},
					{
						name: '注销账号',
						'desc': '',
						'path': ''
					},
					{
						name: '青少年模式',
						'switch': 1,
						'desc': '',
						'path': ''
					},
					{
						name: '客服热线',
						'desc': '400-888-1688',
						'path': ''
					}
				]
			}
		},
		onLoad() {
			setTimeout(function() {
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: '#00000000',
					animation: {
						duration: 400,
						timingFunc: 'easeIn'
					}
				})
			}, 200);
		},
		onShow() {
			this.loadData();
		},
		methods: {
			onBack() {},
			chkSel() {
				if (this.sel == 1) {
					this.sel = 0;
				} else {
					this.sel = 1;
				}
			},
			loadData() {
				console.log("this.globalData", getApp().globalData);
				let obj2 = {
					is_first: 0
				}
				const postData = Object.assign({}, getApp().globalData.postHeader, obj2);

				console.log(postData);

				uni.request({
					url: this.$apiHost + '/Gushi/getmyinfo', //仅为示例，并非真实接口地址。
					data: postData,
					method: 'POST',
					header: {
						'content-type': 'application/json', //自定义请求头信息
						'Access-Control-Allow-Origin': '*'
					},
					success: (res) => {
						console.log('data:', res.data);
						this.myinfo = res.data;
					}
				});



			},
			EditNickname() {
				let that = this;
				this.$refs['DialogBox'].confirm({
					title: '更改昵称',
					placeholder: '请输入修改的昵称',
					value: that.myinfo.nickname,
					DialogType: 'input',
					animation: 0
				}).then((res) => {
					if (res.value.length < 1) {
						uni.showToast({
							title: "请输入有效的昵称",
							icon: 'none'
						});
						return;
					}
					that.myinfo.nickname = res.value;
					let obj2 = {
						nickname: res.value
					}
					const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
					uni.request({
						url: that.$apiHost + '/Gushi/editinfo', //检测是否已绑定
						data: postData,
						method: 'POST',
						header: {
							'content-type': 'application/json', //自定义请求头信息
							'Access-Control-Allow-Origin': '*'
						},
						success: (res) => {
							uni.showToast({
								title: res.data.str,
								icon: 'none'
							});
						}
					});
				})
			},
		}
	}
</script>

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