<!-- 我的-活动订单列表 -->

<template>
	<view>
		<view class="head">
			<view @click="change_type" :data-type="0" :class="type=='0'?'focus':''">已报名</view>
			<view @click="change_type" :data-type="1" :class="type=='1'?'focus':''">已使用</view>
		</view>
		<view style="background-color: #F4F4F4;height: 20upx;"></view>
		<view class="loading_text" v-if="loading">加载中...</view>
		<view v-else>
			<view @click="to_detail(item)" v-for="(item, index) in data" class="con box">
				<view style="margin-left: 4%;display: flex;align-items: center;">
					<view style="">
						<view>
							{{item.title}}
						</view>
						<view
							style="color: #8D8D8D;font-size: 28upx;margin-top: 20upx;display: flex;align-items: center;">
							<image style="width: 27upx;height: 27upx;margin-right: 10upx;"
								src="../../static/clock_grey.png"></image>
							{{item.begin_datetime.slice(5,10)}}~{{item.finish_datetime.slice(5,10)}}
						</view>
					</view>
				</view>
				<view style="margin-right: 4%;text-align: right;">
					<view style="color: #FF663D;">{{type==0?'已报名':'已使用'}}</view>
					<view style="margin-top: 10upx;color: #666666;">{{item.price}}元</view>
				</view>
			</view>
		</view>
		<view class="loading_text" v-if="data.length==0&&!loading">暂无数据</view>
	</view>
</template>

<script>
	import commonData from '../../commonData.js'
	import commonFun from '../../commonFun.js'

	export default {
		data() {
			return {
				type: 0,
				data: [],
				loading: true,
			}
		},
		methods: {
			to_detail(item) {
				uni.navigateTo({
					url: '../activity/detail?id=' + item.market_activityid + '&type=1',
				})
			},
			change_type(e) { //切换tab
				this.type = e.currentTarget.dataset.type
				this.get_data()
			},
			get_data() {
				if (this.isTrader2 == 1 || this.FOREND_TOKEN == '') {
					uni.stopPullDownRefresh()
					return
				}

				this.loading = true
				uni.showLoading({
					title: '加载中...',
					mask: true
				})
				let params = {
					bizCatalog: 'MActivityEntity',
					handleMode: 'fetchallSelf',
					pageIndex: 1,
					pageSize: 1000,
					orderby: 0,
					query: {
						status: this.type + 2,
					}
				}
				console.log('我的活动订单列表请求参数')
				console.log(params)
				commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=fetchPageData', params, res => {
					if (res.status) {
						this.data = res.data.Result.pageData
						console.log('我的活动获取数据')
						console.log(this.data)
					}
					this.loading = false
					uni.hideLoading()
					uni.stopPullDownRefresh()
				})
			},
		},
		components: {},
		onLoad() {
			this.get_data()
		},
		onPullDownRefresh() {
			this.get_data();
		},
	};
</script>

<style>
	.box {
		border-bottom: 2upx solid #ececec;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.head view.focus {
		border-bottom: 6upx solid #00AB92;
		color: #00AB92;
	}

	.head view {
		height: 70upx;
		margin-top: 40upx;
		width: 150upx;
		text-align: center;
	}

	.head {
		display: flex;
		justify-content: space-around;
		overflow: hidden;
	}

	.con {
		width: 100%;
		height: 180upx;
		background: #FFFFFF;
	}

	.wal {
		width: 100%;
		height: 254upx;
		background: linear-gradient(90deg, #0ABACC 0%, #00DC7C 100%);
		border-radius: 26upx;
		color: #ffffff;
		margin-top: 20upx;
		overflow: hidden;
	}
</style>
