<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 ==  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">¥<text
					class="margle font40">0.00</text></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 mart15" v-if="userInfo.secUser.objectType ==  3">
				<view class="width50 fcorfff font14 flleft">
					<view class="width100">进件成功数量</view>
					<view class="width100 mart15 font22">{{auditnum.contractSuccess}}</view>
				</view>
				<view class="width48 fcorfff font14 flright">
					<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 mart145" @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 line10"></view>
		<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 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',
						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'
					}
				]
				return;
			}
			//商户
			if (this.userInfo.secUser.objectType == 4) {
				this.funcList = [{
						title: '收款记录',
						url: '../../index/collectNotes/collectNotes',
						img: '../../../static/img/home1.png'
					},
					{
						title: '门店管理',
						url: '../../index/doorManage/doorManage',
						img: '../../../static/img/home3.png'
					}
				]
				return;
			}
			//门店
			if (this.userInfo.secUser.objectType == 5) {
				this.funcList = [{
						title: '收款记录',
						url: '../../index/collectNotes/collectNotes',
						img: '../../../static/img/home1.png'
					}, {
						title: '二维码列表',
						url: '../../index/scanList/scanList',
						img: '../../../static/img/home2.png'
					},
					{
						title: '我的设备',
						url: '../../index/mineService/mineService?id=1',
						img: '../../../static/img/casihr.png'
					},
					{
						title: '设备申请',
						url: '../../index/serviceApplicationList/serviceApplicationList',
						img: '../../../static/img/apply.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;
					}
				})
			},
			// 业务员查询统计
			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
				})
			},
			//跳转记录
			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>
