diff --git a/pages/school/classesDetail.vue b/pages/school/classesDetail.vue index 9e99692..2bef479 100644 --- a/pages/school/classesDetail.vue +++ b/pages/school/classesDetail.vue @@ -188,15 +188,40 @@ console.log('收藏', detailClass.value.is_collect); if (detailClass.value.is_collect == 1) { detailClass.value.is_collect = 0 - uni.showToast({ - title: '已取消收藏', - icon: 'none' + const data = { + id: detailClass.value.id, + is_collect: detailClass.value.is_collect + } + sheep.$api.school.classesCollect(data).then((res) => { + if(res.code == 1) { + uni.showToast({ + title:'已取消收藏', + icon:'none', + duration: 2000, + }) + setTimeout(() =>{ + getDetail() + },1000) + } }) } else { detailClass.value.is_collect = 1 - uni.showToast({ - title: '已收藏', - icon: 'none' + const data1 = { + id: detailClass.value.id, + is_collect: detailClass.value.is_collect + } + sheep.$api.school.classesCollect(data1).then((res) => { + if(res.code == 1) { + uni.showToast({ + title:'已收藏', + icon:'none', + duration: 2000, + }) + setTimeout(() =>{ + getDetail() + },1000) + + } }) } } diff --git a/sheep/api/school.js b/sheep/api/school.js index 1d1e531..95d412f 100644 --- a/sheep/api/school.js +++ b/sheep/api/school.js @@ -20,6 +20,13 @@ export default { id: id, }, }), + //收藏 + classesCollect: (data) => + request({ + url: 'meal.classes/collect', + method: 'POST', + data, + }), // detail: (id, user_coupon_id) => // request({ // url: 'coupon/detail',