Merge branch 'master' into 버그픽스_상범

This commit is contained in:
백창훈
2022-03-18 18:09:47 +09:00
committed by GitHub
23 changed files with 377 additions and 58 deletions

View File

@@ -1,5 +1,6 @@
import axios from "axios";
import jwt from "@/common/jwt";
import router from "@/router/router";
export default {
async requestReissue() {
@@ -22,5 +23,12 @@ export default {
axios.defaults.headers.common['Authorization'] = "Bearer " + jwt.getToken();
return axios.get(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL+"/user-service/auth/check/access-token");
},
logout(){
axios.post(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL+"/user-service/auth/logout",'',{headers: {"X-AUTH-TOKEN": jwt.getToken(),}})
.finally(()=>{
router.push('/login')
jwt.destroyAll()
})
}
}

View File

@@ -41,5 +41,12 @@ export default {
},
requestStore(storeId) {
return axios.get(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL + "/store-service/store/" + storeId);
},
getFavoriteStoreByStoreId(storeId) {
return axios.get(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL + "/store-service/api/customer/favoriteStore/" + storeId);
},
markStar(storeId) {
return axios.patch(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL + "/store-service/api/customer/favoriteStore/" + storeId);
}
}

View File

@@ -23,6 +23,9 @@ export default {
localStorage.removeItem(EXPIRED_TIME_NAME);
},
isExpired() {
if(this.getExpiredTime() == null || this.getToken() == null)
return true;
const expiredTime = this.getExpiredTime();
const expiredMoment = moment(expiredTime);

View File

@@ -6,7 +6,7 @@
elevation="1"
>
<v-app-bar-nav-icon>
<v-app-bar-nav-icon @click="$router.back()">
<v-icon>mdi-arrow-left</v-icon>
</v-app-bar-nav-icon>
<v-spacer></v-spacer>
@@ -29,16 +29,31 @@
<v-icon>mdi-bell-outline</v-icon>
</v-badge>
</v-btn>
<v-btn
color="white"
elevation="0"
@click="logout"
>
<v-icon>mdi-logout</v-icon>
</v-btn>
</v-app-bar>
</template>
<script>
import authApi from "@/api/auth";
export default {
name: "AppNavigation",
props: ["notificationCounts"],
methods: {
goNotification: function() {
this.$router.push('/notification');
},
logout: function () {
if(confirm("로그아웃하시겠습니까?")){
authApi.logout();
}
}
}
}

View File

@@ -15,16 +15,69 @@
<b>{{store.name}}</b>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
<v-btn
icon
@click="markStar()"
>
<v-icon
:color="favoriteStore.color"
>{{ favoriteStore.icon }}</v-icon>
</v-btn>
</v-app-bar>
</template>
<script>
import storeApi from "@/api/store";
export default {
name: "StoreNavigation",
props: ["store"],
data: function() {
return {
storeId:-1,
favoriteStore:{
status:true,
color:null,
icon: 'mdi-heart-outline'
}
}
},
methods:{
markStar:function () {
this.changeStarStatus()
var vm = this
storeApi.markStar(this.storeId)
.then(()=>{
vm.favoriteStore.status?
alert('즐겨찾는 매장에서 제외되었습니다.') : alert('즐겨찾는 매장에 등록되었습니다.')
})
},
getFavoriteStoreByStoreId: function (storeId){
var vm = this
storeApi.getFavoriteStoreByStoreId(storeId)
.then((response)=>{
if(response.data.data.exist) vm.changeStarStatus()
})
},
changeStarStatus(){
if(this.favoriteStore.status){
this.favoriteStore.color = "rgb(255, 152, 0)"
this.favoriteStore.icon = "mdi-heart"
}else{
this.favoriteStore.color = null
this.favoriteStore.icon = "mdi-heart-outline"
}
this.favoriteStore.status= !this.favoriteStore.status
}
},
mounted() {
console.log(this.$route.params)
this.storeId =this.$route.params.storeId
this.getFavoriteStoreByStoreId(this.storeId)
}
}
</script>

View File

@@ -32,51 +32,63 @@ const routes = [
{
path: '/',
redirect: 'home',
beforeEnter: authCheck,
component: HomeLayout,
children: [
{
path: "/home",
beforeEnter: authCheck,
name: 'home',
beforeEnter: authCheck,
component: () => import('../views/HomeView')
},
{
path: "/search",
beforeEnter: authCheck,
name: 'search-store',
beforeEnter: authCheck,
component: () => import('../views/SearchStore')
},
{
path: "/history",
beforeEnter: authCheck,
name: 'order-history',
beforeEnter: authCheck,
component: () => import('../views/OrderHistory')
},
{
path: "/favorite",
beforeEnter: authCheck,
name: 'favorite-store',
beforeEnter: authCheck,
component: () => import('../views/FavoriteStore')
},
{
path: "/notification",
beforeEnter: authCheck,
name: 'notification',
beforeEnter: authCheck,
component: () => import('../views/NotificationView')
},
{
path: "/item/:itemId",
beforeEnter: authCheck,
name: 'itemDetail',
beforeEnter: authCheck,
component: () => import('../views/ItemDetail')
},
{
path: "/order",
beforeEnter: authCheck,
name: 'orderPage',
beforeEnter: authCheck,
component: () => import('../views/OrderPage')
},
{
path: "/mypage",
beforeEnter: authCheck,
name: 'mypage',
component: () => import('../views/MyPage')
},
]
},
{
@@ -87,12 +99,12 @@ const routes = [
{
path: '/store',
redirect: 'store',
beforeEnter: authCheck,
component: StoreLayout,
children: [
{
path: "/store/:storeId",
name: "store",
beforeEnter: authCheck,
component: () => import('../views/StoreView'),
props: true
},

View File

@@ -36,6 +36,7 @@
<v-col >
<v-container>
<v-text-field
readonly
v-model="setItem.count"
append-outer-icon="mdi-plus"
prepend-icon="mdi-minus"
@@ -111,7 +112,7 @@ export default {
itemOptions:[],
},
setItem:{
count:0,
count:1,
storeId:-1,
itemId:-1,
price:0,
@@ -145,9 +146,12 @@ export default {
},
addItemCount: function (v){
this.setItem.count =
this.setItem.count+v >=0? this.setItem.count+v: 0;
this.setItem.count+v >=1? this.setItem.count+v: 1;
},
addItem: function(){
if(!this.validItem())
return;
orderApi.addItemToBasket(this.setItem)
.then(response=>{
console.log(response)
@@ -156,7 +160,16 @@ export default {
.catch(error=>{
console.log(error.response)
})
},
validItem(){
if(this.setItem.count <= 0 || isNaN(this.setItem.count)){
alert("수량이 잘못되었습니다.")
this.setItem.count =1
return false
}
}
},
}
</script>

View File

@@ -120,7 +120,6 @@ export default {
},
},
async mounted() {
if (!jwt.isExpired())
await router.push("/");

View File

@@ -56,11 +56,6 @@
@click="saveOrder"
color="primary"
>주문하기</v-btn>
<!-- <v-btn-->
<!-- style="position: absolute; bottom: 0;transform: translateY(-100%); width: 100%"-->
<!-- @click="orderItems"-->
<!-- >주문하기</v-btn>-->
</div>
</template>
@@ -90,10 +85,12 @@ export default {
orderApi.saveOrder()
.then(()=>{
this.$emit('plusCount')
alert('주문되었습니다.')
this.$router.push("/history")
})
.catch(error=>{
alert("문제가 발생하였습니다. 다시 시도해보세요.")
console.log(error)
//this.$router.replace("/")
})
@@ -105,8 +102,9 @@ export default {
this.orderData=response.data.data
})
.catch(error=>{
alert("장바구니에 상품이 없습니다.")
this.$router.back();
console.log(error.response)
history.back();
})
},
}

View File

@@ -28,6 +28,7 @@
class="mx-auto mb-5"
outlined
v-for="item in category.items"
@click="itemDetail(item.id)"
:key="item.id"
>
<v-list-item three-line>
@@ -91,6 +92,9 @@ export default {
this.tags.push(category.name);
})
},
itemDetail: function (itemId) {
this.$router.push("/item/"+itemId)
}
}
}
</script>