Commit eeb7c314 by Lin

feat(PreStudyPopup):优化学习启动功能及界面调整

- 更新 PreStudyPopup,使其在按钮点击时处理学习启动逻辑,若课程状态不符合条件则阻止操作。
-操作。
- 调整课程项的高度和边距样式,以改善布局效果。
- 修改 HomeFrame 组件,集成新的学习启动事件处理逻辑。
- 优化 CustomerSide 组件,将图标替换为图片,提升视觉一致性。
1 parent e6db716a
......@@ -15,7 +15,11 @@
<!-- 右 -->
<view class="header-right" v-if="type === 'out'" @click="handleGoCustomerFiles">
<view class="header-right-icon">
<view class="sprite-icon icon-customer-add"></view>
<image
class="header-add-icon"
:src="require('@/assets/images/common/icon-add-files.png')"
mode="aspectFit"
/>
</view>
<view class="header-right-text">
客户建档
......@@ -211,6 +215,12 @@ export default {
justify-content: center;
}
.header-add-icon {
width: 16px;
height: 16px;
flex-shrink: 0;
}
.header-right-text {
line-height: 1;
color: #2C66F7;
......
......@@ -193,10 +193,10 @@
</StudyPopup>
<!-- 预学习弹框 -->
<StudyPopup :show.sync="showPreStudyPopup" title="提示" :width="848" :height="1028"
<StudyPopup :show.sync="showPreStudyPopup" title="提示" :width="848" :height="968"
:topImage="require('@/assets/images/common/warning-notice.webp')" :topImageWidth="848" :topImageHeight="248">
<PreStudyPopup :confirmText="examPopInfo.confirmText" @cancel="handlePreStudyCancel"
@confirm="handlePreStudyConfirm" />
@confirm="handlePreStudyConfirm" @start-study="handlePreStudyStart" />
</StudyPopup>
<!-- 学习中心权限弹窗 -->
......@@ -367,7 +367,7 @@ export default {
confirmText: '确认已提交'
},
showStudyPermissionPopup: false,
showPreStudyPopup: false,
showPreStudyPopup: true,
courseInfo: {
title: ''
},
......@@ -559,6 +559,9 @@ export default {
handlePreStudyConfirm() {
this.showPreStudyPopup = false
},
handlePreStudyStart() {
this.showPreStudyPopup = false
},
handleStudyPermissionConfirm() {
this.showStudyPermissionPopup = false
if (this.lockReason == '2') {
......
......@@ -6,13 +6,16 @@
class="course-item"
v-for="(item, index) in displayCourseList"
:key="item.id || index"
@click="handleStartStudy(item, index)"
>
<view class="course-item-title">
<view class="course-item-title-text">{{ item.title }}</view>
<view class="course-item-desc">{{ item.description }}</view>
</view>
<view class="course-item-btn" v-if="item.state === 0">开启学习</view>
<view
class="course-item-btn"
v-if="item.state === 0"
@click.stop="handleStartStudy(item, index)"
>开启学习</view>
<view class="course-item-btn course-item-btn--learned" v-else>已学习</view>
</view>
</scroll-view>
......@@ -39,12 +42,6 @@ const DEFAULT_COURSE_LIST = [
title: 'AITO 春醒悦享车衣套餐',
description: '包含:原厂定制隐形车衣 + 专属天窗....',
state:0
},
{
id: 3,
title: 'AITO 春醒悦享车衣套餐',
description: '包含:原厂定制隐形车衣 + 专属天窗....',
state:0
}
]
......@@ -67,7 +64,11 @@ export default {
},
methods: {
handleStartStudy(item, index) {
if (item.state !== 0) return
this.$emit('start-study', item, index)
uni.navigateTo({
url: '/pages/common/prelearnBridge'
})
},
handleCancel() {
this.$emit('cancel')
......@@ -97,7 +98,7 @@ export default {
.course-list {
width: 100%;
height: toRpx(480);
height: toRpx(440);
box-sizing: border-box;
}
......@@ -175,8 +176,7 @@ export default {
justify-content: center;
width: 100%;
gap: toRpx(16);
margin-top: auto;
margin-top: toRpx(48);
margin-top: toRpx(8);
}
.confirm-button {
......
......@@ -15,6 +15,7 @@
v-if="webviewUrl && isAppClient"
class="demo-webview"
:src="webviewUrl"
:fullscreen="false"
:webview-styles="webviewInsetStyle"
@message="handleWebMessage"
@onPostMessage="handleWebMessage"
......@@ -52,6 +53,9 @@ export default {
employeeName: '演示员工',
storeId: 'STORE-DEMO-001',
},
pendingAppBackTimer: null,
pendingAppBackRequestId: null,
navBackHotArea: null,
}
},
computed: {
......@@ -100,6 +104,7 @@ export default {
this.measureNavBarForWebview()
this.captureChildWebview()
this.initBrowserBridge()
this.createNavBackHotArea()
},
onBackPress(options) {
if (options.from === 'backbutton') {
......@@ -109,6 +114,8 @@ export default {
return false
},
onUnload() {
this.clearPendingAppBack()
this.destroyNavBackHotArea()
// #ifdef H5
window.removeEventListener('message', this.handleBrowserMessage)
// #endif
......@@ -201,6 +208,10 @@ export default {
if (message.type === 'PRELEARN_BACK_TO_APP') {
this.handleH5BackEvent(message)
}
if (message.type === 'PRELEARN_APP_BACK_HANDLED') {
this.handleH5BackHandled(message)
}
},
captureChildWebview() {
// #ifdef APP-PLUS
......@@ -242,6 +253,10 @@ export default {
if (message.type === 'PRELEARN_BACK_TO_APP') {
this.handleH5BackEvent(message)
}
if (message.type === 'PRELEARN_APP_BACK_HANDLED') {
this.handleH5BackHandled(message)
}
})
},
normalizeMessages(event) {
......@@ -321,8 +336,34 @@ export default {
}
}, 500)
},
clearPendingAppBack() {
if (this.pendingAppBackTimer) {
clearTimeout(this.pendingAppBackTimer)
this.pendingAppBackTimer = null
}
this.pendingAppBackRequestId = null
},
scheduleAppBackFallback(requestId, delayMs = 400) {
this.clearPendingAppBack()
this.pendingAppBackRequestId = requestId
this.pendingAppBackTimer = setTimeout(() => {
if (this.pendingAppBackRequestId !== requestId) return
console.log('[prelearn bridge demo] H5 did not confirm back, fallback navigateBack')
this.clearPendingAppBack()
this.navigateBack()
}, delayMs)
},
handleH5BackHandled(message) {
const requestId = message && (message.requestId || message.data && message.data.requestId)
if (requestId && this.pendingAppBackRequestId && requestId !== this.pendingAppBackRequestId) {
return
}
console.log('[prelearn bridge demo] H5 handled back internally:', message)
this.clearPendingAppBack()
},
handleH5BackEvent(message) {
console.log('[prelearn bridge demo] APP received H5 back event:', message)
this.clearPendingAppBack()
this.navigateBack()
},
notifyH5AppBackPressed() {
......@@ -334,6 +375,8 @@ export default {
console.log('[prelearn bridge demo] APP header back pressed, notify H5:', payload)
let notifiedH5 = false
// #ifdef H5
const iframe = document.querySelector('iframe')
if (iframe && iframe.contentWindow) {
......@@ -342,7 +385,7 @@ export default {
type: 'PRELEARN_APP_BACK_PRESSED',
...payload,
}, '*')
return
notifiedH5 = true
}
// #endif
......@@ -355,13 +398,64 @@ export default {
if (this.childWebview && this.childWebview.evalJS) {
this.childWebview.evalJS(script)
return
notifiedH5 = true
}
// #endif
if (notifiedH5) {
this.scheduleAppBackFallback(requestId)
return
}
console.log('[prelearn bridge demo] H5 missing, fallback navigateBack')
this.navigateBack()
},
createNavBackHotArea() {
// #ifdef APP-PLUS
if (this.navBackHotArea) return
const run = () => {
uni.createSelectorQuery()
.in(this)
.select('.nav-leading')
.boundingClientRect((rect) => {
if (!rect || rect.width <= 0 || rect.height <= 0) return
try {
this.destroyNavBackHotArea()
this.navBackHotArea = new plus.nativeObj.View('prelearnNavBackHotArea', {
top: `${Math.max(0, Math.floor(rect.top))}px`,
left: `${Math.max(0, Math.floor(rect.left))}px`,
width: `${Math.ceil(rect.width)}px`,
height: `${Math.ceil(rect.height)}px`,
backgroundColor: 'rgba(0,0,0,0)',
})
this.navBackHotArea.addEventListener('click', () => {
this.back()
}, false)
this.navBackHotArea.show()
} catch (error) {
console.log('[prelearn bridge demo] create nav back hot area failed:', error)
}
})
.exec()
}
this.$nextTick(() => {
run()
setTimeout(run, 120)
setTimeout(run, 400)
})
// #endif
},
destroyNavBackHotArea() {
// #ifdef APP-PLUS
if (!this.navBackHotArea) return
try {
this.navBackHotArea.close()
} catch (error) {
console.log('[prelearn bridge demo] destroy nav back hot area failed:', error)
}
this.navBackHotArea = null
// #endif
},
back() {
this.notifyH5AppBackPressed()
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!