<template>
	<view class="content">
		<view class="box">


			<!-- 			<block  v-for="(item, index) in list" :key="index">
				<view class="orderItem">
					<image class="goodImg"
						:src="item.type==0?item.pimage:'https://ymyun-oss.oss-cn-hangzhou.aliyuncs.com/yidu_tc/public/upload/12/8/846cd1a69879ec4f551d44e87c7500bf.png'">
					</image>
					<view class="orderInfo">
						<view class="info1">
							<view>{{ item.type==0?item.pname:'提现'}}</view>
							<view :class="item.type==0?'color1':''">{{ item.type==0?'+'+item.money:'-'+item.money}}</view>
						</view>
						<view class="info3" v-if="item.type==0">
							<view>实付:¥{{ item.order_price }}</view>
							<view :class="true?'color1':''" v-if="item.score">+{{ item.score }}积分</view>
						</view>
						<view class="info2" v-if="item.type==0">
							<view>二级分销</view>
						</view>
				
						<view class="info2">
							<view >
							{{ parse.filterTime(item.createtime) }}
							</view>
						</view>
					</view>
				</view>
				
			</block> -->



			<block v-for="(item, index) in list" :key="index">
				<view class="orderItem" v-if="item.type==0">
					<view class="info1">
						<view>{{ parse.filterTime(item.createtime) }}</view>
						<view>{{item.state==0?'未支付':item.state==1?'已支付':item.state==2?'已发货':item.state==3?'已收货':''}}</view>
					</view>

					<view class="orderinfo">
						<image :src="item.pimage">
						</image>
						<view class="orderdesc">
							<view class="desctop">
								<view>{{item.pname}}</view>
								<view >+{{item.score}}佣金</view>
							</view>

							<view class="descbot">
								<view>购买人:{{item.nickname||''}}</view>
								<view>实付:¥{{item.order_price}}</view>
							</view>


						</view>

					</view>
					

					<block v-for="(item2,index2) in item.slist" :key="index2">

						<view class="ordertip"  v-if="item2.lv !=-1">
							<view>{{item2.lv}}级分销:{{item2.nickname}} </view>
							<view>+{{item2.type==0?item2.num:item2.num+'积分'}}</view>
						</view>

					</block>



				</view>







				<view class="orderItem" v-if="item.type==1">
					<view class="info1">
						<view>{{ parse.filterTime(item.createtime) }}</view>
					</view>

					<view class="orderinfo1">
						<image
							src="https://ymyun-oss.oss-cn-hangzhou.aliyuncs.com/yidu_tc/public/upload/12/8/846cd1a69879ec4f551d44e87c7500bf.png">
						</image>

						<view class="cashtip">
							<view>
								提现
							</view>

							<view>
								-{{item.money}}
							</view>
						</view>





					</view>


				</view>


			</block>





			<view v-if="!list.length" style='color:#999;text-align:center;margin:150rpx 0;font-size:30rpx'>暂无数据</view>


		</view>
	</view>
</template>
<script module="parse" lang="wxs">
	module.exports = {
		filterTime: function(time) {

			console.log(time)

			var nowDate = getDate(time * 1000);
			var year = nowDate.getFullYear();
			var month = nowDate.getMonth() + 1;
			var date = nowDate.getDate();
			var hours = nowDate.getHours();
			var minutes = nowDate.getMinutes();
			var seconds = nowDate.getSeconds();

			month = month > 9 ? month : '0' + month;
			date = date > 9 ? date : '0' + date;
			hours = hours > 9 ? hours : '0' + hours;
			minutes = minutes > 9 ? minutes : '0' + minutes;
			seconds = seconds > 9 ? seconds : '0' + seconds;

			return year + '-' + month + '-' + date + " " + hours + ":" + minutes + ":" + seconds;

		}
	}
</script>
<script>
	// pages/backstage/index/index.js
	var app = getApp();
	// import { request } from '../../../utils/request.js';
	export default {
		data() {
			return {
				page: 1,
				pageSize: 10,
				list: [],
				loaded: false,
			};
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		onLoad: function(options) {

			this.getlist();
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {
			this.init();
			this.getlist();
			uni.stopPullDownRefresh();
		},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {
			this.loaded || this.getlist();
		},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {

			async getlist() {
				var that = this;
				let res = await this.$api.request('/wallet/money_log', 'GET', {
					page: this.page,
					limit: this.pageSize
				});

				console.log(res)
				if (res) {
					if (res.data.length > 0) {

						this.list = this.list.concat(res.data);

						this.page++;

					} else {
						this.loaded = true
						this.$api.msg('没有更多数据');
					}
				}
			},

			init() {
				this.page = 1
				this.loaded = false
				this.list = []
			}
		}
	};
</script>
<style>
	page {
		background: #f4f5f9;
	}

	.content {
		margin: 26rpx;
		border-radius: 20rpx;
	}

	.orderItem {

		background: #fff;
		padding: 30rpx 20rpx;
		box-sizing: border-box;
		border-radius: 12rpx;
		margin-bottom: 24rpx;
	}

	.info1 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 12rpx;
	}

	.info1>view:nth-child(1) {
		font-size: 24rpx;
		color: #8E8E8E;
	}

	.info1>view:nth-child(2) {
		font-size: 24rpx;
		color: #7B9D3E;
	}

	.orderinfo {
		display: flex;
		align-items: center;
		padding-bottom: 36rpx;
		border-bottom: 1px solid #F0EDF1;
	}

	.orderinfo1 {
		display: flex;
		align-items: center;
		margin-top: 20rpx;

	}

	.orderinfo1>image {
		width: 100rpx;
		height: 100rpx;
	}


	.orderinfo>image {
		width: 100rpx;
		height: 100rpx;
	}

	.orderdesc {
		margin-left: 15rpx;
		flex: 1;

	}


	.desctop {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 10rpx;
	}

	.desctop>view:nth-child(1) {
		color: #010101;
		font-size: 28rpx;
		width: 280rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.desctop>view:nth-child(2) {
		font-size: 26rpx;
		font-weight: 700;
		color: #FB4C6F;
	}


	.descbot {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.descbot>view:nth-child(1) {
		color: #8E8E8E;
		font-size: 28rpx;
		width: 302rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.descbot>view:nth-child(2) {
		color: #8E8E8E;
		font-size: 24rpx;
	}

	.ordertip {
		margin: 20rpx 0 0;
		padding-left: 136rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.ordertip>view:nth-child(1) {
		font-size: 24rpx;
		color: #8E8E8E;
		width: 350rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.ordertip>view:nth-child(2) {
		font-size: 26rpx;
		font-weight: 700;
		color: #FB4C6F;
	}


	.cashtip {

		flex: 1;
		margin-left: 14rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.cashtip>view:nth-child(1) {
		font-size: 28rpx;
		color: #010101;
		font-weight: 700;
	}

	.cashtip>view:nth-child(2) {
		font-size: 26rpx;
		font-weight: 700;
		color: #010101;
	}
</style>
