feat:app嵌套h5

This commit is contained in:
liu.huiying@ebiz-digits.com
2025-03-12 18:25:52 +08:00
parent d05cc14ff3
commit b486dd4ccd
6 changed files with 171 additions and 162 deletions

View File

@@ -10,6 +10,8 @@ onMounted(async() => {
appBridge.setHeaderShown(false); appBridge.setHeaderShown(false);
// 设置系统状态栏明暗主题 // 设置系统状态栏明暗主题
appBridge.setStatusBarStyle('light'); appBridge.setStatusBarStyle('light');
// 设置禁止原生返回
// appBridge.takeOverAndroidBack();
} }
}); });
</script> </script>

View File

@@ -92,22 +92,22 @@ export default {
}); });
}, },
// /** /**
// * @desc 跳转到H5页面 * @desc 跳转到H5页面
// * @param {String} h5Url 目标H5链接 * @param {String} h5Url 目标H5链接
// * @param {String} name 导航头中的标题文案 * @param {String} name 导航头中的标题文案
// * @param {Boolean} fullscreen 是否全屏显示(隐藏导航头) * @param {Boolean} fullscreen 是否全屏显示(隐藏导航头)
// * @returns {Boolean} 操作是否成功 * @returns {Boolean} 操作是否成功
// */ */
// navigateToH5(h5Url, name, fullscreen = false) { navigateToH5(h5Url, name, fullscreen = false) {
// if (fullscreen) { if (fullscreen) {
// h5Url = this.appendQueryParam(h5Url, 'fullscreen', 'true'); h5Url = this.appendQueryParam(h5Url, 'fullscreen', 'true');
// } }
// return this.postMessageToRN({ return this.postMessageToRN({
// type: 'navigate', type: 'navigate',
// url: `authH5?url=${encodeURIComponent(h5Url)}&name=${name}` url: `authH5?url=${encodeURIComponent(h5Url)}&name=${name}`
// }); });
// }, },
// /** // /**
// * @desc 给URL添加查询参数 // * @desc 给URL添加查询参数

View File

@@ -6,15 +6,11 @@ import App from './App.vue';
import router from './router'; import router from './router';
// 2. 引入组件样式 // 2. 引入组件样式
import 'vant/lib/index.css'; import 'vant/lib/index.css';
// // 调整路由守卫的设置位置 import appBridge from '@/assets/js/appBridge';
// router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
// if (to.query.digitalYiliToken) { appBridge.setTitle(to.meta.title as string);
// utils.delCookie('xToken'); next();
// utils.clearCookie('xToken'); });
// utils.setCookie('xToken', to.query.xToken, 7);
// }
// next();
// });
const app = createApp(App); const app = createApp(App);
app.use(createPinia()); app.use(createPinia());
app.use(router); app.use(router);

View File

@@ -59,7 +59,7 @@ const router = createRouter({
}, { }, {
path: '/publish', path: '/publish',
name: 'publish', name: 'publish',
meta: { title: '问卷发布' }, meta: { title: '问卷投放' },
component: () => import('../views/Survey/views/Publish/Index.vue') component: () => import('../views/Survey/views/Publish/Index.vue')
} }
] ]

View File

@@ -3,29 +3,34 @@
import LastSurvey from './components/LastSurvey/Index.vue'; import LastSurvey from './components/LastSurvey/Index.vue';
import Market from './components/Market/Index.vue'; import Market from './components/Market/Index.vue';
import CreateSurvey from './components/CreateSurvey/Index.vue'; import CreateSurvey from './components/CreateSurvey/Index.vue';
import { onMounted } from 'vue'; import { onMounted,ref } from 'vue';
import utils from '@/assets/js/common'; import utils from '@/assets/js/common';
import { getUserInfo } from '@/api/common/index.js'; import { getUserInfo } from '@/api/common/index.js';
import { showFailToast } from 'vant'; import { showFailToast } from 'vant';
let contentShow = ref(false);
onMounted(async() => { onMounted(async() => {
if (utils.getParameter('digitalYiliToken')) { if (utils.getParameter('digitalYiliToken')) {
const appToken = utils.getParameter('digitalYiliToken'); const appToken = utils.getParameter('digitalYiliToken');
getUserInfo(appToken).then((res) => { getUserInfo(appToken).then((res) => {
if (res.data) { if (res.data) {
contentShow = true;
utils.setSessionStorage('userInfo', res.data.data); utils.setSessionStorage('userInfo', res.data.data);
} else { } else {
contentShow = false;
showFailToast(error.response.data?.message || error.data?.message || error.message || '服务器错误'); showFailToast(error.response.data?.message || error.data?.message || error.message || '服务器错误');
} }
}).catch((error) => { }).catch((error) => {
contentShow = false;
showFailToast(error.response.data?.message || error.message || '服务器错误'); showFailToast(error.response.data?.message || error.message || '服务器错误');
}); });
}else{
contentShow = true
} }
}); });
</script> </script>
<template> <template>
<div class="container"> <div class="container" v-if="contentShow">
<create-survey /> <create-survey />
<!-- 最新问卷 --> <!-- 最新问卷 -->

View File

