<template>
	<view class="content">
		<view class="header">
			<view class="money">
				<image src="../../static/icon/logo.png" mode=""></image>
				<view class="">
					3330.30
				</view>
			</view>
			<view class="header-right">
				<view @click="navTo('/pages/money/USDThuzhuan')">USDT互转</view>
				<view @click="navTo('/pages/money/conversionIntegral')">转换积分</view>
			</view>
		</view>
		<view class="list">
			<scroll-view scroll-y="true" class="scroll-y">
				<view class="item" v-for="l in list">
					<view class="item-left">
						<image src="../../static/icon/money.png" mode=""></image>
						<text>{{l.type}}</text>
						<text>{{l.time}}</text>
					</view>
					<view class="item-right">
						{{l.money}}
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="footer">
			<view class="recharge" @click="navTo('/pages/money/recharge')">
				充币
			</view>
			<view class="withdrawal" @click="navTo('/pages/money/withdrawal')">
				提币
			</view>
		</view>
	</view>
</template>

<script>
import { getMoneyStyle } from '@/utils/rocessor.js';
// #ifdef H5
import { rechargeWechat } from '@/api/wallet.js';
// #endif
// #ifdef MP
import { rechargeRoutine } from '@/api/wallet.js';
// #endif
import { mapState } from 'vuex';
export default {
	filters: {
		getMoneyStyle
	},
	data() {
		return {
			type: 'weixin',
			money: '', //充值金额
			payLoding: false ,//是否加载中
			list: [{
				type: "充币",
				time: "2018-05-12 16:24:45",
				money: 9898,
			},
			{
				type: "提币",
				time: "2020-05-12 16:24:45",
				money: 99,
			},
			{
				type: "充币",
				time: "2018-05-12 16:24:45",
				money: 9898,
			},
			{
				type: "充币",
				time: "2018-05-12 16:24:45",
				money: 9898,
			},
			{
				type: "充币",
				time: "2018-05-12 16:24:45",
				money: 9898,
			},
			{
				type: "充币",
				time: "2018-05-12 16:24:45",
				money: 9898,
			},
			{
				type: "充币",
				time: "2018-05-12 16:24:45",
				money: 9898,
			},
			{
				type: "充币",
				time: "2018-05-12 16:24:45",
				money: 9898,
			}]
		};
	},
	onLoad(options) {},
	computed: {
		// #ifdef H5
		...mapState(['weichatObj'])
		// #endif
	},
	methods: {
		// 跳转
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		// 切换选中对象
		tabRadio(e) {
			this.type = e;
		},
		// 提交
		confirm() {
			let obj = this;
			obj.payLoding = true;
			// #ifdef H5
			rechargeWechat({ price: this.money, from: this.type })
				.then(e => {
					let da = e.data.data;
					obj.weichatObj.chooseWXPay({
						timestamp: da.timestamp,
						nonceStr: da.nonceStr,
						package: da.package,
						signType: da.signType,
						paySign: da.paySign,
						success: function(res) {
							uni.showToast({
								title: '充值成功',
								duration: 2000,
								position: 'top'
							});
						}
					});
					obj.payLoding = false;
				})
				.catch(e => {
					obj.payLoding = false;
					console.log(e);
				});
			// #endif
			// #ifdef MP
			rechargeRoutine({ price: this.money})
				.then(e => {
					let da = e.data;
						wx.requestPayment({
								timeStamp: da.timestamp,
								nonceStr: da.nonceStr,
								package: da.package,
								signType: da.signType,
								paySign: da.paySign,
								success: function(res) {
									uni.redirectTo({
										url: '/pages/money/paySuccess'
									});
								},
								
							})
					
					obj.payLoding = false;
				})
				.catch(e => {
					obj.payLoding = false;
					console.log(e);
				});
			// #endif
		},
		//获取订单列表
		loadData(source) {
			console.log(source);
			//这里是将订单挂载到tab列表下
			let index = this.tabCurrentIndex;
			let navItem = this.navList[index];
			let state = navItem.state;
			if (source === 'tabChange' && navItem.loaded === true) {
				//tab切换只有第一次需要加载数据
				return;
			}
			if (navItem.loadingType === 'loading') {
				//防止重复加载
				return;
			}
			navItem.loadingType = 'loading';
			setTimeout(() => {
				let orderList = [];
				orderList.forEach(item => {
					navItem.orderList.push(item);
				});
				//loaded新字段用于表示数据加载完毕，如果为空可以显示空白页
				this.$set(navItem, 'loaded', true);
				//判断是否还有数据， 有改为 more， 没有改为noMore
				navItem.loadingType = 'more';
			}, 600);
		}
	}
};
</script>

