<template>
	<view style="background-color: #EBF4F7;letter-spacing: 1rpx;min-height: 100vh;">
		<tn-nav-bar :isBack="false" backTitle="" :bottomShadow="true" backgroundColor="#FFFFFF">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
				<view style="padding-left: 15rpx;" @click="goBack()">
					<text class="tn-icon-left" style="font-size: 40rpx;"></text>
				</view>
				<view class="tn-margin-top"
					style=";text-shadow:  1rpx 0 0 #FFF, 0 1rpx 0 #FFF, -1rpx 0 0 #FFF , 0 -1rpx 0 #FFF;">

					<tn-tabs :list="[{name:'协会活动'}]" :current="topCurrent" activeColor="#000" :bold="false"
						:fontSize="36"></tn-tabs>
				</view>
			</view>
		</tn-nav-bar>
		<view :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin">
				<view class="justify-content-item align-content-item" style="width: 100%;">
					<view class="tn-flex tn-flex-col-center"
						style="border-radius: 100rpx;padding: 10rpx 20rpx 10rpx 20rpx;width: 95%;background-color: rgba(255, 255, 255, 0.9);">
						<text class="tn-icon-search justify-content-item tn-padding-right-xs tn-color-gray tn-text-lg"></text>
						<input v-model="content" class="justify-content-item" placeholder="请填写活动标题" name="input"
							placeholder-style="color:#AAAAAA" style="width: 90%;"></input>
					</view>
				</view>

				<view>
					<view class="justify-content-item tn-text-center">
						<tn-button backgroundColor="#3668fc" shape="round" padding="20rpx 20rpx" width="150rpx" @click="onsubmit()">
							<text class="tn-color-white">搜 索</text>
						</tn-button>

					</view>
				</view>
			</view>
			<!-- <view class="tn-flex tn-flex-row-between tn-flex-center tn-flex-col-center" style="padding: 0px 30rpx;">
        <view
          style="text-align: center;background-color: #FFF;padding:10rpx 30rpx;width: 48%;border-radius: 5rpx;">
          <text>年（全部显示)</text>
          <text class="tn-icon-down-triangle"></text>
        </view>
        <view
          style="text-align: center;background-color: #FFF;padding:10rpx 30rpx;width: 48%;border-radius: 5rpx;">
          <text>月（全部显示)</text>
          <text class="tn-icon-down-triangle"></text>
        </view>
      </view> -->
			<tn-tabs :list="tabList" :isScroll="false" :current="current" name="name" @change="tabChange"
				activeColor="#3668FC"></tn-tabs>
			<!-- <view style="padding: 30rpx;">
        <view class="tn-flex tn-flex-center tn-flex-col-center tn-flex-row-between"
          style="text-align: center;padding: 30rpx;background-color: #FFF;border-radius: 20rpx;">
          <view>
            <view>
              <image src="/static/ico1.png" style="width: 70rpx;height: 70rpx;"></image>
            </view>
            <view style="margin-top: 10rpx;">
              <text>协会活动</text>
            </view>
          </view>
          <view>
            <view>
              <image src="/static/ico2.png" style="width: 70rpx;height: 70rpx;"></image>
            </view>
            <view style="margin-top: 10rpx;">
              <text>知识学堂</text>
            </view>
          </view>
          <view>
            <view>
              <image src="/static/ico3.png" style="width: 70rpx;height: 70rpx;"></image>
            </view>
            <view style="margin-top: 10rpx;">
              <text>供需服务</text>
            </view>
          </view>
          <view>
            <view>
              <image src="/static/ico4.png" style="width: 70rpx;height: 70rpx;"></image>
            </view>
            <view style="margin-top: 10rpx;">
              <text>金融服务</text>
            </view>
          </view>
        </view>
      </view> -->
		</view>
		<!-- 	<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-flex-row-center"
      style="padding:10rpx 30rpx;margin-top: 20rpx;">
      <view style="font-size: 36rpx;">协会活动</view>
      <view style="color: #808080;" @click="openUrl('/pages/index/events_list')">
        <text>更多</text>
        <text class="tn-icon-right"></text>
      </view>
    </view> -->
		<view style="padding-bottom: 30rpx;">
			<!-- <scroll-view :scroll-x="true" style="padding:0rpx 30rpx;white-space: nowrap;">
        <view v-for="(item,index) in 3" @click="openUrl('/pages/index/events_info')"
          style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(12,0,5,0.1);position: relative;;display: inline-block;width: 300rpx;text-align: center;background-color: #FFF;border-radius: 20rpx;overflow: hidden;margin-right: 20rpx;">
          <view>
            <image src="/static/hd1.jpg" mode="widthFix" style="width: 300rpx;"></image>
          </view>
          <view style="padding:10rpx 20rpx;font-weight: 400;">
            <view class="tn-text-ellipsis-2" style="letter-spacing: 1px;">青年企业家能力提升 计划培训班(第20期)</view>
          </view>
          <view style="position: absolute;top: 10rpx;left: 10rpx;">
            <tn-button v-if="index==0" width="80rpx" height="40rpx" size="sm" backgroundColor="#6BC7F0 "
              fontColor="tn-color-white">报名中</tn-button>
            <tn-button v-if="index==1" width="80rpx" height="40rpx" size="sm" backgroundColor="#EE9556 "
              fontColor="tn-color-white">预告</tn-button>
            <tn-button v-if="index==2" width="80rpx" height="40rpx" size="sm" backgroundColor="#E12B33 "
              fontColor="tn-color-white">进行中</tn-button>
          </view>
        </view>
      </scroll-view> -->
			<view style="padding: 30rpx 0rpx;">
				<tn-grid align="left" :col="2">
					<block v-for="(item,index) in actList">
						<tn-grid-item style="width:50%">
							<view @click="openUrl('/pages/index/event_info?id='+item.id)"
								style="margin-bottom: 30rpx;background-color: #FFF;box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(12,0,5,0.1);position: relative;display: inline-block;width: 350rpx;text-align: center;border-radius: 20rpx;overflow: hidden;">
								<view>
									<image :src="apiImgUrl+item.activity_image" style="width: 350rpx;height: 170rpx;">
									</image>
								</view>
								<view style="padding:10rpx 20rpx;font-weight: 400;">
									<view class="tn-text-ellipsis " style="text-align: left;">{{ item.activity_name }}
									</view>
									<view class="tn-flex tn-flex-row-between" style="font-size: 24rpx;color:#808080;padding: 15rpx 0rpx;">
										<view>
											<text v-if="item.activity_type==1">线下活动</text>
											<text v-if="item.activity_type==2">调查问卷</text>
											<text v-if="item.activity_type==3">公益捐赠</text>
											<text v-if="item.activity_type==4">学习培训</text>
										</view>
										<!--                    <view>-->
										<!--                      <text class="tn-icon-eye"></text>-->
										<!--                      <text style="margin-left: 5rpx;">{{item.eye}}</text>-->
										<!--                    </view>-->
									</view>
								</view>
								<!--								<view style="position: absolute;top: 10rpx;left: 10rpx;">-->
								<!--									<tn-button v-if="item.is==0" padding="0" width="80rpx" height="40rpx" size="sm"-->
								<!--										backgroundColor="#6BC7F0 " fontColor="tn-color-white">报名中</tn-button>-->
								<!--									<tn-button v-if="item.is==1" padding="0" width="80rpx" height="40rpx" size="sm"-->
								<!--										backgroundColor="#EE9556 " fontColor="tn-color-white">预告</tn-button>-->
								<!--									<tn-button v-if="item.is==2" padding="0" width="80rpx" height="40rpx" size="sm"-->
								<!--										backgroundColor="#E12B33 " fontColor="tn-color-white">进行中</tn-button>-->
								<!--								</view>-->
							</view>
						</tn-grid-item>
					</block>
				</tn-grid>
				<!-- <view style="position: absolute;top: 10rpx;left: 10rpx;">
          <tn-button v-if="index==0" width="80rpx" height="40rpx" size="sm" backgroundColor="#6BC7F0 "
            fontColor="tn-color-white">报名中</tn-button>
          <tn-button v-if="index==1" width="80rpx" height="40rpx" size="sm" backgroundColor="#EE9556 "
            fontColor="tn-color-white">预告</tn-button>
          <tn-button v-if="index==2" width="80rpx" height="40rpx" size="sm" backgroundColor="#E12B33 "
            fontColor="tn-color-white">进行中</tn-button>
        </view> -->
			</view>
		</view>
		<!-- <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-flex-row-center" style="padding:10rpx 30rpx;">
      <view style="font-size: 36rpx;">知识学堂</view>
      <view style="color: #808080;" @click="openUrl('/pages/index/knowledge_list')">
        <text>更多</text>
        <text class="tn-icon-right"></text>
      </view>
    </view>
    <view style="padding:0rpx 30rpx;">
      <view @click="openUrl('/pages/index/new_info')"
        style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(12,0,5,0.1);position: relative;width: 100%;background-color: #FFF;border-radius: 20rpx;overflow: hidden;">
        <view>
          <image src="/static/s1.jpg" mode="widthFix" style="width: 100%;"></image>
        </view>
        <view style="padding:10rpx 20rpx;font-weight: 400;">
          <view class="tn-text-ellipsis-2">青年企业家能力提升 计划培训班(第20期)</view>
          <view class="tn-flex tn-flex-row-between"
            style="font-size: 24rpx;color:#808080;padding: 20rpx 0rpx;">
            <view>河南青企协</view>
            <view>
              <text class="tn-icon-eye"></text>
              <text style="margin-left: 5rpx;">568</text>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view style="padding: 30rpx 0rpx;">
      <scroll-view :scroll-x="true" style="padding:0rpx 30rpx;white-space: nowrap;">
        <view v-for="(item,index) in 3" @click="openUrl('/pages/index/new_info')"
          style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(12,0,5,0.1);position: relative;;display: inline-block;width: 335rpx;text-align: center;background-color: #FFF;border-radius: 20rpx;overflow: hidden;margin-right: 20rpx;">
          <view>
            <image src="/static/hd1.jpg" style="width: 335rpx;height: 200rpx;"></image>
          </view>
          <view style="padding:10rpx 20rpx;font-weight: 400;">
            <view class="tn-text-ellipsis" style="letter-spacing: 1px;">青年企业家能力提升 计划培训班(第20期)</view>
            <view class="tn-flex tn-flex-row-between"
              style="font-size: 24rpx;color:#808080;padding: 15rpx 0rpx;">
              <view>河南青企协</view>
              <view>
                <text class="tn-icon-eye"></text>
                <text style="margin-left: 5rpx;">568</text>
              </view>
            </view>
          </view>
        </view>
      </scroll-view>
    </view>
    <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-flex-row-center" style="padding:10rpx 30rpx;">
      <view style="font-size: 36rpx;">供需服务</view>
      <view style="color: #808080;" @click="openUrl('/pages/index/goods_list')">
        <text>更多</text>
        <text class="tn-icon-right"></text>
      </view>
    </view>
    <view style="padding:10rpx  30rpx 100rpx 30rpx;">
      <view v-for="(item,index) in 3" @click="openUrl('/pages/index/goods_info')" style="background-color: #FFF;padding: 20rpx;border-radius: 20rpx;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(12,0,5,0.1);margin-bottom: 20rpx;">
        <view class="tn-text-ellipsis">
          <tn-tag v-if="index%2==0" shape="radius" size="sm" backgroundColor="tn-main-gradient-red--reverse"
            width="60rpx">需求</tn-tag>
          <tn-tag v-if="index%2!=0" shape="radius" size="sm" backgroundColor="tn-main-gradient-blue"
            width="60rpx">供应</tn-tag>
          <text style="vertical-align: middle;padding-left: 20rpx;font-size:30rpx;">
            劲捷飞燕系列P056C旅拍三脚架碳纤维摄影旅拍三脚架碳纤维摄影</text>
        </view>
        <view style="font-size: 24rpx;color: #808080;margin-top: 20rpx;">洛阳灵睿网络技术有限公司</view>
        <view>
          <tn-tag shape="radius" width="auto" backgroundColor="#F7F7F7" fontColor="#808080">洛阳市</tn-tag>
          <tn-tag shape="radius" margin="20rpx" width="auto" backgroundColor="#EBF4F7"
            fontColor="#3377FF">合作意向18人</tn-tag>
          <tn-tag shape="radius" width="auto" backgroundColor="#F7F3EB" fontColor="#FF8C19">项目金额1万以下</tn-tag>
        </view>
        <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-flex-row-center"
          style="margin-top: 20rpx;">
          <view style="color: #808080;font-size: 24rpx;">2023-12-19</view>
          <view>
            <tn-button shape="round" :fontSize="22" width="160rpx" height="50rpx"
              backgroundColor="tn-main-gradient-orange" fontColor="#ffffff">意向合作</tn-button>
          </view>
        </view>
      </view>
    </view> -->
		<tn-load-more class="tn-margin-top" :status="load_status"></tn-load-more>
	</view>
