<template>
	<view class="content">
		<view class="dyquan-wrap" v-for="(item,index) in list" :key="index">
			<view class="showtime">
				<text>{{ item.card_name|| '' }}</text>
			</view>
			<view class="item-info" v-for="good in item.card" @click="goGoods(good)">
				<image class="tip" :src="good.product.image" mode=""></image>
				<view class="info-info">
					<view class="line2">
						{{good.product.store_name || ''}}
					</view>
					<view class="info-cs clamp2">
						原价：{{good.product.price|| ''}}
					</view>
					<view class="info-cs">
						剩余使用次数：{{good.repertory || ''}}
					</view>
				</view>
			</view>
		</view>
		
		<view v-if="list.length == 0 && loadingType=='nomore'">
			<emptyPage title="暂无订单信息~"></emptyPage>
		</view>
	</view>
</template>

<script>
	import { getMyServeList} from "@/api/user.js";
	import emptyPage from '@/components/emptyPage.vue';
	export default {
		components: {
			emptyPage
		},
		data() {
			return {
				page: 1,
				pageSize: 10,
				loaded: false,
				loadingType: 'more',
				list: []
			}
		},
		onLoad(opt) {

		},
		onShow() {
			this.getList()
		},
		onReachBottom() {
			this.getList()
		},
		onReady() {

		},
		methods: {
			goGoods(item) {
				console.log(item)
				uni.navigateTo({
					url:'/pages/goods_details/index?id=' + item.product_id
				})
			},
			tabClick(item, index) {
				this.tabCurrentIndex = index;
			},
			getList(type) {
				let that = this
				if (type == 'reload') {
					// item.list
					return
				}
				if (type == 'tab' && that.loaded) {
					return
				}
				if (that.loadingType == 'loading' || that.loadingType == 'nomore') {
					return
				}
				that.loadingType = 'loading'

				getMyServeList({
					page: that.page,
					limit: that.pageSize,
					name: ''
				}).then(({
					data
				}) => {
					that.list = that.list.concat(data.list)
					that.page++
					if (data.length == that.pageSize) {
						that.loadingType = 'more'
					} else {
						that.loadingType = 'nomore'
					}
				})

			}
		}
	}
</script>

<style lang="scss">
	.content {
		background-color:#f8f6f6 ;
		height: auto;
		min-height: 100%;
		padding-top: 30rpx;
		
	}
	.dyquan-wrap {
		padding: 30rpx;
		background-color: #fff;
		margin: 0 30rpx;
		margin-bottom: 30rpx;
		border-radius: 20rpx;
		.showtime {
			height: 50rpx;
			border-bottom: 1px solid #f8f6f6;
			font-size: 30rpx;
			font-weight: bold;
		}
		.item-info {
			display: flex;
			justify-content: flex-start;
			align-items: stretch;
			padding-top: 20rpx;
			.tip {
				width: 160rpx;
				height: 160rpx;
				margin-right: 20rpx;
				border-radius: 10rpx;
				flex-shrink: 0;
			}

			.info-info {
				font-size: 30rpx;
				font-weight: 500;
				color: #666666;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: flex-start;
				.info-cs {
					font-size: 26rpx;
					font-weight: 500;
					color: #999999;
				}
			}
		}
	}
</style>
