<template>
	<view>
		<view class="promotion_bg backcorf06 width100 height90 fcorfff fotct font24 fontspec10">代理商平台</view>
		<view class="promotion_dt width90 height100p backcorfff" @click="jumpRunWater">
			<view class="width100 mart10 fcor333 font14 fontwig6 height22">
				<view class="promotion_xg flleft"></view>
				<view class="promotion_mixg flleft" style="margin-left: -6px;"></view>
				<view class="flleft promotoin_text font16" style="margin-top: -2px;">今日数据</view>
				<view class="promotion_mixg flleft"></view>
				<view class="promotion_xg flleft" style="margin-left: -6px;"></view>
			</view>
			<view class="width90 mart5 height22">
				<view class="width50 flleft font18 fcor333 fontwig6 fotlt">{{agentList.orderCount}}</view>
				<view class="width50 flright font18 fcor333 fontwig6 fotrt">{{agentList.turnoverPrice}}</view>
			</view>
			<view class="width90 mart10">
				<view class="width50 flleft font15 fcor666 fontwig6 fotlt">今日订单</view>
				<view class="width50 flright font15 fcor666 fontwig6 fotrt">今日流水</view>
			</view>
		</view>
		<!-- <view class="mart70">
			<QSTabs ref="tabs" :tabs="tabs" animationMode="line2" :current="current" @change="change"
				activeColor="#089bf5" lineColor="#089bf5" minWidth="374">
			</QSTabs>
			<view class="line1"></view>
		</view> -->

		<!-- //库存管理 -->
		<view class="width100" v-if="current == 0">
			<view class="width100 mart20">
				<view class="width90 mart10 fcor333 font14 fontwig6 height22">
					<view class="promotion_xg flleft"></view>
					<view class="promotion_mixg flleft" style="margin-left: -6px;"></view>
					<view class="flleft promotoin_text font16" style="margin-top: -2px;">库存管理</view>
					<view class="promotion_mixg flleft"></view>
					<view class="promotion_xg flleft" style="margin-left: -6px;"></view>
				</view>
			</view>
			<view class="promotion_kc width90 mart10">
				<image class="flleft pro_img mart15 margle" :src="imagewxUrl+imgadres">
				</image>
				<view class="pro_cont paddtop15">
					<view class="flleft font16 fcor333 fontwig6  pro_title">
						剩余库存({{agentList.laveStockCount}})
					</view>
					<view class="pro_price fotrt  fcor333 font15 fontwig6">
						总计 ¥{{agentList.surplusCountPrice}}
					</view>
				</view>
				<!-- //循环:class="[index==0?'colorfe':'']" -->
				<view v-if="minepros == ''" class="width90">暂无数据</view>
				<view v-for="(mers,index) in minepros" :key="mers.id" class="pro_mok marb10 colore7"
					@click="jumpAgent(1,mers.couponId,1)">
					<view class="width100 font14 fcor333 fontwig6 fotct paddtop10">
						面额{{mers.salesPrice}}
					</view>
					<view class="width100 font14 fcor999 fotct mart10">
						{{mers.stockCount}}张
					</view>
					<view class="width100 font15 fcor333 fontwig6 fotct mart10">
						{{mers.salesPrice*mers.stockCount}}
					</view>
				</view>
			</view>
			<!-- //销售统计 -->
			<view class="width100 mart20">
				<view class="width90 mart10 fcor333 font14 fontwig6 height22">
					<view class="promotion_xg flleft"></view>
					<view class="promotion_mixg flleft" style="margin-left: -6px;"></view>
					<view class="flleft promotoin_text font16" style="margin-top: -2px;">销售统计</view>
					<view class="promotion_mixg flleft"></view>
					<view class="promotion_xg flleft" style="margin-left: -6px;"></view>
				</view>
			</view>
			<view class="promotion_kc width90 mart10">
				<image class="flleft pro_img mart15 margle" :src="imagewxUrl+imgadres">
				</image>
				<view class="pro_cont paddtop15">
					<view class="flleft font16 fcor333 fontwig6  pro_title">
						已销售({{agentList.soldCount}})
					</view>
					<view class="pro_price fotrt  fcor333 font15 fontwig6">
						总计 ¥{{agentList.salesCountPrice}}
					</view>
				</view>
				<view v-if="minepros == ''" class="width90">暂无数据</view>
				<!-- //循环 -->
				<view v-for="(mers,index) in minepros" :key="mers.id" class="pro_mok marb10 colore9"
					@click="jumpAgent(2,mers.couponId,1)">
					<view class="width100 font14 fcor333 fontwig6 fotct paddtop10">
						面额{{mers.salesPrice}}
					</view>
					<view class="width100 font14 fcor999 fotct mart10">
						{{mers.salesCount}}张
					</view>
					<view class="width100 font15 fcor333 fontwig6 fotct mart10">
						{{mers.salesPrice*mers.salesCount}}
					</view>
				</view>
			</view>
		</view>
		<!-- 兑换码库存 -->
		<view class="width100 mart80" v-if="current == 1">
			<view class="width100 mart20">
				<view class="width90 mart10 fcor333 font14 fontwig6 height22">
					<view class="promotion_xg flleft"></view>
					<view class="promotion_mixg flleft" style="margin-left: -6px;"></view>
					<view class="flleft promotoin_text font16" style="margin-top: -2px;">销售统计</view>
					<view class="promotion_mixg flleft"></view>
					<view class="promotion_xg flleft" style="margin-left: -6px;"></view>
				</view>
			</view>
			<view class="promotion_kc width90 mart10">
				<image class="flleft pro_img mart15 margle" :src="imagewxUrl+imgadres">
				</image>
				<view class="pro_cont paddtop15">
					<view class="flleft font16 fcor333 fontwig6  pro_title">
						待销售({{couponList.noSalesNum}})
					</view>
					<view class="pro_price fotrt  fcor333 font15 fontwig6">
						总计 ¥{{couponList.noSalesPrice}}
					</view>
				</view>
				<view v-if="couponCont == ''" class="width90">暂无数据</view>
				<view v-for="(mers,index) in couponCont" :key="mers.id" class="pro_mok marb10 colore7"
					@click="jumpAgent(1,mers.couponId,2)">
					<view class="width100 font14 fcor333 fontwig6 fotct paddtop10">
						面额{{mers.salesPrice}}
					</view>
					<view class="width100 font14 fcor999 fotct mart10">
						{{mers.stockCount}}张
					</view>
					<view class="width100 font15 fcor333 fontwig6 fotct mart10">
						{{mers.salesPrice*mers.stockCount}}
					</view>
				</view>
			</view>
			<!-- 兑换码统计 -->
			<!-- <view class="width100 mart20">
				<view class="width90 mart10 fcor333 font14 fontwig6 height22">
					<view class="promotion_xg flleft"></view>
					<view class="promotion_mixg flleft" style="margin-left: -6px;"></view>
					<view class="flleft promotoin_text font16" style="margin-top: -2px;">销售统计</view>
					<view class="promotion_mixg flleft"></view>
					<view class="promotion_xg flleft" style="margin-left: -6px;"></view>
				</view>
			</view> -->
			<view class="promotion_kc width90 mart20">
				<image class="flleft pro_img mart15 margle" :src="imagewxUrl+imgadres">
				</image>
				<view class="pro_cont paddtop15">
					<view class="flleft font16 fcor333 fontwig6  pro_title">
						已销售({{couponList.salesNum}})
					</view>
					<view class="pro_price fotrt  fcor333 font15 fontwig6">
						总计 ¥{{couponList.salesPrice}}
					</view>
				</view>
				<view v-if="couponCont == ''" class="width90">暂无数据</view>
				<!-- //循环 -->
				<view v-for="(mers,index) in couponCont" :key="mers.id" class="pro_mok marb10 colore9"
					@click="jumpAgent(2,mers.couponId,2)">
					<view class="width100 font14 fcor333 fontwig6 fotct paddtop10">
						面额{{mers.salesPrice}}
					</view>
					<view class="width100 font14 fcor999 fotct mart10">
						{{mers.noUsedNum}}张
					</view>
					<view class="width100 font15 fcor333 fontwig6 fotct mart10">
						{{mers.noUsedPrice}}
					</view>
				</view>
			</view>

			<view class="width100 mart20">
				<view class="width90 mart10 fcor333 font14 fontwig6 height22">
					<view class="promotion_xg flleft"></view>
					<view class="promotion_mixg flleft" style="margin-left: -6px;"></view>
					<view class="flleft promotoin_text font16" style="margin-top: -2px;">使用统计</view>
					<view class="promotion_mixg flleft"></view>
					<view class="promotion_xg flleft" style="margin-left: -6px;"></view>
				</view>
			</view>
			<view class="promotion_kc width90 mart20">
				<image class="flleft pro_img mart15 margle" :src="imagewxUrl+imgadres">
				</image>
				<view class="pro_cont paddtop15">
					<view class="flleft font16 fcor333 fontwig6  pro_title">
						待使用({{couponList.noUsedNum}})
					</view>
					<view class="pro_price fotrt  fcor333 font15 fontwig6">
						总计 ¥{{couponList.noUsedPrice}}
					</view>
				</view>
				<view v-if="couponCont == ''" class="width90">暂无数据</view>
				<view v-for="(mers,index) in couponCont" :key="mers.id" class="pro_mok marb10 colore7"
					@click="jumpAgent(2,mers.couponId,2)">
					<view class="width100 font14 fcor333 fontwig6 fotct paddtop10">
						面额{{mers.salesPrice}}
					</view>
					<view class="width100 font14 fcor999 fotct mart10">
						{{mers.noUsedNum}}张
					</view>
					<view class="width100 font15 fcor333 fontwig6 fotct mart10">
						{{mers.noUsedPrice}}
					</view>
				</view>
			</view>
			<!-- 兑换码统计 -->
			<!-- <view class="width100 mart20">
				<view class="width90 mart10 fcor333 font14 fontwig6 height22">
					<view class="promotion_xg flleft"></view>
					<view class="promotion_mixg flleft" style="margin-left: -6px;"></view>
					<view class="flleft promotoin_text font16" style="margin-top: -2px;">使用统计</view>
					<view class="promotion_mixg flleft"></view>
					<view class="promotion_xg flleft" style="margin-left: -6px;"></view>
				</view>
			</view> -->
			<view class="promotion_kc width90 mart20">
				<image class="flleft pro_img mart15 margle" :src="imagewxUrl+imgadres">
				</image>
				<view class="pro_cont paddtop15">
					<view class="flleft font16 fcor333 fontwig6  pro_title">
						已使用({{couponList.usedNum}})
					</view>
					<view class="pro_price fotrt  fcor333 font15 fontwig6">
						总计 ¥{{couponList.usedPrice}}
					</view>
				</view>
				<view v-if="couponCont == ''" class="width90">暂无数据</view>
				<!-- //循环 -->
				<view v-for="(mers,index) in couponCont" :key="mers.id" class="pro_mok marb10 colore9"
					@click="jumpAgent(2,mers.couponId,3)">
					<view class="width100 font14 fcor333 fontwig6 fotct paddtop10">
						面额{{mers.salesPrice}}
					</view>
					<view class="width100 font14 fcor999 fotct mart10">
						{{mers.usedNum}}张
					</view>
					<view class="width100 font15 fcor333 fontwig6 fotct mart10">
						{{mers.usedPrice}}
					</view>
				</view>
			</view>
		</view>
		<view class="btnw50 mart50 marb30" @click="toPage()">修改密码</view>
	</view>
