<template>
	<view class="contentColumn">
		<customNav :shownav="true" :title="$t('user.gerenzhongxin')" tinColor="#40AE36" jiantou="0"></customNav>
		<view style="background-color: #40AE36;">
			<view style="width: 92%;margin-left: 4%;">
				<view class="contentInRowS" style="align-items: center;" @click="userIconkl">
					<view class="contentInRowL" style="align-items: center;margin-top: 20rpx;">
						<myImage class="iconImg" :isIcon="true" :mysrc="userInfo.avatar" mymode="scaleToFill"></myImage>
						<view class="contentColumn" style="padding-left: 20rpx;">
							<text class="nameText">{{nickName}}</text>
							<!-- <text class="phoneText">{{userName}}</text> -->
						</view>
					</view>
					<image class="jiantouImg" src="/static/imags/fanhui1@3x.png" mode="scaleToFill"></image>
				</view>
				<view style="height: 100rpx;"></view>
				<!-- <view class="contentInRowS" style="align-items: center;width: 80%;margin-left: 10%;padding-bottom: 50rpx;">
					<view class="contentColumn" style="padding-top: 20rpx;" >
						<text class="titleText" style="margin-bottom: 16rpx;">{{$t('zhanghu.jinriwanch')}}</text>
						<text class="nameText" style="margin-bottom: 16rpx;">0</text>
					</view>
					<label style="width: 6rpx;height: 100rpx;background-color:royalblue"></label>
					<view class="contentColumn" style="padding-top: 20rpx;">
						<text class="titleText" style="margin-bottom: 16rpx;">{{$t('zhanghu.jinrishour')}}</text>
						<text class="nameText" style="margin-bottom: 16rpx;">0</text>
					</view>
				</view> -->
			</view>
		</view>
		<view class="contentInRowS dengjiView" @click="tixian">
			<text class="dengjiText">{{$t('zhanghu.yuer')}}: {{$formPr(ketixianJE)}}{{$t('api.huobidanwei')}}</text>
			<view class="contentInRowL" style="align-items: center;margin-right: 30rpx;">
				<text class="dengjiText">{{$t('tixian.tixian')}}</text>
				<image class="jiantouImgS" src="/static/imags/fanhui1@3x.png" mode="scaleToFill"></image>
			</view>
		</view>
		<scrollViewR class="actListView" style="margin-top: 30rpx;" :itemList="actList" v-on:EitemSelect="actIndex"></scrollViewR>
		<!-- <view class="contentInRowS" style="margin-top: 30rpx;">
			<text class="jinriText">{{$t('zhanghu.jinrizhangd')}}</text>
		</view>
		<view class="jinricontent">
			<view class="contentInRowS" style="padding-top: 30rpx;width: 84%;margin-left: 8%;">
				<view class="contentColumn" style="align-items: center;">
					<text>+100.5</text>
					<text>{{$t('zhanghu.yujishouru')}}</text>
				</view>
				<view class="contentColumn" style="align-items: center;">
					<text>+0.00</text>
					<text>{{$t('zhanghu.yujizhichu')}}</text>
				</view>
			</view>
			<view style="width: 94%;margin-left: 3%;height: 4rpx;background-color: lavender;"></view>
			<text class="shournote">{{$t('zhanghu.peisongsr')}}100.05，{{$t('zhanghu.huodongsr')}}0</text>
		</view> -->
		<!-- <view class="">
			<view class="contentInRowS duoyuyanctv" @click="duoyuyan">
				<view class="contentInRowL">
					<image class="duoyuyIcon" src="/static/imags/yuyan@3x.png" mode="scaleToFill"></image>
					<text>Ngôn ngữ/语言</text>
				</view>
				<image style="width: 30rpx;" src="/static/imags/youjian@3x.png" mode="widthFix"></image>
			</view>
		</view> -->
		<view style="width: 94%;margin-left: 3%;background-color: white;margin-top: 30rpx;">
			<view v-for="(item,index) in balanceList">
				<view class="contentInRowL" style="padding-top: 20rpx;">
					<view class="contentColumn" style="width: 97%;padding-left: 1%;">
						<view class="contentInRowS">
							<text class="timeText">{{rtType(item.type)}}</text>
							<text class="yujidzText" style="margin-left: auto;margin-right: 10rpx;">No.{{item.ddId}}</text>
						</view>
						<view class="contentInRowS">
							<text class="timeText">{{$formPr(item.amount)}}{{$t('api.huobidanwei')}}</text>
							<!-- <text class="yujidzText" style="margin-left: auto;margin-right: 10rpx;">{{$formPr(item.divvy)}}{{$t('api.huobidanwei')}}</text> -->
						</view>
						<view class="contentInRowS">
							<text class="timeText">{{item.cretim}}</text>
							<text class="yujidzText" style="margin-left: auto;margin-right: 10rpx;">{{$t('zhanghu.zhuangtai')}}: {{rtState(item.state)}}</text>
						</view>
					</view>
				</view>
				<view style="width: 94%;margin-left: 3%;height: 4rpx;background-color: lavender;margin-top: 10rpx;"></view>
			</view>
			<view style="height: 40rpx;"></view>
		</view>
	</view>
