<template>
	<view>
		<view class="head-box"></view>
		<uv-navbar autoBack :title="$t('pages_my.qiandao_list.title')" leftIconColor="#fff" :bgColor="bgColor" height="100rpx" :titleStyle="{color:'#fff'}"></uv-navbar>
	
		<view class="content">
			<zlx-item 
			:item="detail.activityInfo || detail.travel"
			:showBottom="false"></zlx-item>
			<view class="xie-box-val" v-for="(item,i) in list" :key="i">
				<view class="val-text">
					<view>{{item.name}}</view>
					<view class="phone-box">{{item.phone}}</view>
					<view class="type-box">{{typeList[item.typePrice].name}}X{{item.num}}</view>
				</view>
				<view class="choose-box">
					<view class="normol-box" v-if="item.open == 'N'"></view>
					<image src="./static/choose-icon.png" mode="widthFix" v-else></image>
				</view>
			</view>
		</view>
		
		<view class="btn-box">
			<uv-button @click="saoma" :text="$t('pages_my.qiandao_list.scan_checkin')" color="#381615" shape="circle" :customStyle="btnCustomStyle"></uv-button>
		</view>
	</view>
</template>

<script>
	import zlxItem  from '@/components/zhaomu/zlx-item.vue'
	import listMixin from '@/mixins/list.js'
	export default{
		mixins: [listMixin],
		components:{
			zlxItem
		},
		data() {
			return {
				mixinsListApi : 'getSignInUserPageList',
				btnCustomStyle:{
					color:'#FF5858'
				},
				bgColor:'transparent',
				detail : {
					activityInfo : {},
				},
				typeList:[],
				type : 0,
			}
		},
		onPageScroll(e) {
			if(e.scrollTop > 50) {
				this.bgColor = '#49070c'
			}else{
				this.bgColor = 'transparent'
			}
		},
		onLoad({id, type}) {
			// 初始化国际化数据
			this.typeList = [
				{
					name: this.$t('pages_my.qiandao_list.early_bird'),
					price: 168
				},
				{
					name: this.$t('pages_my.qiandao_list.single_ticket'),
					price: 198.01
				},
				{
					name: this.$t('pages_my.qiandao_list.premium_ticket'),
					price: 268
				}
			]
			
			this.queryParams.recruitId = id
			this.queryParams.pageSize = 20
			this.queryParams.type = type
			this.type = type
			this.getActivityInfo()
		},
		methods:{
			saoma() {
				let self = this
				uni.scanCode({
					success(code) {
						self.$api('signIn', {
							orderId: code.result
						}, res => {
							if (res.code == 200) {
								uni.showToast({
									title: res.message,
									icon: 'none'
								})
							}
							self.getData()
							self.getActivityInfo()
						})
					}
				})
			},
			getActivityInfo(){
				this.$api(['activityInfo', 'travelInfo'][this.type], {
					activityId : this.queryParams.recruitId,
					travelId : this.queryParams.recruitId,
				}, res => {
					if(res.code == 200){
						this.detail = res.result
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #060504;
	}
</style>
<style lang="scss" scoped>
	.head-box {
		background: url('@/static/image/nav-bg.png') no-repeat;
		background-size: 100% 100%;
		width: 100%;
		height: 534rpx;
		position: absolute;
		z-index: -1;
		top: 0;
	}
	.content {
		margin-top: 40rpx;
		padding: 0 30rpx;
		padding-top: calc(var(--status-bar-height) + 110rpx);
		.xie-box-val {
			margin-top: 34rpx;
			margin-bottom: 16rpx;
			height: 116rpx;
			background: #1B1713;
			border-radius: 27rpx 27rpx 27rpx 27rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 36rpx;
			.val-text {
				font-weight: 400;
				font-size: 25rpx;
				color: #FFFFFF;
				display: flex;
				align-items: center;
				.phone-box {
					color: #666666;
					margin: 0 10rpx;
				}
				.type-box {
					background: #322511;
					border-radius: 0rpx 12rpx 12rpx 12rpx;
					color: #FFA200;
					font-size: 20rpx;
					padding: 10rpx 10rpx;
				}
			}
			.choose-box {
				.normol-box {
					width: 31rpx;
					height: 31rpx;
					border: 1px solid #fff;
					border-radius: 5rpx;
				}
				image {
					width: 31rpx;
					height: 31rpx;
				}
			}
		}
	}

	.btn-box {
		position: fixed;
		bottom: 70rpx;
		left: 0;
		right: 0;
		padding: 0 40rpx;
	}
</style>