</template>

<script>
	import {
		activityIndex,
	} from '@/util/api.js';
	import store from '@/store/index.js'

	export default {
		data() {
			//1.线下活动2.调查问卷3.公益捐赠4.学习培训
			return {
				current: 0,
				load_status: 'loading ',
				tabList: [{
					name: '全部',
					id: 0
				}, {
					name: '线下活动',
					id: 1
				}, {
					name: '调查问卷',
					id: 2
				}, {
					name: '公益捐赠',
					id: 3
				}, {
					name: '学习培训',
					id: 4
				}],
				apiImgUrl: this.$store.state.imgUrl,
				content: '',
				topCurrent: 0,
				actList: [],
				page: 1,
			}
		},
		mounted() {
			this.getActivityIndex();
		},
		methods: {
			onsubmit() {
				this.page = 1;
				this.actList = [];
				this.getActivityIndex();
			},
			tabChange(d) {
				console.log(d);
				this.current = d;
				this.page = 1;
				this.actList = [];
				this.getActivityIndex();
			},
			ReachBottom() {
				console.log('service');
				this.page = this.page + 1;
				this.getActivityIndex();
				//this.getIndex();
			},
			getNewInfo() {
				this.current = 0;
				this.page = 1;
				this.actList = [];
				this.getActivityIndex();
			},
			getActivityIndex() {
				var type = this.tabList[this.current].id;
				activityIndex({
						association_id: store.state.Gid,
						page: this.page,
						size: 10,
						activity_name: this.content,
						activity_type: type
					})
					.then(res => {
						console.log(res);
						if (res.code == 1) {
							this.actList.push(...res.data.ret);
						} else {
							this.load_status = 'nomore';
						}
					})
					.catch(error => {
						uni.showToast({
							title: error,
							duration: 2000
						});
					})
			},
			goBack() {
				if (getCurrentPages().length > 1) {
					uni.navigateBack()
				} else {
					uni.redirectTo({
						url: '/pages/index/index'
					})

				}
			},
			openUrl(e) {
				uni.navigateTo({
					url: e
				})
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>