积分转换页顶部返回

This commit is contained in:
whitechiina 2026-10-09 13:49:16 +08:00
parent bf1cab2698
commit d5c45ca962
34 changed files with 136 additions and 19 deletions

View File

@ -122,6 +122,11 @@ export default {
this.navLayout = fallbackLayout; this.navLayout = fallbackLayout;
}, },
handleBack() { handleBack() {
if (this.$listeners && this.$listeners["back-click"]) {
this.$emit("back-click");
return;
}
if (getCurrentPages().length > 1) { if (getCurrentPages().length > 1) {
uni.navigateBack(); uni.navigateBack();
return; return;

View File

@ -1,6 +1,9 @@
<template> <template>
<view class="asset-page asset-theme points-home-page"> <view class="asset-page asset-theme points-home-page">
<asset-page-shell title="积分转换" /> <asset-page-shell
title="积分转换"
@back-click="handleShellBack"
/>
<view class="asset-scroll points-home-scroll"> <view class="asset-scroll points-home-scroll">
<view class="hero-card"> <view class="hero-card">
@ -96,12 +99,19 @@
import AssetPageShell from "../../components/asset-page-shell.vue"; import AssetPageShell from "../../components/asset-page-shell.vue";
import { fetchPointsConvertHome } from "../../api/assets"; import { fetchPointsConvertHome } from "../../api/assets";
const EXIT_WEBVIEW_PROTOCOL_URL = "uniwebview://close";
function isEnabledFlag(value) {
return String(value || "").trim() === "1";
}
export default { export default {
components: { components: {
AssetPageShell, AssetPageShell,
}, },
data() { data() {
return { return {
shouldExitWebview: false,
hasShown: false, hasShown: false,
selectedMonth: "", selectedMonth: "",
detail: { detail: {
@ -143,7 +153,8 @@ export default {
return "没有更多了"; return "没有更多了";
}, },
}, },
onLoad() { onLoad(options) {
this.shouldExitWebview = isEnabledFlag(options && options.ewuFlag);
this.selectedMonth = this.currentMonth(); this.selectedMonth = this.currentMonth();
this.resetPagingState(); this.resetPagingState();
this.loadPage(true, 1); this.loadPage(true, 1);
@ -167,6 +178,107 @@ export default {
this.loadMore(); this.loadMore();
}, },
methods: { methods: {
handleShellBack() {
if (!this.shouldExitWebview) {
this.defaultNavigateBack();
return;
}
if (this.tryCloseAppWebview()) {
return;
}
if (this.isH5Runtime()) {
this.backToPreviousH5Url();
return;
}
if (this.tryNotifyHostClose()) {
return;
}
this.defaultNavigateBack();
},
defaultNavigateBack() {
if (
typeof getCurrentPages === "function" &&
getCurrentPages().length > 1 &&
typeof uni !== "undefined" &&
typeof uni.navigateBack === "function"
) {
uni.navigateBack();
return;
}
uni.reLaunch({
url: "/pages/index/index",
});
},
tryCloseAppWebview() {
try {
if (
typeof plus !== "undefined" &&
plus.webview &&
typeof plus.webview.currentWebview === "function"
) {
const currentWebview = plus.webview.currentWebview();
if (currentWebview && typeof currentWebview.close === "function") {
currentWebview.close("auto");
return true;
}
}
} catch (error) {
// H5 环境可能没有 plus,继续走宿主协议和浏览器兜底。
}
return false;
},
isH5Runtime() {
return (
typeof window !== "undefined" &&
typeof document !== "undefined" &&
!this.hasAppWebviewHint()
);
},
hasAppWebviewHint() {
if (typeof plus !== "undefined") {
return true;
}
const userAgent =
typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
return userAgent.toLowerCase().indexOf("html5plus") > -1;
},
backToPreviousH5Url() {
if (typeof window === "undefined") {
this.defaultNavigateBack();
return;
}
if (window.history && window.history.length > 1) {
window.history.back();
return;
}
const referrer =
typeof document !== "undefined" ? String(document.referrer || "") : "";
if (referrer) {
window.location.replace(referrer);
return;
}
this.defaultNavigateBack();
},
tryNotifyHostClose() {
if (typeof window === "undefined" || !window.location) {
return false;
}
window.location.href = EXIT_WEBVIEW_PROTOCOL_URL;
return true;
},
resetPagingState() { resetPagingState() {
this.page = 1; this.page = 1;
this.hasMore = false; this.hasMore = false;

View File

@ -1,2 +1,2 @@
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>白马交易所</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)')) <!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>白马交易所</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/bmt/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/bmt/static/js/chunk-vendors.a58c62f3.js></script><script src=/bmt/static/js/index.d2373521.js></script></body></html> document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/bmt/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/bmt/static/js/chunk-vendors.a58c62f3.js></script><script src=/bmt/static/js/index.0a43b5b8.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long