Commit eeb7c314 by Lin

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

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