Commit fe84681d authored by xinzhedeai's avatar xinzhedeai

fix: 代码格式修改; 首页加载顺序代码重构promise

parent 504bc6ea
......@@ -453,3 +453,4 @@ border-right: 1px solid #eee; */
color: #333333;
line-height: 1.2;
}
......@@ -29,6 +29,8 @@
</script>
<script type="text/javascript" src="./home.js"></script>
<div id="app" class="page_wrapper" v-cloak>
<!-- 原有内容(数据加载完成后显示) -->
<div v-show="!isLoading">
<!-- 第二层:商户图标、名称、等级、场所类型和地址 -->
<div class="second-layer second-layer-zf" v-if="showOrg" v-cloak>
<!-- v-show="" -->
......@@ -113,24 +115,9 @@
<!-- 第一个提醒项:整改未通过 -->
<div class="reminder-item" v-for="item in remindStatistic" @click="navTo(`${item.name}`)">
<div class="reminder-badge" :class="`reminder-badge${item.icon}`">{{item.num}}</div>
<img :src="`./image/code/home/icon${item.icon}.png`" class="reminder-img" alt="整改未通过">
<img :src="`./image/code/home/icon${item.icon}.png`" class="reminder-img">
<p class="reminder-text">{{item.title}}</p>
</div>
<!-- <div class="reminder-item" @click="navTo('nopass')">
<div class="reminder-badge">3</div>
<img src="./image/code/home/icon1.png" class="reminder-img" alt="整改未通过">
<p class="reminder-text">整改未通过</p>
</div>
<div class="reminder-item" @click="navTo('willExpire')">
<div class="reminder-badge orange-badge">5</div>
<img src="./image/code/home/icon2.png" class="reminder-img" alt="整改未通过">
<p class="reminder-text">即将超期</p>
</div>
<div class="reminder-item" @click="navTo('expired')">
<div class="reminder-badge red-badge">2</div>
<img src="./image/code/home/icon3.png" class="reminder-img" alt="整改未通过">
<p class="reminder-text">整改超期</p>
</div> -->
</div>
<!-- 原第三层统计信息 -->
......@@ -151,6 +138,9 @@
</div>
</div>
</div>
</div>
</div>
</body>
......
......@@ -6,6 +6,7 @@ window.onload = function () {
el: '#app',
data() {
return {
isLoading: true, // 新增:加载状态标记
showPopup4completionDate: false,
// 控制日期选择器弹窗的显示与隐藏
showPicker: false,
......@@ -19,14 +20,13 @@ window.onload = function () {
// maxDate: new Date(new Date().getFullYear() + 10, 11),
maxDate: new Date(),
userInfo: {
userType: 'sj1', // 登录用户type
userType: 'consumers', // 登录用户type
userType: '', // 登录用户type
userId: '1', // 登录用户id
userName: '张三', // 登录用户name
userName: '', // 登录用户name
deptId: '1', // 登录用户部门id
deptName: '部门1', // 登录用户部门name
deptName: '', // 登录用户部门name
safeLevel: '0', //0:绿、1:黄、2:红
role: 'dudao',
role: '',
roleName: '',
},
showOrg: false, //是否显示组织
......@@ -41,8 +41,6 @@ window.onload = function () {
hiddenCount: 0, //隐患数
hiddenNoReCount: 0, //未整改数
},
page: 1, // 页码
size: 10, // 每页显示的数量
accessType: 'manage', // 访问类型 shop商家 saoma 扫码 manage 管理
remindStatistic: []
}
......@@ -156,11 +154,11 @@ window.onload = function () {
let url = gemhoUtil.setParameter(`src/_${stringifyUrl}.html`)
gemhoUtil.navigatePage(url, '跳转中...')
},
init() {
async init() {
// 在组件挂载后执行
// 调用你的方法
this.getUserInfo()
this.getUserData()
await this.getUserInfo();
await this.getStatisticData();
this.isLoading = false; // 数据加载完成后关闭加载状态
},
showPopup() {
this['showPopup4completionDate'] = true
......@@ -169,7 +167,7 @@ window.onload = function () {
this.selectedDate = gemhoUtil.getTargetDateYMByPara(value)
this.showDate = gemhoUtil.getTargetDateYMByPara(value)
this.showPopup4completionDate = false
this.getUserData()
this.getStatisticData()
},
// 格式化日期显示的函数,根据需要自定义
......@@ -186,37 +184,20 @@ window.onload = function () {
this.showPicker = false
},
getUserInfo() {
vant.Toast.loading({
message: '正在加载...',
forbidClick: true,
loadingType: 'spinner',
})
setTimeout(() => {
http2.post(
{
return new Promise((resolve) => {
http2.post({
serviceId: API_KEY_MAP['no-page']['id'],
interfacePublicKey: API_KEY_MAP['no-page']['publicKey'],
interfacePrivateKey: API_KEY_MAP['no-page']['privateKey'],
reqParams: {
sign: 9,
pageNum: this.page++, // 每次请求增加下一页
pageSize: this.size,
sort: 'lawId,desc',
},
},
(res) => {
console.log(JSON.parse(res), 'JSON.parse(res)')
if (!res) {
// 中台返回为undefined 重新请求
vant.Toast.clear()
setTimeout(() => {
this.getUserInfo()
}, 0)
return
}
if (res) {
var result = JSON.parse(res)
if (result.code !== 200 && result.data == null) {
console.log('getUserInfo=>code200datanull')
return
}
this.userInfo = {
......@@ -250,52 +231,35 @@ window.onload = function () {
console.log('菜单', result.data.modules)
// 生成最终菜单列表
this.menuList = result.data.modules
resolve();
}
setTimeout(() => {
this.$nextTick(() => {
vant.Toast.clear()
})
}, 0)
}
)
}, 0)
});
},
// 获取用户数据的方法
getUserData() {
vant.Toast.loading({
message: '正在加载...',
forbidClick: true,
loadingType: 'spinner',
})
setTimeout(() => {
http2.post(
{
getStatisticData() {
return new Promise((resolve) => {
http2.post({
serviceId: API_KEY_MAP['no-page']['id'],
interfacePublicKey: API_KEY_MAP['no-page']['publicKey'],
interfacePrivateKey: API_KEY_MAP['no-page']['privateKey'],
reqParams: {
sign: 6,
date: this.selectedDate,
merId: gemhoUtil.getParameter('merId'),
merId: gemhoUtil.getParameter('merId')|| '',
},
},
(res) => {
if (!res) {
// 中台返回为undefined 重新请求
vant.Toast.clear()
setTimeout(() => {
this.getUserData()
}, 0)
return
}
if (res) {
var result = JSON.parse(res)
console.log('用户Data')
this.userData = result.data
resolve();
}
}
)
}, 0)
},
});
}
},
//过滤器
filters: {
......
......@@ -21,15 +21,15 @@ window.onload = function () {
// 2025年5月30日08:45:33 添加消费者访问逻辑
console.log('userType', gemhoUtil.getCookie('userType') == 'consumers')
var url = ''
if(gemhoUtil.getCookie('userType') == 'consumers'){
if (gemhoUtil.getCookie('userType') == 'consumers') {
url = gemhoUtil.setParameter(`./src/_consumer_home.html`, param)
}else{ // 非消费者
} else { // 非消费者
url = gemhoUtil.setParameter(`./src/_shanghu_home.html`, param)
}
console.log('userType-url', url)
gemhoUtil.navigatePage(url, '跳转中...')
} else {
if(gemhoUtil.getCookie('userType') == 'consumers'){
if (gemhoUtil.getCookie('userType') == 'consumers') {
vant.Dialog.alert({
title: '信息提示',
message: '请扫描商户码访问~',
......@@ -39,7 +39,7 @@ window.onload = function () {
fail: function (data) { },
})
});
}else{
} else {
gemhoUtil.navigatePage('home.html', '跳转中...')
}
}
......@@ -126,9 +126,9 @@ function getUserInfo() {
// gemhoUtil.setCookie('userType', 'consumers') // 存储1天后过期
gemhoUtil.setCookie('userType', result.userType) // 存储1天后过期
if(gemhoUtil.getCookie('userType') == 'consumers'){
if (gemhoUtil.getCookie('userType') == 'consumers') {
let merId = gemhoUtil.getParameter('merId')
if(!merId){
if (!merId) {
vant.Dialog.alert({
title: '信息提示',
message: '请扫描商户码访问~',
......
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