Fix:2826 【商城小程序】农民店铺无法取消收藏,收藏时点取消图标未变更

This commit is contained in:
linxi
2024-12-24 10:26:16 +08:00
parent a9b63ca251
commit 420a14f6d9
2 changed files with 9 additions and 5 deletions
+3
View File
@@ -21,4 +21,7 @@ export function setFarmerShopCollection(data) {
return request.post("/collection/farmerShop/add", data)
}
export function removeFarmerShopCollection(data) {
return request.post("/collection/farmerShop/remove", data)
}
+6 -5
View File
@@ -81,14 +81,14 @@
:src="webUrl + '/icon/icon-star-on.png'"
mode="scaleToFill"
class="icon"
@click="doneFavorite"
@click="doneFavorite(store.hasFavorite)"
/>
<image
v-else
:src="webUrl + '/icon/icon-star-off.png'"
mode="scaleToFill"
class="icon"
@click="doneFavorite"
@click="doneFavorite(store.hasFavorite)"
/>
<text>{{ store.favoriteCount }}</text>
</view>
@@ -340,7 +340,7 @@
</template>
<script>
import { getFarmerShop, setFarmerShopZan, getFarmerShopNews, setFarmerShopCollection } from '@/api/farmer'
import { getFarmerShop, setFarmerShopZan, getFarmerShopNews, removeFarmerShopCollection, setFarmerShopCollection } from '@/api/farmer'
import { postCountyFamousNewsZan, postCountyFamousNewsView } from '@/api/qianxian'
import imgBox from '@/components/imageTypeSet/imagebox.vue'
export default {
@@ -514,11 +514,12 @@ export default {
}
})
},
doneFavorite() {
doneFavorite(has) {
const api = !has ? setFarmerShopCollection : removeFarmerShopCollection
const params = {
farmerShopId: this.id
}
setFarmerShopCollection(params).then(res => {
api(params).then(res => {
this.getFarmerData()
})
},