<template>
	<view class="container all-type-list-wrapper">
		<commodity-list ref="childList" :empty-text="emptyText"></commodity-list>
	</view>
</template>

<script>
	import commodityList from '@/components/module/listTemplate/commodityList'
	
	export default{
		components:{
			commodityList
		},
		data(){
			return{
				userID: '',
				serverUrl: '',
				emptyText: '',
				lastPageType: '',
				lastPageVal: ''
			}
		},
		onShow() {
			let pages = getCurrentPages(),
				thisPage = pages[pages.length - 1];
			if(thisPage.refresh) {
				this.setServerUrl(thisPage.listData);
			}
			this.$api.loginStatus().then((resolveData) => {
				this.$refs.childList.loginStatus = resolveData;
			});
		},
		onLoad() {
			this.$api.getStorage().then((resolve) =>{
				this.userID = resolve.userID
				this.setServerUrl();
			})
		},
		methods:{
			setServerUrl() {
				this.lastPageType = '再次购买';
				this.lastPageVal = '再次购买';
				// 空内容文案
				const emptyTxt = '您还没有购买过任何商品哟~';
				this.serverUrl = `/order/purchase?userID=${this.userID}`;
				this.$refs.childList.getListFromServer();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: $sub-bg-color;
		.all-type-list-wrapper {
			display: flex;
			flex-direction: column;
		}
	}
</style>
