From 229adacd44e00fe379cd0a8058fc1af66c5165fb Mon Sep 17 00:00:00 2001 From: wangzimeng <3297159934@qq.com> Date: Fri, 1 Aug 2025 15:41:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AF=BE=E7=A8=8B=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/school/classesDetail.vue | 37 ++++++++++++++++++++++++++++------ sheep/api/school.js | 7 +++++++ 2 files changed, 38 insertions(+), 6 deletions(-) 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',