<template>
	<view class="itemContent">
		<view class="thumbnailBox">
			<image :src="thumbnailPath" alt="" mode="widthFix"></image>
		</view>
		<view class="courseDetailBox">
			<view class="title">
				<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{title}}</view>
				<!-- <text class="detailBtn" @click="viewDetail()" v-if="isNeedViewDetail">订单详情></text> -->
			</view>
			<view class="summaryBox" v-if="summaryBox">
				<view class="text-wrap">{{summaryBox}}</view>
			</view>
			<view class="dataBox" v-if="dataList">
				<view class="price" v-if="dataList.coursePrice != 0" >￥{{dataList.coursePrice}}</view>
				<!-- <text v-if="dataList.coursePrice == 0">免费</text> -->
				<text v-if="dataList.coursePrice != 0">{{dataList.salesNumber}}人购买</text>
			</view>
			<!-- <view class="tagListBox" v-if="tagList || fileLecturerId">
				<template v-if="tagList">
					<view class="tagItem" v-for="tagItem in tagConcat(tagList.v1,tagList.v2)">{{tagItem}}</view>
				</template>
				<template v-else-if="_tagList">
					<view class="tagItem" v-for="tagItem in tagConcat(_tagList.v1,_tagList.v2)">{{tagItem}}</view>
				</template>

			</view> -->
		</view>
	</view>
</template>

<script>
	import api from "@/api/api";
	export default {
		name: "courseItem",
		props: {
			fileLecturerId: {
				type: Number
			},
			thumbnailPath: {
				type: String
			},
			title: {
				type: String
			},
			summaryBox: {
				type: String
			},
			dataList: {
				type: Object
			},
			isNeedViewDetail: {
				type: Boolean,
				// 销售课程传参判断是否需要显示订单详情字段 --暂时废弃
			},
			orderId: {
				type: Number
			},
			tagList: {
				type: Object
			},
			fileId: {
				type: Number
			}
		},
		data() {
			return {
				_tagList: {}
			};
		},
		methods: {
			tagConcat(v1, v2) {
				if (v1 && v2 && v2.indexOf(',') > 0 && v1.indexOf(',') > 0) {
					return [].concat(v2.split(',').split(','), v1.split(','))
				} else if (v1 && v1.indexOf(',') > 0) {
					return [].concat(v2, v1.split(','))
				} else if (v2 && v2.indexOf(',') > 0) {
					return [].concat(v2.split(','), v1)
				} else {
					return [].concat(v2, v1)
				}
			},
			lecturerQuery() {
				api.lecturerQuery({
					id: this.fileLecturerId
				}).then(res => {
					if (res['success']) {
						this._tagList['v1'] = res['data']['lecturerInfos'][0]['lecturerRankNames'];
						this._tagList['v2'] = res['data']['lecturerInfos'][0]['lecturerName'];
					}
				})
			}

		},
		updated() {
			if (this.fileLecturerId) {
				this.lecturerQuery()
			}
		},
		mounted() {}
	}
</script>

<style lang="scss" scoped>
	.itemContent {
		box-sizing: border-box;
		display: flex;
		justify-content: flex-start;
		height: 100%;
		width: 100%;
		.thumbnailBox {
			box-sizing: border-box;
			flex-basis: 300rpx;
			margin-right: 26rpx;
			align-items: center;
			 width: 200rpx;
			flex: 0 0 auto;
			image {
				width: 100%;
				height: auto;
			}
		}

		.courseDetailBox {
			flex: 1;
			color: #333;
			height: auto;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			.title {
				// flex: 1;
				display: flex;
				// max-width: 260rpx;
				// width: 0;
				// flex-basis: 100rpx;
				font-size: 32rpx;
				// overflow: hidden;
				// text-overflow: ellipsis;
				// white-space: nowrap;
				.detailBtn {
					font-size: 24rpx;
					color: #4A4A4A;
				}
			}

			h4 {
				font-size: 32rpx;
			}

			.summaryBox {
				// overflow: hidden;
				// text-overflow: ellipsis;
				// white-space: nowrap;
				width: 100%;
				font-size: 24rpx;
				// margin: 10rpx 0;
				display: flex;
				.text-wrap {
				  white-space: pre-wrap;
				  word-break: break-word;
				}
				text {
					margin-right: 20rpx;
				}
			}

			.dataBox {
				display: flex;
				flex-direction: row;
				align-items: center;
				.price {
					width:150rpx;
					color: #F15A1F;
					font-size: 30rpx;
					margin: 10rpx 20rpx 10rpx 0;
					font-weight: 600;
				}

				text {
					font-size: 28rpx;
				}
			}

			.tagListBox {
				display: flex;
				flex-wrap: wrap;
				// margin-top: 20rpx;

				.tagItem {
					color: #20279B;
					font-size: 24rpx;
					border-radius: 20rpx;
					border-top-left-radius: 0;
					border-bottom-right-radius: 0;
					padding: 5rpx 18rpx;
					border: 1px solid #20279B;
					margin-right: 20rpx;
					white-space: nowrap;
					margin-bottom: 10rpx;
				}
			}
		}
	}
</style>
