<template>
	<view class="rf-index">
		<!--		<guideAD :show="guideAD" :time="5" @close="guideAD = false"></guideAD>-->
		<!--搜索导航栏-->
		<rf-search-bar @search="navToSearch" icon="iconkuaijiecaidan" @tab="tabClick"
			:placeholder="$i18n.locale == 'zh'? '请输入关键字': 'Please input keywords'" @showPage="showPage"
			:msgNumber="msgNumber" />

		<view style="clear: both;"></view>
		<!-- #ifdef APP-PLUS -->
		<view style="paddingTop:160upx">
			<!-- #endif -->
			<!-- #ifdef H5 -->
			<view style="paddingTop:90upx">
				<!-- #endif -->
				<block>
					<view style="background: linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%);
				height: 52vw;">

						<!-- <image src="../../static/img/index/1.png" style="width: 400upx;height: 70upx;margin-top: 20upx;"></image>
					<image src="../../static/img/index/2.png" style="width: 100%;height: 80upx;"></image> -->
						<image src="../../static/img/index/indexBACK.png" mode="" style="width: 100%;height: 100%;"
							v-if="$i18n.locale=='zh'"></image>
						<image src="../../static/img/index/indexBackEn.png" mode="" style="width: 100%;height: 100%;"
							v-else></image>
					</view>
				</block>
				<block>
					<!-- 分类列表 -->
					<view class="swiper" style="margin-top: 20upx;">
						<view class="swiper-box2">
							<swiper @change="handleDotChange" :indicator-dots="indicatorDots">
								<swiper-item>
									<view class="classification-list"
										:style="$i18n.locale=='zh'?'padding:0':'padding:0 0 15upx 0'">
										<view :class="$i18n.locale=='zh'?'module-classify-icon':'module-classify-icon2'"
											v-for="(item,index,trueindex) in initData"
											@click="navTo(item.value),changeIcon(trueindex)">
											<view :class="$i18n.locale=='zh'?'viewImg':'viewImg2'"
												style="width: 100upx;height: 100upx;" :style="{'backgroundImage':'url(  '+ item.icon +' )',
													'background-repeat':'no-repeat', backgroundSize:'100upx 100upx'}">
												<view class="newIcon"
													v-if="$i18n.locale=='zh'?newIcon[trueindex]>mynewIcon[trueindex]:newIcon[trueindex]>mynewIconEn[trueindex]">
													{{ $i18n.locale=='zh'?newIcon[trueindex] - mynewIcon[trueindex]:newIcon[trueindex] - mynewIconEn[trueindex] }}
												</view>
											</view>
											<text
												:style="$i18n.locale=='en'?'height: 45upx;display: block;':''">{{i18n(item.label)}}</text>
										</view>

									</view>
								</swiper-item>
								<swiper-item>
									<view class="classification-list2">
										<view :class="$i18n.locale=='zh'?'module-classify-icon':'module-classify-icon2'"
											v-for="(item,index,trueindex) in initData2"
											@click="navTo(item.value),changeIconEn(trueindex)">
											<view :class="$i18n.locale=='zh'?'viewImg':'viewImg2'"
												style="width: 100upx;height: 100upx;margin-left: 10upx;" :style="{'backgroundImage':'url(  '+ item.icon +' )',
													'background-repeat':'no-repeat', backgroundSize:'100upx 100upx'}">
												<view class="newIcon"
													v-if="$i18n.locale=='zh'?newIcon[trueindex+10] > mynewIcon[trueindex+10]:newIcon[trueindex+8] > mynewIconEn[trueindex+8]">
													{{ $i18n.locale=='zh'?newIcon[trueindex+10] - mynewIcon[trueindex+10]:newIcon[trueindex+8] - mynewIconEn[trueindex+8] }}
												</view>
											</view>
											<text :style="$i18n.locale=='en' || item.label == 'NationalregionalCommissions'?
													'height: 45upx;display: block;':''">{{i18n(item.label)}}</text>
										</view>

									</view>
								</swiper-item>
							</swiper>

						</view>
					</view>
					<!-- 信息播报部分 -->
					<!-- <view class="broadcast" v-if="newSum!=0">
					<view class="testtest_one" :class="{'testtest_tow':broadcastFlag_one,'testtest_three':broadcastFlag_tow,}"> -->
					<!-- 信息播报 -->
					<!-- <view class="inforTitle" style="color:orange;margin-right:10rpx;">New </view >
							<view class="inforTitle" style="color:white;">{{$i18n.locale=='zh'?'信息播报':'Information broadcast'}} : </view> -->
					<!-- 播报滚动的情况 -->
					<!-- <view class="testtest_one scroll-up" id="scroll" style="display:inline-block" v-if="scrollArr.length>1">
								<ul style="width:300px;padding-left: 20rpx;">
									<li style="height:100%;width:100%;list-style: none;"  v-for="(item,index) in broadcastList" :key="index">
										<template v-if="item.number != 0">
										  <span style="color:white">{{item.title}}:</span> <span style="color:orange;margin-right:10px">{{item.number}}</span>
										</template>
									</li>
								</ul>
								<ul style="width:300px;padding-left: 20rpx;">
									<li style="height:100%;width:100%;list-style: none;"  v-for="(item,index) in broadcastList" :key="index">
										<template v-if="item.number != 0">
										    <span style="color:white">{{item.title}}:</span> <span style="color:orange;margin-right:10px">{{item.number}}</span>
										</template>
									</li>
								</ul>
							</view> -->
					<!-- 播报不滚动的情况 -->
					<!-- <view class="testtest_one scroll-up" style="display:inline-block" v-if="scrollArr.length<2">
								<ul style="width:300px;padding-left: 20rpx;">
									<li style="height:100%;width:100%;list-style: none;"  v-for="(item,index) in broadcastList" :key="index">
										<template v-if="item.number != 0">
										    <span style="color:white">{{item.title}}:</span> <span style="color:orange;margin-right:10px">{{item.number}}</span>
										</template>
									</li>
								</ul>
							</view> -->
					<!-- 信息播报 -->
					<!-- </view>
				</view> -->
					<!--新闻通知-->
					<rf-swiper-slide v-if="announceList.length > 0" :list="announceList" @navToList="navToList"
						style="margin-top: 20upx;">
						<view slot="header" class="swiper-slide-header">
							<text class="InformationTrends">{{i18n('InformationTrends')}}</text>
						</view>
					</rf-swiper-slide>
					<!-- 会议区域 -->
					<view class="swiper ">
						<view class="swiper-box">
							<swiper @change="handleDotChange" autoplay="true" circular="true">
								<swiper-item :key="index" v-for="(item, index) in recommendAppData" v-if="index <= 2">
									<view class="swiper-item" style="height: 300upx;" @click="toDetils(1,item)">
										<image :src="websiteUrl + item.meetingPicUrl + '?custom=600_390'" alt=""
											v-if="item.meetingPicUrl" style="width: 100%;height: 100%;">
											<image :src="websiteUrl+'/def/projectdefault.png'" alt="" v-else
												style="width: 100%;height: 100%;">
									</view>
								</swiper-item>
							</swiper>

						</view>
					</view>

				</block>

				<view style="background-color: #fff;">
					<scroll-view scroll-x class="index-cate">
						<text style="font-size: 35upx;color: #0B0B11;margin-left: 50upx;">{{i18n('recommend')}}</text>
						<view style="margin-left: 80upx;display: inline-block;">
							<view v-for="(item, index) in categoryList" :key="index" class="index-cate-item"
								:class="tabCurrentIndex === index ? `text-${themeColor.name} active` : ''"
								style="color: #000;" @tap.stop="tabClick(index, item.value)">
								{{ i18n(item.label) }}
							</view>
						</view>

					</scroll-view>
				</view>
				<view style="min-height: 1000upx;background-color: #F5F5F5;">
					<!-- 项目 -->
					<view v-if="tabCurrentIndex==0">
						<view
							style="margin: 10upx 20upx;height: 200upx;border-radius: 30upx;overflow: hidden;background-color: #fff;"
							v-for="(item,index) in ProjectList" @click="toDetils(tabCurrentIndex,item.projectId)">
							<img :src="websiteUrl + item.bannerList[0] + '?custom=370_220'" alt=""
								v-if="item.bannerList[0]" style="width: 200upx;height: 200upx;">
							<img :src="websiteUrl+'/def/projectdefault.png'" alt="" v-else
								style="width: 200upx;height: 200upx;">
							<view class="recommend-bottom">
								<view class="recommend-bottom-name">{{item.projectName}}</view>
								<!-- <view>{{i18n('Releasedate')}}：{{handlePublishTimeDesc(toDate,item.createDate,$i18n.locale)}} {{$t('common.release')}}</view> -->
							</view>
						</view>
					</view>
					<!-- 会议 -->
					<view v-if="tabCurrentIndex==1">
						<view
							style="margin: 10upx 20upx;height: 200upx;border-radius: 30upx;overflow: hidden;background-color: #fff;"
							v-for="(item,index) in recommendData" v-if="index<=9"
							@click="toDetils(tabCurrentIndex,item)">
							<img :src="websiteUrl+ item.meetingPicUrl  + '?custom=600_390'" alt=""
								v-if="item.meetingPicUrl" style="width: 200upx;height: 200upx;">
							<img :src="websiteUrl+'/def/projectdefault.png'" alt="" v-else
								style="width: 200upx;height: 200upx;">
							<view class="recommend-bottom">
								<view class="recommend-bottom-name">
									{{$i18n.locale=='zh'?item.meetingName:item.meetingNameEn}}
								</view>
								<!-- <view>{{i18n('Releasedate')}}：{{handlePublishTimeDesc(toDate,item.createDate,$i18n.locale)}} {{$t('common.release')}}</view> -->
							</view>
						</view>
					</view>
					<!-- 活动 -->
					<view v-if="tabCurrentIndex==2">
						<view
							style="margin: 10upx 20upx;height: 200upx;border-radius: 30upx;overflow: hidden;background-color: #fff;"
							v-for="(item,index) in activityInfo"
							@click="toDetils(tabCurrentIndex,item.baseActivityEntityId)">
							<img :src="websiteUrl+ item.activityLogo + '?custom=840_350'" alt=""
								v-if="item.activityLogo" style="width: 200upx;height: 200upx;">
							<img :src="websiteUrl+'/def/projectdefault.png'" alt="" v-else
								style="width: 200upx;height: 200upx;">

							<view class="recommend-bottom">
								<view class="recommend-bottom-name">{{item.activityName}}</view>
								<!-- <view>{{i18n('Releasedate')}}：{{handlePublishTimeDesc(toDate,item.updateDate,$i18n.locale)}} {{$t('common.release')}}</view> -->
							</view>
						</view>
					</view>
				</view>
			</view>
			<!--页面加载动画-->
			<rfLoading isFullScreen :active="loading"></rfLoading>
			<rf-back-top :scrollTop="scrollTop"></rf-back-top>
			<!-- <rf-back-home></rf-back-home> -->
			<u-toast ref="uToast" />

		</view>
