uni-app 课程组件

uni-app 课程组件

UI给的图 - 这个用的比较多封个组件

代码

<template>
	<view
		class="MyCurriculum"
		:style="{
			filter: gray ? 'grayscale(' + hue + '%)' : ''
		}"
	>
		<view class="_new" :style="newStyle" v-if="isnew">{{ newText }}</view>
		<slot name="image">
			<view class="showImage"><image :src="img" mode="widthFix" :style="{ height: !img ? '200rpx' : '' }"></image></view>
		</slot>
		<slot name="content">
			<view class="content-container">
				<view class="title">{{ title }}</view>
				<view class="">开通时间:{{ start }}</view>
				<view class="">剩余时间:{{ surplus }}</view>
				<view class="">学习进度条:{{ plan }}</view>
			</view>
		</slot>
		<view class="_tag" v-if="tagText" :style="tagStyle">{{ tagText }}</view>
	</view>
</template>

<script>
export default {
	name: 'my-curriculum',
	data() {
		return {};
	},
	props: {
		isnew: { type: Boolean, default: false },
		newText: { type: String, default: '新课' },
		newStyle: {
			type: Object,
			default: () => {
				return {};
			}
		},
		gray: { type: Boolean, default: false },
		hue: { type: [Number,String], default: 100  },
		plan: { type: String, default: '' },
		img: { type: String, default: '' },
		tagText: { type: String, default: '' },
		tagStyle: {
			type: Object,
			default: () => {
				return {};
			}
		},
		title: { type: String, default: '' },
		start: { type: String, default: '' },
		surplus: { type: String, default: '' }
	}
};
</script>

<style lang="scss">
.MyCurriculum {
	display: flex;
	overflow: hidden;
	position: relative;
	background-color: #ffffff;
	border-radius: $uni-border-radius-base;
	._tag,
	._new {
		top: 10rpx;
		z-index: 999;
		color: #ffffff;
		font-weight: bold;
		position: absolute;
		padding: 10rpx 50rpx;
	}
	._tag {
		right: -50rpx;
		background: red;
		transform: rotate(45deg);
	}
	._new {
		left: 0;
		font-size: 16rpx;
		padding: 0rpx 10rpx;
		background: linear-gradient(90deg, #ffb90c, #ff2b17);
		border-radius: 0px $uni-border-radius-circle $uni-border-radius-circle 0px;
	}
	.showImage {
		flex-grow: 1;
		display: flex;
		overflow: hidden;
		min-width: 310rpx;
		align-items: center;
		justify-content: center;
		border-radius: $uni-border-radius-base;
		image {
			width: 100%;
		}
	}
	.content-container {
		color: #666666;
		font-size: 24rpx;
		font-weight: bold;
		margin-left: 30rpx;
		overflow: hidden;
		width: calc(100% - 30rpx);
		.title {
			color: #333333;
			overflow: hidden;
			font-size: 34rpx;
			font-weight: bold;
			white-space: nowrap;
			margin-bottom: 30rpx;
		}
	}
}
</style>

 使用

	<my-curriculum
					class="list-item"
					v-for="(item, index) in 10"
					:key="index"
					:isnew="item % 3 ? true : false"
					:gray="item % 2 ? true : false"
					:hue="item % 2 ? '100' : '20'"
					:tagText="item % 3 ? '已过期' : index % 3 ? '' : '最热'"
					img="../../static/img/1.png"
					:title="'这是标题' + item"
					start="2021/12/17"
					:surplus="item ** 5 + '天'"
					:plan="item ** 4 + '%'"
				></my-curriculum>

大概的一个效果

 这个是按照我的需求来的  你们有啥需求可以自己去修改

有什么好的建议可以留言或私信反馈谢谢

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值