merge limo to daylight

This commit is contained in:
Mauve
2026-09-22 16:37:00 +08:00
parent 0c92868836
commit a7359d443b
73 changed files with 11614 additions and 1040 deletions
+224 -84
View File
@@ -1,5 +1,6 @@
<template>
<view>
<u-navbar
:safeAreaInsetTop="true"
:placeholder="true"
@@ -10,31 +11,33 @@
bgColor="#C39A4B"
titleStyle="font-weight:bold;color:#ffffff;"
>
<view
@click="logout"
style="margin-top:2px;margin-right:3px;"
slot="right"
>
<image src="/static/images/ico_exit.png" style="width:24px;height:24px;"></image>
</view>
<view
v-show="canViewApproval"
@click="toNotification"
style="margin-top:2px;margin-right:3px; position: relative"
slot="left"
>
<image src="/static/images/160task01.png" style="width:24px;height:24px;"/>
<u-badge :value="countAp" type="error" :offset="[-8, -8]" :show="countAp > 0" :absolute="true"></u-badge>
<view
v-if="showNotificationBell"
@click="goNotification"
class="notification-bell-wrap"
slot="left"
>
<u-icon name="bell" color="#FFFFFF" size="24"></u-icon>
<view v-if="notificationCount > 0" class="notification-badge">
<text class="notification-badge-text">{{ notificationBadgeText }}</text>
</view>
</view>
<view @click="logout"
style="margin-top:2px;margin-right:3px;"
slot="right"
>
<image src="../../static/images/ico_exit.png" style="width:24px;height:24px;"></image>
</view>
</u-navbar>
<view class="hz-text-center" style="margin-top:120rpx;">
<image src="../../static/images/room_book.png" style="width:128rpx;height:128rpx;"></image>
<image src="/static/images/limo.png" class="mr-[40]" style="width: 58px; height: 58px;"></image>
<image src="/static/images/room_book.png" class="find-player-ico"></image>
</view>
<view class="hz-font-bolder hz-font-xl hz-text-center hz-font-color-primary">
{{$t('hotel.roombooking')}}
</view>
<view class="hz-font-bolder hz-font-xl hz-text-center hz-font-color-dark" style="margin-top:160rpx;">
<view class="hz-font-bolder hz-font-xl hz-text-center hz-font-color-dark mt-[160]">
{{$t('findPlayer.title')}}
</view>
<view style="margin-top:30rpx;margin-right:60rpx;margin-left:60rpx;">
@@ -58,7 +61,8 @@
<script>
import { getApprovalCount } from '../../api/approvalApi.js';
import {playerLookup} from '../../api/mgmApi.js'
import {playerLookup} from '../../api/mgmApi.js'
import { countNotification } from '../../api/notificationApi.js'
import mgmHeader from '@/components/header/header.vue'
@@ -67,25 +71,30 @@ import {playerLookup} from '../../api/mgmApi.js'
mgmHeader // 注册组件
},
data() {
return {
// 数据变量
playerIdStr: this.$t("common.playerId"),
searchPlayerId: '',
userData:null,
deviceData:null,
siteData:null,
countAp: '',
// 定时器变量
approvalCountTimer: null,
// 页面激活态(避免残留定时器回调在非当前页继续请求)
isFindPlayerActive: false,
// 界面变量
showMsg:false,
title: '',
msgStr:'',
yesText:this.$t("common.ok"),
canViewApproval:false
}
return {
// 数据变量
playerIdStr: this.$t("common.playerId"),
searchPlayerId: '',
userData:null,
deviceData:null,
siteData:null,
// 界面变量
showMsg:false,
title: '',
msgStr:'',
yesText:this.$t("common.ok"),
notificationCount: 0,
approvalRoutingCount: 0,
limoNotificationCount: 0,
countAp: '',
// 定时器变量
approvalCountTimer: null,
notificationCountTimer: null,
// 页面激活态(避免残留定时器回调在非当前页继续请求)
isFindPlayerActive: false,
canViewApproval:false
}
},
onLoad() {
// 初始化界面
@@ -95,56 +104,133 @@ import {playerLookup} from '../../api/mgmApi.js'
},
onShow() {
this.isFindPlayerActive = true;
this.getApporvalCount();
// this.getApporvalCount();
this.userData = uni.getStorageSync("userData");
this.searchPlayerId = '';
this.playerIdStr=this.$t("common.playerId");
if(this.userData!==null && this.userData!==undefined){
this.title = this.userData.userName+','+this.userData.userId;
this.showTabbarByPermission(this.userData);
const realUserData = this.getEffectiveUserData(this.userData);
this.showTabbarByPermission(realUserData);
this.title = realUserData.userName+','+realUserData.userId;
}
this.isLogin();
this.$nextTick(() => {
const header = this.$refs.headerRef;
if(header) {
header.updateUserData();
}
});
this.fetchNotificationCount();
// 切回页面时,先停后启,避免存在残留定时器
this.stopApprovalCountTimer();
this.startApprovalCountTimer();
if(this.userData.canViewApproval!==undefined && this.userData.canViewApproval==true) this.canViewApproval = true;
this.stopNotificationCountTimer();
this.startNotificationCountTimer();
this.canViewApproval = this.effectiveUserData.canViewApproval === true;
},
onHide() {
this.isFindPlayerActive = false;
// 切到其他页面时立即停止定时器,避免后台持续调用
this.stopApprovalCountTimer();
// this.stopApprovalCountTimer();
this.stopNotificationCountTimer();
},
onUnload() {
this.isFindPlayerActive = false;
// 页面销毁时兜底清理
this.stopApprovalCountTimer();
// this.stopApprovalCountTimer();
this.stopNotificationCountTimer();
},
onReady(){
},
methods: {
startApprovalCountTimer() {
if (!this.approvalCountTimer) {
this.approvalCountTimer = setInterval(() => {
// 双保险:非当前页不请求
getEffectiveUserData(userData) {
if (userData && userData.data && typeof userData.data === 'object') {
return userData.data;
}
return userData || {};
},
goNotification() {
const url = this.buildNotificationUrl();
uni.navigateTo({
url
});
},
buildNotificationUrl(extraParams = []) {
const params = extraParams.slice();
if (this.effectiveUserData.canViewNotification === true) {
params.push('notificationCount=' + encodeURIComponent(this.limoNotificationCount));
}
if (this.effectiveUserData.canViewApproval === true) {
params.push('approvalRoutingCount=' + encodeURIComponent(this.approvalRoutingCount));
}
return params.length
? '/limo/notification/notification?' + params.join('&')
: '/limo/notification/notification';
},
getUserIdFromUserData(userData) {
const realUserData = this.getEffectiveUserData(userData);
if (userData == null || userData === '') {
return '';
}
const userId = realUserData.userId != null && realUserData.userId !== ''
? realUserData.userId
: realUserData.UserId;
return userId != null && userId !== '' ? userId : '';
},
parseNotificationCounts(res) {
const data = res && res.data && typeof res.data === 'object' ? res.data : (res || {});
return {
count: Number(data.count ?? data.Count) || 0,
notificationCount: Number(data.notificationCount ?? data.NotificationCount) || 0,
approvalRoutingCount: Number(data.approvalRoutingCount ?? data.ApprovalRoutingCount) || 0,
};
},
async fetchNotificationCount() {
this.userData = uni.getStorageSync('userData');
const userId = this.getUserIdFromUserData(this.userData);
if (!userId) {
this.notificationCount = 0;
this.limoNotificationCount = 0;
this.approvalRoutingCount = 0;
return;
}
try {
const res = await countNotification({ userId });
const counts = this.parseNotificationCounts(res);
this.notificationCount = counts.count;
this.limoNotificationCount = counts.notificationCount;
this.approvalRoutingCount = counts.approvalRoutingCount;
} catch (error) {
console.error('[FindPlayer] countNotification failed', error);
this.notificationCount = 0;
this.limoNotificationCount = 0;
this.approvalRoutingCount = 0;
}
},
startNotificationCountTimer() {
if (!this.notificationCountTimer) {
this.notificationCountTimer = setInterval(() => {
if (this.isFindPlayerActive) {
this.getApporvalCount();
this.fetchNotificationCount();
}
}, 30000); // 30秒
}, 30000);
}
},
stopApprovalCountTimer() {
if (this.approvalCountTimer) {
clearInterval(this.approvalCountTimer);
this.approvalCountTimer = null;
stopNotificationCountTimer() {
if (this.notificationCountTimer) {
clearInterval(this.notificationCountTimer);
this.notificationCountTimer = null;
}
},
// startApprovalCountTimer() {
// if (!this.approvalCountTimer) {
// this.approvalCountTimer = setInterval(() => {
// // 双保险:非当前页不请求
// if (this.isFindPlayerActive) {
// // this.getApporvalCount();
// }
// }, 30000); // 30秒
// }
// },
// stopApprovalCountTimer() {
// if (this.approvalCountTimer) {
// clearInterval(this.approvalCountTimer);
// this.approvalCountTimer = null;
// }
// },
// 数据方法
async getProfileByPlayerId(){
if(!this.searchPlayerId){
@@ -155,7 +241,7 @@ import {playerLookup} from '../../api/mgmApi.js'
title: this.$t("common.loading")
});
try{
let params = {playerId:this.searchPlayerId,userId:this.userData.userId};
let params = {playerId:this.searchPlayerId,userId:this.effectiveUserData.userId};
const res = await playerLookup(params);
if(res.success == true){
if(res.data !== null){
@@ -177,38 +263,39 @@ import {playerLookup} from '../../api/mgmApi.js'
uni.$u.toast(e.errMsg,5000);
var request = e.config!=undefined?JSON.stringify(e.config):"";
var response = e.data!=undefined?JSON.stringify(e.data):"";
await this.writeLog(this.userData.userId,"find_player","","[APP][findPlayer.vue][getProfileByPlayerId][Catch Exception]"+e.errMsg,request,response,1,false);
}finally{
uni.hideLoading();
}
},
async getApporvalCount(){
if (!this.isFindPlayerActive) return;
try{
let params = {};
const res = await getApprovalCount(params);
if(res.success == true){
if(res.data !== null){
this.countAp = res.data;
}
}
}catch(e){
console.error(e);
uni.$u.toast(e.errMsg,5000);
var request = e.config!=undefined?JSON.stringify(e.config):"";
var response = e.data!=undefined?JSON.stringify(e.data):"";
await this.writeLog(this.userData.userId,"find_player","","[APP][findPlayer.vue][getProfileByPlayerId][Catch Exception]"+e.errMsg,request,response,1,false);
await this.writeLog(this.effectiveUserData.userId,"find_player","","[APP][findPlayer.vue][getProfileByPlayerId][Catch Exception]"+e.errMsg,request,response,1,false);
}finally{
uni.hideLoading();
}
},
// async getApporvalCount(){
// if (!this.isFindPlayerActive) return;
// try{
// let params = {};
// const res = await getApprovalCount(params);
// if(res.success == true){
// if(res.data !== null){
// this.countAp = res.data;
// }
// }
// }catch(e){
// console.error(e);
// uni.$u.toast(e.errMsg,5000);
// var request = e.config!=undefined?JSON.stringify(e.config):"";
// var response = e.data!=undefined?JSON.stringify(e.data):"";
// await this.writeLog(this.effectiveUserData.userId,"find_player","","[APP][findPlayer.vue][getProfileByPlayerId][Catch Exception]"+e.errMsg,request,response,1,false);
// }finally{
// uni.hideLoading();
// }
// },
// 界面方法
confirmMsg(){
this.msgStr = '';
this.showMsg = false;
},
toNotification(){
this.navTo("/pages/notification/notification",0,false)
this.navTo(this.buildNotificationUrl(['tab=1']),0,false)
},
clearSearchInput(){
this.searchPlayerId = '';
@@ -222,6 +309,24 @@ import {playerLookup} from '../../api/mgmApi.js'
wv.show();
},
},
computed: {
effectiveUserData() {
return this.getEffectiveUserData(this.userData);
},
showNotificationBell() {
return !!(
this.effectiveUserData &&
(this.effectiveUserData.canViewApproval === true ||
this.effectiveUserData.canViewNotification === true)
);
},
notificationBadgeText() {
if (this.notificationCount > 99) {
return '99+';
}
return String(this.notificationCount);
}
}
}
</script>
@@ -232,4 +337,39 @@ import {playerLookup} from '../../api/mgmApi.js'
border-style: solid;
height:30px;
}
.notification-bell-wrap {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
margin-top: 2px;
margin-left: 3px;
width: 24px;
height: 24px;
overflow: visible;
}
.notification-badge {
position: absolute;
top: -4px;
right: -5px;
min-width: 16px;
height: 16px;
padding: 0 4px;
border-radius: 8px;
background-color: #fa3534;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
z-index: 10;
}
.notification-badge-text {
color: #ffffff;
font-size: 10px;
line-height: 1;
font-weight: bold;
}
</style>