<template>
	<view class="center">
		<view class="content-money">
			<view class="status_bar"><!-- 这里是状态栏 --></view>
			<view class="money-box">
				<view class="goback-box" @click="toBack"><image class="goback" src="../../static/img/fanhui.png" mode=""></image></view>
				<view class="header">艺术品挂牌交易区</view>
				<image class="money_bg" src="../../static/img/hinfo-bg.png"></image>
			</view>
		</view>
		<view class="hallist-bg">
			<image src="../../static/img/hallbanner.png" mode=""></image>
		</view>
		<view class="message flex" >
			<image class="message-left" src="../../static/img/hinco.png" mode=""></image>
			<u-notice-bar
				style="width: 100%;"
				mode="vertical"
				type="none"
				:volume-icon="false"
				:more-icon="true"
				:list="text"
				@click="goDetails"
				@getMore="navTo('/pages/index/message')"
			></u-notice-bar>
		</view>
		<view class="navbar">
			<view class="navbar-item" @click="navTo('/pages/money/qudou')">
				<view class="navbar-font">
					<image class="navbar-image" src="../../static/img/been.png" mode=""></image>
					<view class="font">趣豆</view>
				</view>
				<view class="navbar-num">{{ userInfo.integral || '0.00' }}</view>
			</view>
			<view class="vvv"></view>
			<view class="navbar-item">
				<view class="navbar-font" @click="navTo('/pages/user/award')">
					<image class="navbar-image" src="../../static/money/m03.png" mode=""></image>
					<view class="font">佣金</view>
				</view>
				<view class="navbar-num">{{ userInfo.brokerage_price }}</view>
			</view>
			<view class="vvv"></view>
			<view class="navbar-item">
				<view class="navbar-font" @click="navTo('/pages/user/myAppointment')">
					<image class="navbar-image" src="../../static/money/m04.png" mode=""></image>
					<view class="font">预约券</view>
				</view>
				<view class="navbar-num">{{ userInfo.anticipate }}</view>
			</view>
		</view>
		<view class="main" v-for="(item, index) in list" :key="index">
			<view class="mtitle-english">{{ item.show }}</view>
			<view class="mmain flex">
				<view class="mmain-info">
					<view class="mmain-title">
						<image class="mmaint-left" :src="item.time_image" mode=""></image>
						<view class="mmaint-font">{{ item.nickname }}</view>
						<view class="mmaint-time">{{ item.radd_time }}开售</view>
					</view>
					<view class="mmain-time" style="margin-top: 28rpx;">预约时间:{{ item.add_time }}-{{ item.end_time }}</view>
					<view class="mmain-time">入场时间:{{ item.radd_time }}-{{ item.rend_time }}</view>
					<view class="mmain-time flex">
						<view class="mmain-font">距预约结束:</view>
						
						<view class="lyy-b-jz flex" v-if="item.hours < 0 || item.minutes < 0 || item.minutes < 0" style="font-size: 30rpx; color: #d13737;">
							已结束
						</view>
						<view class="lyy-b-jz flex" v-else>
							<uni-countdowns
								color="#FFFFFF"
								splitor-color="#FECD57"
								background-color="#FECD57"
								border-color="#FECD57"
								:show-day="false"
								:hour="item.hours"
								:minute="item.minutes"
								:second="item.seconds"
							></uni-countdowns>
						</view>
					</view>
				</view>
				<view class="mmain-image"><image :src="item.image" mode=""></image></view>
			</view>
			<view class="bottom" @click="open(item)">
				<view class="bottom-font">立即{{item.str}}</view>
				<image class="bottom-image" src="../../static/img/jt.png" mode=""></image>
			</view>
		</view>
		<uni-popup ref="popup" type="center">
			<view class="popup">
				<view class="popup-title">预约需要{{price}}预约券是否立即预约？</view>
				<view class="btn-box">
					<view class="btn-left" @click="close()">取消</view>
					<view class="btn-right" @click="appointment()">确定</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
