App.vue
3.69 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
<!--
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-26 23:52:36
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-12-06 17:40:43
* @FilePath: /data-table/src/App.vue
* @Description:
-->
<template>
<van-row v-if="is_pc">
<van-col span="20" offset="2">
<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 } from "@/utils/tools";
import { styleColor } from "@/constant.js";
import { getFormSettingAPI } from "@/api/form.js";
// 使用 include + pinia 状态管理动态缓存页面
const store = mainStore();
const keepPages = computed(() => store.getKeepPages);
// // TAG: 全局设置页面标题
const $route = useRoute();
// watchEffect(() => useTitle("表单标题"));
// 监听路由变化
// 切换路由页面返回顶部
const $router = useRouter();
watch(
() => $router.currentRoute.value,
(newValue, oldValue) => {
nextTick(() => {
// document.getElementById('app')?.scrollIntoView();
});
// console.warn(wxInfo().isMobile);
},
{ immediate: true }
);
// TAG: 全局配置Toast
// Toast.setDefaultOptions({
// duration: 2000,
// className: 'zIndex'
// });
// web端判断
const is_pc = computed(() => wxInfo().isPC);
onMounted(async () => {
// const { data } = await wxJsAPI();
// data.jsApiList = apiList;
// wx.config(data);
// wx.ready(() => {
// wx.showAllNonBaseMenuItem();
// });
// wx.error((err) => {
// console.warn(err);
// });
// 数据收集设置
const code = getUrlParams(location.href) ? getUrlParams(location.href).code : '';
const { data } = await getFormSettingAPI({ form_code: code });
const form_setting = {};
if (data.length) {
data[0].property_list.forEach((prop) => {
const key = prop["property_code"];
const obj = {
[key]:
prop["setting_value"].length > 1
? prop["setting_value"]
: prop["setting_value"][0],
};
Object.assign(form_setting, obj, data[0]['extend']);
});
}
// 缓存表单设置
store.changeFormSetting(form_setting);
// 判断跳转页面
if (form_setting.sjsj_enable && form_setting.sjsj_enable === 0) {
// 表单已结束
$router.push("/stop?status=disable");
}
// 开启后有开始和结束时间,不在时间范围的显示表单还未开始或者已经结束
if (form_setting.sjsj_is_time_range && form_setting.sjsj_is_time_range === 1) {
// 未开始
if (form_setting.server_time < form_setting.sjsj_begin_time) {
$router.push("/stop?status=apply");
}
// 已结束
if (form_setting.server_time > form_setting.sjsj_end_time) {
$router.push("/stop?status=finish");
}
}
});
</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;
p {
margin: 0;
padding: 0;
}
}
#app {
min-height: calc(100vh);
position: relative;
}
.@{prefix} {
color: red;
}
.global-center {
position: relative;
top: 50%;
transform: translateY(-50%);
}
.zIndex {
z-index: 4500 !important;
}
</style>