Skip to content
Snippets Groups Projects
Commit 7b08a2e9 authored by YongJae's avatar YongJae
Browse files

final modify

parent aa6d284b
Branches finalmodify
No related tags found
1 merge request!21final modify
......@@ -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 }]
......
......@@ -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>
......@@ -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);
......
<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 => {
......
......@@ -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) {
......
......@@ -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>&nbsp;&nbsp; {{transaction.bookTitle}}</span>
<span>&nbsp;&nbsp; {{ transaction.bookTitle }}</span>
<span>&nbsp;&nbsp;구매 대기중</span>
<span>&nbsp;&nbsp;판매자 아이디: {{transaction.sellerId}}</span>
<span>&nbsp;&nbsp;판매자 아이디: {{ 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>
......@@ -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 => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment