<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="iconfont icon-youjiantou " v-if="showDetail"></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" >￥{{Number(dataList.coursePrice).toFixed(2)}}</view>
				<text v-if="dataList.coursePrice != 0 && dataList.salesNumber">{{dataList.salesNumber}}人购买</text>
			</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
			},
			showDetail: { //展示详情箭头
				type: Boolean,
				default:false
			},
		},
		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;
				align-items: center;
				justify-content: space-between;
				// 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>
