fix:app嵌套h导航栏

This commit is contained in:
LHY\18810
2025-03-16 11:37:20 +08:00
parent 9a6887d2ec
commit 78c4f11039
7 changed files with 80 additions and 55 deletions

View File

@@ -1,6 +1,6 @@
.van-nav-bar {
padding-top: var(--status-bar-height) !important;
height: calc(46px + var(--status-bar-height)) !important;
height: calc(60px + var(--status-bar-height)) !important;
}
.van-cell {
padding: 8px !important;

BIN
src/assets/img/back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

View File

@@ -311,5 +311,24 @@ export default {
type: 'newAuthToken',
cbId
});
},
/**
* @desc H5历史记录
*/
routerCanGoBack(router) {
const position = router.options.history.state?.position;
return typeof position === 'number' && position > 1;
},
/**
* @desc 当前系统h5返回
* @returns {Boolean} 操作是否成功
*/
async h5RouterBack(router) {
const canGoBack = this.routerCanGoBack(router);
if (canGoBack) {
router.go(-1);
} else {
this.navigateBack();
}
}
};

View File

@@ -2,12 +2,11 @@
<div class="common-layout">
<!-- title 标题和搜索栏 -->
<header class="header">
<van-nav-bar
class="header-nav"
:title="$route.meta.title"
left-arrow
@click-left="$router.go(-1)"
/>
<van-nav-bar :title="$route.meta.title" left-arrow safe-area-inset-top @click-left="goBack">
<template #left>
<img src="@/assets/img/back.png" alt="" class="back-icon" />
</template>
</van-nav-bar>
</header>
<!-- content -->
<RouterView />
@@ -15,7 +14,14 @@
</template>
<script setup>
import { RouterView } from 'vue-router';
import { RouterView, useRouter } from 'vue-router';
import appBridge from '@/assets/js/appBridge';
const router = useRouter();
function goBack() {
appBridge.h5RouterBack(router);
}
</script>
<style scoped lang="scss">
@@ -36,5 +42,10 @@ import { RouterView } from 'vue-router';
align-items: end;
justify-content: center;
}
.back-icon {
width: 18px;
height: 18px;
}
}
</style>

View File

@@ -13,17 +13,17 @@ import { getDomText } from '@/utils/utils';
* @param options
*/
function showModal(options) {
const confirm = (...rest) => {
if (options.incompleteQuestionList?.length) {
if (options.onOk) {
options.onOk(...rest);
}
const firstQuestion = options.incompleteQuestionList[0];
// store.commit(`common/${A_COMMON_SET_ACTIVEQUESTION}`, JSON.stringify(firstQuestion));
// const el = document.getElementById(firstQuestion.id);
// new Scroll(el).animate();
}
};
// const confirm = (...rest) => {
// if (options.incompleteQuestionList?.length) {
// if (options.onOk) {
// options.onOk(...rest);
// }
// const firstQuestion = options.incompleteQuestionList[0];
// store.commit(`common/${A_COMMON_SET_ACTIVEQUESTION}`, JSON.stringify(firstQuestion));
// const el = document.getElementById(firstQuestion.id);
// new Scroll(el).animate();
// }
// };
showConfirmDialog({
title: '提示',
@@ -31,7 +31,7 @@ function showModal(options) {
...options
})
.then(() => {
confirm();
// confirm();
})
.catch(() => {});
}
@@ -133,9 +133,7 @@ const canPlanetPublish3D = function (data) {
canFB = false;
qSteams.push(`(${s.title})`);
}
} catch (error) {
console.warn(error);
}
} catch (error) {}
}
});
@@ -186,9 +184,7 @@ const canPlanetPublish3D = function (data) {
qSteams.push(`(${s.title})`);
}
}
} catch (error) {
console.warn(error);
}
} catch (error) {}
}
});
@@ -396,7 +392,11 @@ function isLoopingLogicValid(data, publishType) {
return false;
}
/**
* 判断问卷是否可以投放(原本应该后端实现,前端实现会有并发的问题,但后端表示做不了)
* @param sn
* @param publishType undefined投放null投放0投放1预览2投放3测试
*/
export const canPlanetPublish = async function (sn, publishType) {
const parsedPublishType = !publishType ? 2 : publishType;
const num = window.location.href.indexOf('code=');

View File

@@ -6,10 +6,14 @@ import { onMounted, ref } from 'vue';
// import utils from '@/assets/js/common';
// import { getUserInfo } from '@/api/common/index.js';
// import { showFailToast } from 'vant';
import { RouterView, useRouter } from 'vue-router';
import appBridge from '@/assets/js/appBridge';
const router = useRouter();
const contentShow = ref(false);
const show = ref(false);
onMounted(async() => {
onMounted(async () => {
contentShow.value = true;
// if (utils.getSessionStorage('xToken')) {
// const appToken = utils.getParameter('digitalYiliToken');
@@ -29,8 +33,9 @@ onMounted(async() => {
// contentShow.value = true;
// }
});
function create() {
show.value = true;
function create () {
router.push({ name: 'publish' });
// show.value = true;
}
</script>
@@ -57,13 +62,13 @@ function create() {
padding: 30px 10px 80px;
background: linear-gradient(0deg, #f5f5f5 0%, #f5f5f5 84%, #a5d380 100%);
& > :first-child {
&> :first-child {
display: flex;
justify-content: space-around;
border-radius: 6px;
background-color: white;
& > div {
&>div {
display: flex;
flex-direction: column;
width: 50px;

View File

@@ -1,6 +1,6 @@
<template>
<div class="container">
<van-nav-bar :title="surveyTitle" left-arrow @click-left="$router.go(-1)" />
<layout />
<div class="content">
<van-cell-group v-if="status === 1" inset style="padding-top: 15px">
<div>
@@ -39,6 +39,7 @@
</template>
<script setup lang="ts">
import layout from '@/layouts/index.vue';
import { useRoute } from 'vue-router';
import { onMounted, reactive, ref, watch } from 'vue';
import { showFailToast, showToast } from 'vant';
@@ -144,22 +145,19 @@ function downLoadImg () {
document.body.removeChild(link);
}
}
function handlePublish () {
publishSurvey({
sn,
publish_type: publishType.value
})
.then(() => {
fetchInfo();
})
.catch((error) => {
showFailToast(error.data?.message || error.message || '服务器错误');
});
}
async function openPublishModal () {
const res = await canPlanetPublish(route.query.sn as string);
const res = await canPlanetPublish(route.query.sn as string, publishType.value);
if (res) {
handlePublish();
await publishSurvey({
sn,
publish_type: publishType.value
})
.then(() => {
fetchInfo();
})
.catch((error) => {
showFailToast(error.data?.message || error.message || '服务器错误');
});
}
}
@@ -206,19 +204,11 @@ onMounted(async () => {
height: 100vh;
background-color: #f5f5f5;
* {
font-size: 10px;
}
button {
padding: 3px 20px;
border: none;
background-color: #f2f2f2;
}
* {
font-size: 12px;
}
}
.content {