Commit 3113698b by Lin

feature(activity):添加预学习脚本和跳过面板API

- 在活动模块中实现了 `getPrelearnScriptBoardAPI` 和 `getPrelearnSkipBoardAPI` 方法。
- 更新了 `prelearnBridge.vue`,使用新 API 获取剩余跳过次数,并优化了返回导航逻辑。
1 parent f1a9e2db
...@@ -74,6 +74,9 @@ module.exports = { ...@@ -74,6 +74,9 @@ module.exports = {
...data ...data
}) })
}, },
/**
* 查询预学习脚本状态
*/
getPrelearnScriptBoardAPI(data) { getPrelearnScriptBoardAPI(data) {
return http.post({ return http.post({
method: 'dj.api.pad.prelearn.script.board', method: 'dj.api.pad.prelearn.script.board',
...@@ -81,4 +84,11 @@ module.exports = { ...@@ -81,4 +84,11 @@ module.exports = {
...data ...data
}) })
}, },
getPrelearnSkipBoardAPI(data) {
return http.post({
method: 'dj.api.pad.prelearn.skip.info',
projectName: 'pad',
...data
})
},
} }
\ No newline at end of file \ No newline at end of file
...@@ -748,8 +748,6 @@ export default { ...@@ -748,8 +748,6 @@ export default {
// #endif // #endif
}, },
async checkMainPushStaffLearnStatus() { async checkMainPushStaffLearnStatus() {
console.log('[prelearnBridge] goodsInfo res:',this.goodsInfo)
console.log('[prelearnBridge] prelearnContext res:', this.prelearnContext)
const res = await uni.$api.activityApi.getPrelearnScriptBoardAPI({ const res = await uni.$api.activityApi.getPrelearnScriptBoardAPI({
activityId: this.goodsInfo.activityId || this.prelearnContext.activityId, activityId: this.goodsInfo.activityId || this.prelearnContext.activityId,
activityProductId: this.goodsInfo.productId || this.prelearnContext.activityProductId, activityProductId: this.goodsInfo.productId || this.prelearnContext.activityProductId,
...@@ -758,64 +756,39 @@ export default { ...@@ -758,64 +756,39 @@ export default {
const status = Number(res?.staffLearnStatus) const status = Number(res?.staffLearnStatus)
return status === 1 || status === 2 return status === 1 || status === 2
}, },
showMainPushBackTip() { async fetchPrelearnSkipCount() {
uni.showModal({ const activityId = this.goodsInfo.activityId || this.prelearnContext.activityId
title: '提示', if (!activityId) return
content: '请先完成预学习后再退出', try {
showCancel: false, const res = await uni.$api.activityApi.getPrelearnSkipBoardAPI({ activityId })
confirmText: '知道了', console.log('[prelearnBridge] 查询剩余跳过次数 res:', res)
}) if (res?.remainingSkipCount != null) {
this.prelearnContext.skipCount = res.remainingSkipCount
}
} catch (error) {
console.error('[prelearnBridge] 查询剩余跳过次数失败:', error)
}
}, },
async back() { async back() {
if (this.enteredViaRow && Number(this.isMainPush) !== 1) { if (this.enteredViaRow && Number(this.isMainPush) !== 1) {
this.navigateBack() this.navigateBack()
return return
} }
console.log('this.isMainPush***', this.isMainPush);
// if (Number(this.isMainPush) === 1) {
let learned = false let learned = false
try { try {
learned = await this.checkMainPushStaffLearnStatus() learned = await this.checkMainPushStaffLearnStatus()
console.log("学习状态查询***", learned);
} catch (error) { } catch (error) {
console.error('[prelearnBridge] 预学习状态查询失败:', error) console.error('[prelearnBridge] 预学习状态查询失败:', error)
} }
if (learned) { if (learned) {
this.navigateBack() this.navigateBack()
return return
} }
if (this.prelearnContext.entrySource === 'home_popup') {
await this.fetchPrelearnSkipCount()
this.showBackPopup = true this.showBackPopup = true
} else {
this.showMainPushBackTip()
}
// }
// try {
// const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
// console.log('[prelearnBridge] getPrelernHomePopupAPI res:', res)
// const packages = res.packages || []
// const allStudied = packages.length > 0 && packages.every(
// (pkg) => pkg.learnStatus === 'STUDIED'
// )
// if (allStudied) {
// this.navigateBack()
// return
// }
// if (res.activityId != null) {
// this.prelearnContext.activityId = String(res.activityId)
// }
// // 仅当接口返回有效值时更新,避免 undefined 覆盖 onLoad 已写入的 skipCount
// if (res.remainingSkipCount != null) {
// this.prelearnContext.skipCount = res.remainingSkipCount
// }
// this.showBackPopup = true
// } catch (error) {
// console.error('[prelearnBridge] 预学习返回弹框查询失败:', error)
// this.showBackPopup = true
// }
}, },
handleBackPopupCancel() { handleBackPopupCancel() {
this.showBackPopup = false this.showBackPopup = false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!