<template>
	<view>
		<view class="headcont fotct">
			<view class="width94 fcorfff font18 alijus paddtop20">
				<text v-if="userinfo">{{userinfo.merchantStore.storeName}}</text>
				<text v-else>暂无信息</text>
				<!-- <image mode="widthFix" class="margle iconw" src="../../../static/img/jt.png"></image> -->
			</view>
			<view class="font15 height40 fcorfff mart10 width94">今日加油总额</view>
			<view class="font28 fcorfff mart5 width94">¥<text class="margle font40">{{oilInfo.today.incomePrice}}</text></view>
			<view class="width94 mart5">
				<view class="width50 fcorfff font16 flleft">
					<view class="width100">收款笔数</view>
					<view class="width100 mart15 font22">{{oilInfo.today.incomeCount}}</view>
				</view>
				<view class="width48 fcorfff font16 flright">
					<view class="width100">退款笔数</view>
					<view class="width100 mart15 font22">{{oilInfo.today.refundCount}}</view>
				</view>
			</view>
		</view>
		<!-- 消息中心 -->
		<view class="width100  backcorfff" @click="jumpmess">
			<view class="width94 alijusstart height50">
				<image src="../../../static/img/mer6.png" mode="widthFix" class="iconw25 marglerig" style="height: 25px;"></image>
				<text class="width85 font14">消息中心</text>
				<!-- <view class="width70 fotrt fcor666 font14">异常商户号通知</view> -->
				<image class="iconw alicntend" mode="widthFix" src="../../../static/img/jtg.png" style="height: 15px;"></image>
			</view>
		</view>
		<!-- 菜单功能 -->
		<view class="width100 line10"></view>
		<view class="funcss" v-for="(item,index) in funcList" :key="index" @click="jumpdesfun(item)">
			<image :src="item.menuUrlImg" mode="widthFix" class="funicon"></image>
			<view class="width100 font14 mart5">{{item.menuName}}</view>
		</view>
		<view class="width100 height40p"></view>
	</view>
</template>

<script>
	import {
		logout,
		getGasStatistical
	} from '../../../Utils/Api.js';
	let app = getApp();
	export default {
		data() {
			return {
				funcList: [
					// {
					// 	title: '配置油枪',
					// 	url: '../../user/oil-list/oil-list?id=1',
					// 	img: '../../../static/img/3.png'
					// },
					// {
					// 	title: '配置油品价格',
					// 	url: '../../user/oil-list/oil-list?id=2',
					// 	img: '../../../static/img/2.png'
					// },
					// {
					// 	title: '修改密码',
					// 	url: '../../login/updatePsd/updatePsd',
					// 	img: '../../../static/img/9.png'
					// },
					// {
					// 	title: '退出登录',
					// 	url: '',
					// 	img: '../../../static/img/7.png'
					// }
				],
				auditnum: '', //统计数据
				userinfo: '', //用户信息
				oilInfo: '' //油站数据

			};
		},
		onLoad() {
			this.userinfo = app.globalData.userInfo;
			for(var i =0;i<this.userinfo.menuList.length;i++){
				if(this.userinfo.menuList[i].menuUrl == 'APPLETS_MER'){
					this.funcList = this.userinfo.menuList[i].children;
				}
			}
		},
		onShow() {
			this.getGasStatistical();
		},
		methods: {
			//查询个人信息
			getGasStatistical() {
				getGasStatistical().then(res => {
					if (res.return_code == '000000') {
						this.oilInfo = res.return_data;
					}
				});
			},
			//跳转信息
			jumpmess() {
				uni.showToast({
					title: '暂无数据',
					duration: 1500,
					icon: 'none'
				})
			},
			//跳转
			jumpdesfun(item) {
				if (item.menuMobileUrl == '#') {
					this.logout();
					uni.closeSocket();
				}
				uni.navigateTo({
					url: item.menuMobileUrl
				})
			},
			//退出登录
			logout() {
				let that = this;
				uni.showModal({
					title: '退出登录',
					content: '是否退出当前账号',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								title: '操作中'
							})
							logout().then(res => {
								uni.hideLoading();
								if (res.return_code == '000000') {
									app.globalData.userInfo = '';
									app.globalData.token = '';
									app.globalData.positionType = 0;
									app.globalData.positionGunPrice = 0;
									uni.setStorage({
										key: "oiluser",
										data: ''
									})
									uni.setStorage({
										key: "oiltoken",
										data: ''
									})
									uni.reLaunch({
										url: '../../login/login/login'
									})
								}
							});
						}
					}
				})

			}
		}

	};
</script>
<style lang="scss">
	page {
		background-color: #F8F8F8;
	}


	.headcont {
		height: 220px;
		background-color: #0083f5;
	}

	.width48 {
		width: 50%;
		height: 65px;
	}

	.mart145 {
		margin-top: 145px;
	}

	// 菜单
	.funcss {
		width: 33%;
		height: 100px;
		border-right: 1px solid #e8e8e8;
		border-bottom: 1px solid #e8e8e8;
		background-color: #FFFFFF;
		text-align: center;
		display: inline-block;

		.funicon {
			width: 25px;
			height: 25px;
			padding-top: 15px;
		}
	}
</style>
