<template>
	<!-- 积分详情 -->
	<view>
		<view class='integral-details' :style="colorStyle">
			<view class='header'>
				<view class="headerBox">
					<view>
						<view class='currentScore'>当前绿积分</view>
						<view class="scoreNum">{{userInfo.green_integral||0}}</view>
					</view>
					<!-- <view >
						<view class='currentScore'>当前母积分</view>
						<view class="scoreNum">{{userInfo.base_integral}}</view>
					</view> -->
				</view>
				<view class='line'></view>
				<!-- <view class='nav acea-row'>
					<view class='item'>
						<view class='num'>{{userInfo.sum_integral}}</view>
						<view>累计积分</view>
					</view>
					<view class='item'>
						<view class='num'>{{userInfo.deduction_integral}}</view>
						<view>累计消费</view>
					</view>
					<view class='item'>
						<view class='num'>{{userInfo.today_integral}}</view>
						<view>今日获得</view>
					</view>
				</view> -->
				<navigator url="./itemuser">
					<view class="rightGm">
						购买绿积分
					</view>
				</navigator>
				
			</view>
			<view class='wrapper'>
				<view class='nav acea-row'>
					<view class='item acea-row row-center-wrapper' style='flex-grow:1' :class='current==index?"on":""'
						v-for="(item,index) in navList" :key='index'><text class='iconfont'
							:class="item.icon"></text>{{item.name}}</view>
				</view>
				<view class='list2'>
					<view class='borderRadius15'>
						<view class='item acea-row row-between-wrapper'>
							<view class='item-title'>转账ID</view>
							<input class="input" type='number' v-model="changeID" placeholder='请输入转账人ID'
								placeholder-class='placeholder' pattern="\d*"></input>
						</view>
						<view class='item acea-row row-between-wrapper'>
							<view class='item-title'>转账绿积分</view>
							<input class="input" type='number' v-model="changeMoney" placeholder='请输入转账绿积分个数'
								placeholder-class='placeholder' pattern="\d*"></input>
						</view>
						<!-- <view class='item acea-row row-between-wrapper'>
							<view class='item-title'>转账类型</view>
							<view class="input">
								<label class="radio" @click="checkedType=1">
									<radio :checked="checkedType === 1" />
									<text>绿积分</text>
								</label>
								<label class="radio" style="margin-left: 20rpx;" @click="checkedType=2">
									<radio :checked="checkedType === 2" />
									<text>母积分</text>
								</label>
							</view>
						</view> -->
					</view>
					<button class='keepBnt bg-color' @click="setGreedIntegralList">立即转账</button>
				</view>
			</view>
		</view>
		<home v-if="navigation"></home>
		<!-- #ifdef MP -->
		<authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
		<!-- #endif -->
	</view>
</template>