<style lang="scss">
page {
	height: 100%;
	background-color: #fff;
}

// .add-btn {
// 	&.modified {
// 		color: $base-color;
// 	}
// 	&.up {
// 		background-color: $base-color;
// 		color: #fff;
// 	}
// 	display: flex;
// 	align-items: center;
// 	justify-content: center;
// 	width: 690rpx;
// 	height: 80rpx;
// 	margin: 0 auto;
// 	margin-top: 30rpx;
// 	font-size: $font-lg;
// 	border-radius: 10rpx;
// 	// box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
// }
.content {
	height: 100%;
}
.header {
	height: 350rpx;
	
	.money {
		text-align: center;
		height: 300rpx;
		padding: calc(50% - 300rpx) 0;
		image {
			width: 140rpx;
			height: 140rpx;
		}
		view {
			height: 60rpx;
			line-height: 60rpx;
		}
	}
	.header-right {
		position: absolute;
		right: 0;
		top: 80rpx;		
		view {
			text-align: center;
			border-radius: 10rpx 0 0 10rpx;
			margin-bottom: 10rpx;
			padding: 10rpx;
			background: linear-gradient(90deg, #438BED 0%,  #44BFEC 100%);
			color: #fff;
			font-size: 28rpx;
		}
		view:nth-child(2) {
			background: linear-gradient(90deg, #FFB238 0%,  #FFE138 100%);
		}
	}
}
.list {
	height: calc(100% - 350rpx - 100rpx - 10rpx);//350rpx头部100rpx底部30rpx
	.scroll-y {
		height: 100%;
	}
	.item {
		display: flex;
		justify-content: space-between;
		padding: 50rpx;
		margin: 30rpx;
		border-radius: 20rpx;
		box-shadow:0 0 20rpx 6rpx #f1f1f1;
		.item-left {
			image {
				width: 35rpx;
				height: 40rpx;
				margin-bottom: -10rpx;
				margin-right: 20rpx;
			}
			text:nth-child(2) {
				color: #333333;
				margin-right: 20rpx;
			}
			text:nth-child(3) {
				color: #999999;
				font-size: 20rpx;
			}
		}
		.item-right {
			color: #FB3A2F;
			font-size: 38rpx;
		}
		
	}
}
// .row-box {
// 	margin-top: 30rpx;
// 	padding: 20rpx 30rpx;
// 	background: #fff;
// 	.title {
// 		font-size: $font-base + 2rpx;
// 		color: $font-color-dark;
// 	}
// 	.row {
// 		display: flex;
// 		align-items: center;
// 		position: relative;
// 		height: 80rpx;
// 		.tit {
// 			flex-shrink: 0;
// 			width: 40rpx;
// 			font-size: 30rpx;
// 			color: $font-color-dark;
// 		}
// 		.input {
// 			flex: 1;
// 			font-size: 30rpx;
// 			color: $font-color-dark;
// 		}
// 		.iconlocation {
// 			font-size: 36rpx;
// 			color: $font-color-light;
// 		}

// 		.buttom {
// 			color: $font-color;
// 			font-size: $font-base;
// 		}
// 	}
// }
// .list {
// 	padding-left: 30rpx;
// 	margin-top: 30rpx;
// 	background-color: #ffffff;
// 	.box {
// 		display: flex;
// 		align-items: center;
// 		width: 100%;
// 		height: 120rpx;
// 		border-bottom: 1px solid $border-color-light;
// 		.icon {
// 			font-size: 48rpx;
// 			padding-right: 20rpx;
// 		}
// 		.iconweixin1 {
// 			color: #18bf16;
// 		}
// 		.iconzhifubao {
// 			color: #08aaec;
// 		}
// 		.title-box {
// 			flex-grow: 1;
// 			text-align: left;
// 			.title {
// 				font-size: $font-base + 2rpx;
// 				color: $font-color-base;
// 			}
// 			.node {
// 				font-size: $font-sm;
// 				color: $font-color-light;
// 			}
// 		}
// 	}
// }
// /deep/ .uni-radio-input {
// 	width: 45rpx;
// 	height: 45rpx;
// }
.footer {
	height: 100rpx;
	position: absolute;
	bottom: 0;
	display: flex;
	text-align: center;
	width: 100%;
	view {
		width: 50%;
		line-height: 100rpx;
		// padding: 20rpx;
		color: #fff;
	}
	.recharge {
		background-color: #FFB238;
	}
	.withdrawal {
		background-color: #438BED;
	}
}
</style>
