<template>
	<view class="bg-gray page-content">
		<cu-custom class="main-totextbar bg-main-oil" :isBack="true" bgColor="bg-main-oil">
			<block slot="backText">返回</block>
			<block slot="content">设置</block>
		</cu-custom>
		<view class="cu-list menu ">
			<view class="cu-item">
				<view class="content">
					星油账号
				</view>
				<view class="value padding-right-sm">
					{{userInfo.userCode}}
				</view>
			</view>
			<view class="cu-item arrow">
				<view class="content">
					绑定手机号
				</view>
				<view class="value">
					{{userInfo.userPhone}}
				</view>
			</view>
		</view>
		<view class="cu-list menu ">
			<!-- <view class="cu-item arrow">
				<view class="content">
					微信账号
				</view>
				<view class="value">
					{{userInfo.userWeChatAccount ?'已':'未'}}绑定
				</view>
			</view> -->
			<view class="cu-item arrow" @tap="resMsg">
				<view class="content">
					订单状态通知
				</view>
				<view class="value">
					订阅
				</view>
			</view>
			<!-- <view class="cu-item arrow">
				<view class="content">
					支付宝账号
				</view>
				<view class="value">
					{{userInfo.userAliPayAccount?'已':'未'}}绑定
				</view>
			</view> -->
		</view>
		<view class="cu-list menu ">
			<view class="cu-item arrow">
				<view class="content">
					登录密码
				</view>
				<view class="value">
					{{userInfo.userLoginPwdState?'已':'未'}}设置
				</view>
			</view>
			<view class="cu-item arrow">
				<view class="content">
					支付密码
				</view>
				<view class="value">
					{{userInfo.userPayPwdState?'已':'未'}}设置
				</view>
			</view>
		</view>
		<view class="cu-list menu ">
			<view class="cu-item arrow">
				<view class="content">
					帮助与反馈
				</view>

			</view>
			<view class="cu-item arrow">
				<view class="content">
					关于星油
				</view>
				<view class="value">
					版本{{'1.0.6'}}
				</view>
			</view>
		</view>
		<view class="cu-list menu">
			<view class="cu-item arrow">
				<view class="content">
					注销账号
				</view>
			</view>
		</view>
		<view class="bottom-btn padding-top-lg">
			<button class="text-center bg-white text-block" @tap="logOut">退出登录</button>
		</view>
	</view>
</template>

<script>
	import accountApi from '@/api/account.js'
	export default {
		data() {
			return {
				userInfo: {

				}
			}
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			resMsg() {
				wx.requestSubscribeMessage({
					tmplIds: ['ZXdtqtVmzbJY0_A2Va6MBHDrRIKN99o5lSg8fU7f77c'],
					success: (res) => {
						console.log(res)
					}
				})
			},
			getUserInfo() {
				accountApi.getUserInfo().then(res => {
					if (res.code == 20000) {
						this.userInfo = res.data
					}
				})
			},
			logOut() {
				if (uni.getStorageSync('user')) {
					accountApi.logout('authSystem').then(res => {
						if (res.code == '20000') {
							uni.showToast({
								title: res.msg
							})
							uni.clearStorageSync()
							uni.setStorageSync('loginOut', true)
							setTimeout(() => {
								uni.reLaunch({
									url: '/BagAuth/pages/login/login'
								})
							}, 1000)
						}
					})
				} else {
					setTimeout(() => {
						uni.setStorageSync('loginOut', true)
						uni.reLaunch({
							url: '/BagAuth/pages/login/login'
						})
					}, 1000)
				}
			}
		}
	}
</script>

<style scoped>
	.page-content {
		min-height: 100vh;
	}

	.value {
		color: #777;
	}
</style>
