<template>
	<view class="content">
		<view class="comment-content">
			<view scroll-y class="scrollView" @scrolltolower="ReachBottom" @scroll="scrolly" :scroll-top="slide_Top">
				<view class="comment-list">
					<view class="comment-item p-top-bom-30" v-for="(DynamicItem,index) in DynamicData" :key="index">
						<view class="comment-header dis-flex flex-x-between m-btm40">
							<view class="comment-header-left dis-flex flex-y-center">
								<view class="user-avatar m-right20" :style="{'background-image':'url('+DynamicItem.logo+')'}"></view>
								<view class="user-info">
									<view class="user-nickname col-3 f-28">{{DynamicItem.storename}}</view>
									<view class="comment-time col-9 f-24">{{DynamicItem.datetime}}</view>
								</view>
							</view>
						</view>
						<view class="commentInfo twolist-hidden f-24 col-3 m-btm30">{{DynamicItem.content}}</view>
						<block v-if="!!DynamicItem && !!DynamicItem.imgs">
							<view class="commentPhoto dis-flex flex-warp">
								<view class="photo-item inlinBlock" :style="{'background-image':'url('+imgsItem+')'}" v-for="(imgsItem,index) in DynamicItem.imgs"
								 :key="index" @click="prevPhoto(index,DynamicItem.imgs)"></view>
							</view>
						</block>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import App from "@/common/js/app.js";
	export default {
		data() {
			return {
				DynamicData:[],
				totalPage: null,
				slide_Top: 0, // 滚动距离
				current_page: 1, // 当前页数
			}
		},
		onLoad(e) {

		},
		mounted() {

		},
		computed: {

		},
		components: {

		},
		computed: {

		},
		props: {
			storeId: {
				type: String,
				default: function() {
					return ""
				}
			},
			tabType: {
				type: String,
				default: function() {
					return ""
				}
			}
		},
		methods: {
			getStoreDynamic(page = 1, isPage = false) {
				let _this = this,
					requestData = {
						sid: _this.storeId,
						page,
					};
				App._post_form('&p=store&do=getStoreDynamic', requestData, res => {
					let DynamicData = res.data;
					console.log(DynamicData)
					if (isPage) {
						if (goodsData.list.length > 0) {
							_this["DynamicData"].push(...DynamicData.list);
						} else {
							_this.loading = true;
						}
					} else {
						_this.setData({
							DynamicData: res.data.list,
							totalPage: res.data.total
						})
						// _this.loading = ShopData.list.length === 0 || _this.current_page === ShopData.page_total;
					}
				}, false, () => {
					uni.hideLoading()
				})
			},
			/**
			 * 滑动高度 
			 */
			scrolly(e) {
				this.slide_Top = e.detail.scrollTop;
			},
			//加载更多
			ReachBottom() {
				let _this = this;
				if (_this.current_page >= _this.totalPage) {
					// _this.loading = true;
					return false;
				}
				_this.getStoreDynamic(++_this.current_page, true);
			},
			prevPhoto(currentIndex, image_urls) {
				let _this = this;
				uni.previewImage({
					current:image_urls[currentIndex],
					urls: image_urls,
					indicator: "default"
				})
			},
			tabbarShow() {
				let _this = this;
				uni.showLoading()
				_this.slide_Top = 0;
				_this.current_page = 1;
				_this.getStoreDynamic();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.inlinBlock{
		display: inline-block;
	}
	.comment-content{
		.scrollView{
			min-height: calc(100vw);
		}
	}
	.comment-item {
		border-bottom: 1px solid #EEEEEE;

		.comment-header {
			.comment-header-left {
				.user-avatar {
					width: 76upx;
					height: 76upx;
					background: rgba(238, 238, 238, 1);
					border-radius: 38upx;
					background-repeat: no-repeat;
					background-size: 76upx 76upx;
				}
			}
		}

		.commentPhoto {
			width: 100%;
			flex-grow: 1;

			.photo-item {
				
				width: 31.33%;
				height: 216upx;
				border-radius: 10upx;
				background-repeat: no-repeat;
				background-size: 100% 216upx;
				margin: 0 10upx 10upx 0;
			}
		}
	}
</style>
