<template>
	<view class="content">
		<view class="qiehuan">
			<view @click="getlist(v)" v-for="(v,i) in arr" :key="i">
				<view :class="show==v?'xzs':'wzs'">{{v}}</view>
				<view class="qiehuan_line" v-if="show==v"> </view>
			</view>
		</view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">

			<view class="qbt_con">
				<view v-for="(item,index) in listdata" :key="index" class="qbt_con_item" @click="todetails(item)"
					:style="'background: url('+ z_imgPath + 'kuang_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
					<view class="list_1">
						<image :src="item.imgurl"></image>
						<view class="qbt_con_item_price ">
							<text>{{item.sale_stock}}/{{item.stock}}</text>
							<image :src="z_imgPath + 'box1.png'"></image>
						</view>
					</view>
					<view class="list_2 hang1"> 龙珠手办店</view>
				</view>
			</view>
		</mescroll-body>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				z_imgPath: this.$z_img + 'shouye/',
				arr: ['新品推荐', '一番赏', '积分赏', '无限赏', '擂台赏'],
				show: '新品推荐',
				keyword: '',
				listdata: [],
				downOption: {
					auto: false
				},

			}
		},


		onHide() {
			let pages = getCurrentPages()
			uni.setStorageSync('page', this.$mp.page.route)
		},
		onLoad(v) {
			if (v.pid) {
				uni.setStorageSync('pid', v.pid)
			}
			if (v.token) {
				uni.setStorageSync('token', v.token)
			}
		},
		onShareAppMessage() {
			let that = this;
			return {
				title: "吧唧一番，正版潮玩手办一番赏",
				imageUrl: that.advert[0].imgurl,
				path: "/pages/shouye/index?pid=" + uni.getStorageSync('userinfo').ID
			};
		},
		methods: {

			/*下拉刷新的回调 */
			downCallback() {
				// this.mescroll.resetUpScroll()
				this.loadData(1)
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				//联网加载数据
				this.loadData(page.num);
			},
			loadData(pageNo) {
				// 模拟接口
				let that = this;
				that.req({
					url: 'goods',
					data: {
						page: pageNo,
						type: that.show,
						keyword: that.keyword,
					},
					success(res) {
						that.mescroll.endByPage(res.data.data.length, res.data.data.last_page);
						if (pageNo == 1) {
							that.listdata = res.data.data;
						} else {
							that.listdata = that.listdata.concat(res.data.data);
						}
					}
				})
			},
			todetails(e) {

				uni.navigateTo({
					url: 'detail?goods_id=' + e.id
				})

			},
			getlist(v) {
				this.show = v;
				// this.listdata = []
				// this.mescroll.resetUpScroll()
				this.loadData(1)
			},
		}
	}
</script>

<style>
	.content {
		background: #222222;
		width: 100vw;
		/* height: 100vh; */
		box-sizing: border-box;
		position: relative;
		background-attachment: fixed;
		position: relative;
		padding-top: 100rpx;
		box-sizing: border-box;
	}


	.qiehuan {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 750rpx;
		height: 100rpx;
		padding: 0 30rpx;
		margin: 0 auto;
		box-sizing: border-box;
		/* font-family: 'zcq'; */
		font-weight: bold;
		position: fixed;
		/* #ifdef H5 */
		top: 88rpx;
		/* #endif */
		/* #ifndef H5 */
		top: 0;
		/* #endif */
		background: #222222;
		z-index: 15;
	}

	.qiehuan_line {
		margin: -10rpx auto;
		width: 50rpx;
		height: 20rpx;
		border-bottom: 4rpx solid #FF7514;
		border-radius: 2rpx;
	}


	.qiehuan>view {
		flex: 1;
		text-align: center;
	}

	.wzs {
		font-size: 32rpx;
		color: rgba(255, 255, 255, 0.6);
	}

	.xzs {
		font-size: 34rpx;
		color: #FF7514;
	}

	.qbt_con {
		margin: 0rpx auto;
		width: 710rpx;
		padding-bottom: 100rpx;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		font-size: 24rpx;
	}

	.qbt_con_item {
		margin-top: 30rpx;
		border-radius: 20rpx 20rpx 0 0;
		width: 335rpx;
		height: 403rpx;
		position: relative;
		padding: 16rpx 20rpx 0;
		box-sizing: border-box;
	}

	.list_1 {
		width: 300rpx;
		height: 300rpx;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;

	}

	.list_1>image {
		width: 300rpx;
		height: 300rpx;
		border-radius: 10rpx 10rpx 0 0;
		margin-top: 5rpx;
	}

	.list_2 {
		padding: 20rpx 0;
		border-radius: 0rpx 0rpx 10rpx 10rpx;
		color: #FFFFFF;
		text-align: center;
	}


	.qbt_con_item_price {
		display: flex;
		align-items: center;
		background: #FF6500;
		border-radius: 18rpx 0px 0px 18rpx;
		padding: 0 10rpx 0 20rpx;
		color: #FFFFFF;
		position: absolute;
		top: 27rpx;
		right: 0rpx;
	}

	.qbt_con_item_price>image {
		width: 24rpx;
		height: 24rpx;
		margin-left: 10rpx;
	}
</style>
