hookehuyr

✨ feat(家长,老师上传模块): 处理上传跳转回页面数据问题

......@@ -45,7 +45,7 @@
</van-row>
</div>
<template v-for="(item, key) in kgInfo.book" :key="key">
<book-card :item="item" type="B" @on-click="onClick(item)"></book-card>
<book-card :item="item" type="B" :user_id="kgInfo.user_id" @on-click="onClick(item)"></book-card>
</template>
</div>
<div style="height: 1rem;"></div>
......
......@@ -10,7 +10,7 @@
<p style=" margin-bottom: 0.5rem;">您是否愿意与偏远山区的小朋友</p>
<p>共读这么精彩的书籍</p>
</div>
<div style="padding: 0 15% 0.5rem 15%;">
<div v-if="book_id" style="padding: 0 15% 0.5rem 15%;">
<my-button @on-click="toDonate" type="plain">我要爱心捐书</my-button>
</div>
<div style="padding: 0 15% 1rem 15%;">
......@@ -36,20 +36,43 @@ const $route = useRoute();
const $router = useRouter();
/*************** 捐书模块START ***************/
const donateItem = ref({})
const book_id = $route.query.x_field_1 ? $route.query.x_field_1.split('-')[1] : '';
if (!book_id) {
Toast.fail('书籍数据不全');
}
axios.get('/srv/?a=default_perf', {
params: {
book_id
}
})
.then(res => {
if (res.data.code === 1) {
donateItem.value = res.data.data;
} else {
console.warn(res);
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
});
// TODO: 作品上传完成后,回调到成功页面,需要返回书籍的详情
// 弹出捐赠弹框模块
const showDonate = ref(false);
const toDonate = () => {
showDonate.value = true;
// TODO: 这些信息到时候需要后台带过来
// 生成捐赠数据
donateItem.value = {
book_id: '314134',
avatar: 'https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngc434046fdf1f9499d251b280af2568ddbe64839799d00a9aee226edbeb710aed',
name: '逃家小兔绘本',
price: '59'
book_id: donateItem.value.book_id,
avatar: donateItem.value.book_cover,
name: donateItem.value.book_name,
price: donateItem.value.book_price
}
}
......@@ -60,7 +83,10 @@ const closeDonate = (v) => {
const goBack = () => {
$router.push({
path: '/client/bookDetail'
path: '/client/bookDetail',
query: {
id: donateItem.value.book_id
}
})
}
......