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

View File

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

View File

@@ -27,6 +27,8 @@ import java.util.List;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; 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.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
@@ -76,14 +78,10 @@ class CategoryOwnerApiControllerTest {
//then //then
actions.andExpect(MockMvcResultMatchers.status().isOk()) 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(MockMvcResultHandlers.print())
.andDo(MockMvcRestDocumentation.document("get-categoryList", .andDo(MockMvcRestDocumentation.document("get-categoryList",
requestParameters( requestHeaders(
parameterWithName("storeId").description("매장 고유 번호") headerWithName("user-id").description("로그인한 유저 id")
), ),
responseFields( responseFields(
fieldWithPath("code").description("결과 코드 SUCCESS/ERROR"), fieldWithPath("code").description("결과 코드 SUCCESS/ERROR"),