</template>

<script>
	import {
		getUserMsg
	} from '@/pages/api/login';
	import {
		getUsbalance
	} from '@/pages/api/basic.js';
	export default {
		data() {
			return {
				imageURL:'/static/imags/huituceng@3x.png',
				isLogin:true,
				actList:[],
				userInfo:'',
				userName:'',
				nickName:'',
				avatar:'',
				ketixianJE:0.00,
				balanceList:''
			}
		},
		onShow() {
			this.actList=[
				{ imagStr:'/static/imags/zhanghumingxi@3x.png', title: this.$t('zhanghu.zhanghumingxi') },
				// { imagStr:'/static/imags/shouzhitj@3x.png', title: this.$t('zhanghu.shouzhitj')},
				// { imagStr:'/static/imags/baozhengjin@3x.png', title: this.$t('zhanghu.baozhegnjin')},
				{ imagStr:'/static/imags/yinhangka@3x.png', title: this.$t('zhanghu.yinhangka') },
				// { imagStr:'/static/imags/tixianjilu@3x.png', title:'打IM'},
				{ imagStr:'/static/imags/kefu.png', title: this.$t('user.kefuzhongxin') },
			];
			var that =this;
			try {//读取
				that.token = uni.getStorageSync("token");
				//console.log('2222',that.token)
				if(that.token == '' || that.token == undefined || that.token == null){
					that.isLogin=false;
					that.userName='';
					that.nickName='';
					that.avatar='';
					return;
				}
				else{
					that.isLogin=true;
					that.getUserMsg(that.token);
					that.getUsbalance();
					return;
				}
			} catch(e){//错误
				return;
			}
		},
		methods: {
			userIconkl(){
				this.gotoNextView('/pages/user/Usermanager')
			},
			tixian(){
				this.gotoNextView('/pages/tixian/Tixian')
			},
			duoyuyan(){
				uni.navigateTo({
					url:'/pages/user/duoyuyan'
				})
			},
			actIndex(index){
				var url = '';
				if(index==0){
					this.gotoNextView('/pages/order/Zhanghumingxi')
				}
				// if(index==1){
				// 	this.gotoNextView('/pages/order/Myorderlist')
				// }
				// if(index==1){
				// 	this.gotoNextView('/pages/tixian/Baozhengjin')
				// }
				if(index==1){
					this.gotoNextView('/pages/tixian/Wodeyanhangka?state=0')
				}
				if(index==2){
					var that = this;
					uni.showModal({
					    title: that.$t('api.message'),
					    content: that.$t('api.nqdbddh'),
						cancelText: that.$t('index.quxiao'), // 取消按钮的文字
						confirmText: that.$t('index.queren'), // 确认按钮的文字 
					    success: function (res) {
					        if (res.confirm) { //这里是点击了确定以
								plus.device.dial('0938088913', false );
					        } else { //这里是点击了取消以后
					          console.log('用户点击取消')
					        }
					    }
					})
					return;
				}
				// if(index==3){
				// 	uni.navigateTo({
				// 		url:'/pages/imcall/vidioCall?caller=1'
				// 	})
				// 	return;
				// }
				if(index==4){
					this.gotoNextView('/pages/order/Tixianjilv')
				}
			},
			
			gotoNextView(url){
				if(this.isLogin){
					uni.navigateTo({
						url:url
					})
				}
				else{
					uni.navigateTo({
						url:'/pages/user/LoginView'
					})
				}
			},
			async getUserMsg(token){
				//console.log('getUserMsg')
				await this.$http.get(`${getUserMsg}`, {
				},true)
				.then(async r => {
					console.log(r.data)
					this.userInfo=r.data.data;
					getApp().globalData.auditStatus=this.userInfo.auditStatus;
					this.userName=r.data.data.userName;
					this.nickName=r.data.data.nickName;
					this.avatar=r.data.data.avatar;
					//console.log('this.avatar',this.avatar)
					uni.setStorageSync('userInfo',r.data.data);
					if(r.data.data.userType==1){
						this.isShangjia=true;
					}
				})
				.catch(err => {
					console.log(err)
				})
			},
			async getUsbalance(){
				//console.log('getUserMsg')
				await this.$http.get(`${getUsbalance}`, {
					type:'',
					sort:false,
					page:1,
					size:20,
				},true)
				.then(async r => {
					console.log(r)
					this.ketixianJE=r.data.data.sum;
					this.balanceList=r.data.data.list;
				})
				.catch(err => {
					console.log(err)
				})
			},
			rtState(state){
				if(state==0){
					return this.$t('order.wancheng')
				}
				if(state==1){
					return this.$t('index.quxiao')
				}
				if(state==2){
					return this.$t('index.quxiao')
				}
				if(state==3){
					return this.$t('order.weizhifu')
				}
			},
			rtType(type){
				if(type==0){
					return this.$t('zhanghu.peisongsr')
				}
				if(type==1){
					return this.$t('tixian.chongzhi')
				}
				if(type==2){
					return this.$t('tixian.tixian')
				}
			},
		}
	}
