diff --git a/src/views/ShowFindPost.vue b/src/views/ShowFindPost.vue index ea7a0d0fd72fc43dc0b83b2a3c03ec390b6b659d..daec719ddc746ba331be58e0af503f542e04795f 100644 --- a/src/views/ShowFindPost.vue +++ b/src/views/ShowFindPost.vue @@ -1,6 +1,30 @@ <template> <v-container fill-height fluid grid-list-xl> <v-layout justify-center wrap> + <v-dialog + v-model="loginDialog" + persistent + max-width="290" + > + <v-card> + <v-card-title class="headline">불러오기 실패</v-card-title> + + <v-card-text> + 로그인이 필요한 기능입니다. + </v-card-text> + + <v-card-actions> + <v-spacer></v-spacer> + <v-btn + color="green darken-1" + text + @click="moveLogin" + > + 로그인 이동 + </v-btn> + </v-card-actions> + </v-card> + </v-dialog> <v-flex xs12 md8> <material-card color="green" v-bind:title="findpost.title" v-bind:text="findpost.created" display-2> <v-card :elevation="20" width="300" :shaped="true" v-if="dataLoading" class="mx-auto"> @@ -192,121 +216,133 @@ <script> export default { created: function () { + if(this.$store.commit('getToken')){ const _id = this.$route.params._id; + this.$http.get(`/finderboard/${_id}`) - .then((response) => { - this.dataLoading = true; - this.findpost = response.data.board; - this.items = this.findpost.comments; - var base64data=Buffer.from(this.findpost.image.data.data,'binary').toString('base64'); - this.image='data:image/jpeg;base64,'+base64data; - this.dataLoading = false; - }); + .then((response) => { + + this.dataLoading = true; + this.findpost = response.data.board; + this.items = this.findpost.comments; + var base64data=Buffer.from(this.findpost.image.data.data,'binary').toString('base64'); + this.image='data:image/jpeg;base64,'+base64data; + this.dataLoading = false; + }); + } + else{ + this.loginDialog = true; + } }, data: () => { - return{ - headers: [ - { text: '작성자', value: 'writer', sortable: false}, - { text: '덧글 내용', value: 'body', sortable: false, filterable: false}, - { text: '작성날짜', value: 'created', sortable: true, align: 'right'} - ], - findpost: {}, - newComment: { - writer: '', - body: '', - created: '', - }, - items: [], - postDeleteDialog: false, - commentDeleteDialog: false, - commentSnackbar: false, - postSnackbar: false, - comment_id: '', - dataLoading: true - } + return{ + headers: [ + { text: '작성자', value: 'writer', sortable: false}, + { text: '덧글 내용', value: 'body', sortable: false, filterable: false}, + { text: '작성날짜', value: 'created', sortable: true, align: 'right'} + ], + findpost: {}, + newComment: { + writer: '', + body: '', + created: '', + }, + items: [], + postDeleteDialog: false, + commentDeleteDialog: false, + commentSnackbar: false, + postSnackbar: false, + comment_id: '', + loginDialog: false, + dataLoading: true + } }, methods:{ - onCommentCreate: function(){ - const today = new Date(); - const date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate(); - const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); - const dateTime = date +' '+ time; + onCommentCreate: function(){ + const today = new Date(); + const date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate(); + const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); + const dateTime = date +' '+ time; - this.newComment.created = dateTime; + this.newComment.created = dateTime; - this.newComment.writer = this.$store.state.userInfo.name; + this.newComment.writer = this.$store.state.userInfo.name; - const _id = this.$route.params._id; + const _id = this.$route.params._id; - this.$http.post(`/finderboard/${_id}/comments`, - {newComment: this.newComment}) - .then((res)=>{ - this.newComment={ - writer: '', - body: '', - created: '' - }; - this.$http.get(`/finderboard/${_id}`) - .then((response) => { - this.findpost = response.data.board; - this.items = this.findpost.comments; - }); - }).catch((err) => { - alert(err); - }) - }, - onCommentDelete: function(comment_id){ - const comment_idx = this.comment_id; + this.$http.post(`/finderboard/${_id}/comments`, + {newComment: this.newComment}) + .then((res)=>{ + this.newComment={ + writer: '', + body: '', + created: '' + }; + this.$http.get(`/finderboard/${_id}`) + .then((response) => { + this.findpost = response.data.board; + this.items = this.findpost.comments; + }); + }).catch((err) => { + alert(err); + }) + }, + onCommentDelete: function(comment_id){ + const comment_idx = this.comment_id; - const post_idx = this.$route.params._id; - const user_id = this.$store.state.userInfo.ID; + const post_idx = this.$route.params._id; + const user_id = this.$store.state.userInfo.ID; - const index = this.items.findIndex(function(item, i){ - return item._id === comment_idx - }); + const index = this.items.findIndex(function(item, i){ + return item._id === comment_idx + }); - if(this.items[index].id === user_id){ - this.$http.delete(`/finderboard/${post_idx}/comments/${comment_idx}`) - .then( (response) => { - if(JSON.stringify(response.data.success) === "true"){ - this.$http.get(`/finderboard/${post_idx}`) - .then((response) => { - this.findpost = response.data.board; - this.items = this.findpost.comments; - }); - } - }) - this.commentDeleteDialog = false - } - else{ - this.commentDeleteDialog = false - this.commentSnackbar = true; - } - }, - onPostDelete: function(id){ - const post_id = id; - const user_id = this.$store.state.userInfo._id; - const user_ID = this.$store.state.userInfo.ID; - const post_writer_ID = this.findpost.id; + if(this.items[index].id === user_id){ + this.$http.delete(`/finderboard/${post_idx}/comments/${comment_idx}`) + .then( (response) => { + if(JSON.stringify(response.data.success) === "true"){ + this.$http.get(`/finderboard/${post_idx}`) + .then((response) => { + this.findpost = response.data.board; + this.items = this.findpost.comments; + }); + } + }) + this.commentDeleteDialog = false + } + else{ + this.commentDeleteDialog = false + this.commentSnackbar = true; + } + }, + onPostDelete: function(id){ + const post_id = id; + const user_id = this.$store.state.userInfo._id; + const user_ID = this.$store.state.userInfo.ID; + const post_writer_ID = this.findpost.id; - if(user_ID === post_writer_ID){ - this.$http.delete(`/finderboard/${post_id}`) - .then( (response) => { - if(JSON.stringify(response.data.success) === "true"){ - this.$router.push(`/finderboard`); - } - }) - } - else{ - this.postSnackbar = true; - } - this.postDeleteDialog = false; - }, - onPostChange: function(item_id){ - this.$router.push({ - path:`/modifyfindpost/${item_id}` - }) - } + if(user_ID === post_writer_ID){ + this.$http.delete(`/finderboard/${post_id}`) + .then( (response) => { + if(JSON.stringify(response.data.success) === "true"){ + this.$router.push(`/finderboard`); + } + }) + } + else{ + this.postSnackbar = true; + } + this.postDeleteDialog = false; + }, + onPostChange: function(item_id){ + this.$router.push({ + path:`/modifyfindpost/${item_id}` + }) + }, + moveLogin: function(){ + this.loginDialog = false; + this.$router.push(`/login`); + } }, } </script> diff --git a/src/views/ShowLostPost.vue b/src/views/ShowLostPost.vue index 851f16b3326ea46c749baab2241bd971eb0b53f4..1445fd7b4fa041815c35e00efc8e8aadb3de4cbd 100644 --- a/src/views/ShowLostPost.vue +++ b/src/views/ShowLostPost.vue @@ -1,6 +1,30 @@ <template> <v-container fill-height fluid grid-list-xl> <v-layout justify-center wrap> + <v-dialog + v-model="loginDialog" + persistent + max-width="290" + > + <v-card> + <v-card-title class="headline">불러오기 실패</v-card-title> + + <v-card-text> + 로그인이 필요한 기능입니다. + </v-card-text> + + <v-card-actions> + <v-spacer></v-spacer> + <v-btn + color="green darken-1" + text + @click="moveLogin" + > + 로그인 이동 + </v-btn> + </v-card-actions> + </v-card> + </v-dialog> <v-flex xs12 md8> <material-card color="green" v-bind:title="lostpost.title" v-bind:text="lostpost.created"> <v-card :elevation="20" width="300" :shaped="true" v-if="dataLoading" class="mx-auto"> @@ -188,7 +212,9 @@ <script> export default { created: function () { + if(this.$store.commit('getToken')){ const _id = this.$route.params._id; + this.$http.get(`/losterboard/${_id}`) .then((response) => { this.dataLoading = true; @@ -198,6 +224,10 @@ export default { this.image='data:image/jpeg;base64,'+base64data; this.dataLoading = false; }); + } + else{ + this.loginDialog = true; + } }, data: () => { return{ @@ -219,6 +249,7 @@ export default { commentSnackbar: false, postSnackbar: false, comment_id: '', + loginDialog: false, dataLoading: true, } }, @@ -298,7 +329,11 @@ export default { this.postSnackbar = true; } this.postDeleteDialog = false; - } + }, + moveLogin: function(){ + this.loginDialog = false; + this.$router.push(`/login`); + } }, } </script>