|
@@ -33,12 +33,40 @@ export default {
|
|
|
isRouterBack: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ // 用于内嵌页面,标识为最后一页
|
|
|
+ isGoBack: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ visible: true,
|
|
|
+ isApp: null,
|
|
|
+ isAndroid: null,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // 如果是安卓的需要判断一下是否显示h5内置的返回按钮
|
|
|
+ // 如果是H5、微信小程序,不需要显示次按钮
|
|
|
+ this.isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser
|
|
|
+ this.isAndroid = this.$userAgent.isAndroid;
|
|
|
+ if (!this.isApp) return this.visible = false
|
|
|
+ if (this.isApp && this.isAndroid) {
|
|
|
+ this.visible = !!window.native.goneBack
|
|
|
+ // 判断是否有注册goneBack方法,有就调用
|
|
|
+ if(!!window.native.goneBack){
|
|
|
+ console.log('this.visible', this.visible)
|
|
|
+ window.native.goneBack() // 安卓隐藏返回按钮
|
|
|
+ }
|
|
|
+ // setTimeout(()=>{
|
|
|
+ // console.log('window.native.goneBack', window.native.goneBack)
|
|
|
+ // console.log(' !!window.native.goneBack', !!window.native.goneBack)
|
|
|
+ // this.visible && window.native.goneBack() // 安卓隐藏返回按钮
|
|
|
+ // }, 100)
|
|
|
+ }
|
|
|
},
|
|
|
- mounted() { },
|
|
|
computed: {
|
|
|
containerStyle() {
|
|
|
// if (this.isShowApp) {
|
|
@@ -67,9 +95,9 @@ export default {
|
|
|
},
|
|
|
isShowNavBar() {
|
|
|
// 是否是APP
|
|
|
- const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
|
|
|
- const isAndroid = this.$userAgent.isAndroid;
|
|
|
- const isIos = this.$userAgent.isIos;
|
|
|
+ // const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
|
|
|
+ // const isAndroid = this.$userAgent.isAndroid;
|
|
|
+ // const isIos = this.$userAgent.isIos;
|
|
|
const isWx = this.$userAgent.isWx;
|
|
|
// 如果是App并且是安卓,就不显示头部, ios显示
|
|
|
// 如果微信小程序环境的,也不显示头部
|
|
@@ -77,7 +105,8 @@ export default {
|
|
|
let bool = false;
|
|
|
// bool = isApp ? (isAndroid ? !isAndroid : isIos) : (isWx ? !isWx : !isWx);
|
|
|
|
|
|
- bool = (isApp && (isAndroid || isIos)) || isWx ? false : true;
|
|
|
+ // bool = (isApp && (isAndroid || isIos)) || isWx ? false : true;
|
|
|
+ bool = isWx ? false : true;
|
|
|
|
|
|
// console.log()
|
|
|
return bool || this.forceShowNavBar;
|
|
@@ -90,7 +119,12 @@ export default {
|
|
|
this.$emit('goBack');
|
|
|
return;
|
|
|
}
|
|
|
- this.$router.go(-1);
|
|
|
+ // 如果为true是最前一页
|
|
|
+ if (this.isGoBack) {
|
|
|
+ this.isAndroid ? window.native.backClick() : window.webkit.messageHandlers.appGoBack.postMessage({})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$router.go(-1)
|
|
|
},// 退出相关逻辑
|
|
|
},
|
|
|
};
|