</script>

<style lang="scss">
	@import '@/common/common.scss';
	page{
		background-color: whitesmoke;
	}
	.iconImg{
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		width: 110rpx;
		height: 110rpx;
		border-radius: 55rpx;
		background-color: #1A1A1A;
	}
	.jiantouImg{
		width: 40rpx;
		height: 40rpx;
	}
	.jiantouImgS{
		width: 30rpx;
		height: 30rpx;
	}
	
	.nameText{
		font-size: 32rpx;
		color: white;
	}
	.phoneText{
		font-size: 26rpx;
		color: white;
	}
	.titleText{
		color: white;
		font-size: 26rpx;
	}
	.dingdanText{
		font-size: 28rpx;
		color: lightgrey;
	}
	
	.dengjiView{
		margin-top: -40rpx;
		width: 94%;
		margin-left: 3%;
		height: 80rpx;
		align-items: center;
		//background-color: #616A89;
		background-image: url('/static/imags/huituceng@3x.png');
		background-size: 100% 100%;
	}
	
	.dengjiText{
		color: white;
		font-size: 28rpx;
		padding-left: 30rpx;
	}
	
	.actListView{
		width: 92%;
		margin-left: 4%;
		border-radius: 10rpx;
		box-shadow: 0px 0rpx 10rpx 0rpx darkgray;
		background-color: white;
	}
	.jinriText{
		color: #1A1A1A;
		font-size: 28rpx;
		padding-left: 40rpx;
	}
	
	.jinricontent{
		margin-top: 30rpx;
		width: 92%;
		margin-left: 4%;
		border-radius: 10rpx;
		box-shadow: 0px 0rpx 10rpx 0rpx darkgray;
		background-color: white;
		padding-bottom: 30rpx;
	}
	.shournote{
		color: darkgray;
		font-size: 26rpx;
		
		padding-left: 20rpx;
	}
	
	.ruzhangNote{
		padding-left: 10rpx;
		overflow:hidden;
		text-overflow:ellipsis;
		display:-webkit-box;
		-webkit-line-clamp:2;
		-webkit-box-orient:vertical;
	}
	.timeText{
		color: #1A1A1A;
		font-size: 26rpx;
		padding-left: 20rpx;
	}
	
	.yujidzText{
		color: sandybrown;
		font-size: 26rpx;
		padding-left: 20rpx;
	}
	
	.duoyuyanctv{
		margin-top: 20rpx;
		padding: 30rpx;
		border: solid lavender;
		border-width: 0px 0px 1rpx 0px;
	}
	.duoyuyIcon{
		width: 40rpx;
		height: 40rpx;
	}
	

</style>
