<template>
	<uni-table class="table-box" emptyText="暂无更多数据">
		<!-- 表头行 -->
		<uni-tr>
			<uni-th>
				<view class="table-th">
					交易对
				</view>
			</uni-th>
			<uni-th >
				<view class="table-th table-th-title"  @click.stop="alterRankRule(`rankRule`)">
					<text>最新价</text>
					<view class="title-arrows">
						<image class="arrows-icon" :src="rankRule === 1 ? activeRankRuleIcon : rankRuleIcon"
							mode="aspectFit"></image>
						<image class="arrows-icon" :src="rankRule === 2 ? activeRankRuleIcon : rankRuleIcon"
							mode="aspectFit"></image>
					</view>
				</view>
			</uni-th>
			<uni-th >
				<view class="table-th table-th-title"  @click.stop="alterRankRule(`rankRule`)">
					<text>日涨跌</text>
					<view class="title-arrows">
						<image class="arrows-icon" :src="rankRule === 1 ? activeRankRuleIcon : rankRuleIcon"
							mode="aspectFit"></image>
						<image class="arrows-icon" :src="rankRule === 2 ? activeRankRuleIcon : rankRuleIcon"
							mode="aspectFit"></image>
					</view>
				</view>
			</uni-th>
		</uni-tr>
		<!-- 表格数据行 -->
		<uni-tr v-for="item in 30" :rise-fall="stocksColor">
			<uni-td>
				<view class="table-title">
					<view class="title">
						<text>BTC</text>
						<text class="title-sub">/USDT</text>
					</view>
					<view class="title-num">
						24H额：476.62m
					</view>
				</view>
			</uni-td>
			<uni-td>
				<view class="title">
					<view class="">
						30188.2
					</view>
					<view class="title-num">
						￥207695.01
					</view>
				</view>
			</uni-td>
			<uni-td class="table-right">
				<view class="table-btn-box">
					<view :class="['table-btn' , item % 2 ? 'fall-btn' : 'rise-btn']">
						+0.03%
					</view>
				</view>
			</uni-td>
		</uni-tr>

	</uni-table>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	export default {
		name: "marketplace",
		data() {
			return {
				rankRule: 0,
				rankRuleIcon: require("@/static/images/jiantou.png"),
				activeRankRuleIcon: require("@/static/images/jiantou_01.png")
			};
		},
		computed: {
			...mapGetters([
				'stocksColor'
			]),
		},
		methods: {
			alterRankRule(rankRule) {
				console.log('alterRankRule' , rankRule)
				switch (this['rankRule']) {
					case 0:
						this['rankRule'] = 1;
						break;
					case 1:
						this['rankRule'] = 2;
						break;
					default:
						this['rankRule'] = 0
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.table-box {
		.uni-table-tr {

			.uni-table-th,
			.uni-table-td {
				padding: 0;
				flex-shrink: 0;

				&:nth-child(3n - 2) {
					padding-left: $pages-padding;
					flex: 2;
				}

				&:nth-child(3n - 1) {
					text-align: right !important;
					flex: 2;
				}

				&:nth-child(3n) {
					flex: 1;
					padding-right: $pages-padding;
				}

				// &:nth-child()
			}
			.table-th{
				padding-top: 20rpx;
				padding-bottom: 10rpx;
			}
			.uni-table-th {
				font-size: 22rpx;
				border-bottom: none;

				.table-th-title {
					width: 100%;
					display: flex;
					justify-content: flex-end;

					.title-arrows {
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: flex-end;
						padding-left: 3px;

						.arrows-icon {
							width: 18rpx;
							height: 18rpx;

							&:first-child {
								transform: rotate(180deg);
								margin-bottom: -4rpx;
							}

							&:last-child {
								margin-top: -4rpx;
							}
						}
 
					}
				}

			}

			.uni-table-td {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				.table-title {
					width: 100%;
					line-height: 1.2;

				}

				.title {
					line-height: 1.2;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Bold;
					font-weight: 700;

					.title-sub {
						font-size: 24rpx;
						font-weight: 400;
					}
				}

				.title-num {
					padding-top: 18rpx;
					font-size: 24rpx;
				}

				// <view class="table-title">
				// 	<view class="title">
				// 		<text>BTC</text>
				// 		<text class="title-sub">/USDT</text>
				// 	</view>
				// 	<view class="title-num">
				// 		24H额：476.62m
				// 	</view>
				// </view>
				// 	&:nth-child(3n - 2) {
				// 		padding-left: $pages-padding;
				// 	}

				// 	&:nth-child(3n) {
				// 		padding-right: $pages-padding;
				// 		background-color: yellow;
				// 		text-align: right;
				// 	}

				// &:nth-child()
			}

			.table-btn-box {
				// width: 100%;
				// height: 100%;
				// display: flex;
				// justify-content: flex-end;
				// align-items: center;
				// background-color: yellowgreen;
			}

			.table-btn {
				// 138
				// width: 138rpx;
				// height: 60rpx;
				border-radius: 6rpx;
				color: #fff;
				font-family: PingFang SC, PingFang SC-Bold;
				font-weight: 700;
				text-align: center;
				// line-height: 60rpx;
				font-size: 26rpx;
				// margin-left: calc(100% - 138rpx);
			}
		}

		.table-right {
			padding: 0 !important;
			// display: flex;
			// justify-content: flex-end;
			// align-items: center;
			 
		}
	}
</style>