<template>
	<view class="rf-category">
		<view style="width:90%;height:99upx">
			<view class="leftArrow" @tap="back">
				<u-icon name="arrow-left" color="#fff" size="40"></u-icon>
			</view>
			<rf-search-bar2 @search="inputValue" icon="iconkuaijiecaidan" @tab="tabClick"
				:title=" i18n('return')  " style="z-index: 99;" />
		</view>
		<!-- 轮播图 -->
		<view class="uni-padding-wrap">
			<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
				:duration="duration">
				<swiper-item v-for="(item,index) in activityInfos" :key="index"
					v-if="item.logoFlag && item.logoFlag=='n'">
					<view style="padding: 10upx 20upx;">
						<view class="swiperImg" @click="toActivityInfo(item.baseActivityEntityId)">
							<image v-if="item.activityLogo" :src="websiteUrl+ item.activityLogo + '?custom=840_350'"
								alt="" style="width: 100%;height: 300upx;border-radius: 40upx;" />
							<image :src="websiteUrl+'/def/projectdefault.png'" alt="" v-else
								style="width: 100%;height: 300upx;" />
							<text style="display: inline-block;">
								<text v-if="item.activityStatusDict=='0'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff; background-color:#32C5FF;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 170upx;':'margin-left: 240upx;'">{{i18n('Notstarted')}}</text>
								</text>
								<text v-if="item.activityStatusDict=='1'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff ;background-color:#32C5FF;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 120upx;':'margin-left: 240upx;'">{{i18n('Registrationinprogress')}}</text>
								</text>
								<text v-if="item.activityStatusDict=='2'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff;background-color:#9B9B9B;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 170upx;':'margin-left: 240upx;'">{{i18n('Inaction')}}</text>
								</text>
								<text v-if="item.activityStatusDict=='3'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff;background-color:#9B9B9B;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 170upx;':'margin-left: 240upx;'">{{i18n('Finished')}}</text>
								</text>
								<text v-if="$i18n.locale=='zh'"
									:class="item.activityType=='会员活动'?'yellow':item.activityType=='联盟活动'?'green':'red'">
									<text style="">{{item.activityType}}</text>
								</text>
								<text v-if="$i18n.locale=='en'" style="padding-right: 250upx;margin-right: 200upx;"
									:class="item.activityType=='会员活动'?'yellow'
								 														:item.activityType=='联盟活动'?'green'
								 															:'red' ">
									<text style="margin-left: 10upx;">{{item.activityType=='会员活动'?'MemberActivities'
								 			:item.activityType=='联盟活动'?'AllianceActivities'
								 				:'CooperationActivities'}}</text>

								</text>
							</text>
						</view>
						<view class="recommend-bottom">
							<view class="recommend-activityName" @click="toActivityInfo(item.baseActivityEntityId)">
								{{item.activityName}}
							</view>
							<view class="recommend-bottom-time">
								<u-icon name="map" color="#D8D8D8" size="36" style="margin: 0px 26upx 0px 0px;">
								</u-icon>
								{{item.activityCity}} | {{formatDate(item.activityStartTime)}} -
								{{formatDate(item.activityEndTime)}}
							</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 分类列表 -->
		<!-- tabs -->
		<view class="uni-padding-wrap">
			<u-tabs :list="list" :current="current" @change="tabClick" gutter="50" bar-width="80"></u-tabs>
			<view v-if="activityInfo.length!=0">
				<view v-for="(item,index) in activityInfo" :key="index">
					<view style="margin: 18upx 20upx; ">
						<view class=" swiperImg" @click="toActivityInfo(item.baseActivityEntityId)">
							<image v-if="item.activityLogo" :src="websiteUrl+ item.activityLogo + '?custom=840_350'"
								alt="" style="width: 100%;height: 300upx;border-radius: 40upx;" />
							<image :src="websiteUrl+'/def/projectdefault.png'" alt="" v-else
								style="width: 100%;height: 300upx;" />
							<text style="display: inline-block;">
								<text v-if="item.activityStatusDict=='0'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff; background-color:#32C5FF;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 170upx;':'margin-left: 240upx;'">{{i18n('Notstarted')}}</text>
								</text>
								<text v-if="item.activityStatusDict=='1'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff ;background-color:#32C5FF;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 140upx;':'margin-left: 240upx;'">{{i18n('Registrationinprogress')}}</text>
								</text>
								<text v-if="item.activityStatusDict=='2'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff;background-color:#9B9B9B;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 170upx;':'margin-left: 240upx;'">{{i18n('Inaction')}}</text>
								</text>
								<text v-if="item.activityStatusDict=='3'"
									:class="$i18n.locale=='zh'?'activityStatus':'activityStatusEn'"
									style="color: #ffffff;background-color:#9B9B9B;">
									<text
										:style="$i18n.locale=='en'?'margin-left: 170upx;':'margin-left: 240upx;'">{{i18n('Finished')}}</text>
								</text>
								<text v-if="$i18n.locale=='zh'"
									:class="item.activityType=='会员活动'?'yellow':item.activityType=='联盟活动'?'green':'red'">
									<text style="">{{item.activityType}}</text>
								</text>
								<text v-if="$i18n.locale=='en'" style="padding-right: 250upx;margin-right: 200upx;"
									:class="item.activityType=='会员活动'?'yellow'
								 														:item.activityType=='联盟活动'?'green'
								 															:'red' ">
									<text style="margin-left: 10upx;">{{item.activityType=='会员活动'?'MemberActivities'
								 			:item.activityType=='联盟活动'?'AllianceActivities'
								 				:'CooperationActivities'}}</text>
								</text>
							</text>
						</view>
						<view class="recommend-bottom">
							<view class="recommend-activityName" @click="toActivityInfo(item.baseActivityEntityId)">
								{{item.activityName}}
							</view>
							<view>
								<u-icon name="map" color="#D8D8D8" size="36" style="margin: 0px 26upx 0px 0px;">
								</u-icon>
								{{item.activityCity}} | {{formatDate(item.activityStartTime)}} -
								{{formatDate(item.activityEndTime)}}
							</view>
						</view>
					</view>
					<view class="module-classify-border"></view>
				</view>
			</view>
			<view v-else>
				<view style="display: flex; justify-content: center;align-items: center;height: 667upx; ">
					<u-icon name="file-text" color="#a5a5a5" size="200" label-pos="bottom" label-size="36"
						:label="$i18n.locale==='zh'?'敬请期待':'Please waiting'"></u-icon>
				</view>
			</view>
		</view>
		<!-- <view class="module-classify-border"></view> -->
		<u-modal v-model="show" @confirm="confirm" :show-cancel-button="true" :content="content"></u-modal>
	</view>
