<template>
	<view class="page">
		<view class="topBody">
			<view class="header">
			</view>
			<view class="myinfo">
				<view class="line"></view>
				<view class="numlist" v-if="type == 'GMM'">
					<view class="left">
						<view class="num">
							<text>{{num}}</text>
							<view class="name">{{$t('txt.M币数量')}}</view>
						</view>
					</view>
					<view class="right">
						<view class="buyBtn" @click="goPage('/pages/my/M_purchase')">
							<text>{{$t('txt.立即充值')}}</text>
						</view>
					</view>
					<image class="icon" src="../../static/me/M_coin_bg1.png" mode="heightFix" />
				</view>
				<view style="padding-top: 20rpx;margin-left: 40rpx;">
					<text style="color:#FFFFFF;font-size: 32rpx;">{{$t('txt.进出明细')}}</text>
				</view>

				<view class="mingxiList" v-if="false">
					<view class="left">
						<text style="font-size: 28rpx;color: #999999;">{{$t('txt.明细类型')}}</text>
						<image class="icon" src="../../static/me/arrow_down_gray.png" mode="heightFix" />
					</view>
					<view class="right">
						<text style="font-size: 28rpx;color: #999999;">{{$t('txt.开始时间-结束时间')}}</text>
						<image class="icon" src="../../static/me/arrow_down_gray.png" mode="heightFix" />
					</view>
				</view>

				<view class="numlist2">
					<view class="item" v-for="(item, index) in list" :key="index">
						<view class="left">
							<view class="num">
								<text>{{ $t(item.name) }}</text>
								<view class="data">{{item.create_time}}</view>
							</view>
						</view>
						<view class="right">
							<view v-if="item.num>0" class="num1">
								<text>+{{ item.num }}</text>
							</view>
							<view v-else class="num1 num2">
								<text>-{{ item.num }}</text>
							</view>
						</view>
					</view>
				</view>
				<view class="no-content" v-if="hasNo">
					<image class="icon" mode="widthFix" src="../../static/home/no.png"></image>
					<text>还没有消息</text>
				</view>

			</view>


			<view class="blankHeight"></view>
		</view>


		<!-- 提示框 -->
		<DialogBox ref="DialogBox"></DialogBox>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				type: 'GMM',
				num: '0',
				sel: 1,
				M_coinInfo: {
					myMcoin: 0
				},
				list: [],
				page: 1,
				hasNo: true,
			}
		},
		onLoad(parms) {
			this.type = parms.type || 'GMM';
		},
		onShow() {
			this.loadData();
		},
		methods: {
			onBack() {},
			goPage(page) {
				uni.navigateTo({
					url: page,
				})
			},
			chkSel() {
				if (this.sel == 1) {
					this.sel = 0;
				} else {
					this.sel = 1;
				}
			},
			loadData() {
				var offset = (this.page - 1) * 20;
				uni.request({
					url: this.$apiHost + '/My/recordlist',
					data: {
						uuid: getApp().globalData.uuid,
						type: this.type,
						offset: offset,
					},
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						console.log("res", res.data)
						this.num = res.data.num;
						if (res.data.list != null && res.data.list != undefined) {
							if (res.data.list.length > 0) {
								this.hasNo = false;
							}
							if (this.page <= 1) {
								this.list = res.data.list;
							} else {
								this.list = this.list.concat(res.data.list);
							}
						}
						uni.setNavigationBarTitle({
							title: res.data.name
						})
					}
				});

			},

		}
	}
</script>

<style scoped lang="scss">
	@import 'recordList.scss';
</style>