Commit 2e70546b authored by xinzhedeai's avatar xinzhedeai

add :权限变量值公共提取,逻辑判断代码修改。工具js加载时序问题优化处理。去除无用js引用。

parent 3a47b3f6
body {
letter-spacing: 0.02rem;
[v-cloak] {
display: none;
}
.page_wrapper {
......@@ -16,6 +16,7 @@ body {
}
body {
letter-spacing: 0.02rem;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-color: #f5f5f5;
}
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>商户检查页面</title>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>高区安全“码”上查监管平台-首页</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewprot-fit:cover" />
<title>高区安全“码”上查监管平台-首页</title>
<link rel="stylesheet" href="home.css" />
<style>
[v-cloak] {
display: none;
}
</style>
<!-- 在 includeHead.js 之后添加环境判断 -->
<script src="./sdk/includeHead.js"></script>
</head>
<body>
<!-- 获取授权用户信息 本地token等操作 -->
<script>
if (window.env === 'pro') {
document.write('<script type="text/javascript" src="sdk/jssdk2/index.js"><\/script>')
}
// 监听 includeHead.js 加载完成事件
document.querySelector('script[src="./sdk/includeHead.js"]').onload = function() {
// includeHead.js 加载完成后,动态加载 home.js
const homeScript = document.createElement('script');
homeScript.type = 'text/javascript';
homeScript.src = './home.js';
document.body.appendChild(homeScript);
};
</script>
<script type="text/javascript" src="./home.js"></script>
</head>
<body>
<div id="app" class="page_wrapper" v-cloak>
<!-- 原有内容(数据加载完成后显示) -->
<div v-show="!isLoading">
......
var VUE = null
window.onload = function () {
// 在页面加载完成后执行
// 执行你的代码
const currentDate = gemhoUtil.getTargetDateYM()
window.onload = function() {
// const currentDate = gemhoUtil.getTargetDateYM()
VUE = new Vue({
el: '#app',
data() {
return {
isLoading: true, // 新增:加载状态标记
showPopup4completionDate: false,
// 控制日期选择器弹窗的显示与隐藏
showPicker: false,
showPopup4completionDate: false, // 控制日期选择器弹窗的显示与隐藏
showOrg: false, //是否显示组织
showShop: false, //是否显示店铺
// 存储选择的日期
selectedDate: new Date(currentDate), // '', // gemhoUtil.formatDate(new Date(value)),
selectedDate: '', // new Date(currentDate), // '', // gemhoUtil.formatDate(new Date(value)),
//显示的日期
showDate: currentDate,
showDate: '', // currentDate,
// 日期选择的最小范围,这里设置为当前日期的前 10 年
minDate: new Date(new Date().getFullYear() - 10, 0),
// 日期选择的最大范围,这里设置为当前日期的后 10 年
......@@ -30,11 +28,6 @@ window.onload = function () {
role: '',
roleName: '',
},
showOrg: false, //是否显示组织
showShop: false, //是否显示店铺
// 修改默认菜单结构为最小化配置
menuList: [],
// 初始化为空数组,等待接口数据填充
userData: {
checkCount: 0, //检查数
......@@ -43,19 +36,23 @@ window.onload = function () {
hiddenNoReCount: 0, //未整改数
},
accessType: 'manage', // 访问类型 shop商家 saoma 扫码 manage 管理
// 修改默认菜单结构为最小化配置
menuList: [],
remindStatistic: []
}
},
mounted() {
// 在组件挂载后执行
// 调用你的方法
this.init()
},
computed: {},
methods: {
async init() {
// 在组件挂载后执行
await this.getUserInfo();
await this.getStatisticData();
this.isLoading = false; // 数据加载完成后关闭加载状态
},
getRemindStatistic() {
http2.post(
{
http2.post({
serviceId: API_KEY_MAP['no-page']['id'],
interfacePublicKey: API_KEY_MAP['no-page']['publicKey'],
interfacePrivateKey: API_KEY_MAP['no-page']['privateKey'],
......@@ -78,52 +75,15 @@ window.onload = function () {
}
)
},
openDebug() { // 双击开启debugg模式,再次双击则关闭
console.log('开启关闭debug')
if (localStorage.getItem('debug') == 'Y') {
localStorage.setItem('debug', 'N')
} else {
localStorage.setItem('debug', 'Y')
}
},
scanCode(toData) {
if (!toData) {
lightAppJssdk.device.scan({
success: function (data) {
// 获取到data为二维码的url路径,从这里取请求参数,商户id,在下面跳转本地系统路径
// alert('扫码成功'+JSON.stringify(data))
const strUrl = new URL(data);
const param = {
merId: strUrl.searchParams.get('merId'),
accessType: strUrl.searchParams.get('accessType')
};
if (param.merId == null || param.merId == '') {
alert('请扫描正确的商家二维码')
return
} else {
let url = gemhoUtil.setParameter(`./src/_shanghu_home.html`, param)
gemhoUtil.navigatePage(url, '跳转中...')
}
},
fail: function (data) {
//错误返回
alert('扫码失败')
},
})
} else {
// if (this.userInfo.userType === 'shop' && toData === 'checkrecord') {
// toData = 'checkrecord'
// } else {
// toData = 'shanghu_list'
// }
scanCode(toData) { // 有菜单地址则是跳转页面,没有则是扫码操作
if (toData) {
let param = {
accessType: this.accessType,
merId: this.userInfo.merId || '',
unitName: this.userInfo.unitName,
smallPlaceTypeName: this.userInfo.smallPlaceTypeName,
}
if (this.userInfo.userType === 'shop') {
if (gemhoUtil.isShop()) {
param = {
...param,
accessType: 'shop',
......@@ -131,7 +91,6 @@ window.onload = function () {
if (toData == 'check_info') {
param = {
...param,
accessType: 'shop',
flag: 'ADD',
pageName: '../home',
......@@ -140,49 +99,33 @@ window.onload = function () {
}
let url = gemhoUtil.setParameter(`src/_${toData}.html`, param)
gemhoUtil.navigatePage(url, '跳转中...')
// gemhoUtil.navigatePage(`src/_${toData}.html`)
}
},
navTo(type) { // 消息统计跳转
} else {
lightAppJssdk.device.scan({
success: function(data) {
// 获取到data为二维码的url路径,从这里取请求参数,商户id,在下面跳转本地系统路径
// alert('扫码成功'+JSON.stringify(data))
const strUrl = new URL(data);
const param = {
type,
merId: this.userInfo.merId
merId: strUrl.searchParams.get('merId'),
accessType: strUrl.searchParams.get('accessType')
};
let url = gemhoUtil.setParameter(`./src/_yh_check.html`, param)
gemhoUtil.navigatePage(url, '跳转中...')
},
gotoPage(stringifyUrl) {
let url = gemhoUtil.setParameter(`src/_${stringifyUrl}.html`)
if (param.merId == null || param.merId == '') {
alert('请扫描正确的商家二维码')
return
} else {
let url = gemhoUtil.setParameter(`./src/_shanghu_home.html`,
param)
gemhoUtil.navigatePage(url, '跳转中...')
}
},
async init() {
// 在组件挂载后执行
await this.getUserInfo();
await this.getStatisticData();
this.isLoading = false; // 数据加载完成后关闭加载状态
},
showPopup() {
this['showPopup4completionDate'] = true
},
confirm4completionDate(value) {
this.selectedDate = gemhoUtil.getTargetDateYMByPara(value)
this.showDate = gemhoUtil.getTargetDateYMByPara(value)
this.showPopup4completionDate = false
this.getStatisticData()
fail: function(data) {
//错误返回
alert('扫码失败')
},
// 格式化日期显示的函数,根据需要自定义
needData(type, val) {
if (type === 'year') {
return `${val}`
} else if (type === 'month') {
return `${val}`
})
}
return val
},
// 取消选择日期时的回调函数
onCancel() {
this.showPicker = false
},
getUserInfo() {
return new Promise((resolve) => {
......@@ -202,31 +145,33 @@ window.onload = function () {
return
}
this.userInfo = {
userType: result.data.roleDeptNameVo.userType, // 登录用户type
userType: result.data.roleDeptNameVo
.userType, // 登录用户type
userId: '1', // 登录用户id
userName: '张三', // 登录用户name
deptId: '1', // 登录用户部门id
safeLevel: result.data.merchantInfoNumVo?.safeLevel, //0:绿、1:黄、2:红
deptName: result.data.roleDeptNameVo.deptName, // 登录用户部门name
businessAddress:
result.data.merchantInfoNumVo?.businessAddress, //
smallPlaceTypeName:
result.data.merchantInfoNumVo?.smallPlaceTypeName, //
safeLevel: result.data.merchantInfoNumVo
?.safeLevel, //0:绿、1:黄、2:红
deptName: result.data.roleDeptNameVo
.deptName, // 登录用户部门name
businessAddress: result.data.merchantInfoNumVo
?.businessAddress, //
smallPlaceTypeName: result.data.merchantInfoNumVo
?.smallPlaceTypeName, //
unitName: result.data.merchantInfoNumVo?.unitName, //
role: 'dudao',
roleName: result.data.roleDeptNameVo?.roleName,
merId: result.data.merchantInfoNumVo?.id, //
}
gemhoUtil.setCookie('userType', this.userInfo.userType)
if (this.userInfo.userType === 'shop') { // 2025年5月14日新增消费者逻辑
if (gemhoUtil.isShop()) { // 2025年5月14日新增消费者逻辑
this.showOrg = false //是否显示组织
this.showShop = true //是否显示店铺
this.getRemindStatistic() // 2025年6月9日 新增珊瑚提醒
} else if (['admin', 'common', 'industry', 'street', 'wgy'].includes(this.userInfo.userType)) {
} else {
this.showOrg = true //是否显示组织
this.showShop = false //是否显示店铺
}
console.log('菜单', result.data.modules)
......@@ -247,21 +192,64 @@ window.onload = function () {
reqParams: {
sign: 6,
date: this.selectedDate,
merId: gemhoUtil.getParameter('merId')|| '',
merId: gemhoUtil.getParameter('merId') || '',
},
},
(res) => {
if (res) {
var result = JSON.parse(res)
console.log('用户Data')
console.log('用户Data', result)
this.userData = result.data
resolve();
}
}
)
});
},
showPopup() {
this['showPopup4completionDate'] = true
},
confirm4completionDate(value) {
this.selectedDate = gemhoUtil.getTargetDateYMByPara(value)
this.showDate = gemhoUtil.getTargetDateYMByPara(value)
this.showPopup4completionDate = false
this.getStatisticData()
},
// 格式化日期显示的函数,根据需要自定义
needData(type, val) {
if (type === 'year') {
return `${val}`
} else if (type === 'month') {
return `${val}`
}
return val
},
// 取消选择日期时的回调函数
onCancel() {
this.showPicker = false
},
openDebug() { // 双击开启debugg模式,再次双击则关闭
console.log('开启关闭debug')
if (localStorage.getItem('debug') == 'Y') {
localStorage.setItem('debug', 'N')
} else {
localStorage.setItem('debug', 'Y')
}
},
navTo(type) { // 消息统计跳转
const param = {
type,
merId: this.userInfo.merId
};
let url = gemhoUtil.setParameter(`./src/_yh_check.html`, param)
gemhoUtil.navigatePage(url, '跳转中...')
},
gotoPage(stringifyUrl) {
let url = gemhoUtil.setParameter(`src/_${stringifyUrl}.html`)
gemhoUtil.navigatePage(url, '跳转中...')
},
},
//过滤器
filters: {
//格式化日期显示的函数,根据需要自定义
......
// ['admin', 'common', 'industry', 'street', 'wgy']
var AUTH = {
WGY: 'wgy', // 网格员
SHOP: 'shop', // 商户
CONSUMERS: 'consumers', // 消费者
}
var gemhoUtil = window.gemhoUtil || {}
gemhoUtil.isWgy = function () {
return gemhoUtil.getCookie('userType') == AUTH.WGY
}
gemhoUtil.isShop = function () {
return gemhoUtil.getCookie('userType') === AUTH.SHOP
}
gemhoUtil.isConsumers = function () {
return gemhoUtil.getCookie('userType') == AUTH.CONSUMERS
}
gemhoUtil.formatDate = function (date, type) {
var ymd = `${date.getFullYear()}-${
(date.getMonth() + 1 > 9 ? '' : '0') + (date.getMonth() + 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment