<template>
	<view :style="themeColor">
		<mescroll-uni ref="mescroll" @getData="getData" class="member-point" :size="8" @listenRefresh="listenRefresh">
			<block class="goods_list" slot="list">
				<block v-if="collectionList.length > 0">
					<view class="goods_li margin-top" v-for="(item, index) in collectionList" :key="index"
						@click.stop="toDetail(item)">
						<view class="pic">
							<image :src="$util.img(item.goods_image.split(',')[0], { size: 'mid' })" mode="aspectFill"
								@error="goodsImageError(index)"></image>
						</view>
						<view class="goods_info">
							<view class="goods_name font-size-base">{{ item.sku_name }}</view>
							<view class="goods_opection">
								<view class="left  lineheight-clear ">
									<text class="symbol price-style small">￥</text>
									<text class="price price-style large">{{
										parseFloat(item.discount_price).toFixed(2).split('.')[0] }}</text>
									<text class="symbol price-style small">.{{
										parseFloat(item.discount_price).toFixed(2).split('.')[1] }}</text>
								</view>
								<view class="right">
									<view class="cars" @click.stop="deleteItem(item.goods_id)">
										<view class="icon iconfont icon-icon7"></view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
				<!-- 第一个列表为空时 -->
				<view class="collection-empty" v-else>
					<ns-empty v-if="collectionList.length == 0 && isShowEmpty" text="暂无关注的商品" subText="赶紧去逛逛, 关注心仪的商品吧"
						:isIndex="Boolean(storeToken)" :emptyBtn="{ text: $lang('toGoodsCategoryPage'), url: '/pages_goods/category' }"></ns-empty>
					<button type="primary" size="mini" class="button mini" v-if="!storeToken"
						@click="toLogin">{{ $lang('toLogin') }}</button>					
				</view>

				<ns-goods-recommend ref="goodsRecommend"></ns-goods-recommend>
			</block>
		</mescroll-uni>
		<ns-login ref="login"></ns-login>
		<loading-cover ref="loadingCover"></loading-cover>
	</view>
</template>

<script>
import common from './public/js/common.js';
import collection from './public/js/collection.js';

export default {
	mixins: [common, collection],
	data() {
		return {};
	},
	onShow() {
		if (this.storeToken) {
			if (this.$refs.mescroll) this.$refs.mescroll.refresh();
		} else {
			this.$nextTick(() => {
				this.$refs.loadingCover.hide();
			});
		}
	},
	watch: {
		storeToken: function (nVal, oVal) {
			if (nVal) {
				this.$refs.mescroll.refresh();
			}
		}
	}
};
</script>

<style lang="scss" scoped>
/deep/ .fixed {
	position: relative;
	top: 0;
}

/deep/ .empty {
	margin-top: 0 !important;
}

@import './public/css/collection.scss';
</style>

<style lang="scss" scoped>
/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
	max-height: unset !important;
}
</style>