<template>
	<view class="">
		<u-popup :customStyle="{ backgroundColor: '#f4f4f4' }" :show="popShow" :round="10" mode="bottom" @close="popShow = false" closeable>
			<view class="popCon o-plr-30 o-pt-20 o-pb-40">
				<view class="l-flex-center c-text-20">金额明细</view>
				<view class="content">
					<view class="l-flex-between o-mt-20">
						<text class="c-text-12">商品总价</text>
						<text class="c-color-MR c-text-12">￥{{ allDiscounts.allPrice }}</text>
					</view>
					<view class="l-flex-between o-mt-20">
						<text class="c-text-12">共减</text>
						<text class="c-color-MR c-text-12">￥{{ allDiscounts.discountPrices }}</text>
					</view>
					<!-- <block v-for="(value, key, index) in goodsDiscDetail">
						<view v-if="value != 0"  class="l-flex-between o-mt-20 o-plr-30">
							<text class="c-text-12 c-color-8">{{ key }}</text>
							<text class="c-text-12 c-color-MR">￥{{ value }}</text>
						</view>
					</block> -->
					<view class="l-flex-between o-mt-20">
						<text class="c-text-12">合计</text>
						<text class="c-color-MR c-text-12">￥{{ allDiscounts.totalPrice }}</text>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
/**
 * discountPop 金额明细弹窗组件
 * @description 本组件主要是金额明细弹窗。
 *
 * @property {Boolean}			popShow				是否展示弹窗
 *
 */
export default {
	data() {
		return {
			// 是否展示弹窗
			popShow: false,
			shopsData: [],
			allDiscounts: {}
		};
	},
	// computed: {
	// 	goodsDiscDetail() {
	// 		let discDetail = {};
	// 		if (this.shopsData.length > 0) {
	// 			this.shopsData.forEach(item => {
	// 				if (item.isCheck) {
	// 					if (!discDetail[item.imgName]) {
	// 						discDetail[item.imgName] = item.discountList.reduce((prev, cur) => {
	// 							return this.$M_Big(prev)
	// 								.add(cur)
	// 								.toNumber();
	// 						}, 0);
	// 					}
	// 				}
	// 			});
	// 		}
	// 		console.log('各种商品的优惠', discDetail);
	// 		return discDetail;
	// 	}
	// },
	methods: {
		// 开启弹窗
		popOpen(shopsData, allDiscounts) {
			// 算出总价格
			allDiscounts.allPrice = this.$M_Big(allDiscounts.totalPrice)
				.add(allDiscounts.discountPrices)
				.toNumber();
			this.allDiscounts = allDiscounts;
			this.shopsData = shopsData;
			this.popShow = true;
		}
	}
};
</script>

<style lang="scss" scoped></style>
