Skip to content

Commit

Permalink
✨ 상품 등록 페이지 개발 [#10]
Browse files Browse the repository at this point in the history
- 상품 등록 View 페이지 개발

Related to: #10
  • Loading branch information
jun108059 committed Jan 8, 2023
1 parent c7531d9 commit 1308b94
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 0 deletions.
1 change: 1 addition & 0 deletions vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"core-js": "^3.8.3",
"roboto-fontface": "*",
"vue": "^3.2.13",
"vue-media-upload": "^1.2.1",
"vue-toastification": "^2.0.0-rc.5",
"vuetify": "^3.0.0-beta.0",
"webfontloader": "^1.0.0"
Expand Down
6 changes: 6 additions & 0 deletions vue/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import HomeView from "@/views/HomeView.vue";
import LoginView from "@/views/member/LoginView.vue";
import JoinView from "@/views/member/JoinView.vue";
import JoinOkView from "@/views/member/JoinOkView.vue";
import ProductRegisterView from "@/views/product/ProductRegisterView.vue";

const router = createRouter({
history: createWebHistory(),
Expand All @@ -28,6 +29,11 @@ const router = createRouter({
name: "JoinOk",
component: JoinOkView,
},
{
path: "/product/register",
name: "ProductRegister",
component: ProductRegisterView,
},
],
});

Expand Down
130 changes: 130 additions & 0 deletions vue/src/views/product/ProductRegisterView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<template>
<v-toolbar color="orange" elevation="2">
<v-icon
style="padding-left: 20px"
icon="mdi-arrow-u-left-top-bold"></v-icon>
<v-toolbar-title>중고거래 글쓰기</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn><h3>완료</h3></v-btn>
</v-toolbar>
<v-container fluid>
<v-form v-on:submit.prevent="submitForm" id="join" lazy-validation>
<v-row>
<v-col cols="12"><h3>사진첨부 🥕</h3></v-col>
</v-row>
<v-row>
<v-col cols="12">
<!-- https://dev.to/saimo/how-to-upload-multiple-images-with-preview-using-laravel-and-vue-282j-->
<!-- <upload-media-->
<!-- server="/api/upload"-->
<!-- error="@error('media'){{$message}}@enderror">-->
<!-- </upload-media>-->
<!-- <update-media-->
<!-- server="/api/upload"-->
<!-- media-file-path="/storage/post_images"-->
<!-- media-server="/api/media/{{$post->id}}"-->
<!-- error="@error('media'){{$message}}@enderror">-->
<!-- </update-media>-->
</v-col>
<v-col cols="12">
<v-text-field
v-model="state.title"
type="text"
placeholder="제목"
required />
<v-select
v-model="state.defaultSelected"
label="카테고리"
:items="state.categoryList"
item-title="categoryName"
item-value="categoryCode">
</v-select>
<v-text-field
v-model="state.price"
type="number"
placeholder="가격(원)" />
<v-textarea
v-model="state.content"
type="text"
placeholder="게시글 내용을 작성해주세요." />
가짜 품목 및 판매금지품목은 게시가 제한됩니다.
</v-col>
</v-row>
</v-form>
</v-container>
</template>

<script>
import axios from "axios";
import { onMounted, reactive } from "vue";
export default {
setup() {
const state = reactive({
title: "",
price: "",
content: "",
defaultSelected: {
categoryCode: "1",
categoryName: "디지털기기",
},
categoryList: [
{
categoryCode: "",
categoryName: "",
},
],
});
onMounted(() => {
getCategory();
});
const getCategory = () => {
const url = "http://localhost:8081/api/v1/category/list";
axios
.get(url)
.then(function (response) {
console.log(response);
state.categoryList = response.data.data;
})
.catch(function (error) {
console.log(error);
alert("서버 에러입니다. \n잠시 후 다시 시도해주세요.");
});
};
const submitForm = () => {
const url = "http://localhost:8081/api/v1/product/register";
axios
.post(url)
.then(function (response) {
console.log(response);
state.categoryList = response.data.data;
})
.catch(function (error) {
console.log(error);
alert("서버 에러입니다. \n잠시 후 다시 시도해주세요.");
});
};
return {
state,
submitForm,
};
},
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.product-row {
position: relative;
border-bottom: solid 1px #ff931e;
padding: 10px 0;
}
.addButton {
position: absolute;
bottom: 40px;
right: 20px;
width: 30%;
height: 80px;
}
</style>

0 comments on commit 1308b94

Please sign in to comment.