</template>

<script>
	import {
		getAgentCount,
		getAgentConvertCodeCount
	} from "../../../Utils/Api.js";
	import QSTabs from '../../../components/QS-tabs/QS-tabs.vue';
	let app = getApp();
	export default {
		components: {
			QSTabs
		},
		data() {
			return {
				imagewxUrl: app.globalData.imageWxImg,
				imgadres: 'wenj.png',
				agentList: [], //总统计
				minepros: [], //分发数据
				couponList:[], //兑换码数据
				couponCont:[], //卡券数据
				tabs: ["销售码", "兑换码"], //切换操作
				current: 1, //默认
			}
		},
		onLoad() {
			// this.getAgentCount(1);
			// this.getAgentConvertCodeCount();
		},
		onShow() {
			this.getAgentCount(1);
			this.getAgentConvertCodeCount();
		},
		methods: {
			//查询代理商信息
			getAgentCount(item) {
				uni.showLoading({
					title: '加载中'
				})
				let datas = {
					type: item
				}
				getAgentCount(datas).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000') {
						this.agentList = res.return_data;
						this.minepros = res.return_data.list;
					} else {
						this.agentList = [];
						this.minepros = [];
						uni.showToast({
							title: res.return_msg,
							icon: "none",
							duration: 2000
						})
					}
				})
			},
			//查询兑换码
			getAgentConvertCodeCount() {
				uni.showLoading({
					title: '加载中'
				})
				getAgentConvertCodeCount().then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data) {
						this.couponList = res.return_data;
						this.couponCont = res.return_data.list;
					} else {
						uni.showToast({
							title: res.return_msg,
							icon: "none",
							duration: 2000
						})
						this.couponList = [];
						this.couponCont = [];
					}
				});
			},
			//筛选
			change(index) {
				this.$refs.tabs.setFinishCurrent(index);
				this.swiperCurrent = index;
				this.current = index;
				if (index == 0) {
					this.getAgentCount(1);
				} else {
					this.getAgentConvertCodeCount();
				}
			},
			//跳转流水
			jumpRunWater() {
				uni.navigateTo({
					url: '../runningWater/runningWater'
				})
			},
			//跳转代理商卡券
			jumpAgent(item, items, itemtype) {
				uni.navigateTo({
					url: '../agentCoupons/agentCoupons?id=' + item + '&couponsId=' + items + '&typeid=' + itemtype
				})
			},
			//修改密码
			toPage(page) {
				uni.navigateTo({
					url: '../../login/resetpasswd'
				});
			}
		}
	}
