Commit 0dfe5870 by huangzhi

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

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