|
|
@@ -52,7 +52,7 @@
|
|
|
<hr class="my-2">
|
|
|
|
|
|
|
|
|
- <div class="d-flex align-items-center justify-content-between">
|
|
|
+ <div id="scroll-Anchor" class="d-flex align-items-center justify-content-between">
|
|
|
|
|
|
|
|
|
</div>
|
|
|
@@ -65,55 +65,59 @@
|
|
|
id="blogComment"
|
|
|
cols="12"
|
|
|
class="mt-2">
|
|
|
- <h6 class="section-label">
|
|
|
+ <h6 class="section-label" id="comment">
|
|
|
留言
|
|
|
</h6>
|
|
|
<b-card
|
|
|
- v-for="(comment, index) in blogDetail.comments"
|
|
|
- :key="index">
|
|
|
- <b-media no-body>
|
|
|
- <b-media-aside class="mr-75">
|
|
|
- <b-avatar
|
|
|
- :src="require('@/assets/images/avatars/' + comment.author_id + '-small.png')"
|
|
|
- size="38" />
|
|
|
- </b-media-aside>
|
|
|
- <b-media-body>
|
|
|
- <h6 class="font-weight-bolder mb-25">
|
|
|
- {{ formatName(comment.author_id) }}
|
|
|
- </h6>
|
|
|
- <b-card-text>{{ formatTime(comment.created_at) }}</b-card-text>
|
|
|
- <b-card-text>
|
|
|
- {{ comment.content }}
|
|
|
- </b-card-text>
|
|
|
- <b-link>
|
|
|
- <div class="d-inline-flex align-items-center">
|
|
|
- <feather-icon
|
|
|
- icon="CornerUpLeftIcon"
|
|
|
- size="18"
|
|
|
- class="mr-50" />
|
|
|
- <span>回復</span>
|
|
|
- </div>
|
|
|
- </b-link>
|
|
|
- </b-media-body>
|
|
|
- </b-media>
|
|
|
+ v-if="!(blogDetail.comments.length == 0)">
|
|
|
+ <div class="media-list media-bordered">
|
|
|
+ <b-media no-body v-for="(comment, index) in blogDetail.comments"
|
|
|
+ :key="index">
|
|
|
+ <b-media-aside class="mr-75">
|
|
|
+ <b-avatar
|
|
|
+ :src="require('@/assets/images/avatars/' + comment.author_id + '-small.png')"
|
|
|
+ size="38" />
|
|
|
+ </b-media-aside>
|
|
|
+ <b-media-body>
|
|
|
+ <h6 class="font-weight-bolder mb-25">
|
|
|
+ {{ formatName(comment.author_id) }}
|
|
|
+ </h6>
|
|
|
+ <b-card-text>{{ formatTime(comment.created_at) }}</b-card-text>
|
|
|
+ <b-card-text>
|
|
|
+ {{ comment.content }}
|
|
|
+ </b-card-text>
|
|
|
+ <b-link v-if="false">
|
|
|
+ <div class="d-inline-flex align-items-center">
|
|
|
+ <feather-icon
|
|
|
+ icon="CornerUpLeftIcon"
|
|
|
+ size="18"
|
|
|
+ class="mr-50" />
|
|
|
+ <span>回復</span>
|
|
|
+ </div>
|
|
|
+ </b-link>
|
|
|
+ </b-media-body>
|
|
|
+ </b-media>
|
|
|
+ </div>
|
|
|
</b-card>
|
|
|
<b-card
|
|
|
- v-if="(blogDetail.comments.length == 0)"> <!--blogDetail.comments-->
|
|
|
- <b-media no-body>
|
|
|
- <b-media-aside class="mr-75">
|
|
|
- <b-avatar
|
|
|
- size="38" />
|
|
|
- </b-media-aside>
|
|
|
- <b-media-body>
|
|
|
- <h6 class="font-weight-bolder mb-25">
|
|
|
- 暫無留言
|
|
|
- </h6>
|
|
|
- <b-card-text>{{ }}</b-card-text>
|
|
|
- <b-card-text>
|
|
|
- 趕快來留點甚麼吧~
|
|
|
- </b-card-text>
|
|
|
- </b-media-body>
|
|
|
- </b-media>
|
|
|
+ v-else>
|
|
|
+ <div class="media-list media-bordered">
|
|
|
+ <b-media no-body>
|
|
|
+ <b-media-aside class="mr-75">
|
|
|
+ <b-avatar
|
|
|
+ size="38" />
|
|
|
+ </b-media-aside>
|
|
|
+ <b-media-body>
|
|
|
+ <h6 class="font-weight-bolder mb-25">
|
|
|
+ 暫無留言
|
|
|
+ </h6>
|
|
|
+ <b-card-text>{{ }}</b-card-text>
|
|
|
+ <b-card-text>
|
|
|
+ 趕快來留點甚麼吧~
|
|
|
+ </b-card-text>
|
|
|
+ </b-media-body>
|
|
|
+ </b-media>
|
|
|
+ </div>
|
|
|
</b-card>
|
|
|
</b-col>
|
|
|
<!--/ blog comment -->
|
|
|
@@ -131,6 +135,7 @@
|
|
|
<b-col cols="12">
|
|
|
<b-form-group class="mb-2">
|
|
|
<b-form-textarea
|
|
|
+ v-model="new_comment"
|
|
|
name="textarea"
|
|
|
rows="4"
|
|
|
placeholder="留言..." />
|
|
|
@@ -138,6 +143,7 @@
|
|
|
</b-col>
|
|
|
<b-col cols="12">
|
|
|
<b-button
|
|
|
+ @click="postComment()"
|
|
|
v-ripple.400="'rgba(255, 255, 255, 0.15)'"
|
|
|
variant="primary">
|
|
|
發布留言
|
|
|
@@ -273,6 +279,7 @@ import { kFormatter } from '@core/utils/filter'
|
|
|
import ContentWithSidebar from '@core/layouts/components/content-with-sidebar/ContentWithSidebar.vue'
|
|
|
import useJwt from '@/auth/jwt/useJwt'
|
|
|
import moment from 'moment'
|
|
|
+import ToastificationContent from "@core/components/toastification/ToastificationContent.vue";
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
@@ -305,7 +312,7 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
search_query: '',
|
|
|
- commentCheckmark: '',
|
|
|
+ new_comment: '',
|
|
|
blogDetail: [],
|
|
|
blogSidebar: {},
|
|
|
nameList: [],
|
|
|
@@ -313,21 +320,22 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- useJwt.getData('/api/message/detail', { 'id': this.$route.params.id }).then(response => {
|
|
|
+ useJwt.postData('/api/message/detail', { 'id': this.$route.params.id }).then(response => {
|
|
|
this.blogDetail = response.data;
|
|
|
}).catch(error => {
|
|
|
console.log(error)
|
|
|
});
|
|
|
- useJwt.getData('/api/message/user', null).then(response => {
|
|
|
+ useJwt.postData('/api/message/user', null).then(response => {
|
|
|
this.nameList = response.data;
|
|
|
}).catch(error => {
|
|
|
console.log(error)
|
|
|
});
|
|
|
- useJwt.getData('/api/message/recent', null).then(response => {
|
|
|
+ useJwt.postData('/api/message/recent', null).then(response => {
|
|
|
this.blogSidebar = response.data;
|
|
|
}).catch(error => {
|
|
|
console.log(error)
|
|
|
});
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
kFormatter,
|
|
|
@@ -345,16 +353,66 @@ export default {
|
|
|
formatName(id) {
|
|
|
return this.nameList[id];
|
|
|
},
|
|
|
+ postComment() {
|
|
|
+ useJwt.postData('/api/message/storeComment', { 'message_id': this.$route.params.id, 'content': this.new_comment }).then(response => {
|
|
|
+ this.blogDetail.comments.push(response.data);
|
|
|
+ this.new_comment = '';
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ this.$toast({
|
|
|
+ component: ToastificationContent,
|
|
|
+ props: {
|
|
|
+ title: `錯誤`,
|
|
|
+ icon: 'AlertTriangleIcon',
|
|
|
+ variant: 'warning',
|
|
|
+ text: `發布留言不能為空`,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ // let toaster = 'b-toaster-bottom-center';
|
|
|
+ // this.$bvToast.toast(`發布留言不能為空`, {
|
|
|
+ // title: `錯誤`,
|
|
|
+ // toaster,
|
|
|
+ // solid: true,
|
|
|
+ // variant: 'warning',
|
|
|
+ // appendToast: false,
|
|
|
+ // })
|
|
|
+ this.scrollToComment();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ scrollToComment() {
|
|
|
+ console.log(location.hash);
|
|
|
+ if (location.hash == '#blogComment') {
|
|
|
+ const element = document.getElementById('scroll-Anchor');
|
|
|
+ element.scrollIntoView({
|
|
|
+ block: 'start',
|
|
|
+ behavior: 'smooth',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
'$route': function () {
|
|
|
- useJwt.getData('/api/message/detail', { 'id': this.$route.params.id }).then(response => {
|
|
|
+ useJwt.postData('/api/message/detail', { 'id': this.$route.params.id }).then(response => {
|
|
|
this.blogDetail = response.data;
|
|
|
}).catch(error => {
|
|
|
console.log(error)
|
|
|
});
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ let scroll = this;
|
|
|
+ ttt(scroll);
|
|
|
+ function ttt(scroll) {
|
|
|
+ setTimeout(() => {
|
|
|
+ if (document.getElementById('scroll-Anchor') != null) {
|
|
|
+ scroll.scrollToComment();
|
|
|
+ } else {
|
|
|
+ ttt(scroll);
|
|
|
+ }
|
|
|
+ }, 100)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
</script>
|
|
|
|