<template>
	<view class="main">
		<view class="list-box-h">
			<view v-for="(item, index) in dataList" :key="index" class="guess-item" @click="navToDetailPage(item)">
				<image :src="item.image"></image>
				<view class="guess-box">
					<view class="title clamp2">{{ item.store_name }}</view>
					<view class="price-box flex">
						<view class="yuanprice">{{ item.ot_price }}</view>
						<image src="../../static/img/jiantou.png" mode=""></image>
						<view class="jiang">直降{{ (item.ot_price - item.price).toFixed(2) }}元</view>
					</view>
					<view class="price">￥{{ item.price }}</view>
					<view class="btn">立即购买</view>
				</view>
			</view>
		</view>
		<uni-load-more :status="loadingType"></uni-load-more>
	</view>
</template>

<script>
	import { article } from '@/api/user.js';
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				loadingType: 'more',
				cid: 0,
			}
		},
		onLoad(opt) {
			this.cid = opt.cid
			this.tit = decodeURI(opt.tit)
			uni.setNavigationBarTitle({
				title: this.tit 
			})
			this.getArticleList()
		},
		methods: {
			navto(url) {
				uni.navigateTo({
					url: url
				})
			},
			getArticleList() {
				let obj = this
				if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
					return
				}
				obj.loadingType = 'loading'
				article({
					page: obj.page,
					limit: obj.limit
				},obj.cid).then(({data}) => {
					obj.list = obj.list.concat(data)
					obj.page++
					if(data.length == obj.limit) {
						obj.loadingType = 'more'
					}else {
						obj.loadingType = 'noMore'
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #fff;
		min-height: 100%;
	}
	.main {
		margin-top: 40rpx;
		padding: 0 40rpx;
		.main-t-t {
			// width: 100;
			display: flex;
			justify-content: center;
			.main-t-t-i {
				width: 376rpx;
				height: 34rpx;
				margin: auto;
			}
		}
		.main-top {
			align-items: center;
	
			.main-left {
				display: flex;
				justify-content: flex-start;
				align-items: center;
	
				.shu {
					width: 8rpx;
					height: 38rpx;
					background: #05ab81;
					border-radius: 4rpx;
				}
	
				.main-title {
					margin-left: 10rpx;
					font-size: 36rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #202739;
				}
	
				.main-tip {
					font-size: 22rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #95a0b1;
					margin-left: 14rpx;
				}
			}
		}
	}
</style>