import uniCountdowns from '@/components/uni-countdown/uni-countdowns.vue';
import { pay_list } from '../../api/wallet.js'
import { article } from '@/api/user.js'
import { mapState, mapMutations } from 'vuex';
import { auction_list,subscribe,advance } from '@/api/hall.js';
import { timeComputed } from '@/utils/rocessor.js';
export default {
	components: {
		uniCountdowns
	},
	data() {
		return {
			name:'',//馆名字
			peoplename:'',//馆长名字
			price:'',//预约的价格
			id: '',//预约会场id
			page: 1,
			limit: 10,
			loadingType: 'more',
			text: [],
			article:[],
			list: [],
			aliData: {},
			bankData: {},
			wx:{},
		};
	},
	onLoad(option) {
		this.id = option.id;
		this.name = option.name;
		this.peoplename = option.peoplename
		this.loadData();
		article({},1).then(({data}) =>{
			data.forEach(e =>{
				this.text.push(e.synopsis)
			})
			this.article = data
			pay_list({}).then(({data}) =>{
				this.wx = data.wx
				this.aliData = data.zfb
				this.bankData = data.bank
			})
		})
	},
	computed: {
		...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
	},
	methods: {
		loadData() {
			const obj = this;
			if (obj.loadingType == 'nomore' || obj.loadingType == 'loading') {
				return;
			}
			obj.loadingType = 'loading';
			auction_list({
				page: obj.page,
				limit: obj.limit,
				auction_gu_id: obj.id
			}).then(({ data }) => {
				console.log(data, '123456');
				data.forEach(e => {
					let now_time = timeComputed(e.time);
					console.log(e.time,now_time);
					e.hours = now_time.hours;
					e.minutes = now_time.minutes;
					e.seconds = now_time.seconds;
					let jcsj = e.radd_time.split(':')
					if(jcsj[0]*1 >= 8 && jcsj[0]*1 < 12){
						e.time_image = '../../static/img/morningicon.png'
						e.show = 'MORNING SHOWS'
					}else if(jcsj[0]*1 >= 12 && jcsj[0]*1 < 18){
						e.show = 'AFTERNOON SHOWS'
						e.time_image = '../../static/img/afternoonicon.png'
					}else {
						e.time_image = '../../static/img/eveningicon.png'
						e.show = 'EVENING SHOWS'
					}
				});
				obj.list = obj.list.concat(data);
				if (data.length != obj.limit) {
					obj.loadingType = 'more';
					obj.page++;
				} else {
					obj.loadingType = 'nomore';
				}
			});
		},
		open(item) {
			if(this.wx == '' && this.aliData =='' && this.bankData == ''){
				uni.showModal({
					title: '提示',
					content:"您未填写收款信息无法参与，是否前去填写收款信息？",
					success: function (res) {
							if (res.confirm) {
								uni.navigateTo({
									url:'/pages/collection/collection'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
				})
				return
			}
			if(item.sta != 1) {
				this.id = item.id
				advance({id: item.id}).then(e =>{
					console.log(e,'success');
					this.nav()
				}).then(e =>{
					console.log(e,'fail');
				})
			}else {
				this.price = item.anticipate
				this.id = item.id
				this.$refs.popup.open();
			}
		},
		goDetails(e) {
			console.log(e, '123456');
			uni.navigateTo({
				url: '/pages/index/messageInfo?id=' + this.article[e].id
			});
		},
		close() {
			this.price = ''
			this.id = ''
			this.$refs.popup.close();
		},
		nav() {
			uni.navigateTo({
				url:'/pages/hall/hallinfo?id=' + this.id + '&name=' + this.name + '&peoplename=' + this.peoplename
			});
		},
		navTo(url){
			uni.navigateTo({
				url
			})
		},
		toBack() {
			uni.navigateBack({});
		},
		appointment() {
			subscribe({id: this.id}).then(({data}) =>{
				this.$api.msg('预约成功')
				window.location.reload();
				console.log(data);
				this.price = ''
				this.id = ''
				this.$refs.popup.close();
			}).catch(e =>{
				this.price = ''
				this.id = ''
				this.$refs.popup.close();
				console.log(e);
			})
		}
	}
};
</script>

<style lang="less">
page,
.center {
	height: auto;
	min-height: 100%;
	background: #f2f5f4;
}
.money-box {
	color: #ffffff;
	text-align: center;
	position: relative;
	.header {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 80rpx;
		font-size: 32rpx;
		font-weight: 700;
		z-index: 99;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.goback-box {
		position: absolute;
		left: 18rpx;
		top: 0;
		height: 80rpx;
		display: flex;
		align-items: center;
	}
	.goback {
		z-index: 100;
		width: 34rpx;
		height: 34rpx;
	}
	.money_bg {
		width: 100%;
		height: 382rpx;
		display: block;
	}
}
.shingle-mmain {
	position: relative;
	z-index: 2;
	margin: -90rpx auto 0;
	width: 690rpx;
	height: 176rpx;
	background: #ffffff;
	box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
	border-radius: 20rpx;
	background-color: #ffffff;
	.smmain-item {
		width: 33%;
		display: flex;
		flex-direction: column;
		align-items: center;
		.red {
			color: #fd3b39 !important;
		}
		.smitem-top {
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: bolder;
			color: #0c1732;
		}
		.smitem-bottom {
			margin-top: 10rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #0c1732;
		}
		.people {
			justify-content: center;
			.peopleitem {
				width: 24rpx;
				height: 34rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
	.shu {
		width: 2rpx;
		height: 70rpx;
		background: #dcdcdc;
	}
}
.main {
	margin: 30rpx auto 0;
	padding: 50rpx 50rpx 36rpx 50rpx;
	width: 690rpx;
	background: #ffffff;
	box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
	border-radius: 20rpx;
	.mtitle-english {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #9ea6ba;
	}
	.mmain {
		margin-top: 24rpx;
		.mmain-info {
			.mmain-title {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				.mmaint-left {
					width: 52rpx;
					height: 40rpx;
				}
				.mmaint-font {
					margin-left: 10rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #0c1732;
				}
				.mmaint-time {
					margin-left: 20rpx;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #0c1732;
				}
			}
			.mmain-time {
				justify-content: flex-start;
				margin-top: 10rpx;
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #0c1732;
				.lyy-b-jz {
					margin-left: 10rpx;
				}
			}
		}
		.mmain-image {
			padding-top: 14rpx;
			width: 182rpx;
			height: 182rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
	}
	.bottom {
		margin-top: 32rpx;
		width: 380rpx;
		height: 64rpx;
		background: #d13737;
		border-radius: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		.bottom-font {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #ffffff;
		}
		.bottom-image {
			margin-left: 12rpx;
			width: 24rpx;
			height: 22rpx;
		}
	}
}
.popup {
	width: 582rpx;
	background: #ffffff;
	border-radius: 20rpx;
	padding: 118rpx 20rpx 30rpx;
	.popup-title {
		text-align: center;
		font-size: 42rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #0c1732;
	}
	.btn-box {
		padding-top: 90rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.btn-left {
			width: 248rpx;
			height: 78rpx;
			border: 2rpx solid #DC262B;
			border-radius: 10rpx;
			font-size: 34rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #DC262B;
			text-align: center;
			line-height: 78rpx;
		}
		.btn-right {
			width: 248rpx;
			height: 78rpx;
			background: #DC262B;
			border-radius: 10rpx;
			font-size: 34rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
			text-align: center;
			line-height: 78rpx;
		}
	}
}
.message {
	justify-content: space-around;
	margin: 20rpx auto 0;
	padding: 16rpx 40rpx 16rpx 50rpx;
	width: 690rpx;
	background: #ffffff;
	box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
	border-radius: 20rpx;
	.message-left {
		width: 52rpx;
		height: 52rpx;
		flex-shrink: 0;
	}
	.message-font {
		margin: 0 40rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #0c1732;
	}
	.message-right {
		width: 18rpx;
		height: 30rpx;
	}
}
.hallist-bg {
	position: relative;
	z-index: 10;
	margin: -240rpx auto 0;
	width: 702rpx;
	height: 300rpx;
	border-radius: 14rpx;
	image {
		width: 100%;
		height: 100%;
	}
}
.navbar {
	display: flex;
	align-items: center;
	justify-content: space-around;
	width: 700rpx;
	background: #ffffff;
	box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
	border-radius: 20rpx;
	margin: 40rpx auto 0;
	padding: 40rpx 0 50rpx;

	.vvv {
		width: 2rpx;
		height: 74rpx;
		background: #dcdcdc;
	}

	.navbar-item {
		display: flex;
		flex-direction: column;
		align-items: center;

		.navbar-font {
			margin-bottom: 10rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			image {
				margin-right: 10rpx;
				width: 40rpx;
				height: 40rpx;
			}

			.font {
				font-size: 30rpx;
				font-weight: bold;
				color: #0c1732;
			}
		}

		.navbar-num {
			font-size: 34rpx;
			font-weight: bold;
			color: #0c1732;
		}
	}
}
</style>
