<template>
	<view class="gallery" :style="{background:'url('+ bannerImage +')#ffffff'}">
		<view><nav-bar title="none" icon="none" background="transparent" border-color="transparent" ></nav-bar></view>
		<view class="logo"><re-image imgSrc="/retail/main/img_logo.png" width="300" height="56"></re-image></view>
		<view class="content">
			<view class="news">
				<view class="info flex">
					<image :src="avatar || defaultAvatar" class="img" width="104" height="104"></image>
					<view class="info-text flex-column jcsa">
						<view class="info-top flex">
							<view class="name">{{name}}</view>
							<view class="level flex aic">
								<re-image imgSrc="/retail/main/ic_chuji.png" width="40" height="44"></re-image>
								<view class="level-text">{{lvName}}</view>
							</view>
						</view>
						<view class="phone">{{username}}</view>
					</view>
				</view>
				<view class="news-total flex jcsa">
					<view class="total-item">
						<view class="item-num">{{sumPayNum || 0}}</view>
						<view class="item-text">总销订单</view>
					</view>
					<view class="total-item">
						<view class="item-num">{{sumGameCurrency || 0}}</view>
						<view class="item-text">总销游戏币</view>
					</view>
					<view class="total-item">
						<view class="item-num orange">¥{{sumIncome || 0}}</view>
						<view class="item-text">预估总收益</view>
					</view>
				</view>
			</view>
			<view class="list-title-wrapper flex jcsb aic">
				<view class="list-title flex aic">
					<span class="title-line"></span>
					套餐充值
				</view>
				<!-- <view class="timer">
					赠送游戏币倒计时
					<span>
						<span class="lb" id="day">2</span>
						天
						<span class="lb" id="hours">17</span>
						时
						<span class="lb" id="mins">56</span>
						分
					</span>
				</view> -->
			</view>
			<view class="list-wrapper">
				<view class="list-item" v-for="(item,index) in list" :key="index">
					<view class="item-wrapper">
						<view class="sub-title" v-if="item.name">{{item.name}}</view>
						<view class="big">
							<view class="">
								<view class="flex jcsb aic">
									<view>
										<span class="strong">{{item.gameCurrency}}</span><span class="strong-text">游戏币</span>
									</view>
									<view>
										<span class="symbol">¥</span>
										<span class="list-price">{{item.discountPrice}}</span>
									</view>
								</view>
								<view class="original">¥{{item.price}}</view>
							</view>
							<view class="msg flex jcsb aic">
								<view class="msg-left">
									<span class="zeng" v-if="item.additionalGameCurrency || item.grabTimes">赠</span>
									<span class="og" v-if="item.additionalGameCurrency"><span class="num">{{item.additionalGameCurrency}}</span>游戏币</span>
									<!-- <span class="og">
										<span class="">+</span>
										<span class="">2M</span>
									</span> -->
									<span class="og red" v-if="item.additionalGameCurrency && item.grabTimes">
										<span class=""
											style="margin-left:2px">+</span>
										<view class="red-box">
											<re-image width="30" imgSrc="/retail/main/ic_putonghb.png"></re-image>
											<span>红包机会x{{item.grabTimes}}</span>
										</view>
									</span>
								</view>
								<span class="time-text">{{item.expireDays}}天有效</span>
								<view class="pay-btn" @click="toMall(item.id)">去充值</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import defaultConfig from '@/config/default.js'
	import { packagePage } from '@/apis/main'
	import { getUserInfo } from '@/apis/user'
	export default {
		components: {},
		computed: {
			statusBarHeight() {
				return this.$store.state.info.systemInfo?.statusBarHeight
			},
		},
		data() {
			return {
				bannerImage: defaultConfig.ossImgUrl + '/retail/main/img_bgtop.png',
				title: 'Hello',
				navBarHeight: uni.getStorageSync('navBarHeight'),
				sumPayNum: '',// 总销订单
				sumGameCurrency: '',// 总销游戏币
				sumIncome: '',//预估总收益，
				avatar:'',
				defaultAvatar:'../../static/image/img_touxiang.png',
				name:'',
				lvName:'',
				list:[],
				username:'',
			}
		},
		onLoad() {

		},

		methods: {
			// async getInfo(){
			// 	const res = await getUserInfo()
			// 	if(res){
			// 		const { avatar,sumPayNum,sumPay,sumIncome,sumGameCurrency,name } = res
			// 		this.avatar = avatar || '../../static/image/img_touxiang.png'
			// 		this.sumPayNum = sumPayNum
			// 		this.sumGameCurrency = sumGameCurrency
			// 		this.sumIncome = sumIncome
			// 		this.name = name
			// 		uni.setStorageSync('avatar',avatar)
			// 		uni.setStorageSync('sumPayNum',sumPayNum)
			// 		uni.setStorageSync('sumGameCurrency',sumGameCurrency)
			// 		uni.setStorageSync('sumIncome',sumIncome)
			// 		uni.setStorageSync('name',name)
			// 	}
			// },
			toMall(id){
				uni.navigateTo({
					url: '/pages/mall/mallRecharge/index?id='+ id
				})
			},

			async getInfo(){
				const userInfo = await getUserInfo()
				if(userInfo){
					const { sumPayNum,sumGameCurrency,sumIncome,avatar,name,lvName,username } = userInfo
					this.sumPayNum = sumPayNum
					this.sumGameCurrency = sumGameCurrency
					this.sumIncome = sumIncome
					this.avatar = avatar
					this.name = name
					this.lvName = lvName
					this.username = username
				}
			},
			
			async getData(){
				const res = await packagePage()
				if(res){
					this.list = res.records
				}
				
			}
		},
		onShow() {
			this.getData()
			this.getInfo()
		},
	}