</script>

<style lang="scss">
	.promotion_bg {
		position: relative;
	}

	.promotion_dt {
		position: absolute;
		top: 50px;
		border-radius: 5px;
		box-shadow: 0px 2px 6px 2px #999999;
	}

	.promotion_xg {
		width: 15px;
		height: 2px;
		margin-top: 8px;
		background-color: #0083f5;
		transform: rotate(100deg);
	}

	.promotoin_text {
		margin-left: 5px;
		margin-right: 5px;
	}

	.promotion_mixg {
		width: 10px;
		margin-top: 8px;
		height: 2px;
		background-color: #0083f5;
		transform: rotate(100deg);
	}

	.promotion_kc {
		padding-bottom: 10px;
		border-radius: 5px;
		box-shadow: 0px 2px 4px 2px #999999;
	}

	.pro_img {
		width: 25px;
		height: 25px;
	}

	.pro_cont {
		height: 35px;
		margin-left: 40px;
	}

	.pro_title {
		width: 110px;
	}

	.pro_price {
		margin-right: 10px;
		margin-left: 110px;
	}

	.pro_mok {
		height: 95px;
		margin-left: 2.5%;
		width: 30%;
		display: inline-block;
	}

	.colorfe {
		background-color: #fef7e5;
	}

	.colore9 {
		background-color: #e9f3ff;
	}

	.colore7 {
		background-color: #e7fcf3;
	}
</style>