<template>
	<view>
		<view class="mart5 width100 backcorfff">
			<view class="notes">
				<view class="fcor666 width40">商户名称</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.merName}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">商户简称</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.merAbbreviate}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">活动编号</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.activityNo}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">活动余额</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.activityAccount.amount}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">活动类型</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityName}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">优惠类型</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{preferentialName}}</view>
			</view>
			<view class="notes" v-if="activityDetails.condition">
				<view class="fcor666 width40">优惠条件</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.condition}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">优惠金额</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.price}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">限制类型</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{partakeName}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width40">限制使用次数</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.restrictPartakeNum}}</view>
			</view>
			
			<view class="notes" v-if="activityDetails.startTime">
				<view class="fcor666 width40">活动开始时间</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.startTime | timeFormat('yyyy-mm-dd hh:mm:ss')}}</view>
			</view>
			
			<view class="notes" v-if="activityDetails.endTime">
				<view class="fcor666 width40">活动结束时间</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.endTime | timeFormat('yyyy-mm-dd hh:mm:ss')}}</view>
			</view>
			
			<view class="notes" v-if="activityDetails.realityEndTime">
				<view class="fcor666 width40">实际结束时间</view>
				<view class="font14 fcor333 text2 width60 fotrt">{{activityDetails.realityEndTime | timeFormat('yyyy-mm-dd hh:mm:ss')}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getActivityDetail
	} from '../../../Utils/Api.js';
	let app = getApp();
	export default {
		data() {
			return {
				activityNo: '', //活动编号
				activityDetails: '', //活动详情
				activityName: '', //活动类型名称
				activityList: app.globalData.Dictionaries.REBATE_ACTIVITY_TYPE,
				preferentialName: '', //优惠类型名称
				preferentialList: app.globalData.Dictionaries.REBATE_PREFERENTIAL_TYPE,
				partakeName: '', //限制类型名称
				partakeList: app.globalData.Dictionaries.REBATE_PARTAKE_TYPE, //限制类型数据
			}
		},
		onLoad(options) {
			this.activityNo = options.activityno;
			this.getActivityDetail();
		},
		methods: {
			//查询活动详情
			getActivityDetail() {
				let data = {
					activityNo: this.activityNo
				}
				getActivityDetail(data).then(res => {
					if (res.return_code == '000000') {
						this.activityDetails = res.return_data;
						for (var i = 0; i < this.activityList.length; i++) {
							if (res.return_data.activityType == this.activityList[i].codeValue) {
								this.activityName = this.activityList[i].codeName;
							}
						}
						for (var j = 0; j < this.preferentialList.length; j++) {
							if (res.return_data.preferentialType == this.preferentialList[j].codeValue) {
								this.preferentialName = this.preferentialList[j].codeName;
							}
						}
						if (res.return_data.preferentialType == 1) {
							this.condition = res.return_data.condition;
						}
						for (var k = 0; k < this.partakeList.length; k++) {
							if (res.return_data.restrictPartakeType == this.partakeList[k].codeValue) {
								this.partakeName = this.partakeList[k].codeName;
							}
						}
					} else {
						uni.showToast({
							title: res.return_msg,
							icon: 'none',
							duration: 2000
						})
					}
				});
			},
		}
	}
</script>

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

	.notes {
		width: calc(100% - 40rpx);
		display: flex;
		align-items: center;
		padding: 30rpx 0 30rpx 20rpx;
		border-bottom: 1px solid #f6f6f6;
	}
</style>