<template>
	<!-- 账户积分 -->
	<view class="" style="background-color: #ebebeb;">
		<view style="background-color: $color-white !important;">
			<u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
				:background="background" title-width="300" :title="i18n('getPersonIntegrate')"></u-navbar>
		</view>
		<view class="content">
			<view class="user-info">
				<view class="user-pic">
					<image class="ui-pic-detail" :src="websiteUrl+picDetail.userPic" mode=""></image>
					<view class="user-grade-now">
						{{userInfos.levelName}}
					</view>
				</view>
				<view class="integrate-now"><text
						class="big-num">{{userInfos.point}}</text>{{$i18n.locale=='zh'?'积分':'Integral'}}</view>
				<u-button class=" get-integrate" type="custom" shape="circle" @tap="toListDetails">
					<text class="get-integrate-info">{{$i18n.locale=='zh'?'明细':'Detail'}}</text>
				</u-button>
			</view>

			<view class="container">
				<view class="container-title">{{$i18n.locale=='zh'?'热门兑换':'Hot for'}}</view>
				<view class="container-content" v-for="(InfoList,index) in ShopInfo" :key="index">
					<view class="content-left">
						<image :src="websiteUrl + InfoList.picture" class="left-pic">
						</image>
						<view class="littlt-pic">
							<image src="/static/fill-little.png" class="fire-pic" />TOP<text
								class="little-num">{{index}}</text>
						</view>
					</view>
					<view class="content-right">
						<view class="content-right-title">
							{{$i18n.locale=='zh'? InfoList.commodityName:InfoList.commodityNameEn}}
						</view>
						<view class="content-right-need">
							{{$i18n.locale=='zh'?'所需分值：':'The score'}}<text class="need-num">{{InfoList.point}}</text>
						</view>
						<view class="content-right-lost">
							<view class="lost-num">
								{{$i18n.locale=='zh'?'累计兑换量：':'Accumulated exchange:'}}{{InfoList.exchangeQuantity}}
							</view>
							<view class="lost-info">
								{{$i18n.locale=='zh'?`${InfoList.inventoryQuantity>=100?'库存充足':InfoList.inventoryQuantity}`:
								`${InfoList.inventoryQuantity>=100?"sufficientstock":InfoList.inventoryQuantity}`}}
							</view>
						</view>

						<button class="button-popup-success2" @tap="toShopInfo(InfoList.id)"
							v-if="InfoList.commodityStatus==2">
							<text class="button-text-success">{{$i18n.locale=='zh'?'立即兑换':'Immediately change'}}</text>
						</button>
						<button class="button-popup-success" @tap="toShopInfo(InfoList.id)" v-else>
							<text class="button-text-success">{{$i18n.locale=='zh'?'立即兑换':'Immediately change'}}</text>
						</button>
					</view>

				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {

		data() {
			return {
				background: {
					backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
				},
				backStyle: {
					color: '#FFFFFF',
				},
				picDetail: {},
				ShopInfo: {},
				userInfos: {},

			};
		},
		onShow() {
			this.getUserDetail();
			this.getUserInfo();
			this.getShoppingDetail();
		},
		methods: {
			i18n(data) {
				return this.$t('common.' + data);
			},
			toListDetails() {
				uni.navigateTo({
					url: './integrateListDetail'
				})

			},
			toGetIntegrate() {
				uni.navigateTo({
					url: './getIntegrate'
				})
			},
			toShopInfo(id) {
				uni.navigateTo({
					url: './userShopDetails?id=' + id
				})
			},

			async getUserInfo() {
				const res = await this.$myRequest({
					url: '/uc/userCenter/findBasicInfo',
					data: {},
				});
				this.picDetail = res.data
				await this.getUserDetail();
			},
			async getShoppingDetail() {
				const res = await this.$myRequest({
					url: '/uc/umsPointCommoditys/commodityList',
					data: {}
				});
				this.ShopInfo = res.data.pointCommoditys
			},
			async getUserDetail() {
				const res = await this.$myRequest({
					url: '/uc/umsUserPoints/getUserPoint',
					data: {

					}
				});
				this.userInfos = res.data.umsUserPoints[0]
				if (this.userInfos.levelName == '白银用户') {
					if (this.$i18n.locale == 'zh') {
						this.userInfos.levelName = '白银用户'
					} else {
						this.userInfos.levelName = 'Silver User'
					}
				} else if (this.userInfos.levelName == '黄金用户') {
					if (this.$i18n.locale == 'zh') {
						this.userInfos.levelName = '黄金用户'
					} else {
						this.userInfos.levelName = 'Gold User'
					}
				} else if (this.userInfos.levelName == '铂金用户') {
					if (this.$i18n.locale == 'zh') {
						this.userInfos.levelName = '铂金用户'
					} else {
						this.userInfos.levelName = 'Platinum User'
					}
				} else {
					if (this.$i18n.locale == 'zh') {
						this.userInfos.levelName = '星钻用户'
					} else {
						this.userInfos.levelName = 'Star User'
					}
				}
			},

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		height: 100%;

		.user-info {
			display: flex;
			justify-content: space-around;
			background-image: url('/static/bgc-user.png');
			background-size: 100%;
			height: 200rpx;
			position: relative;

			.user-pic {
				width: 20%;
				height: 73%;
				margin-top: 4%;
				margin-left: 4%;
				border-radius: 50%;
				background-color: #e9e9e9;
				overflow: hidden;

				.ui-pic-detail {
					width: 100%;
					height: 100%;
				}
			}

			.user-grade-now {
				font-size: 20rpx;
				width: 25%;
				text-align: center;
				transform: translateY(410%);
				border-radius: 50rpx;
				background-color: #DFAC74FF;
				z-index: 999;
				position: absolute;
				left: 2%;
				top: 30rpx;
			}
		}

		.integrate-now {
			width: 30%;
			text-align: center;
			margin-left: 11%;

			.big-num {
				display: block;
				font-size: 60rpx;
				font-weight: 700;
				margin-bottom: -8%;
				margin-top: 18%;
			}
		}

		.get-integrate {
			width: 30%;
			height: 26%;
			transform: translateX(50%) translateY(145%);
			background-color: #44D7B6FF;
			border: none;

			.get-integrate-info {
				font-size: 30rpx;
				color: #fff;
				transform: translateX(-85%);
			}
		}
	}

	.container {
		width: 100%;
		background-color: #fff;
		margin-top: 4%;

		.container-title {
			font-size: 36rpx;
			font-weight: 700;
			margin-left: 4%;
			padding-bottom: 12px;
			transform: translateY(20%);
			margin-bottom: 4%;
		}

		.container-content {
			width: 92%;
			margin-left: 4%;
			margin-bottom: 4%;
			display: flex;
			justify-content: space-between;

			.content-left {
				width: 34%;
				height: 300rpx;
				background-color: antiquewhite;

				.left-pic {
					width: 100%;
					height: 100%;
				}

				.littlt-pic {
					width: 120rpx;
					height: 30rpx;
					border-radius: 0 0 60rpx 0;
					background-color: #F29D43FF;
					transform: translateY(-1052%);
					font-size: 8rpx;
					color: #fff;
					line-height: 31rpx;

					.fire-pic {
						width: 20rpx;
						height: 20rpx;
						margin: 0 6rpx;
					}

					.little-num {
						margin-left: 4rpx;
						font-size: 26rpx;
						font-weight: 700;
					}
				}
			}

			.content-right {
				width: 65%;

				.content-right-title {
					font-size: 30rpx;
					font-weight: 700;
					color: #0B0B11FF;
				}

				.content-right-need {
					color: #0B0B11FF;
					margin-top: 16rpx;
					margin-bottom: 16rpx;
					margin-left: 4%;
					font-size: 24rpx;

					.need-num {
						color: #E02020FF;
						// margin-left: 6%;
					}
				}

				.content-right-lost {
					color: #0B0B11FF;
					display: flex;
					justify-content: space-between;
					margin-bottom: 18rpx;

					.lost-num {
						margin-left: 3%;
						font-size: 22rpx;
					}

					.lost-info {
						margin-right: 5%;
						font-size: 22rpx;
					}
				}

				.button-popup-success2 {
					color: deepskyblue;
					width: 40%;
					height: 48rpx;
					line-height: 48rpx;
					margin-left: 4%;
					font-size: 18rpx;
					border-radius: 50rpx;
					border: 1rpx solid #a6a9ad;
					background-color: #a6a9ad;

					.button-text-success {
						color: black;
					}
				}

				.button-popup-success {
					color: deepskyblue;
					width: 40%;
					height: 48rpx;
					line-height: 48rpx;
					margin-left: 4%;
					font-size: 18rpx;
					border-radius: 50rpx;
					border: 1rpx solid wheat;

					.button-text-success {
						color: black;
					}
				}
			}
		}
	}
</style>
