<template>
	<view class="NumberWeight">
		<!-- 有订单列表 -->
		<view class="" v-if="lists.length > 0">
			<!-- 订单列表 -->
			<view class="order-list" v-for="(item,index) in lists" :key="index">
				<NumberWeightTemplate :item="item" />
				<view class="actions">
					<view @click="navMarkets(item.symbol)" class="nowPay make">权证转让</view>
					<view @click="nowTake(item.symbol)" class="nowPay">去提货</view>
				</view>
			</view>
		</view>
		<!-- 没有订单列表 -->
		<no-list v-if="lists.length === 0" name='no-order' txt="暂无数据~" />
		<!-- <u-toast ref="uToast" /> -->
		
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import NumberWeightTemplate from '@/components/number-weight-template/number-weight-template'
	import {
		mallWarrants
	} from '@/apis/interfaces/numberWeight'
	export default {
		components: {
			NumberWeightTemplate
		},
		data() {
			return {
				lists: [],
				page: 1,
				total: 0
			};
		},
		onLoad() {
			this.getList()
		},
		onShow() {
			if (uni.getStorageSync('refresh')) {
				this.page = 1
				this.total = 0
				this.lists = []
				this.getList()
			}
		},
		onUnload() {
			uni.setStorageSync('refresh', false)
		},
		onReachBottom() {
			if (this.total > this.lists.length) {
				this.page = this.page + 1
				this.getList()
			} else {
				this.$refs.uToast.show({
					title: '吼吼吼~我是有底的~',
					type: 'error',
					icon: false,
					duration: 3000
				})
			}
		},
		methods: {
			getList() {
				let data = {
					perPage: 10,
					page: this.page
				}
				mallWarrants(data).then(res => {
					this.lists = this.lists.concat(res.data)
					this.total = res.total
				}).catch(err => {
					this.$refs.uToast.show({
						title: err.message,
						type: 'error',
						icon: false,
						duration: 3000
					})
				})
			},
			// 立即提货
			nowTake(symbol) {
				uni.navigateTo({
					url: './numberWeightInfo?symbol=' + symbol
				})
			},
			// 转让权证
			navMarkets(symbol) {
				this.$Router.push({
					name: 'marketTransfer',
					params: {
						symbol
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		width: 100%;
		height: 100%;
	}

	.NumberWeight {
		width: 100%;
		min-height: 100vh;
		box-sizing: border-box;
		background-color: #F7F7F7;

		// 订单nav
		.nav {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			box-sizing: border-box;
			font-size: $title-size*0.95;
			padding: 0 30rpx;
			background-color: #fff;
			color: #666;
			border-top: solid 20rpx #f7f7f7;

			.nav-item {
				border-bottom: solid 4rpx #fff;
				padding: 30rpx 10rpx;
			}

			.nav-item-selected {
				border-bottom: solid 4rpx $mian-color;
				color: $mian-color;
			}
		}

		// 订单列表
		.order-list {
			background-color: #fff;
			border-radius: 20rpx;
			min-height: 300rpx;
			margin: 30rpx 20rpx 0 20rpx;
			padding: 30rpx 30rpx 20rpx 30rpx;
			// border-top: solid 4rpx #cacaca;

			// 操作信息
			.actions {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: flex-end;
				box-sizing: border-box;
				flex-wrap: wrap;
				flex: 1;
				font-size: 28rpx;
				color: #fff;
				border-top: solid 1rpx #EFF4F2;

				.nowPay {
					padding: 10rpx 30rpx;
					border-radius: 40rpx;
					margin-left: 20rpx;
					margin-top: 20rpx;
					background-color: $mian-color;
					&.make{
						background: white;
						border:solid 1rpx $mian-color;
						color: $mian-color;
					}
				}

				.cancelOrder {
					padding: 10rpx 30rpx;
					border-radius: 40rpx;
					margin-left: 20rpx;
					margin-top: 20rpx;
					background-color: #DD524D;
				}

				.logistics {
					background-color: $mian-color;
					padding: 10rpx 30rpx;
					border-radius: 40rpx;
					margin-left: 20rpx;
					margin-top: 20rpx;
				}

				.sign {
					background-color: #DD524D;
					padding: 10rpx 30rpx;
					border-radius: 40rpx;
					margin-left: 20rpx;
					margin-top: 20rpx;
				}

				.evaluate {
					background-color: $mian-color;
					padding: 10rpx 30rpx;
					border-radius: 40rpx;
					margin-left: 20rpx;
					margin-top: 20rpx;
				}
			}
		}
	}
</style>
