Commit 0dfe5870 by huangzhi

feat: 支付成功页使用replace策略,返回后刷新

parent f290c6ef
...@@ -210,7 +210,7 @@ export default { ...@@ -210,7 +210,7 @@ export default {
pagePath = 'pay/groupSuccess' pagePath = 'pay/groupSuccess'
} }
const url = `${hostPrefix}/h5-course/${pagePath}?${urlStr}` const url = `${hostPrefix}/h5-course/${pagePath}?${urlStr}`
uni.navigateTo({ uni.redirectTo({
url: `/pages/web/web?title=${'支付成功'}&loadUrl=${encodeURIComponent(url)}`, url: `/pages/web/web?title=${'支付成功'}&loadUrl=${encodeURIComponent(url)}`,
}) })
}, },
......
...@@ -15,8 +15,9 @@ export default { ...@@ -15,8 +15,9 @@ export default {
name: 'WebPage', name: 'WebPage',
data() { data() {
return { return {
cccc: '',
loadUrl: '', loadUrl: '',
// 只用于页面第一次初始化的时候,只要加载页面数据一次,防止onShow时重复加载
isMountedPageLoaded: false,
options: {}, options: {},
} }
}, },
...@@ -31,20 +32,20 @@ export default { ...@@ -31,20 +32,20 @@ export default {
}) })
} }
this.cccc = options.scene this.isMountedPageLoaded = true
this.loadPage()
// 有scene,说明是扫描二维码进入
if (options.scene) {
uni.showLoading({
title: '加载中',
})
this.getParamsByScene(options.scene)
}
}, },
// 移除登录成功事件 // 移除登录成功事件
onUnload() { onUnload() {
uni.$off('loginSuccess', this.handleLoginSuccess) uni.$off('loginSuccess', this.handleLoginSuccess)
}, },
// 主要用于返回上一页,刷新当前页面
onShow() {
if (this.isMountedPageLoaded) return
if (this.isNeedLoadPageOnShow) {
this.loadPage()
}
},
// 分享给朋友 // 分享给朋友
onShareAppMessage() { onShareAppMessage() {
const getDetailPageUrl = () => { const getDetailPageUrl = () => {
...@@ -70,6 +71,12 @@ export default { ...@@ -70,6 +71,12 @@ export default {
} }
} }
}, },
computed: {
// 课程详情页需要回退后,刷新
isNeedLoadPageOnShow() {
return this.loadUrl && this.loadUrl.includes('h5-course/detail')
},
},
watch: { watch: {
loadUrl: { loadUrl: {
handler(url) { handler(url) {
...@@ -82,13 +89,24 @@ export default { ...@@ -82,13 +89,24 @@ export default {
}, },
}, },
mounted() { mounted() {
// this.options.scene 无值,说明是非扫描二维码,此时自己拼装路径 // 第一次加载完毕,置于初始值
if (!this.options.scene) { this.isMountedPageLoaded = false
this.initWeviewUrl()
}
}, },
methods: { methods: {
loadPage() {
const options = this.options
// 有scene,说明是扫描二维码进入
if (options.scene) {
uni.showLoading({
title: '加载中',
})
this.getParamsByScene(options.scene)
} else {
// this.options.scene 无值,说明是非扫描二维码,此时自己拼装路径
this.initWeviewUrl()
}
},
// 设置页面地址额外的通用参数 // 设置页面地址额外的通用参数
setCommonUrlParams(pageUrl, urlParmas) { setCommonUrlParams(pageUrl, urlParmas) {
let url = decodeURIComponent(pageUrl) let url = decodeURIComponent(pageUrl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment