Commit fe84681d authored by xinzhedeai's avatar xinzhedeai

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

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