<template>
	<view class="padding">
		<view class="text-white padding bg radius">
			<!-- 商品列表 -->
			<view style="margin-left: -16px;">
				<view v-for="(item,index) in shangList" class="shang_list">
					<image class="shang_image" :src="item.goodsPicture.split(',')[0]"></image>
					<view class="shang_name">{{item.goodsName}}</view>
					<view class="shang_time">{{item.createTime}}</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				customStyle: {
					backgroundColor: '#FFCC00',
					color: '#000000',
					border: 0
				},
				shangList:[],
				actShopid:'',
				page: 1,
				limit: 10,
			}
		},
		onLoad(option) {
			this.actShopid=option.actShopid
			//已选择的商品
			this.selectShang()
		},
		methods: {
			//已选择的商品
			selectShang(){
				// var shopId=uni.getStorageSync('shopId')
				this.$Request.get(`/admin/activity-goods/${this.actShopid}`).then(res => {
					if (res.code == 0) {
						let returnData = res.data
						//活动列表
						this.allShang(returnData)
					}else{
						uni.showModal({
							content:res.msg
						})
					}
				});
			},
			//店铺所有商品
			allShang(returnData){
				let data = {
					page: this.page,
					limit: this.limit,
					shopId: uni.getStorageSync('shopId'),
				}
				this.$Request.getA("/admin/goodsShop/selectGoodsByShopId", data).then(res => {
					if (res.code == 0) {
						var total = res.data.totalCount
						let data2 = {
							page: this.page,
							limit: total,
							shopId: uni.getStorageSync('shopId'),
						}
						this.$Request.getA("/admin/goodsShop/selectGoodsByShopId", data2).then(res => {
							if (res.code == 0) {
								uni.hideLoading()
								let newList = res.data.list
								var arr = []
								for(var j in returnData){
									newList.forEach(item => {
										if (item.goodsId === returnData[j]) {
											arr.push(item)
										}
									})
								}
								this.shangList = arr
						}
						})
					}
					uni.stopPullDownRefresh();
					uni.hideLoading()
				});
				
			},
		}
	}
</script>

<style>
	page {
		/* background-color: #F5F5F5; */
	}
	.padding{
		padding-top: 0px;
	}
	/* 商品列表 */
	.shang_list{
		width: 711rpx;
		height: 160rpx;
		margin-top: 20rpx;
		opacity: 1;
		background: rgba(255, 255, 255, 1);
	}
	.shang_circle{
		position: absolute;
		margin: 50rpx 0 0 41rpx;
		width: 60rpx;
		height: 60rpx;
		border-radius: 86rpx;
		border: 1rpx solid rgba(166, 166, 166, 1);
	}
	.shang_circle_select{
		position: absolute;
		margin: 50rpx 0 0 41rpx;
		width: 60rpx;
		height: 60rpx;
		border-radius: 86rpx;
		background-color:rgba(245, 211, 71, 1);
	}
	.shang_image{
		position: absolute;
		margin: 31rpx 0 0 41rpx;
		width: 100rpx;
		height: 100rpx;
		border-radius: 6rpx;
		/* background: url(https://img.js.design/assets/smartFill/img395164da755928.jpeg), rgba(204, 204, 204, 1); */
	}
	.shang_name{
		position: absolute;
		margin: 29rpx 0 0 159rpx;
		font-size: 32rpx;
		color: rgba(0, 0, 0, 1);
	}
	.shang_time{
		position: absolute;
		margin: 90rpx 0 0 159rpx;
		font-size: 24rpx;
		color: rgba(153, 153, 153, 1);
	}
</style>