App.vue
4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!--
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-26 23:52:36
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-07-23 10:33:45
* @FilePath: /temple_material_request/src/App.vue
* @Description:
-->
<template>
<van-row v-if="is_pc">
<van-col span="22" offset="1">
<router-view></router-view>
</van-col>
</van-row>
<router-view v-else></router-view>
</template>
<script setup>
import { mainStore, useTitle } from "@/utils/generatePackage";
import { computed, watchEffect, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import { Toast } from "vant";
// 会根据配置判断是否显示调试控件
// eslint-disable-next-line no-unused-vars
import vConsole from "@/utils/vconsole";
// 初始化WX环境
import wx from 'weixin-js-sdk'
import { wxJsAPI } from '@/api/wx/config'
import { apiList } from '@/api/wx/jsApiList.js'
import { wxInfo, getUrlParams, stringifyQuery } from "@/utils/tools";
import { styleColor } from "@/constant.js";
import { getFormSettingAPI } from "@/api/form.js";
import { showDialog, showConfirmDialog } from 'vant';
import fp3 from '@/utils/fp3';
import { Updater } from '@/utils/versionUpdater';
// 使用 include + pinia 状态管理动态缓存页面
const store = mainStore();
const keepPages = computed(() => store.getKeepPages);
const $route = useRoute();
// watchEffect(() => useTitle("表单标题"));
// 监听路由变化
// 切换路由页面返回顶部
const $router = useRouter();
// web端判断
const is_pc = computed(() => wxInfo().isPC);
// 微信端判断
const is_wx = computed(() => wxInfo().isWeiXin);
// iframe模式判断
const is_iframe = computed(() => window.self !== window.top);
onMounted(async () => {
// // 跳转未授权页
// if (form_setting.auth_error) { // 权限报错信息存在
// $router.replace({
// path: '/no_auth',
// query: {
// code,
// data_id
// }
// });
// }
// // 没有授权判断
// let open_auth = form_setting.wxzq_enable && !form_setting.x_field_weixin_openid;
// // iframe传值openid
// const iframe_openid = getUrlParams(location.href) ? getUrlParams(location.href).openid : '';
// if (iframe_openid) { // 如果获取到iframe传值openid 不再校验授权
// open_auth = false;
// }
// const no_preview_model = model !== 'preview';
// let record_openid = false; // 是否记录open_id
// 需要网页授权-必须要域名相同,需要上传到线上测试
/**
* wxzq_scope 微信公众号授权模式
* 空字符串=不授权,snsapi_base=静默授权,snsapi_userinfo=显式授权
*/
// 非测试环境,没有openid信息,需要授权
// if (!import.meta.env.DEV && open_auth && form_setting.wxzq_scope && record_openid) {
// // 预览模式不开启
// if (no_preview_model) {
// $router.replace({
// path: '/auth',
// query: {
// href: location.hash,
// code
// }
// });
// }
// } else {
// // 启用微信增强,非预览模式
// if (form_setting.wxzq_enable && no_preview_model) {
// const wxJs = await wxJsAPI({ form_code: code, url: raw_url });
// wxJs.data.jsApiList = apiList;
// wx.config(wxJs.data);
// wx.ready(() => {
// wx.showAllNonBaseMenuItem();
// });
// wx.error((err) => {
// console.warn(err);
// });
// }
// }
// TAG:检查是否更新
if (import.meta.env.PROD) {
const upDater = new Updater({
time: 30000
})
upDater.on('no-update', () => {
// console.log('还没更新')
})
upDater.on('update', () => {
showConfirmDialog({
title: '温馨提示',
message: '检测到新版本,是否刷新页面!',
confirmButtonColor: styleColor.baseColor
}).then(() => {
window.location.reload();
});
})
}
});
</script>
<style lang="less">
@prefix: ~"@{namespace}-x";
html,
body {
width: 100%;
// height: 100%;
color: @base-font-color;
// background-color: #f7f8fa;
// background-color: #fff9ef;
padding: 0;
margin: 0;
}
body {
position: relative;
display: flex;
justify-content: center;
p {
margin: 0;
padding: 0;
}
}
#app {
min-height: calc(100vh);
max-width: 800px;
position: relative;
}
.@{prefix} {
color: red;
}
.global-center {
position: relative;
top: 50%;
transform: translateY(-50%);
}
.zIndex {
z-index: 4500 !important;
}
</style>