</template>
<script>
	var bitmap = null;
	import {
		indexList,
		productList
	} from '@/api/product';
	import {
		cmsInformationViews
	} from '@/api/baseUnitView';
	import {
		getDicts
	} from '@/api/dict';
	import {
		notifyAnnounceIndex
	} from '@/api/basic';
	import {
		getBaseProjectViews
	} from '@/api/project/baseProjectView';
	import {
		activityInfos
	} from '@/api/cooperation/baseCooperationUnit';
	import rfSearchBar from '@/components/rf-search-bar/indexMsg';
	// import rfSearchBar from '@/components/rf-search-bar/index';
	import rfSwiperSlide from '@/components/rf-swiper-slide';
	import {
		getConfrences
	} from "@/api/meeting/meetingOutInfo";
	import listCell from '@/components/rf-list-cell';
	import guideAD from "@/components/guideAD";
	import {
		mapMutations
	} from 'vuex';

	export default {
		components: {
			rfSearchBar,
			listCell,
			rfSwiperSlide,
			guideAD
		},
		data() {
			return {
				guideAD: true,
				indexImg: [],
				token: '',
				current: 0, // 轮播图index
				carouselList: {},
				hotProductList: [],
				recommendProductList: [], //
				guessYouLikeProductList: [], //
				newProductList: [], //
				productCateList: [], //
				indicatorDots: true,
				languageChangeShow: false,
				config: {}, //
				toDate: Date.parse(new Date()),
				announceList: [], // 公告列表
				share: {},
				loading: false,
				imgCdnUrl: '/static/img/index/',
				scrollTop: 0,
				kefuShow: true,
				loadingType: 'more',
				hotSearchDefault: '',
				newsBg: this.$mAssetsPath.newsBg,
				errorImage: this.$mAssetsPath.errorImage,
				appName: this.$mSettingConfig.appName,
				categoryProductList: [], // 分类列表
				page: 1,
				ProjectList: [], // 项目信息
				ProjectTotale: 0,
				recommendData: [], // 会议信息
				activityInfo: [], // 活动信息
				initData: {},
				tabCurrentIndex: 0,
				initData2: [],
				LoginShow: false,
				recommendAppData: [],
				categoryList: [{
						"label": 'Project',
						"value": "1"
					},
					{
						"label": 'Conference',
						"value": "2"
					},
					{
						"label": 'Events',
						"value": "3"
					},
					// {"label":'Achievements',"value":"4"},
				],
				page: 0,
				msgNumber: 0,
				//==========================
				broadcastList: [], //新增数据播报
				newIcon: [], //new图标显示的flag
				mynewIcon: [0, 999, 999, 999, 999, 999, 999, 0, 999, 0, 0, 999], //默认用cookie存储的新增值
				mynewIconEn: [0, 999, 999, 999, 999, 999, 999, 0, 999, 0, 0, 999], //默认用cookie存储的新增值(英文)
				broadcastFlag_one: false, //信息播报是否滚动样式flag
				broadcastFlag_tow: false,
				newSum: 0,
				scrollArr: [], //用来判断新增条数,从而判断是否让播报滚动
				scrollArea: '',
				speed: 20,
				timer: null,
				delay: 1000,
				liHeight: '',
			};

		},
		watch: {
			'$i18n.locale'() {
				this.getDataBroadcastInfos()
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onTabItemTap(e) {
			console.log(1111111111)
			console.log(e)
		},
		async onShow() {
			uni.setTabBarItem({
				index: 0,
				text: this.$t('common.Home')
			});
			uni.setTabBarItem({
				index: 1,
				text: this.$t('common.News')
			});
			uni.setTabBarItem({
				index: 2,
				text: this.$t('common.Find')
			});
			uni.setTabBarItem({
				index: 3,
				text: this.$t('common.Service')
			});
			uni.setTabBarItem({
				index: 4,
				text: this.$t('common.Account')
			});
			this.getcmsInformationList(); //资讯信息
			if (this.$i18n.locale == 'zh') {
				this.initData = await this.$api.json('initData');
				this.initData2 = await this.$api.json('initData2');
			} else {
				this.initData = await this.$api.json('initData_en');
				this.initData2 = await this.$api.json('initData2_en');
			}

			this.token = uni.getStorageSync('Auth-Token') ? 'Bearer ' + uni.getStorageSync('Auth-Token') : '';
			//临时代码
			// this.initData2.data10.path = "conference";

			this.indexImg = await this.$api.json('carouselList');
			this.getList();
			this.getActivityInfos(); // 获取会议广告位
			// var icon = plus.nativeObj.View.getViewById("icon");	//根据图标id取到图片
			// if(icon){
			// 	setTimeout( function(){
			// 		icon.show();
			// 	} , 100)
			// }
			this.hasNewMessage()
		},
		onLoad(option) {
			if (option.language) {
				uni.setStorageSync("language", option.language);
				this._i18n.locale = option.language;
			};
		},
		computed: {
			// 计算倒计时时间
			second() {
				return function(val) {
					return Math.floor(15 * 60 - (new Date() / 1000 - val));
				};
			},

		},

		methods: {
			async getActivityInfos() {
				// let page = {
				// 	pageSize:3,
				// 	pageNo:1,
				// 	language:this.$i18n.locale.toUpperCase(),
				// }
				// this.getBase(1,page);
				const res = await this.$myRequest({
					url: '/meeting/meetingBasicInfos/getAppList',
					data: {
						lang: this.$i18n.locale
					}
				})
				if (res.status == 200) {
					if (res.data) {
						if (res.data.meetingBasicInfos) this.recommendAppData = res.data.meetingBasicInfos
					} else this.recommendAppData = [];
				}

			},
			i18n(data) {
				return this.$t('common.' + data);
			},
			createtab: function() {
				//设置水平居中位置
				var leftPos = Math.ceil((plus.screen.resolutionWidth - 60) / 2);
				var view = new plus.nativeObj.View('icon', {
					bottom: '19px',
					left: leftPos + 'px',
					width: '50px',
					height: '50px'
				});
				view.drawBitmap(bitmap, { //使用canvas画布把图标画到tabbar对应位置上
					tag: 'font',
					id: 'icon',
					src: 'static/icons/selectedLu.png',
					position: {
						top: '0px',
						left: '5px',
						width: '50px',
						height: '100%'
					}
				});


				view.addEventListener("click", function(e) { //添加事件监听，点击触发
					uni.switchTab({ //连接到页面lu
						url: '/pages/notify/notify'
					})
				}, false);
				view.show();
			},
			getList(num) {
				let page = {
					pageNo: 1,
					pageSize: 10,
					language: this.$i18n.locale.toUpperCase(),
					descStatus: 0,
					messageOpenType: 'Y',
					status: 1
				};
				this.getBase('0', page); // 获取项目信息
			},

			//资讯信息
			async getcmsInformationList() {
				let list = {
					language: this.$i18n.locale.toUpperCase(),
					pageSize: 3,
					pageNo: 1,
					businessType: 'information'
				};
				const that = this;
				const res = await this.$myRequest({
					url: '/cms/cmsInformationViews/getInformationList/',
					data: {
						...list
					}
				})
				// 给页面的数据赋值
				that.announceList = res.data.allDataList;
			},
			// 获取详情信息
			async getBase(num, page, Reach) {
				const that = this;
				if (num == '0') {
					// 项目
					const res = await this.$myRequest({
						url: '/project/baseProjectViews/',
						data: {
							...page
						}
					});

					if (Reach) {
						this.ProjectList.push(res.data.baseProjectViews);
					} else {
						this.ProjectList = res.data.baseProjectViews || [];
						this.ProjectTotale = res.data.page.totalCount;
					}


				} else if (num == '1') {
					// 会议
					const res = await this.$myRequest({
						url: '/meeting/meetingBasicInfos/getList',
						data: {}
					})
					this.recommendData = res.data.meetingBasicInfos || [];

				} else if (num == '2') {
					// 活动
					const res = await this.$myRequest({
						url: '/project/activityInfos/showActivityInfos',
						data: {
							...page
						}
					});
					this.activityInfo = res.data.activityInfos || [];

				} else if (num == '3') {
					// 会展
				}
			},
			isMeetingOver(t) {
				let ct = Date.parse(new Date());
				if (ct - t < 0) {
					return true;
				} else {
					return false;
				}
			},
			getIconUrl(url) {
				return require("@/static/img/index/" + url + ".png");
			},
			// 顶部tab点击
			tabClick(index, num) {
				this.tabCurrentIndex = index;
				if (index == 0) {
					// 项目
					let page = {
						pageNo: 1,
						pageSize: 10,
						language: this.$i18n.locale.toUpperCase(),
						descStatus: 0,
						messageOpenType: 'Y',
						status: 1
					}
					this.getBase(index, page)
				} else if (index == 1) {
					// 会议
					let page = {}
					this.getBase(index, page)

				} else if (index == 2) {
					// 活动
					let page = {
						pageSize: 10,
						pageNo: 1,
						language: this.$i18n.locale.toUpperCase()
					}
					this.getBase(index, page)

				} else if (index == 2) {
					// 会展
					let page = {
						pageSize: 10,
						pageNo: 1,
						language: this.$i18n.locale.toUpperCase()
					}
					this.getBase(index, page)

				}

			},
			toDetils(num, id) {
				if (num == "0") {
					this.$mRouter.push({
						route: `/pages/country/projectPresentation/projectPresentationDetails?id=${id}`,
					});
				} else if (num == '1') {
					let isMeetingOver = this.isMeetingOver(id.meetingEndDate)
					let path;
					if (isMeetingOver) {
						if (this.$i18n.locale == 'en') {
							path = `/pages/conference/meetingIndexEn/meetingOverEn?id=${id.id}`
						} else {
							path = `/pages/conference/meetingIndexCh/meetingOver?id=${id.id}`
						}
					} else {
						if (this.$i18n.locale == 'en') {
							path = `/pages/conference/meetingIndexEn/meetingDetailEn?id=${id.id}`
						} else {
							path = `/pages/conference/meetingIndexCh/meetingDetail?id=${id.id}`
						}
					}
					this.$mRouter.push({
						route: path,
					});

				} else if (num == '2') {
					this.$mRouter.push({
						route: `/pages/cooperationExchange/cooperationExchangeList/activitiesInfo?ActivitesId=${id}`
					})
				}

			},

			// 判断会议是否结束
			isMeetingOver(t) {
				var ct = Date.parse(new Date());
				if (ct - t > 0) {
					return true;
				} else {
					return false;
				}
			},

			// 监听轮播图切换
			handleDotChange(e) {
				this.current = e.detail.current;
			},

			// 通用跳转
			navTo(route) {

				if (route == 'conferenceServices') {
					if (this.$i18n.locale == 'zh') {
						route = '/pages/conference/meetingIndexCh/meetingIndex';
					} else {
						route = '/pages/conference/meetingIndexEn/meetingIndexEn';
					}
					this.$mRouter.push({
						route
					});
				} else if (route === 'pages/financialService/financialService') {
					uni.navigateTo({
						url: '/' + route
					})
				} else {
					this.$mRouter.push({
						route
					});
				}
			},
			// 跳转至分类模块
			navToCategory(id) {

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

				this.$mRouter.push({
					route: src + '?key=' + data
				});
			},
			navToList(data) {
				this.navToAndList('/pages/information/components/rankDetail', data.baseEntityId)
			},
			//临时方法
			toView(path) {
				if (!path) return;
				uni.navigateTo({
					url: `/pages/${path}/${path}`
				})
			},
			//跳转至消息页面
			showPage(e) {
				if (!this.token) {
					this.$refs.uToast.show({
						title: this.$i18n.locale.toUpperCase() == 'EN' ? 'Please Login' : '请登录',
						type: 'success',
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/public/login?pathName=home',
						})
					}, 1000)
				} else {
					uni.navigateTo({
						url: '/pages/message/index'
					})
				}
			},
			//判断是否有新消息---暂无接口
			async hasNewMessage() {
				if (!this.token) return;
				let res = await this.$myRequest({
					url: '/uc/sysPushMessages/selectMsgInfoNum/',
					header: {
						Token: this.token
					},
					data: {
						readStatus: 'unread'
					}
				})
				if (res.status == 200) {
					if (res.data) {
						let data = res.data
						if (data.page) {
							if (data.page.totalCount) {
								this.msgNumber = parseInt(data.page.totalCount)
							}
						}
					} else {
						this.msgNumber = 0
					}
				} else {
					this.msgNumber = 0
				}

			},
			async getDataBroadcastInfos() {
				const res = await this.$myRequest({
					url: '/op/dataBroadcast/getDataBroadcastInfos',
					data: {
						language: this.$i18n.locale,
					}
				});
				var yes = res.data.dataBroadcastInfos;
				this.broadcastList = [];
				this.newIcon = [];
				if (this.$i18n.locale == 'zh') {
					for (var key in yes) { //把更新的数据判断后放入一个数组
						if (key == 'aProjectTodayNum') {
							this.broadcastList.push({
								title: '项目资源',
								number: yes[key]
							});
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'bNewsTodayNum') {
							this.broadcastList.push({
								title: '资讯数据',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'cCountryTodayNum') {
							this.broadcastList.push({
								title: '国别信息',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'dUnitTodayNum') {
							this.broadcastList.push({
								title: '企业展示',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'eFinanceTodayNum') {
							this.broadcastList.push({
								title: '金融服务',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'fThinkTankTodayNum') {
							this.broadcastList.push({
								title: '智库咨询',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'gCooperationNetworkTodayNum') {
							this.broadcastList.push({
								title: '合作网络',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'hCooperationExchangeTodayNum') {
							this.broadcastList.push({
								title: '合作交流',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'iCommitteeTodayNum') {
							this.broadcastList.push({
								title: '区域和国家委员会',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'jResourceSharingTodayNum') {
							this.broadcastList.push({
								title: '资源共享',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'kMeetingTodayNum') {
							this.broadcastList.push({
								title: '会议服务',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						}
					};
				} else {
					for (var key in yes) { //把更新的数据判断后放入一个数组
						if (key == 'aProjectTodayNum') {
							this.broadcastList.push({
								title: 'Projects',
								number: yes[key]
							});
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'bNewsTodayNum') {
							this.broadcastList.push({
								title: 'Info&Data',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'cCountryTodayNum') {
							this.broadcastList.push({
								title: 'Countries',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'dUnitTodayNum') {
							this.broadcastList.push({
								title: 'Enterprises',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'eFinanceTodayNum') {
							this.broadcastList.push({
								title: 'Financial Service',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'fThinkTankTodayNum') {
							this.broadcastList.push({
								title: 'Consulting',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'gCooperationNetworkTodayNum') {
							this.broadcastList.push({
								title: 'Cooperation Network',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'hCooperationExchangeTodayNum') {
							this.broadcastList.push({
								title: 'Cooperation & Communication',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'iCommitteeTodayNum') {
							this.broadcastList.push({
								title: 'Regional and National Committees',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'jResourceSharingTodayNum') {
							this.broadcastList.push({
								title: 'Resource Sharing',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						} else if (key == 'kMeetingTodayNum') {
							this.broadcastList.push({
								title: 'Conferences',
								number: yes[key]
							})
							this.newIcon.push(Number(yes[key]));
						}
					};
				}
				this.newSum = 0;
				this.scrollArr = [];
				this.newIcon.forEach(item => {
					this.newSum = this.newSum + item
					if (item > 0) {
						this.scrollArr.push(item)
					}
				});
				// console.log('狮子王--------------',this.newIcon,this.newSum,this.scrollArr)
			},
			//cookie存入
			setCookie(cname, cvalue) {
				var d = new Date();
				var tomorrow = Date.parse(new Date(new Date().setHours(0, 0, 0, 0))) + 86400000; //第二天零点的时间戳毫秒数
				var now = Date.parse(new Date()); //现在的时间
				d.setTime(d.getTime() + (tomorrow - now));
				var expires = "expires=" + d.toGMTString();
				document.cookie = cname + "=" + cvalue + "; " + expires;
			},
			//cookie获取
			getCookie(cname) {
				var name = cname + "=";
				var ca = document.cookie.split(';');
				for (var i = 0; i < ca.length; i++) {
					var c = ca[i].trim();
					if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
				}
				return "";
			},
			//打开页面时执行,如果没有cookie就存入,有的话取出赋值给mynewIcon
			getMynewicon() {
				var now = Date.parse(new Date());
				var tomorrow = new Date().setHours(0, 0, 0, 0) + 86400000;
				// var tomorrow = Date.parse(new Date())+60000;
				//存入一个明日凌晨的时间戳
				if (!uni.getStorageSync('Tomorrow')) {
					uni.setStorageSync('Tomorrow', tomorrow);
				}
				//如果打开APP时,时间大于了Tomorrow,就重置newflag与newflagEn,且重新存入明天的tomorrow
				if (uni.getStorageSync('Tomorrow') && uni.getStorageSync('Tomorrow') < now) {
					uni.setStorageSync('Tomorrow', tomorrow);
					uni.setStorageSync('newflag', this.mynewIcon);
					uni.setStorageSync('newflagEn', this.mynewIconEn);
				}
				//如果tomorrow存在,且现在的时间不大于tomorrow,就将newflag与newflagEn取出来
				if (uni.getStorageSync('Tomorrow') && uni.getStorageSync('Tomorrow') > now) {
					//存中文
					if (!uni.getStorageSync('newflag')) {
						uni.setStorageSync('newflag', this.mynewIcon)
					} else {
						this.mynewIcon = uni.getStorageSync('newflag')
					};
					//存英文
					if (!uni.getStorageSync('newflagEn')) {
						uni.setStorageSync('newflagEn', this.mynewIconEn)
					} else {
						this.mynewIconEn = uni.getStorageSync('newflagEn')
					};
				}
				// console.log('华为手机Pro====',this.mynewIcon,this.newIcon)
			},
			//点击图标时改变相应的数据,并重新存入cookie
			changeIcon(i) {
				if (this.$i18n.locale == 'zh') {
					this.mynewIcon[i] = this.newIcon[i];
					uni.setStorageSync('newflag', this.mynewIcon)
				} else {
					this.mynewIconEn[i] = this.newIcon[i];
					uni.setStorageSync('newflagEn', this.mynewIconEn)
				}
				// console.log('华为手机====',this.getCookie('newflag').split(',')[i],this.newIcon[i])
			},
			changeIconEn(i) {
				if (this.$i18n.locale == 'zh') {
					this.mynewIcon[i + 10] = this.newIcon[i + 10];
					uni.setStorageSync('newflag', this.mynewIcon)
				} else {
					this.mynewIconEn[i + 8] = this.newIcon[i + 8];
					uni.setStorageSync('newflagEn', this.mynewIconEn)
				}
				// console.log('华为手机====',this.getCookie('newflag').split(',')[i],this.newIcon[i])
			},
			scrollbar() {
				this.$nextTick(() => {
					this.scrollArea = document.querySelector("#scroll");
					console.log("111111111111111111111", this.scrollArea);
					let li = this.scrollArea.getElementsByTagName("li");
					this.liHeight = li[0].offsetHeight;
					this.scrollArea.scrollTop = 0;
					// this.scrollArea.innerHTML += this.scrollArea.innerHTML;
					this.scrollArr.length > 1 && setTimeout(this.startScroll, this.delay);
				});
			},
			startScroll() {
				this.timer = setInterval(this.scrollUp, this.speed);
				this.scrollArea.scrollTop++;
			},
			scrollUp() {
				// console.log('背灼炎天光',this.liHeight,this.scrollArea.scrollTop)		
				if (Math.round(this.scrollArea.scrollTop) % this.liHeight == 0) {
					clearInterval(this.timer);
					setTimeout(this.startScroll, this.delay);
				} else {
					this.scrollArea.scrollTop++;
					if (this.scrollArea.scrollTop >= this.scrollArea.scrollHeight / 2) {
						this.scrollArea.scrollTop = 0;
					}
				}
			},
		},
		onReady() {
			this.getDataBroadcastInfos(); //获取更新数据值
			this.getMynewicon(); //存cookie
			// setTimeout(()=>{ 
			// 	this.scrollbar();//信息播报滚动
			// },3000)
		},
	};
</script>
<style lang="scss" scoped>
	page {
		background-color: #fafafa;
	}

	.recommend-bottom {
		float: right;
		height: 200upx;
		width: 488upx;
	}

	.recommend-bottom-name {
		font-size: 35upx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #0B0B11;
		line-height: 55upx;
		margin-top: 30upx;
		overflow: hidden;
		// text-overflow:ellipsis;
		// white-space: nowrap;
	}

	.index-cate .index-cate-item {
		margin: 0 40upx 10upx 4upx;
	}

	.InformationTrends {
		font-size: 28upx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #1777FE;
		line-height: 40upx;
	}

	.classification-list {
		height: 55vw;
		display: flex;
		// padding: 0 30upx;
		flex-wrap: wrap;
		justify-content: space-between;
		// padding:  0;
		align-items: center;
		background-color: $color-white;
	}

	.classification-list2 {
		height: 27vw;
		display: flex;
		flex-wrap: wrap;
		// flex-direction:column;
		justify-content: flex-start;
		padding: 0;
		align-items: center;
		background-color: $color-white;
	}

	.module-classify-icon,
	.module-classify-icon2 {
		width: 120upx;
		margin-right: 10upx;
		text-align: center;
		position: relative;
		vertical-align: super;
		font-size: 26upx !important;

		// height: 230upx;
		img {
			width: 100%;
			height: 100%;
		}

		.viewImg {

			vertical-align: super;
			transform: translateX(6upx);
		}

		.viewImg2 {

			vertical-align: super;
			transform: translateX(32upx);
		}
	}

	.module-classify-icon2 {
		width: 170upx;
	}

	/deep/ .input-box {
		background: red;

		.wrapper {
			width: 90%;
		}
	}

	.rf-index {
		background-color: #f5f5f5;

		.wrapper {
			border-radius: 10upx;

			.h-list {
				background-color: $page-color-base;
				white-space: nowrap;
				padding: 0 $spacing-sm;

				.h-item {
					margin: $spacing-sm $spacing-sm $spacing-sm 0;
					display: inline-block;
					background-color: $color-white;
					font-size: $font-sm;
					width: 280upx;
					border-radius: 6upx;

					.h-item-img {
						display: inline-block;
						width: 280upx;
						height: 300upx;
						border-top-left-radius: 12upx;
						border-top-right-radius: 12upx;
						border-bottom: 1upx solid rgba(0, 0, 0, 0.1);
					}

					.title {
						width: 280upx;
						white-space: normal;
						height: 60upx;
						line-height: 30upx;
						font-size: $font-sm;
						padding: 0 $spacing-sm;
						margin: $spacing-sm 0;
					}

					.last-line {
						padding: 0 $spacing-sm $spacing-base;
						margin-bottom: 5upx;
						display: flex;
						justify-content: space-between;
						align-items: center;

						/* 垂直居中 */
						.red {
							font-size: $font-sm;
							margin-right: 4upx;
						}
					}

					.price {
						font-size: $font-base - 2upx;
						line-height: 1;

						.m-price {
							margin-left: 8upx;
							color: $font-color-light;
							font-size: $font-sm;
							text-decoration: line-through;
						}
					}
				}
			}
		}

		/*轮播图*/
		.swiper {
			width: 100%;

			display: flex;
			background-color: $color-white;
			justify-content: center;

			.swiper-box,
			.swiper-box2 {
				width: 92%;
				height: 40vw;
				// margin-bottom: 30upx;
				overflow: hidden;
				border-radius: 15upx;
				box-shadow: 1upx 1upx 8upx 2upx rgba(0, 0, 0, 0.05);
				//兼容ios，微信小程序
				position: relative;
				z-index: 1;

				swiper {
					width: 100%;
					height: 40vw;

					swiper-item {
						image {
							width: 100%;
							height: 40vw;
						}
					}
				}
			}
		}

		.swiper-box2,
		.swiper-box2 swiper {
			height: 55vw !important;
		}

		.swiper-box2 {
			width: 96% !important;
		}

		/* 爆款推荐 */
		.hot-recommend {
			background-color: $color-white;
			display: flex;
			padding: $spacing-base $spacing-lg 0;

			.hot-recommend-image {
				width: 100%;
				height: 100%;
			}

			.left {
				flex: 3;
				height: 350upx;
				margin-right: 15upx;
			}

			.right {
				flex: 4;

				.hot-recommend-image {
					height: 170upx;
				}
			}
		}

		/*轮播图2*/
		.swiper-item-text {
			position: absolute;
			bottom: 16upx;
			left: 30upx;
			height: 48upx;
			line-height: 48upx;
			background: rgba(0, 0, 0, 0.2);
			width: 90%;
			color: $color-white;
			border-bottom-left-radius: 12upx;
			padding-left: 20upx;
		}

		/*新闻通知*/
		.swiper-slide-header {
			.iconfont {
				font-size: $font-lg + 8upx;
				font-weight: 600;
			}
		}

		/*分类列表*/
		.category-list-wrapper {
			padding: 0 $spacing-base;

			.category-list {
				// width: 100%;
				padding: $spacing-base;
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;
				background-color: #fff;
				border-radius: 10px;

				.category {
					margin-top: 10upx;
					width: calc(25% - 20upx);
					height: 132upx;
					display: flex;
					text-align: center;
					flex-wrap: wrap;

					.img {
						width: 100%;
						display: flex;
						justify-content: center;

						image {
							width: 12vw;
							height: 12vw;
							border-radius: 50%;
						}
					}

					.text {
						margin-top: 16upx;
						width: 100%;
						display: flex;
						justify-content: center;
						font-size: 24upx;
						color: #3c3c3c;
					}
				}
			}
		}

		/*版权显示*/
		.copyright {
			margin: 10upx 0;
			width: 100%;
			text-align: center;
			color: #666;

			a {
				display: block;
				color: #666;
				text-decoration: none;
			}
		}

		/*限时抢购*/
		.order-item {
			display: flex;
			flex-direction: column;
			background: #fff;
			padding: 0 30upx;
			margin-bottom: 20upx;

			.goods-box-single {
				display: flex;
				padding: 40upx 10upx 10upx;
				height: 330upx;
				border-radius: 12upx;
				margin-top: 20upx;
				box-shadow: 2px 2px 10px rgba(66, 135, 193, 0.2); // 阴影
				border-bottom: 1px solid rgba(0, 0, 0, 0.05); // 边框
				position: relative;

				.goods-img {
					display: block;
					border-radius: 12upx;
					width: 190upx;
					height: 200upx;
				}

				.right {
					flex: 1;
					display: flex;
					flex-direction: column;
					padding: 0 30upx 0 24upx;
					overflow: hidden;

					.title {
						font-weight: bold;
						line-height: 1.2;
						margin: 10upx 0;
					}

					.attr-box {
						line-height: 1.2;
						margin-bottom: 8upx;
						margin-left: 10upx;
					}

					.last-line {
						margin-top: 3upx;
						display: flex;
						justify-content: space-between;
						align-items: center;

						/* 垂直居中 */
						.red {
							margin-right: 4upx;
						}
					}

					.price {
						font-size: $font-lg;
						line-height: 1;

						.m-price {
							margin-left: 8upx;
							color: $font-color-light;
							font-size: $font-sm;
							text-decoration: line-through;
						}
					}

					.triangle-wrapper {
						position: absolute;
						overflow: hidden;
						top: 0;
						right: 0;
						border-radius: 12upx;

						.triangle {
							color: #5eba8f;
							width: 0;
							height: 0;
							border-top: 120upx solid;
							opacity: 0.8;
							border-left: 120upx solid transparent;
						}

						.triangle-content {
							position: absolute;
							top: 28upx;
							right: 0;
							transform: rotate(45deg);
							font-size: $font-sm - 2upx;
							color: #fff;
						}
					}
				}
			}

			.action-box {
				display: flex;
				justify-content: flex-end;
				align-items: center;
				height: 90upx;
				position: relative;

				.discount-time {
					font-size: $font-sm;
					color: $uni-color-success;
					margin-right: 20upx;
				}
			}
		}

		.index-cate-product-list {
			padding-top: $spacing-sm;
			background-color: $page-color-base;

			.no-data {
				margin: 48upx 0;
				color: $font-color-light;
				display: flex;
				justify-content: center;
				align-items: center;

				.iconfont {
					margin-right: 20upx;
					font-size: $font-lg + 16upx;
				}
			}
		}
	}

	.broadcast {
		width: 100%;
		height: 60rpx;
		background-color: #2b5e9e;
		padding: 0 30rpx;
		margin-bottom: 20rpx;
		margin-top: 16rpx;
		border-radius: 13px;
	}

	.testtest_one {
		height: 100%;
		width: max-content;
		line-height: 60rpx;
		white-space: nowrap;
		overflow: hidden;
	}

	@-webkit-keyframes short {
		0% {
			-webkit-transform: translate3d(0, 0, 0);
			transform: translate3d(0, 0, 0);
		}

		100% {
			-webkit-transform: translate3d(-300px, 0, 0);
			transform: translate3d(-280px, 0, 0);
		}
	}

	@-webkit-keyframes long {
		0% {
			-webkit-transform: translate3d(0, 0, 0);
			transform: translate3d(0, 0, 0);
		}

		100% {
			-webkit-transform: translate3d(-300px, 0, 0);
			transform: translate3d(-980px, 0, 0);
		}
	}

	.testtest_tow {
		width: max-content;
		line-height: 60rpx;
		/* 动画部分 */
		/* animation-name: rowup;
		animation-duration: 5s;
		animation-iteration-count: infinite; */
		-webkit-animation: 10s short linear infinite normal;
		animation: 10s short linear infinite normal;
	}

	.testtest_three {
		width: max-content;
		line-height: 60rpx;
		/* 动画部分 */
		/* animation-name: rowup;
		animation-duration: 5s;
		animation-iteration-count: infinite; */
		-webkit-animation: 12s long linear infinite normal;
		animation: 12s long linear infinite normal;
	}

	.newIcon {
		position: absolute;
		top: 0px;
		right: -15rpx;
		width: 70rpx;
		// right: -2rpx;
		// width: 52rpx;
		padding: 0 10rpx;
		height: 32rpx;
		line-height: 30rpx;
		background-color: red;
		color: white;
		border-radius: 20rpx;
		border: 1rpx solid white;
	}

	.inforTitle {
		display: inline-block;
		height: 90%;
		line-height: 42rpx;
		vertical-align: text-bottom;
	}
</style>
