fix(customer-vue): item detail 즐겨찾기 버튼 버그 픽스

item detail 즐겨찾기 버튼 버그 픽스
This commit is contained in:
hoon7566
2022-03-24 17:03:46 +09:00
parent 256b5257fe
commit 363850f091
3 changed files with 23 additions and 20 deletions

View File

@@ -42,7 +42,6 @@ export default {
props: ["store"],
data: function() {
return {
storeId:-1,
favoriteStore:{
status:true,
color:null,
@@ -50,34 +49,40 @@ export default {
}
}
},
methods:{
watch:{
store (){
// alert()
this.getFavoriteStoreByStoreId()
}
},
methods:{
markStar:function () {
this.changeStarStatus()
this.changeStarStatus(!this.favoriteStore.status)
var vm = this
storeApi.markStar(this.storeId)
storeApi.markStar(this.store.id)
.then(()=>{
vm.favoriteStore.status?
alert('즐겨찾는 매장에서 제외되었습니다.') : alert('즐겨찾는 매장에 등록되었습니다.')
})
},
getFavoriteStoreByStoreId: function (storeId){
getFavoriteStoreByStoreId: function (){
var vm = this
storeApi.getFavoriteStoreByStoreId(storeId)
storeApi.getFavoriteStoreByStoreId(this.store.id)
.then((response)=>{
if(response.data.data.exist) vm.changeStarStatus()
if(response.data.data.exist) vm.changeStarStatus(response.data.data.exist)
})
},
changeStarStatus(){
changeStarStatus(status){
if(this.favoriteStore.status){
if(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
this.favoriteStore.status= status
},
logout: function () {
@@ -89,9 +94,8 @@ export default {
},
mounted() {
console.log(this.$route.params)
this.storeId =this.$route.params.storeId
this.getFavoriteStoreByStoreId(this.storeId)
// this.getFavoriteStoreByStoreId(this.storeId)
}
}
</script>

View File

@@ -124,17 +124,18 @@ export default {
getItemData: async function (){
storeApi.fetchItem(this.itemId)
.then(response=>{
console.log(response)
this.itemData = response.data.data
this.setItem.itemId = this.itemData.id
this.setItem.price = this.itemData.price
this.storeId = this.itemData.storeId
this.setItem.storeId = this.itemData.storeId
this.$emit('getStoreId', this.storeId)
})
.catch(error=>{
console.log(error)
this.$router.push("/")
})
},
parseGroup: function (type){
let group= [];

View File

@@ -27,6 +27,8 @@ import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
@@ -76,14 +78,10 @@ class CategoryOwnerApiControllerTest {
//then
actions.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("data[0].categoryId").value("10"))
.andExpect(MockMvcResultMatchers.jsonPath("data[0].name").value("카테고리1"))
.andExpect(MockMvcResultMatchers.jsonPath("data[1].categoryId").value("11"))
.andExpect(MockMvcResultMatchers.jsonPath("data[1].name").value("카테고리2"))
.andDo(MockMvcResultHandlers.print())
.andDo(MockMvcRestDocumentation.document("get-categoryList",
requestParameters(
parameterWithName("storeId").description("매장 고유 번호")
requestHeaders(
headerWithName("user-id").description("로그인한 유저 id")
),
responseFields(
fieldWithPath("code").description("결과 코드 SUCCESS/ERROR"),