</template>

<script>
	import rfSearchBar2 from '@/components/rf-search-bar-xiangmu';
	export default {
		components: {
			rfSearchBar2,
		},
		data() {
			return {
				background: ['color1', 'color2', 'color3'],
				indicatorDots: true,
				autoplay: true,
				interval: 10000,
				duration: 500,
				activityInfo: [], // 活动信息
				activityInfos: [], // 所有活动信息
				current: 0,
				ActivitesId: "",
				Storage_data: "",
				token: "",
				show: false,
				content: '是否去注册/登录？',
				list: [{
						name: this.i18n('MemberActivities')
					},
					{
						name: this.$i18n.locale === 'zh' ? "联盟活动" : "Alliance Activities",
					}, {
						name: this.i18n('CooperationActivities')
					}
				]

			};
		},

		async onShow() {
			this.getList();
			this.getActivitiesList();
			try {
				this.Storage_data = JSON.parse(uni.getStorageSync('user'));
				this.token = uni.getStorageSync('Auth-Token');

			} catch (e) {

			};

		},
		computed: {


		},
		onLoad(options) {
			this.current = options.id ? options.id : 0
		},
		methods: {
			// back() {
			// 	uni.navigateBack();
			// },
			back() {
				console.log("aaaaaaaa")
				uni.navigateTo({
					url: '../index/index'
				});
			},
			registration(id) {
				console.log('id', id);
				// this.token == undefined
				// console.log('token', this.token)
				// this.show = true;
				if (!this.token) {
					this.show = true;
				} else {
					this.$mRouter.push({
						route: `/pages/cooperationExchange/cooperationExchangeList/cooperationActiveRegistration?ActivitesId=${id}`
					});
				}
			},
			confirm() {
				// setTimeout(() => {
				// 3秒后自动关闭
				uni.navigateTo({
					url: `/pages/public/login`
				});
				this.show = false;
				// 如果不想关闭，而单是清除loading状态，需要通过ref手动调用方法
				// 	this.$refs.uModal.clearLoading();
				// }, 3000)
			},
			toActivityInfo(id) {
				console.log('id', id)
				this.$mRouter.push({
					route: `/pages/cooperationExchange/cooperationExchangeList/activitiesInfo?ActivitesId=${id}`
				});
				// uni.navigateTo({
				// 	url:"cooperationExchangeList/activitiesInfo?ActivitesId="+ActivitesId
				// })
			},
			tabClick(index) {
				this.current = index;
				this.getList();
			},
			async getList() {
				let page = {
					pageSize: 10,
					pageNo: 1,
					language: this.$i18n.locale.toUpperCase(),
					activityTypeDict: this.current,
				}
				const res = await this.$myRequest({
					url: '/project/activityInfos/showActivityInfos',
					data: {
						...page
					}
				});
				this.activityInfo = [];
				this.activityInfo = res.data.activityInfos || [];
				console.log('+++++++', res.data);
			},
			async getActivitiesList() {
				let page = {
					pageSize: 10,
					pageNo: 1,
					language: this.$i18n.locale.toUpperCase(),
				}
				const res = await this.$myRequest({
					url: '/project/activityInfos/showActivityInfos',
					data: {
						...page
					}
				});
				this.activityInfos = res.data.activityInfos;
				console.log(this.activityInfos, "大数据");
			},

			i18n(data) {
				return this.$t('common.' + data);
			},


			// 通用跳转
			navToSearch() {
				this.$mRouter.push({
					route: `/pages/index/search/search?data=${JSON.stringify(this.search)}`
				});
			},
		}
	};
