feat(customer vue , store service): favorite store 등록 및 취소 로직 추가

- favorite store 등록 및 취소 로직 추가
This commit is contained in:
hoon7566
2022-03-18 17:05:30 +09:00
parent 4e5a14116f
commit 2e2526305e
8 changed files with 192 additions and 9 deletions

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

@@ -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-star-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-star"
}else{
this.favoriteStore.color = null
this.favoriteStore.icon = "mdi-star-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

@@ -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

@@ -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,6 +85,7 @@ export default {
orderApi.saveOrder()
.then(()=>{
this.$emit('plusCount')
alert('주문되었습니다.')
this.$router.push("/history")
})