<!--

  充值规则列表页面， 数据渲染 
   业务： 充值规则

  @author terrfly
  @site https://www.jeequan.com
  @date 2022/11/30 07:07
-->
<template>
	<view class="card">
		<view class="card-content">
			<view class="card-content-left">
				<view class="rule">
					<view class="rule-amount">
						<text>{{props.record.storeName}}</text>
						<text class="rule-amount-recharge"  v-if="props.record.packetType == 1">门店专享</text>
						<text class="rule-amount-recharge"  v-if="props.record.packetType == 2">平台通用</text>
					</view>
					<view class="rule-amount">
						<text>折扣比例</text>
						<text class="rule-amount-give">{{props.record.marketScale}}折</text>
					</view>
					
					<view class="rule-amount">
						<text>补贴比例</text>
						<text class="rule-amount-give">{{props.record.platScale}}折</text>
					</view>
					
					<view class="rule-amount">
						<text>红包比例</text>
						<text class="rule-amount-give">{{props.record.userPerkScale*100}}%</text>
					</view>
					<view class="rule-amount">
						<text>红包有效期</text>
						<text class="rule-amount-give">{{props.record.expireNumber}}个月</text>
					</view>
				</view>
				<!-- <view class="rule-state">
					<view class="order-spot" :style="{ backgroundColor: props.record.state ? '#09BB07' : '#CB2972' }"></view>
					<text>{{ props.record.state ? '启用' : '禁用' }}</text>
				</view> -->
			</view>
			<view class="card-content-right" @tap="editFunc(props.record.id)">
				<image src="/static/member/edit.svg" ></image>
				<!-- <view class="right-line"></view>
				<image src="/static/member/delete.svg" @tap="deleteFunc(props.record.ruleId)"></image> -->
			</view>
		</view>
		
		<JeepayPopupConfirm ref="jeepayPopupConfirmRef" />
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue'
import cal from '@/commons/utils/cal.js'
import go from '@/commons/utils/go.js'
import emit from '@/commons/utils/emit.js'
import infoBox from '@/commons/utils/infoBox.js'
import { reqLoad, API_URL_MEMBER_RECHARGE_RULES } from "@/http/apiManager.js"

const jeepayPopupConfirmRef = ref()

// 定义传入属性
const props = defineProps({
  record: { type: Object, default: () => {} }, // 渲染对象
})
console.log(props,'propspropsprops')

const editFunc = (id) => {
	go.to("PAGES_RED_RULE_EDIT", { ruleId: id })
}

const deleteFunc = (ruleId) => {
	jeepayPopupConfirmRef.value.open('确定删除规则？', { confirmColor: 'red' }).then(() => {
		return reqLoad.delById(API_URL_MEMBER_RECHARGE_RULES, ruleId).then(() => {
			infoBox.showSuccessToast("删除成功");
			emit.pageEmit(emit.ENAME_REF_RECHARGE_RULE_LIST) // 更新列表
		})
	}).catch(() => {
		
	})
}

</script>

<style lang="scss" scoped>
	.card {
		width: 711rpx;
		margin: 0 auto;
	}
	.card-content {
		// height: 180rpx;
		display: flex;
		flex-direction: row;
		border-radius: 20rpx;
		background-color: $J-bg-ff;
		margin: 20rpx 0;
		padding: 20rpx 0;
	}
	.card-content-left {
		width: 590rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 40rpx;
		
		.rule {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: flex-start;
			
			.rule-amount {
				color: #808080ff;
				font-size: 30rpx;
				padding: 8rpx 0;
				text{
					margin: 0 10px;
				}
			}
			.rule-amount-recharge {
				margin-left: 10px;
				color: #000000ff;
				font-size: 30rpx;
			}
			.rule-amount-give {
				color: #3d8affff;
				font-size: 30rpx;
			}
		}
		
		.rule-state {
			color: #000000ff;
			font-size: 26rpx;
			display: flex;
			flex-direction: row;
			align-items: center;

			.order-spot {
				width: 10rpx;
				height: 10rpx;
				border-radius: 50%;
			}
			text {
				margin-left: 8rpx;
			}
		}
	}
	.card-content-right {
		width: 120rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-evenly;
		align-items: center;
		border-left: 2rpx solid rgba(0, 0, 0, 0.06);
		
		image {
			width: 40rpx;
			height: 40rpx;
		}
		.right-line {
			width: 100%;
			border-bottom: 2rpx solid rgba(0, 0, 0, 0.06);
		}
	}
</style>