</script>

<style lang="scss" scoped>
	.rf-category {
		background-color: $color-white;

		.uni-padding-wrap {
			// margin-top: 10upx; 
			/* #ifdef APP-PLUS */
			margin-top: 51upx;
			/* #endif */
		}

		.swiper {
			height: 500upx;
			width: 750upx;
		}

		.swiperImg {
			width: 100%;
			height: 75%;
			position: relative;
		}

		.recommend-bottom {
			padding: 0upx 20upx 20upx;
			width: 100%;
			box-sizing: border-box;
		}

		.recommend-bottom-time {
			width: 710upx;
			font-size: 23upx;
			height: 36upx;
			line-height: 36upx;
			box-sizing: border-box;
			position: absolute;
			bottom: 36upx;
		}

		.recommend-activityName {
			// width: 80%;
			font-size: 28upx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 400;
			color: #0B0B11;
			line-height: 50upx;
			padding-right: 10upx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			height: 50upx;
			margin-top: 20upx;
			margin-bottom: 16upx;
		}

		.activityStatus,
		.activityStatusEn {
			position: absolute;
			bottom: 12upx;
			left: 1upx;
			height: 48upx;
			width: 360upx;
			// text-align: right;
			font-size: 24upx;
			color: #fff;
			line-height: 48upx;
			z-index: 20upx;
			border-radius: 0upx 10upx 0upx 0upx;
		}

		.activityStatusEn {
			position: absolute;
			left: 150upx;
		}

		.activityStatus {
			// bottom: 12upx;
		}

		.yellow,
		.green,
		.red {
			position: absolute;
			bottom: 12upx;
			left: 0upx;
			/* min-width: 96px;  */
			padding: 0 0upx;
			height: 48upx;
			width: 180upx;
			// text-align: center;
			line-height: 48upx;
			font-size: 24upx;
			color: #fff;
			border-radius: 10upx 100upx 0upx 0upx;
			padding-left: 24upx;
			// z-index: 50upx;
		}

		.yellow {
			background: rgb(255, 153, 0);
		}

		.green {
			background: rgb(102, 204, 1);
		}

		.red {
			padding-left: 18upx;
			background: rgb(224, 32, 32);
		}

		.module-classify-border {
			background-color: #ebebeb;
			height: 20upx;
			width: 750upx;
		}

	}
</style>
<style>
	/deep/ .swiper .uni-swiper-dots {
		left: initial;
		right: 0upx;
		bottom: 16upx;
	}
</style>
