courseComment.vue
3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<template>
<!-- 评论 -->
<view class="course_comment">
<view class="comment_content">
<textarea v-model="content" placeholder="请输入评论内容,最多1000字" @input="entercomment" />
<!-- 字数 -->
<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="image==''?img:image" mode="widthFix"></image>
</view>
</view>
</view>
<!-- 按钮 -->
<view class="send_wrap" @click="send">
<view class="send_box">发送</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
content:"",
img:"../../static/addpic.png",
addpic:true,
image:'',
cimage:'',
// 打卡记录id
clock_log_id:'',
//评论父级id
comments_id:'',
courseid:''
}
},
methods: {
// 输入评论内容
entercomment(e){
this.content=e.detail.value
},
uploadpic(){
console.log(3874273487)
this.addpic=false
},
// 上传图片
uploadImg() {
let that = this;
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
success: function (res) {
console.log(res.tempFilePaths[0])
app.upload('image', res.tempFilePaths[0],"post").then((res) => {
console.log('上传文件', res);
that.image=res.url
that.cimage=res.kurl
}).catch((err) => {
console.log(err)
})
},
fail: function (res) { }
})
},
//发送
send(){
let that = this;
var url = '/api/comments/commit';
var params = {
clock_log_id:that.clock_log_id,
comments_id: that.comments_id,
content:that.content,
images:that.image
}
app.post(url, params).then((res) => {
console.log(res);
uni.showToast({
title:'提交成功',
icon:'none'
})
setTimeout(function(){
uni.navigateTo({
url:'/pages/course/courseDetail?id='+that.courseid
})
})
}).catch((err) => {
})
}
},
onLoad(options) {
console.log(options)
this.clock_log_id=options.id,
this.courseid=options.courseid
}
}
</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>