123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <template>
- <view class="Answering">
- <view v-for="(item, index) in answerList" :key="index" style="background-color: #ffffff" class="answer_item">
- <view class="chat_box" @click.stop="clearCtx">
- <view style="display: flex; flex: 1">
- <view>
- <image :src="
- item.assignUserId > 0 && !item.realname
- ? '/static/logo_xcx.png'
- : $method.splitImgHost(item.avatar)
- " style="width: 64rpx; height: 64rpx"></image>
- </view>
- <view style="margin-left: 15rpx">
- <view class="chat1">{{
- item.assignUserId > 0 && !item.realname
- ? "祥粤老师"
- : item.realname
- }}</view>
- <view class="chat2">{{
- $method.timestampToTime(item.createTime, false)
- }}</view>
- <view class="chat3">
- <text v-if="item.assignUserId > 0">回复</text>
- <text v-if="item.assignUserId > 0" style="color: #007aff">@{{ item.assignRealname }}</text>
- <view style="word-break: break-all">{{ item.answerText }}</view>
- </view>
- </view>
- </view>
- <view class="btnReply" @click.stop="replyContent(item)" v-if="item.userId != userId">回复</view>
- <view v-else class="btnDel" @click.stop="delAnswer(item.answerId)">删除</view>
- </view>
- <u-line color="#D6D6DB" />
- </view>
- <view v-if="answerList.length == 0" style="text-align: center">暂无记录</view>
- <view class="inputBottom" :style="{ bottom: bottomHeight + 'px' }">
- <view class="flex_auto">
- <input v-model="ctxValue" height="60" fixed="true" :focus="isFocus" :placeholder="placeholder"
- type="text" :custom-style="inputStyle" :adjust-position="false" class="input" @focus="focusNote"
- @blur="blur" />
- </view>
- <view class="btn" @click="postContent">提交</view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "SaasMiniprogramAnswerBox",
- props: {
- userId: {
- type: Number,
- defaule: 0,
- },
- },
- inject: ["paramsFn"],
- data() {
- return {
- answerList: [],
- ctxValue: "",
- isFocus: false,
- placeholder: "您可以在这里输入答疑内容",
- inputStyle: {
- background: "rgba(244, 244, 244, 0.98)",
- borderRadius: "24rpx",
- padding: "8rpx",
- marginBottom: "10rpx",
- },
- bottomHeight: 0,
- assignUserId: 0,
- };
- },
- mounted() {
- this.getAnswerList();
- },
- methods: {
- postContent() {
- if (!this.ctxValue || this.ctxValue == "") {
- this.$u.toast("请输入内容");
- return;
- }
- this.postAnswer();
- },
- blur() {
- this.bottomHeight = 0;
- this.clearTimer = setTimeout(() => {
- this.ctxValue = "";
- this.isFocus = false;
- this.assignUserId = 0;
- this.placeholder = "您可以在这里输入答疑内容";
- }, 2000);
- },
- focusNote(event) {
- this.bottomHeight = event.detail.height;
- },
- getAnswerList() {
- this.$api.answerList(this.params).then((res) => {
- if (res.data.code == 200) {
- this.answerList = res.data.rows;
- }
- });
- },
- postAnswer() {
- let self = this;
- let data = {
- answerText: this.ctxValue,
- ...this.params,
- };
- if (this.assignUserId > 0) {
- data.assignUserId = this.assignUserId;
- }
- this.$api.postAnswer(data).then((res) => {
- if (res.data.code == 200) {
- this.$u.toast("发布成功");
- self.getAnswerList();
- this.isFocus = false;
- this.placeholder = "您可以在这里输入答疑内容";
- this.ctxValue = "";
- this.assignUserId = 0;
- }
- });
- },
- delAnswer(answerId) {
- this.$api
- .delAnswer({
- answerId: answerId,
- status: -1,
- orderGoodsId: this.params.orderGoodsId,
- })
- .then((res) => {
- if (res.data.code == 200) {
- this.getAnswerList();
- }
- });
- },
- clearCtx() {
- this.placeholder = "您可以在这里输入答疑内容";
- this.ctxValue = "";
- this.assignUserId = 0;
- },
- replyContent(item) {
- this.isFocus = true;
- this.assignUserId = item.userId;
- this.placeholder = "@" + item.realname;
- },
- },
- computed: {
- params() {
- return this.paramsFn(["orderGoodsId", "goodsId", "courseId", "gradeId", "moduleId", "chapterId",
- "sectionId"
- ])
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .Answering {
- .answer_item {
- &:nth-child(2) {
- border-radius: 16rpx 16rpx 0rpx 0rpx;
- }
- &:nth-last-child(1) {
- border-radius: 0rpx 0rpx 16rpx 16rpx;
- }
- }
- }
- .chat_box {
- display: flex;
- padding: 20rpx;
- justify-content: space-between;
- }
- .chat3 {
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- margin-top: 10rpx;
- }
- .chat2 {
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- margin-top: 10rpx;
- }
- .chat1 {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- .btnReply {
- width: 80rpx;
- height: 40rpx;
- background: #e3f0ff;
- border-radius: 16rpx;
- text-align: center;
- color: #007aff;
- }
- .btnDel {
- width: 80rpx;
- height: 40rpx;
- background: #ffedf0;
- border-radius: 16rpx;
- text-align: center;
- color: #ff2d55;
- }
- .btnReply {
- width: 80rpx;
- height: 40rpx;
- background: #e3f0ff;
- border-radius: 16rpx;
- font-size: 24rpx;
- }
- .inputBottom {
- position: fixed;
- left: 0;
- bottom: 0;
- background: #ffffff;
- height: 98rpx;
- display: flex;
- align-items: center;
- width: 100%;
- .flex_auto {
- flex: 1;
- margin-left: 10%;
- word-break: break-all;
- // .input {
- // height: 60rpx;
- // }
- }
- .btn {
- color: #007aff;
- font-size: 30rpx;
- font-weight: bold;
- width: 15%;
- text-align: center;
- }
- .input {
- background: rgba(244, 244, 244, 0.98);
- height: 60rpx;
- border-radius: 24rpx;
- margin-top: 12rpx;
- }
- }
- </style>
|