@@ -4,15 +4,13 @@
<van-cell-group inset style="margin-top: 20px; padding: 30px"> <van-cell-group inset style="margin-top: 20px; padding: 30px">
<div> <div>
<img <img width="100%"
width="100%"
src="https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u14.jpg?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333" src="https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u14.jpg?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333"
alt="" alt="" />
/>
</div> </div>
<div class="qrcode"> <div class="qrcode">
<img src="" alt="" width="100px" height="100px" /> <img :src="publishInfo.img_url" alt="" width="100px" height="100px" />
<div> <div class="tit">
<div>液态奶产品研究标准化问卷</div> <div>液态奶产品研究标准化问卷</div>
<div>扫码填写问卷</div> <div>扫码填写问卷</div>
</div> </div>
@@ -20,17 +18,14 @@
<div>移动端仅做数据回收问卷数据分析请前往PC端浏览</div> <div>移动端仅做数据回收问卷数据分析请前往PC端浏览</div>
<div class="operation"> <div class="operation">
<span v-for="(item, index) in operateList" :key="index" @click="operateBtn(item)"> <span v-for="(item, index) in operateList" :key="index" @click="operateBtn(item)">
<img <img width="30px"
width="30px" src="https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u21.png?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333" />
src="https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u21.png?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333"
/>
{{ item.title }} {{ item.title }}
</span> </span>
</div> </div>
</van-cell-group> </van-cell-group>
<!-- 底部功能性按钮 --> <!-- 底部功能性按钮 -->
<div <div style="
style="
position: fixed; position: fixed;
bottom: 0; bottom: 0;
display: flex; display: flex;
@@ -40,8 +35,7 @@
width: 100%; width: 100%;
height: 50px; height: 50px;
background-color: white; background-color: white;
" ">
>
</div> </div>
</div> </div>
</template> </template>
@@ -49,27 +43,27 @@
<script setup lang="ts"> <script setup lang="ts">
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { showFailToast, showSuccessToast } from 'vant';
import utils from '@/assets/js/common';
import appBridge from '@/assets/js/appBridge'; import appBridge from '@/assets/js/appBridge';
import { getQrcode } from '@/api/survey'; import { getQrcode } from '@/api/survey';
import { showFailToast, showSuccessToast } from 'vant';
const route = useRoute(); const route = useRoute();
const surveyTitle = route.meta.title as string; const surveyTitle = route.meta.title as string;
appBridge.setTitle(surveyTitle)
const operateList = reactive([ const operateList = reactive([
{ {
title: '复制链接', title: '复制链接',
type: 'copyLink', type: 'copyLink',
img: ''
}, },
{ {
title: '转发到微信', title: '转发到微信',
type: 'shareLink', type: 'shareLink',
img: ''
}, },
{ {
title: '下载二维码', title: '下载二维码',
type: 'qrCode', type: 'qrCode',
img: ''
} }
]); ]);
@@ -85,18 +79,16 @@ interface PublishInfo {
const publishInfo = ref<PublishInfo>({} as PublishInfo); const publishInfo = ref<PublishInfo>({} as PublishInfo);
type OperateItem = typeof operateList[0]; type OperateItem = typeof operateList[0];
onMounted(async() => { onMounted(async () => {
getQrcode('Xxgdr5EN').then((res) => { getQrcode('Xxgdr5EN').then((res) => {
if (res.data) { if (res.data) {
publishInfo.value = res.data.data || {}; publishInfo.value = res.data.data || {};
console.log(res.data);
} }
}).catch((error) => { }).catch((error) => {
showFailToast(error.data?.message || error.message || '服务器错误'); showFailToast(error.data?.message || error.message || '服务器错误');
}); });
}); });
const operateBtn = (item: OperateItem) => { const operateBtn = (item: OperateItem) => {
console.log(item);
switch (item.type) { switch (item.type) {
case 'shareLink': case 'shareLink':
shareLink(); shareLink();
@@ -112,7 +104,7 @@ const operateBtn = (item: OperateItem) => {
} }
}; };
// 复制链接 // 复制链接
function copyLink() { function copyLink () {
const input = document.createElement('input'); const input = document.createElement('input');
input.value = publishInfo.value.url; input.value = publishInfo.value.url;
document.body.appendChild(input); document.body.appendChild(input);
@@ -122,7 +114,7 @@ function copyLink() {
showSuccessToast('复制成功'); showSuccessToast('复制成功');
} }
// 分享链接 // 分享链接
function shareLink() { function shareLink () {
const params = { const params = {
type: 'shareToWx', type: 'shareToWx',
title: publishInfo.value.download_url.title, title: publishInfo.value.download_url.title,
@@ -137,16 +129,20 @@ function shareLink() {
} }
// 下载二维码 // 下载二维码
function downLoadImg() { function downLoadImg () {
const { title, url } = publishInfo.value.download_url; const { title, url } = publishInfo.value.download_url;
if (utils.getCookie('xToken')) {
appBridge.save2Album(url, (result: any) => {
showSuccessToast('下载成功');
});
} else {
const link = document.createElement('a'); const link = document.createElement('a');
link.href = url; link.href = url;
link.download = title; link.download = title;
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);
// const subdata = publishInfo.value.download_url }
// store.dispatch('common/fileDown', subdata);
} }
</script> </script>
@@ -173,20 +169,30 @@ function downLoadImg() {
.qrcode { .qrcode {
display: flex; display: flex;
margin: 10px 0;
.tit{
display: flex;
flex-direction: column;
justify-content: center;
margin: 0 10px;
line-height: 20px;
}
} }
.operation { .operation {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: start; justify-content: space-between;
margin-right: 20px; margin: 25px 10px 0 0;
span { span {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 10px; img{
margin-bottom: 10px;
}
} }
} }
</style> </style>