评论组件调整

This commit is contained in:
aixianling
2021-12-30 20:28:32 +08:00
parent 4f149cfa3d
commit 78823877da

View File

@@ -2,17 +2,15 @@
<div class="AiComment"> <div class="AiComment">
<div class="comments flex-row"> <div class="comments flex-row">
<div class="comments-box" @click="showCommentBox">{{ boxContent }}</div> <div class="comments-box" @click="showCommentBox">{{ boxContent }}</div>
<img src="AiComment/comment.svg" @click="showCommentList" alt=""/> <u-icon name="thumb-up" size="30" label=""/>
<text>{{ commentCount || 0 }}</text>
</div> </div>
<div class="modalWrapper" v-if="commentBoxPopup" :class="{clickClose:!modelClickClose}" <div class="modalWrapper" v-if="commentBoxPopup" :class="{clickClose:!modelClickClose}"
@click="commentBoxPopup=false"/> @click="commentBoxPopup=false"/>
<div class="commentBox" v-if="commentBoxPopup" :style="{bottom:marginBottom+ 'px'}"> <div class="commentBox" v-if="commentBoxPopup">
<textarea v-model="content" placeholder="写下你的想法…" maxlength="300" :focus="focus" @focus="getMarginBottom" <u-input v-model="content" placeholder="写下你的想法…" type="textarea" auto-height :maxlength="limit"/>
@blur="marginBottom=0" :adjust-position="false" fixed/>
<view class="flex-row form-submit"> <view class="flex-row form-submit">
<div>{{ `字数 ${wordCount || 0} / 300` }}</div> <div>{{ `字数 ${wordCount} / ${limit}` }}</div>
<button @click="submitComment" :disabled="wordCount == 0"></button> <button @click="submitComment" :disabled="wordCount == 0"></button>
</view> </view>
</div> </div>
</div> </div>
@@ -20,29 +18,33 @@
<script> <script>
import {mapState} from "vuex";
export default { export default {
name: "AiComment", name: "AiComment",
props: { props: {
needLogin: Boolean, needLogin: Boolean,
customLogin: Boolean, customLogin: Boolean,
commentCount: Number, commentCount: Number,
modelClickClose: {type: Boolean, default: true} modelClickClose: {type: Boolean, default: true},
placeholder: {default: "我也说两句..."},
limit: {default: 1000}
}, },
computed: { computed: {
...mapState(['token']),
wordCount() { wordCount() {
return this.content.length || 0 return this.content?.length || 0
}, },
boxContent() { boxContent() {
return this.content || "我也说两句..." return this.content || this.placeholder
}, },
isLogin() { isLogin() {
return Boolean(uni.getStorageSync('token')) return !!this.token
}, },
}, },
data() { data() {
return { return {
content: "", content: "",
marginBottom: 0,
commentBoxPopup: false, commentBoxPopup: false,
focus: false focus: false
} }
@@ -76,10 +78,6 @@ export default {
this.commentBoxPopup = false this.commentBoxPopup = false
this.$emit("showCommentList") this.$emit("showCommentList")
}, },
getMarginBottom({detail}) {
this.marginBottom = detail.height
this.focus = true
}
} }
} }
</script> </script>
@@ -94,32 +92,23 @@ export default {
box-sizing: border-box; box-sizing: border-box;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
background: #f7f7f7; background: #fff;
.comments-box { .comments-box {
width: 580px; flex: 1;
min-width: 0;
height: 64px; height: 64px;
line-height: 64px; line-height: 64px;
background-color: #fff; background-color: #f0f0f0;
color: #666; color: #666;
font-size: 26px; font-size: 26px;
padding-left: 16px; padding-left: 16px;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
} border-radius: 30px;
text-align: center;
image { margin-right: 42px;
width: 52px;
height: 52px;
margin-left: 16px;
vertical-align: middle;
}
text {
color: #666666;
font-size: 28px;
line-height: 60px;
} }
} }
@@ -137,9 +126,10 @@ export default {
} }
} }
.commentBox { ::v-deep.commentBox {
width: 100%; width: 100%;
height: 288px; min-height: 288px;
max-height: 60vh;
background-color: #fff; background-color: #fff;
padding: 32px 32px 24px 26px; padding: 32px 32px 24px 26px;
box-sizing: border-box; box-sizing: border-box;
@@ -149,7 +139,9 @@ export default {
textarea { textarea {
width: 100%; width: 100%;
height: 144px; min-height: 144px;
max-height: calc(60vh - 144px);
overflow-y: auto;
color: #666; color: #666;
font-size: 26px; font-size: 26px;
background: #F7F7F7; background: #F7F7F7;