feat(课程详情页): 添加购买流程的微信环境校验
在非开发环境下,对付费课程增加微信内置浏览器环境校验。免费课程跳过校验,非微信环境提示用户并阻止购买流程
Showing
2 changed files
with
18 additions
and
0 deletions
| ... | @@ -39,6 +39,12 @@ https://oa-dev.onwall.cn/f/mlaj | ... | @@ -39,6 +39,12 @@ https://oa-dev.onwall.cn/f/mlaj |
| 39 | - 图片压缩:富文本中若包含 `cdn.ipadbiz.cn` 图片,使用 `?imageMogr2/thumbnail/200x/strip/quality/70` 参数。 | 39 | - 图片压缩:富文本中若包含 `cdn.ipadbiz.cn` 图片,使用 `?imageMogr2/thumbnail/200x/strip/quality/70` 参数。 |
| 40 | - 位置:`/src/views/courses/CourseDetailPage.vue`,“咨询弹窗”模板与交互逻辑(`open_consult_dialog`、`close_consult_dialog`、`call_phone`、`copy_consult_info`)。 | 40 | - 位置:`/src/views/courses/CourseDetailPage.vue`,“咨询弹窗”模板与交互逻辑(`open_consult_dialog`、`close_consult_dialog`、`call_phone`、`copy_consult_info`)。 |
| 41 | 41 | ||
| 42 | + - 购买流程环境校验 | ||
| 43 | + - 行为:仅对非免费课程在详情页点击“购买”时进行校验;生产环境下必须为微信内置浏览器(`wxInfo().isWeiXin`)。 | ||
| 44 | + - 免费课程:跳过微信环境校验,允许直接进入结算流程。 | ||
| 45 | + - 非微信环境(付费课):提示“请在微信内打开进行购买”,不进入结算。 | ||
| 46 | + - 位置:`/src/views/courses/CourseDetailPage.vue` 的 `handlePurchase` 中,使用 `wxInfo` 进行环境判断。 | ||
| 47 | + | ||
| 42 | - 401拦截策略优化(公开页面不再跳登录) | 48 | - 401拦截策略优化(公开页面不再跳登录) |
| 43 | - 行为:接口返回 `code=401` 时,不再对公开页面(如课程详情 `/courses/:id`)进行登录重定向;仅当当前路由确实需要登录权限时才跳转至登录页。 | 49 | - 行为:接口返回 `code=401` 时,不再对公开页面(如课程详情 `/courses/:id`)进行登录重定向;仅当当前路由确实需要登录权限时才跳转至登录页。 |
| 44 | - 原理:响应拦截器调用路由守卫 `checkAuth` 判断当前路由是否为受限页面,受限则清理登录信息并附带 `redirect` 重定向至登录页;公开页面保持当前页,由业务自行处理401。 | 50 | - 原理:响应拦截器调用路由守卫 `checkAuth` 判断当前路由是否为受限页面,受限则清理登录信息并附带 `redirect` 重定向至登录页;公开页面保持当前页,由业务自行处理401。 | ... | ... |
| ... | @@ -377,6 +377,7 @@ import { useRoute, useRouter } from 'vue-router' | ... | @@ -377,6 +377,7 @@ import { useRoute, useRouter } from 'vue-router' |
| 377 | import { useCart } from '@/contexts/cart' | 377 | import { useCart } from '@/contexts/cart' |
| 378 | import { useAuth } from '@/contexts/auth' | 378 | import { useAuth } from '@/contexts/auth' |
| 379 | import { useTitle } from '@vueuse/core'; | 379 | import { useTitle } from '@vueuse/core'; |
| 380 | +import { wxInfo } from '@/utils/tools'; | ||
| 380 | import { showToast, showDialog, showImagePreview } from 'vant'; | 381 | import { showToast, showDialog, showImagePreview } from 'vant'; |
| 381 | import { formatDate } from '@/utils/tools' | 382 | import { formatDate } from '@/utils/tools' |
| 382 | import { sharePage } from '@/composables/useShare.js' | 383 | import { sharePage } from '@/composables/useShare.js' |
| ... | @@ -701,6 +702,17 @@ const handlePurchase = () => { | ... | @@ -701,6 +702,17 @@ const handlePurchase = () => { |
| 701 | return | 702 | return |
| 702 | } | 703 | } |
| 703 | 704 | ||
| 705 | + // 检查是否在微信环境(生产环境下强制要求) | ||
| 706 | + /** | ||
| 707 | + * 判断是否为微信内置浏览器环境 | ||
| 708 | + * 非微信环境提示用户在微信内打开;免费课程跳过校验 | ||
| 709 | + */ | ||
| 710 | + const is_free = (course.value?.price === '0.00' || Number(course.value?.price) === 0) | ||
| 711 | + if (!is_free && !import.meta.env.DEV && !wxInfo().isWeiXin) { | ||
| 712 | + showToast('请在微信内打开进行购买') | ||
| 713 | + return | ||
| 714 | + } | ||
| 715 | + | ||
| 704 | if (course.value) { | 716 | if (course.value) { |
| 705 | // 调试日志:检查course.value.form_url的值 | 717 | // 调试日志:检查course.value.form_url的值 |
| 706 | console.log('CourseDetailPage - course.value.form_url:', course.value.form_url) | 718 | console.log('CourseDetailPage - course.value.form_url:', course.value.form_url) | ... | ... |
-
Please register or login to post a comment