<template>
	<view>
		<image mode="widthFix" class="width100 headimg" src="../../../static/img/head.png"></image>
		<view class="headcont fotct" @click="jumpuserdes('../../tabBar/user/user')">
			<view class="width94 fcorfff font18 alijus" v-if="userInfo.secUser.objectType ==  3">
				{{userInfo.salesman.name}}
				<image mode="widthFix" class="margle iconw" src="../../../static/img/jt.png"></image>
			</view>
			<view class="width94 fcorfff font18 alijus" v-if="userInfo.secUser.objectType ==  4">
				{{userInfo.mer.merAbbreviate}}
				<image mode="widthFix" class="margle iconw" src="../../../static/img/jt.png"></image>
			</view>
			<view class="width94 fcorfff font18 alijus" v-if="userInfo.secUser.objectType ==  2">
				{{userInfo.agent.name}}
				<image mode="widthFix" class="margle iconw" src="../../../static/img/jt.png"></image>
			</view>
			<view class="width94 fcorfff font18 alijus" v-if="userInfo.secUser.objectType ==  5">{{userInfo.store.name}}
				<image mode="widthFix" class="margle iconw" src="../../../static/img/jt.png"></image>
			</view>
			<!-- 业务员 -->
			<view class="font28 fcorfff mart20 width94" v-if="userInfo.secUser.objectType ==  3"></view>
			<view class="font28 fcorfff mart15 width94" v-if="userInfo.secUser.objectType ==  3"></view>
			<!-- 非业务员 -->
			<view class="font15 height40 fcorfff mart20 width94" v-if="userInfo.secUser.objectType !=  3">今日总收入</view>
			<view class="font28 fcorfff mart15 width94" v-if="userInfo.secUser.objectType !=  3">¥<text
					class="margle font40">{{auditnum.tradePrice}}</text></view>
			<!-- 业务员 -->
			<view class="width94 mart80" v-if="userInfo.secUser.objectType ==  3">
				<view class="width50 fcorfff font14 flleft" @click.stop="jumpsuccmerchant">
					<view class="width100">进件成功数量</view>
					<view class="width100 mart15 font22">{{auditnum.contractSuccess}}</view>
				</view>
				<view class="width48 fcorfff font14 flright" @click.stop="jumpwaitmerchant">
					<view class="width100">待审核数量</view>
					<view class="width100 mart15 font22">{{auditnum.contractAudit}}</view>
				</view>
			</view>
			<!-- 非业务员 -->
			<view class="width94 mart15" v-if="userInfo.secUser.objectType != 3" @click.stop="jumpaudt">
				<view class="width50 fcorfff font14 flleft">
					<view class="width100">收款笔数</view>
					<view class="width100 mart15 font22">{{auditnum.tradeSum}}</view>
				</view>
				<view class="width48 fcorfff font14 flright">
					<view class="width100">退款笔数</view>
					<view class="width100 mart15 font22">{{auditnum.refundTradeSum}}</view>
				</view>
			</view>
		</view>
		<!-- 消息中心 -->
		<view class="width100  backcorfff " style="position: absolute;top: 300px;" @click="jumpmescon">
			<view class="width94 alijusstart height50">
				<image src="../../../static/img/mer6.png" mode="widthFix" class="iconw25 marglerig"></image>
				<text class="width90p">消息中心</text>
				<image class="iconw alicntend" mode="widthFix" src="../../../static/img/jtg.png"></image>
			</view>
		</view>
		<!-- 菜单功能 -->
		<view class="width100" style="position: absolute;top:360px;">
			<view class="funcss" v-for="(item,index) in funcList" :key="index" @click="jumpdesfun(item)">
				<image :src="item.img" mode="widthFix" class="funicon"></image>
				<view class="width100 font14 mart5">{{item.title}}</view>
			</view>
		</view>
		<view class="width100 height40p"></view>
	</view>
</template>

