From 7b08a2e9d627d4c4c65c5019f2e284ad78bba4a5 Mon Sep 17 00:00:00 2001 From: YongJae <sdc689@gmail.com> Date: Mon, 9 Dec 2019 14:31:28 +0900 Subject: [PATCH] final modify --- backend/routes/transaction.js | 2 +- frontend/src/components/Buy.vue | 7 ++-- frontend/src/components/Sell.vue | 5 ++- frontend/src/components/login/Login.vue | 36 ++++++++++++------- frontend/src/components/login/SignUp.vue | 12 +++++++ .../components/profilecomponent/buylist.vue | 13 ++++--- .../components/profilecomponent/sellist.vue | 2 +- 7 files changed, 55 insertions(+), 22 deletions(-) diff --git a/backend/routes/transaction.js b/backend/routes/transaction.js index d657063..c57c23c 100644 --- a/backend/routes/transaction.js +++ b/backend/routes/transaction.js @@ -50,7 +50,7 @@ router.post("/success", async (req, res) => { var userId = sess.userid; try { - await Transaction.remove( + await Transaction.deleteOne( { bookTitle: req_bookTitle, $or: [{ buyerId: userId }, { sellerId: userId }] diff --git a/frontend/src/components/Buy.vue b/frontend/src/components/Buy.vue index 2e0c107..9bfa872 100644 --- a/frontend/src/components/Buy.vue +++ b/frontend/src/components/Buy.vue @@ -34,7 +34,9 @@ <div class="md-title">이 책을 구매하시겠습니까?</div> </md-card-header> <md-card-actions> - <md-button class="md-raised md-primary" v-on:click="buyBook">구매</md-button> + <md-button class="md-raised md-primary" v-on:click="buyBook" + >구매</md-button + > </md-card-actions> </md-card> </div> @@ -98,6 +100,7 @@ export default { }) .then(response => { alert("이메일 전송 완료"); + this.$router.push("/home"); }), error => { alert(error.response.data.error); @@ -106,4 +109,4 @@ export default { } } }; -</script> \ No newline at end of file +</script> diff --git a/frontend/src/components/Sell.vue b/frontend/src/components/Sell.vue index ae27fd1..4ef1e0c 100644 --- a/frontend/src/components/Sell.vue +++ b/frontend/src/components/Sell.vue @@ -34,7 +34,9 @@ <div class="md-title">이 책을 판매하시겠습니까?</div> </md-card-header> <md-card-actions> - <md-button class="md-raised md-primary" v-on:click="sellBook">판매</md-button> + <md-button class="md-raised md-primary" v-on:click="sellBook" + >판매</md-button + > </md-card-actions> </md-card> </div> @@ -69,6 +71,7 @@ export default { }) .then(response => { alert("판매 대기열에 등록하였습니다."); + this.$router.push("/home"); }) .catch(error => { alert(error); diff --git a/frontend/src/components/login/Login.vue b/frontend/src/components/login/Login.vue index 6ed1512..4fb9370 100644 --- a/frontend/src/components/login/Login.vue +++ b/frontend/src/components/login/Login.vue @@ -1,15 +1,17 @@ <template> <div id="login"> <md-button class="md-primary" v-on:click="active = true">Login</md-button> - - <md-dialog :md-active.sync="active" style="width: 500px; height: 500px"> - <md-dialog-title>Login</md-dialog-title> - <form novalidate @submit.prevent="validateUser"> + + <md-dialog :md-active.sync="active" style="width: 500px; height: 500px"> + <md-dialog-title>Login</md-dialog-title> + <form novalidate @submit.prevent="validateUser"> <md-content> <md-field :class="getValidationClass('id')"> <label>ID</label> <md-input name="ID" id="ID" v-model="user.id" :disabled="sending" /> - <span class="md-error" v-if="!$v.user.id.required">The ID is required"</span> + <span class="md-error" v-if="!$v.user.id.required" + >The ID is required"</span + > <span class="md-error" v-else-if="!$v.user.id.minlength" >아이디는 다섯 자리 이상이어야 합니다.</span > @@ -17,7 +19,11 @@ <md-field :class="getValidationClass('password')"> <label>Password</label> - <md-input v-model="user.password" type="password" :disabled="sending" /> + <md-input + v-model="user.password" + type="password" + :disabled="sending" + /> <span class="md-error" v-if="!$v.user.password.required" >The Password is required</span > @@ -36,9 +42,8 @@ >Close</md-button > </md-content> - </form> - </md-dialog> - </form> + </form> + </md-dialog> </div> </template> @@ -68,11 +73,10 @@ export default { }, validations: { user: { - id: { + id: { required, minLength: minLength(5) - } - , + }, password: { required, minLength: minLength(3) @@ -80,6 +84,11 @@ export default { } }, methods: { + clearForm() { + this.$v.$reset(); + this.user.id = null; + this.user.password = null; + }, getValidationClass(fieldName) { const field = this.$v.user[fieldName]; if (field) { @@ -107,11 +116,14 @@ export default { alert("success login"); this.active = false; this.sending = false; + this.clearForm(); location.reload(); }, error => { // error 를 보여줌 alert(error.response.data.error); + this.sending = false; + this.clearForm(); } ) .catch(error => { diff --git a/frontend/src/components/login/SignUp.vue b/frontend/src/components/login/SignUp.vue index 77a9021..99fdef7 100644 --- a/frontend/src/components/login/SignUp.vue +++ b/frontend/src/components/login/SignUp.vue @@ -154,6 +154,14 @@ export default { } }, methods: { + clearForm() { + this.$v.$reset(); + this.user.id = null; + this.user.password = null; + this.user.name = null; + this.user.email = null; + this.user.phonenumber = null; + }, getValidationClass(fieldName) { const field = this.$v.user[fieldName]; if (field) { @@ -177,10 +185,14 @@ export default { if (response.data.result === 0) { alert("Error, please, try again"); this.active = false; + this.clearForm(); + this.sending = false; } if (response.data.result === 1) { alert("Success Sign Up !"); this.active = false; + this.clearForm(); + this.sending = false; } }) .catch(function(error) { diff --git a/frontend/src/components/profilecomponent/buylist.vue b/frontend/src/components/profilecomponent/buylist.vue index 445931b..9f3af35 100644 --- a/frontend/src/components/profilecomponent/buylist.vue +++ b/frontend/src/components/profilecomponent/buylist.vue @@ -9,13 +9,16 @@ :key="transaction._id" v-if="transaction.buyerId == userId" > - <md-button class="md-icon-button md-raised" style="color:#1DDB16;backgroundColor:#1DDB16"> + <md-button + class="md-icon-button md-raised" + style="color:#1DDB16;backgroundColor:#1DDB16" + > <img src="../../assets/book-open-flat.png" /> </md-button> <div class="md-list-item-text"> - <span> {{transaction.bookTitle}}</span> + <span> {{ transaction.bookTitle }}</span> <span> 구매 대기중</span> - <span> 판매자 아이디: {{transaction.sellerId}}</span> + <span> 판매자 아이디: {{ transaction.sellerId }}</span> </div> <md-button class="md-icon-button md-raised md-accent" @@ -60,7 +63,7 @@ export default { methods: { cancelTransaction(book_Title) { this.$http - .post("/api/transaction/cancel", { + .post("/api/transaction/success", { bookTitle: book_Title }) .then(response => { @@ -105,4 +108,4 @@ export default { display: inline-block; vertical-align: top; } -</style> \ No newline at end of file +</style> diff --git a/frontend/src/components/profilecomponent/sellist.vue b/frontend/src/components/profilecomponent/sellist.vue index cb05be6..1959577 100644 --- a/frontend/src/components/profilecomponent/sellist.vue +++ b/frontend/src/components/profilecomponent/sellist.vue @@ -54,7 +54,7 @@ export default { methods: { cancelTransaction(book_Title) { this.$http - .post("/api/transaction/cancel", { + .post("/api/transaction/success", { bookTitle: book_Title }) .then(response => { -- GitLab