<template>
	<view class="rf-product-list">
		<view class="rf-product-list-container">
			<block v-for="(item, index) in feedbackList" :key="index">
				<!--商品列表-->
				<view
					class="rf-product-item"

					:class="[isList ? 'rf-product-flex-list' : '']"
					hover-class="hover"
					:hover-start-time="150"
				>
					<view class="rf-product-image-wrapper">
						<image :src="item.image" mode="widthFix" :preview="false" :class="[isList?'rf-product-list-img':'rf-product-img']" ></image>
						<text class="sketch in1line">{{ item.username || item.nickname }}</text>

					</view>
					<view class="rf-pro-content">
						<view class="rf-pro-tit">{{ item.nickname }}</view>
						<view v-if="item">
							<view class="rf-pro-price">
								<text class="rf-sale-price" :class="'text-'+themeColor.name">{{ item.selfRecommendCode }}</text>

							</view>

						</view>
					</view>
				</view>
				<!--商品列表-->
			</block>
		</view>


	</view>
</template>

<script>
import { subdistributioncustomer } from '@/api/sms';

import rfLoadMore from '@/components/rf-load-more/rf-load-more';

export default {
	components: {
		rfLoadMore
	},
	data() {
		return {
			pageNum :0,
			feedbackList: [],
			isList: true,
			loadingType: 'more',
			loading: true
		};
	},
	filters: {
		feedbackFilter(type) {
			const feedbackType = ['', '功能建议', 'BUG反馈', '业务咨询'];
			return feedbackType[parseInt(type, 10)];
		}
	},
	// 下拉刷新
	onPullDownRefresh() {
		this.pageNum = 0;
		this.feedbackList.length = 0;
		this.getFeedbackList('refresh');
	},
	// 加载更多
	onReachBottom() {
  if (this.loadingType === 'nomore') return;
		this.pageNum++
		this.getFeedbackList();
	},
	onShow() {
		this.initData();
	},
	methods: {
		// 数据初始化
		initData() {
			this.pageNum = 0;
			this.feedbackList.length = 0;
			this.getFeedbackList();
		},
		// 获取意见反馈列表
		async getFeedbackList(type) {
			await this.$http
				.get(`${subdistributioncustomer}`, { pageNum: this.pageNum })
				.then(r => {
					this.loading = false;
					if (type === 'refresh') {
						uni.stopPullDownRefresh();
					}
					this.loadingType = r.length === 1000 ? 'more' : 'nomore';
					this.feedbackList = [...this.feedbackList, ...r];
				})
				.catch(() => {
					this.loading = false;
					if (type === 'refresh') {
						uni.stopPullDownRefresh();
					}
				});
		},
		navTo(route) {
			this.$mRouter.push({ route });
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: $page-color-base;
}

.feedback-list {
	position: relative;
	.wrapper {
		display: flex;
		flex-direction: column;
		flex: 1;
	}
	.address-box {
		display: flex;
		align-items: center;
		.tag {
			font-size: 24upx;
			margin-right: 10upx;
			border: 1px solid;
			border-radius: 4upx;
			padding: 4upx 10upx;
			line-height: 1;
		}

		.address {
			font-size: 30upx;
			color: $font-color-dark;
		}
	}

	.u-box {
		font-size: 28upx;
		color: $font-color-light;
		margin-top: 16upx;

		.name {
			margin-right: 30upx;
		}
	}
}
</style>