</script>

<style lang="scss" scoped>
	.gallery {
		background-repeat: no-repeat !important;
		background-size: contain !important;
		// background-position: top;
		width: 100%;
		position: absolute;
		top: 0;
		bottom: 0;
		.logo {
			margin-top: 16rpx;
			margin-left: 24rpx;
		}

		.content {
			padding: 0 32rpx var(--window-bottom);
			.news {
				background: #FFFFFF;
				box-shadow: 0rpx 6rpx 16rpx 0rpx #E3E6F2;
				border-radius: 24rpx;
				margin-top: 48rpx;
				padding: 40rpx;

				.info {
					.img{
						flex-shrink: 0;
						width: 104rpx;
						height: 104rpx;
						border-radius: 8rpx;
						margin-right: 20rpx;
					}
					.info-text {
						.info-top {
							.name {
								font-weight: 500;
								font-size: 32rpx;
								color: #363531;
							}

							.level {
								margin-left: 12rpx;

								.level-text {
									width: 80rpx;
									height: 36rpx;
									padding: 6rpx 12rpx 6rpx 20rpx;
									background: linear-gradient(130deg, #FFB873 0%, #FEC287 0%, #E69349 100%);
									border-radius: 0rpx 18rpx 18rpx 0rpx;
									font-weight: 500;
									font-size: 24rpx;
									color: #FFFFFF;
									line-height: 24rpx;
									margin-left: -12rpx;
									// text-align: left;
								}
							}
						}

					}

					.phone {
						font-weight: 400;
						font-size: 28rpx;
						color: #989897;
					}
				}

				.news-total {
					margin-top: 44rpx;

					.item-num {
						font-weight: bold;
						font-size: 40rpx;
						color: #363531;
					}

					.orange {
						color: #FF6400;
					}

					.item-text {
						font-weight: 400;
						font-size: 28rpx;
						color: #9598A6;
					}
				}

			}

			.list-title-wrapper {
				margin-top: 48rpx;

				.list-title {
					color: #363531;
					font-weight: bold;
					font-size: 36rpx;
					line-height: 36rpx;

					.title-line {
						width: 8rpx;
						height: 32rpx;
						background-color: #FF8800;
						margin-right: 20rpx;
					}
				}

				.timer {
					font-size: 24rpx;

					.lb {
						display: inline-block;
						vertical-align: top;
						width: 32rpx;
						height: 32rpx;
						background-color: #FFE4DA;
						color: #FF4300;
						text-align: center;
						line-height: 32rpx;
						border-radius: 6rpx;
						margin: 0 2rpx;
						font-weight: bold;
					}
				}
			}

			.list-wrapper {
				margin-top: 40rpx;
				
				.list-item {
					margin-bottom: 20rpx;
					position: relative;

					.pay-btn {
						background: linear-gradient(140deg, #FF8500 0%, #FFA600 100%);
						border-radius: 48rpx;
						color: #fff;
						width: 168rpx;
						height: 64rpx;
						text-align: center;
						font-weight: 600;
						font-size: 28rpx;
						color: #FFFFFF;
						line-height: 64rpx;
					}

					.item-wrapper {
						background-color: #F6F6F6;
						border: 4rpx solid #F6F6F6;
						border-radius: 24rpx;
						padding: 40rpx 40rpx 24rpx;
						position: relative;
						border: 2rpx solid #FFB74E;

						.sub-title {
							position: absolute;
							z-index: 10;
							left: -2rpx;
							top: -2rpx;
							padding: 6rpx 16rpx;
							font-size: 24rpx;
							color: #fff;
							line-height: 22rpx;
							background: #FF6400;
							border-radius: 24rpx 0rpx 24rpx 0rpx;
						}


						.big {
							font-size: 24rpx;
							color: #281A13;
							font-weight: bold;

							.symbol {
								color: #2C2B28;
								font-weight: bold;
								font-size: 32rpx;
							}

							.list-price {
								color: #2C2B28;
								font-weight: bold;
								font-size: 48rpx;
							}

							.strong {
								font-size: 48rpx;
								line-height: 58rpx;
								color: #2C2B28;
								font-weight: bold;
								margin-right: 8rpx;
							}
							.original{
								font-weight: bold;
								font-size: 20rpx;
								color: #898989;
								line-height: 24rpx;
								text-decoration-line: line-through;
								text-align: right;
							}

							.strong-text {
								font-size: 28rpx;
								color: #564C47;
								line-height: 28rpx;
								font-weight: normal;
							}
							.hide{
								display: none;
							}
							.msg {
								margin-top: 4rpx;
								font-size: 32rpx;
								color: #2C2B28;

								
								.msg-left {
									width: calc(100% - 150rpx);
									display: flex;
									align-items: center;
									white-space: nowrap;
									overflow: hidden;
									font-weight: normal;
									font-size: 28rpx;
									.num{

									}
								}

								.og {
									color: #FF7C00;
									font-weight: bold;
								}

								.red {
									display: flex;
									align-items: center;

									.red-box {
										display: flex;
										align-items: center;
									}
								}
								

								.time-text {
									position: absolute;
									right: 0;
									top: 0;
									font-size: 24rpx;
									color: #564C47;
									// font-weight: normal;
									z-index: 200;
									background: #E5F1FF;
									border-radius: 0rpx 20rpx 0rpx 20rpx;
									padding: 6rpx 14rpx;
								}

								.zeng {
									flex-shrink: 0;
									object-fit: contain;
									display: inline-block;
									background-color: #5CB020;
									width: 40rpx;
									height: 32rpx;
									line-height: 32rpx;
									color: #fff;
									font-size: 24rpx;
									border-radius: 8rpx;
									text-align: center;
									margin-right: 6rpx;
									// font-weight: normal;
								}
							}
						}

						.sm {
							font-size: 28rpx;
							margin-top: 16rpx;
							color: #74706D;
							padding-right: 20rpx;
						}
					}
				}
			}
		}

	}
</style>