<script>
	import home from '@/components/home';
	import {
		getUserInfo,
		getGreedIntegralList,
		setGreedIntegralList
	} from '@/api/user.js';
	import dayjs from '@/plugin/dayjs/dayjs.min.js';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	import emptyPage from '@/components/emptyPage.vue';
	import colors from '@/mixins/color'
	export default {
		components: {
			emptyPage,
			home
		},
		filters: {
			dateFormat: function(value) {
				return dayjs(value * 1000).format('YYYY-MM-DD');
			}
		},
		mixins: [colors],
		data() {
			return {
				navList: [
					{
						'name': '绿积分转账',
						'icon': 'icon-tishengfenzhi'
					}
				],
				current: 0,
				userInfo: {},
				isShowAuth: false, //是否隐藏授权
				changeID: '',
				changeMoney: '',
				checkedType: 1
			};
		},
		computed: mapGetters(['isLogin']),
		watch: {
			isLogin: {
				handler: function(newV, oldV) {
					if (newV) {
						// #ifdef H5 || APP-PLUS
						this.getUserInfo();
						// #endif
					}
				},
				deep: true
			}
		},
		onLoad() {
			if (this.isLogin) {
				this.getUserInfo();
			} else {
				// #ifdef H5 || APP-PLUS
				toLogin()
				// #endif
				// #ifdef MP
				this.isShowAuth = true;
				// #endif
			}
		},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		methods: {
			setGreedIntegralList() {
				const that = this;
				if (!that.changeID) {
					uni.showToast({
						title: '请填写转账ID',
						icon: "error",
					});
					return
				}
				if (!that.changeMoney) {
					uni.showToast({
						title: '请填写转账积分数',
						icon: "error",
					});
					return
				}
				if (+that.changeMoney > +this.userInfo.green_integral) {
					uni.showToast({
						title: '绿积分不足无法转账',
						icon: "error",
					});
					return
				}
				uni.showLoading({
					title: '转账中...',
					mask: true
				});
				uni.showModal({
					title: '积分转账',
					content: `是否转账给用户ID:${that.changeID}用户${ that.changeMoney }${that.checkedType==1?"绿":"母"}积分`,
					success: res => {
						if (res.confirm) {
							setGreedIntegralList({
								uid: that.changeID,
								num: that.changeMoney,
								type: that.checkedType
							}).then(function(res) {
								uni.hideLoading()
								that.changeID = '';
								that.changeMoney = '';
								uni.showToast({
									title: '转账成功'
								});
								that.page = 1;
								that.integralList = [];
								that.loadend = false;
								that.loading = false;
								that.getIntegralList()
							}).catch((res) => {
								uni.hideLoading();
								uni.showModal({
									title: '错误',
									content: res,
									showCancel: false,
								});
							});
						} else {
							uni.hideLoading()
						}
					},
				});
			},
			/**
			 * 授权回调
			 */
			onLoadFun: function() {
				this.getUserInfo();
				this.isShowAuth = false;
			},
			// 授权关闭
			authColse: function(e) {
				this.isShowAuth = e
			},
			getUserInfo: function() {
				let that = this;
				getUserInfo({}).then(function(res) {
					that.$set(that, 'userInfo', res.data);
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.headerBox{
		width: 100%;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}
	.integral-details {
		.header {
			// background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwkHBgoJCAkLCwoMDxkQDw4ODx4WFxIZJCAmJSMgIyIoLTkwKCo2KyIjMkQyNjs9QEBAJjBGS0U+Sjk/QD3/2wBDAQsLCw8NDx0QEB09KSMpPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT3/wgARCAHMAu4DAREAAhEBAxEB/8QAGQABAQEBAQEAAAAAAAAAAAAAAAECAwQF/8QAGQEBAQEBAQEAAAAAAAAAAAAAAAECAwUH/9oADAMBAAIQAxAAAAD5nh/QwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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GU6vOwTxTq02n2n//EACQRAAMAAgICAgIDAQAAAAAAAAABERIgAjBQYAMQQFExQZCw/9oACAEDAQE/AP8AmZ5GRWVlZkUvqlL1UT9Qpe5OCfpre9RTIpVun6W3rS9FE9U/SW9W+xPVPxdKUpSmRkUpSlKZFRUVfgN9yeq8HSlL+RWVmTMjJFX29G98kZoyW6ei8BfC16PZ8/0Nt6JtC5/vZenz65cm+jjygtFovTnwTH8f6Hwa24P+tV9oqMkZGRWV9lKXzrSY/jQ/jaI198XVoil/IpfOvgmP42cE1/Pgr56E8DS/5/QhCEIQhCEIQhCEIQhCEIQhNqZGRkZFMjIyMi7YmJiYmJiYmJiYGBgYmJiYmJiQnlmtoTaE2S9La6IRE6EvTp3QXqEJ1JCXqs2S8T//2Q==');
			background-repeat: no-repeat;
			background-size: 100% 100%;
			width: 100%;
			height: 460rpx;
			font-size: 72rpx;
			color: #fff;
			padding: 31rpx 0 45rpx 0;
			box-sizing: border-box;
			text-align: center;
			font-family: 'Guildford Pro';
			background-color: var(--view-theme);
			padding-top: 100rpx;

			.currentScore {
				font-size: 26rpx;
				color: rgba(255, 255, 255, 0.8);
				text-align: center;
				margin-bottom: 11rpx;
			}

			.scoreNum {
				font-family: "Guildford Pro";
			}

			.line {
				width: 60rpx;
				height: 3rpx;
				background-color: #fff;
				margin: 20rpx auto 0 auto;
			}

			.nav {
				font-size: 22rpx;
				color: rgba(255, 255, 255, 0.8);
				flex: 1;
				margin-top: 35rpx;

				.item {
					width: 33.33%;
					text-align: center;

					.num {
						color: #fff;
						font-size: 40rpx;
						margin-bottom: 5rpx;
						font-family: 'Guildford Pro';
					}
				}
			}
		}

		.wrapper {
			.nav {
				flex: 1;
				width: 690rpx;
				border-radius: 20rpx 20rpx 0 0 ;
				overflow: hidden;
				margin: -96rpx auto 0 auto;
				background-color: #f7f7f7;
				height: 96rpx;
				font-size: 30rpx;
				color: #bbb;

				.item {
					text-align: center;
					width: 50%;

					&.on {
						background-color: #fff;
						color: var(--view-theme);
						font-weight: bold;
						border-radius: 20rpx 0 0 0;
					}

					&:nth-of-type(2) {
						&.on {
							border-radius: 0 20rpx 0 0;
						}
					}

					.iconfont {
						font-size: 38rpx;
						margin-right: 10rpx;
					}
				}
			}

			.list {
				background-color: #fff;
				padding: 24rpx 30rpx;

				.tip {
					font-size: 25rpx;
					width: 690rpx;
					min-height: 60rpx;
					border-radius: 50rpx;
					background-color: #fff5e2;
					border: 1rpx solid #ffeac1;
					color: #c8a86b;
					padding: 0 20rpx;
					box-sizing: border-box;
					margin-bottom: 24rpx;

					.tipCon {
						width: 595rpx;
					}

					.iconfont {
						font-size: 35rpx;
						margin-right: 15rpx;
					}
				}

				.item {
					border-bottom: 1rpx solid #eee;
					font-size: 24rpx;
					color: #999;
					min-width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 20rpx 0;

					.state {
						width: 100%;
						font-size: 32rpx;
						color: #282828;
						padding-bottom: 8rpx;
					}

					.num {
						font-size: 36rpx;
						font-family: 'Guildford Pro';
						padding-left: 10rpx;
						color: #16AC57;
						flex-shrink: 0;

						&.font-color {
							color: #E93323 !important;
						}
					}
				}
			}

			.list2 {
				background-color: #fff;
				padding: 24rpx 0;
				// background-image: linear-gradient(to right, #fff7e7 0%, #fffdf9 100%);
				// height: 180rpx;
				position: relative;
				border-radius: 10rpx;
				padding: 20rpx 30rpx;
				box-sizing: border-box;
				border-bottom: 1px solid #e9e9e9;

				.keepBnt {
					width: 690rpx;
					height: 86rpx;
					border-radius: 50rpx;
					text-align: center;
					line-height: 86rpx;
					margin: 50rpx auto;
					font-size: 32rpx;
					color: #fff;
				}

				.item {
					// background-image: linear-gradient(to right, #fff7e7 0%, #fffdf9 100%);
					// height: 180rpx;
					position: relative;
					border-radius: 10rpx;
					padding: 20rpx 0;
					box-sizing: border-box;
					border-bottom: 1px solid #e9e9e9;

					.input {
						flex-grow: 1;
						display: flex;

						.radio {
							display: flex;
							line-height: 1;
							align-items: center;
							color: #bbb;

						}
					}

					.item-title {
						width: 150rpx;
					}

					.pictrue {
						width: 90rpx;
						height: 150rpx;
						position: absolute;
						bottom: 0;
						left: 45rpx;
					}

					.pictrue {

						image {
							width: 100%;
							height: 100%;
						}
					}
				}

			}
		}
	}
	.rightGm{
		font-size: 26rpx;
		position: absolute;
		right: 0rpx;
		top: 150px;
		border: 2px solid #fff;
		border-right: none;
		border-top-left-radius: 100px;
		border-bottom-left-radius: 100px;
		padding: 10rpx 30rpx;
	}
</style>