<script>
	import {
		// getDiscountList,
		moveHomeCount,
		mermoveHomeCount,
		storemoveHomeCount,
		getDictionaries
	} from '../../../Utils/Api.js'
	let app = getApp();
	export default {
		data() {
			return {
				funcList: [],
				userInfo: app.globalData.userInfo, //登录信息
				auditnum: '' //统计数据

			};
		},
		onLoad() {
			//业务员
			if (this.userInfo.secUser.objectType == 3) {
				this.funcList = [{
						title: '新增商户',
						url: '../../index/merchant-incoming-parts/merchant-incoming-parts',
						img: '../../../static/img/home3.png'
					},
					{
						title: '进件管理',
						url: '../../index/merchant-management/merchant-management?id=1',
						img: '../../../static/img/home4.png'
					}, {
						title: '商户管理',
						url: '../../index/normal-Merchant/normal-Merchant',
						img: '../../../static/img/home4.png'
					}, {
						title: '我的设备',
						url: '../../index/mineService/mineService?id=3',
						img: '../../../static/img/casihr.png'
					}, {
						title: '申请订单',
						url: '../../index/salesOrderList/salesOrderList',
						img: '../../../static/img/apply.png'
					}, {
						title: '收款记录',
						url: '../../index/collectNotes/collectNotes',
						img: '../../../static/img/home6.png'
					}
				]
				return;
			}
			//商户
			if (this.userInfo.secUser.objectType == 4) {
				this.funcList = [{
						title: '收款记录',
						url: '../../index/collectNotes/collectNotes',
						img: '../../../static/img/home6.png'
					},
					{
						title: '门店管理',
						url: '../../index/doorManage/doorManage',
						img: '../../../static/img/home3.png'
					},
					{
						title: '活动金',
						url: '../../index/activity_Funds/activity_Funds',
						img: '../../../static/img/gift.png'
					}
				]
				return;
			}
			//门店
			if (this.userInfo.secUser.objectType == 5) {
				this.funcList = [{
						title: '收款记录',
						url: '../../index/collectNotes/collectNotes',
						img: '../../../static/img/home6.png'
					}, {
						title: '二维码列表',
						url: '../../index/scanList/scanList',
						img: '../../../static/img/home2.png'
					},
					{
						title: '我的设备',
						url: '../../index/mineService/mineService?id=1&storeid=',
						img: '../../../static/img/casihr.png'
					},
					{
						title: '设备申请',
						url: '../../index/serviceApplicationList/serviceApplicationList',
						img: '../../../static/img/apply.png'
					},
					// {
					// 	title: '核销订单',
					// 	url: '/subpackages/groupBuyingConfiguration/groupVerifyOrder/groupVerifyOrder',
					// 	img: '/static/img/apply.png'
					// },
					{
						title:'扫码点餐',
						url:"/subpackages/groupBuyingConfiguration/groupBuyingConfiguration?storeId="+this.userInfo.store.id,
						img: '/static/img/home4.png'
					}
				]
				return;
			}
			//代理商
			if (this.userInfo.secUser.objectType == 2) {
				this.funcList = [{
					title: '结算审核',
					url: '../../index/review-Settlement/review-Settlement',
					img: '../../../static/img/home1.png'
				}]
				// , {
				// 	title: '权益活动',
				// 	url: '../../index/equity-activity-review/equity-activity-review',
				// 	img: '../../../static/img/home5.png'
				// }
				return;
			}

		},
		onShow() {
			if (this.userInfo.secUser.objectType == 3) {
				this.moveHomeCount();
			}
			if (this.userInfo.secUser.objectType == 4) {
				this.mermoveHomeCount();
			}
			if (this.userInfo.secUser.objectType == 5) {
				this.storemoveHomeCount();
			}
			this.getDictionaries();
		},
		methods: {
			// getDiscountList() {
			// 	let params = {
			// 		pageNum: 1,
			// 		pageSize: 10
			// 	}
			// 	getDiscountList(params).then(res => {
			// 		if (res.return_code == '000000') {

			// 		}
			// 	})
			// },
			//查询数据字典
			getDictionaries() {
				getDictionaries().then(res => {
					if (res.return_code == '000000') {
						app.globalData.Dictionaries = res.return_data;
						uni.setStorageSync("Dictionaries",res.return_data)
					}
				})
			},
			// 业务员查询统计
			moveHomeCount() {
				moveHomeCount().then(res => {
					if (res.return_code == '000000') {
						this.auditnum = res.return_data;
					}
				})
			},
			// 商户查询统计
			mermoveHomeCount() {
				mermoveHomeCount().then(res => {
					if (res.return_code == '000000') {
						this.auditnum = res.return_data.today;
					}
				})
			},
			// 门店查询统计
			storemoveHomeCount() {
				storemoveHomeCount().then(res => {
					if (res.return_code == '000000') {
						this.auditnum = res.return_data.today;
					}
				})
			},
			/**
			 * 跳转功能
			 */
			jumpdesfun(item) {
				if (item.title == '绑定设备') {
					uni.navigateTo({
						url: '../../index/serviceBuild/serviceBuild?id=1&storeid='
					})
				} else {
					uni.navigateTo({
						url: item.url
					})
				}
			},
			//跳转我的资料
			jumpuserdes(item) {
				uni.navigateTo({
					url: item
				})
			},
			//跳转审核商户
			jumpsuccmerchant() {
				uni.navigateTo({
					url: '../../index/normal-Merchant/normal-Merchant'
				})
			},
			//待审核的商户
			jumpwaitmerchant() {
				uni.navigateTo({
					url: '../../index/merchant-management/merchant-management?id=2'
				})
			},
			//跳转记录
			jumpaudt() {
				uni.navigateTo({
					url: '../../index/collectNotes/collectNotes'
				})
			},
			//跳转消息中心
			jumpmescon() {
				uni.navigateTo({
					url: '../../index/message-center/message-center'
				})
			}
		}

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

	.headimg {
		position: absolute;
		max-height: 300px;
	}

	.headcont {
		position: relative;
		top: 50px;
	}

	.width48 {
		width: 49%;
		border-left: 1px solid #4f65cb;
		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: 35px;
			padding-top: 15px;
		}
	}
</style>