<template>
	<view class="page">
		<nav-bar :title="$t('power.title')" bgColor="#F5f5f5"></nav-bar>
		<view class="wallet1">
			<view style="width: 400; font-size: 12px; color: #fff;">{{$t('power.text1')}}</view>
			<view style="width: 500; font-size: 24px; color: #fff; line-height: 55px;">{{power.score.toFixed(4) }}</view>
			<view style="float: left; width: 30%;">
				<view style="width: 400; font-size: 12px; color: #fff;">{{$t('power.text2')}}</view>
				<view style="width: 400; font-size: 16px; color: #fff; line-height: 35px;">{{power.total.toFixed(4)}}</view>
			</view>
			<view style="width: 30%; float: left; margin-left: 5%;">
				<view style="width: 400; font-size: 12px; color: #fff; text-align: center;">{{$t('power.text3')}}</view>
				<view style="width: 400; font-size: 16px; color: #fff; line-height: 35px; text-align: center;">{{power.notfinished.toFixed(4)}}</view>
			</view>
			<view style="width: 30%; float: left; margin-left: 5%;">
				<view style="width: 400; font-size: 12px; color: #fff; text-align: right;">{{$t('power.text4')}}</view>
				<view style="width: 400; font-size: 16px; color: #fff; line-height: 35px; text-align: right;">{{power.expired.toFixed(4)}}</view>
			</view>	
			<view style="clear: both;"></view>
		</view>
		<view style="width: 92%; margin: 10px auto;">
			<view class="cell_list">
				<view style="color: #333; font-size: 18px; font-weight: 600;">{{$t('power.text5')}}</view>
				<view class="cell_right" @click="dialogVisible=true">{{$t('power.text6')}}
					<uni-icons size="20" type="help-filled" style="float: right; margin-left: 5px;"></uni-icons>
				</view>
			</view>

			<view class="cell_list" style="border-bottom: 1px solid #ddd;" v-for="item in list" :key="item.id">
				<view class="t">{{item.type}}<view class="d">{{item.created_at.slice(0, 19)}}</view></view>
				<view class=" u1" style="color: #1D61E7; text-align: right;">{{item.amount}}
				<view class="d" style="text-align: right; ">{{$t('power.text7')}}：{{item.after}}</view></view>
			</view>
			<view style="text-align: center; padding-bottom: 80px;" v-if="list.length <= 0">
				<image style="width: 360rpx; height: 360rpx; margin: 160rpx auto 0rpx auto;" src="/static/images/w5.png" mode="cover"></image>
				<view style="color: #999; font-size: 14px; font-weight: 400;">{{$t('nodata')}}</view>
			</view>
		</view>
		
		<Popup v-model="dialogVisible" type="2000" @change="handleClose">
			<view class="popup_box">
				<view class="popup_title">
					<view style="text-align: center; width: 100%; font-weight: bold;">{{$t('power.text6')}}</view>
				</view>
				<view class="popup_content" style="margin-top: -3px;">
					<view style="border-bottom: 1px solid #ddd; padding-bottom: 20px; line-height: 25px; text-align: left;">{{$t('power.text8')}}</view>
					<view style="margin-top: 10px;">
						<view style="width: 100%; text-align: center; color: #1D61E7; font-size: 16px;" @click="onPageJump('/pages/questionnaire/index')">{{$t('power.text9')}}</view>
					</view>
				</view>
			</view>
		</Popup>
		
	</view>
</template>

<script>
	import zPrompt from '@/components/common/prompt';
	import Popup from '@/components/common/popup';
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		components: {
			Popup,
			zPrompt
		},
		data() {
			return {
				dialogVisible:false,
				power:{
					score: 0.0000,
					total: 0.0000,
					notfinished: 0.0000,
					expired: 0.0000
				},
				list: []
			};
		},
		computed: {
			...mapState(['userInfo'])
		},
		//第一次加载
		onLoad(e) {
			if(this.userInfo.token === typeof(undefined) || this.userInfo.token === undefined){
				this.islogin = false;
				uni.hideLoading();
			}else{
				this.getlist();
				this.power.score = parseFloat(this.userInfo.score);
				this.power.notfinished = parseFloat(this.userInfo.currency2 == null ? 0 : this.userInfo.currency2);
				this.power.expired = parseFloat(this.userInfo.currency2 == null ? 0 : this.userInfo.currency2);
				this.power.total = this.power.notfinished + this.power.expired;
			}
			
		},
		//页面显示
		onShow() {},
		//方法
		methods: {
			getlist(){
				let data = {
					page: 1,
					limit: 10,
					currency: 'score'
				};
				this.$http.post('/api/balanceLog/list', data).then(res => {
					if(res.code == 0){
						this.list = res.data.data;
					}
				});
			},
			onPageJump(url) {
				uni.switchTab({
					url: url
				});
			},
			onTokenJump(url) {
				this.judgeLogin(() => {
					uni.navigateTo({
						url: url
					});
				});
			},
			handleClose(done) {
				this.dialogVisible = false;
			}
		},
		//页面隐藏
		onHide() {},
		//页面卸载
		onUnload() {},
		//页面下来刷新
		onPullDownRefresh() {},
		//页面上拉触底
		onReachBottom() {},
		//用户点击分享
		onShareAppMessage(e) {
			return this.wxShare();
		}
	};
</script>
<style lang="scss" scoped>
	@import '@/style/mixin.scss';
	body{background-color: #fff;}
	.popup_box {
		width: 600rpx;
		border-radius: 50upx;
	}
	.popup_title {
		display: flex;
		justify-content: space-between;
		height: 88upx;
		line-height: 88upx;
		padding: 0 20upx;
		background-color: #FFF;
		border-top-left-radius: 40upx;
		border-top-right-radius: 40upx;
	}
	.popup_title view {
		font-size: 32upx;
	}
	.popup_title text {
		width: 80upx;
		flex-shrink: 0;
		text-align: center;
	}
	.popup_title text {
		font-size: 28upx;
		color: #999;
	}
	.popup_title text:last-child {
		color: $themeColor;
	}
	.popup_content {
		padding: 30rpx 30rpx;
		background-color: #FFFFFF;
		text-align: center;
		border-bottom-left-radius: 40upx;
		border-bottom-right-radius: 40upx;
	}
	.wallet1{
		border-radius: 10px; padding: 20px 15px; width: 84%; margin: 10px auto;
		background: url('/static/images/c1.png') #2B66F6; background-repeat: no-repeat; background-position: 92% 5px;
	}
	.cell_list .t{
		color: #3d3d3d; font-size: 16px; font-weight: 400; line-height: 25px;
	}
	.cell_list .d{
		color: #3d3d3d; font-size: 14px; font-weight: 400; line-height: 25px;
	}
	.cell_list .u{
		color: #1D61E7; font-weight: 600;float: right; font-size: 16px;
	}
	.cell_list .u1{
		color: #333; font-weight: 600;float: right;font-size: 16px;
	}
	.w{
		background-color: #F8F8F8; border-radius: 10px; padding: 20px 10px;
	}
	.w .t{
		text-align: center; margin-top: 10px; font-size: 14px;
	}
</style>