courseComment.vue 2.8 KB
<template>
	<!-- 评论 -->
	<view class="course_comment">
		<view class="comment_content">
			<textarea v-model="content" placeholder="请输入评论内容,最多1000字" />
			
			<!-- 字数 -->
			<view class="word_num">{{content.length}}/1000</view>
			<view v-if="addpic">
				<!-- 添加图片 -->
				<view class="add_pic layer_star"  @click="uploadpic">
					<image src="../../static/tupian_icon@2x.png" mode="widthFix"></image>
					<view class="add_word">添加图片</view>
				</view>
				
			</view>
			
			<view class="picbox" v-else>
				<!-- 上传的图片 -->
				<view class="upload_pic" @click="uploadImg()">
					<image :src="img" mode="widthFix"></image>
				</view>
			</view>
		</view>
		
		
		
		<!-- 按钮 -->
		<view class="send_wrap">
			<view class="send_box">发送</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content:"",
				img:"../../static/addpic.png",
				addpic:true
			}
		},
		methods: {
			uploadpic(){
				console.log(3874273487)
				this.addpic=false
			},
			// 上传图片
			uploadImg(){
				let t = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
					sourceType: ['album'], //从相册选择
					success: chooseImageRes => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						this.img = tempFilePaths[0]
						// App.upload(tempFilePaths[0]).then(res => {
						// 	this.front_image = res.url;
						// });
					}
				});
			},
		},
	}
</script>

<style lang="scss">
	page{
		background-color: #fafbfd;
	}
	.picbox{
		margin-top:85rpx;
	}
	.course_comment{
		padding: 36upx 32upx 150upx;
		// 信息
		.comment_content{
			position: relative;
			border:2upx solid rgba(189,196,206,1);
			padding: 26upx 28upx 50upx;
			background-color: #fff;
			textarea{
				width: 100%;
				
				
				
				box-sizing: border-box;
				height: 500upx;
			}
			// 添加图片
			.add_pic{
				position: absolute;
				left: 26upx;
				bottom: 14upx;
				image{
					width: 36upx;
					margin-right: 12upx;
				}
				.add_word{
					color: #3D444D;
					font-size: 24upx;
					border-bottom: 1px solid #000;
				}
			}
			// 字数
			.word_num{
				position: absolute;
				right: 26upx;
				top: 530upx;
				color: #3D444D;
				font-size: 24upx;
			}
		}
		// 上传的图片
		.upload_pic{
			width:200upx;
			height:200upx;
			font-size:0;
			
			
		}
		// 按钮
		.send_wrap{
			width: 100%;
			position: fixed;
			left: 0;
			padding-bottom: 36upx;
			bottom:0;
			left:0;
			display:flex;
			justify-content: center;
			background: #fff;
			.send_box{
				width:686upx;
				margin: 0 32upx;
				height: 96upx;
				text-align: center;
				line-height: 96upx;
				border-radius: 48upx;
				color: #fff;
				background-color: #EE8B27;
				font-size: 28upx;
				
			}
			
		}
		
	}
</style>