merge limo to daylight
This commit is contained in:
+155
-20
@@ -1,7 +1,35 @@
|
||||
<template>
|
||||
<view>
|
||||
<view>
|
||||
<mgmHeader ref="headerRef" />
|
||||
<!-- <mgmHeader ref="headerRef" :showNotification="true" /> -->
|
||||
<u-navbar
|
||||
:safeAreaInsetTop="true"
|
||||
:placeholder="true"
|
||||
:title="title"
|
||||
:fixed="true"
|
||||
:autoBack="false"
|
||||
leftIconColor="#C39A4B"
|
||||
bgColor="#C39A4B"
|
||||
titleStyle="font-weight:bold;color:#ffffff;"
|
||||
>
|
||||
<view
|
||||
@tap="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 @tap="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 v-if="showDashboardView">
|
||||
<view class="hz-font-bolder hz-font-l hz-font-color-black hz-text-right"
|
||||
style="margin-top:36rpx;margin-right:36rpx;">
|
||||
@@ -109,6 +137,9 @@
|
||||
import {
|
||||
logout
|
||||
} from '../../api/commonApi';
|
||||
import {
|
||||
countNotification
|
||||
} from '../../api/notificationApi';
|
||||
import {
|
||||
formatDate
|
||||
} from '../../common/stringUtils';
|
||||
@@ -124,6 +155,7 @@
|
||||
showMsg: false,
|
||||
okText: this.$t("common.ok"),
|
||||
dataNull:this.$t("common.dataNotFound"),
|
||||
title:'',
|
||||
userData: null,
|
||||
dashboardData: [],
|
||||
dataAsOf:"",
|
||||
@@ -132,10 +164,13 @@
|
||||
NFROValue: '0',
|
||||
IMValue: '0',
|
||||
MRIValue: '0',
|
||||
showAchievement: false,
|
||||
showKPI: false,
|
||||
showKPI:false,
|
||||
showAchievement:false,
|
||||
showDashboardView: false,
|
||||
userSegment: null
|
||||
userSegment: null,
|
||||
notificationCount: 0,
|
||||
notificationCountTimer: null,
|
||||
isDashboardActive: false
|
||||
}
|
||||
},
|
||||
onLoad(opt) {
|
||||
@@ -143,19 +178,84 @@
|
||||
this.initUI();
|
||||
},
|
||||
onShow() {
|
||||
this.isDashboardActive = true;
|
||||
this.playerData = uni.getStorageSync("playerData");
|
||||
this.getTodoDashboardByuserId();
|
||||
this.$nextTick(() => {
|
||||
const header = this.$refs.headerRef;
|
||||
if(header) {
|
||||
header.updateUserData();
|
||||
}
|
||||
});
|
||||
if (this.userData !== null && this.userData !== undefined)
|
||||
this.userData = uni.getStorageSync("userData");
|
||||
if (this.userData !== null && this.userData !== undefined){
|
||||
this.showTabbarByPermission(this.userData);
|
||||
this.title = this.userData.userName+','+this.userData.userId;
|
||||
}
|
||||
this.getTodoDashboardByuserId();
|
||||
this.fetchNotificationCount();
|
||||
this.stopNotificationCountTimer();
|
||||
this.startNotificationCountTimer();
|
||||
},
|
||||
|
||||
onHide() {
|
||||
this.isDashboardActive = false;
|
||||
this.stopNotificationCountTimer();
|
||||
},
|
||||
onUnload() {
|
||||
this.isDashboardActive = false;
|
||||
this.stopNotificationCountTimer();
|
||||
},
|
||||
|
||||
methods: {
|
||||
goNotification() {
|
||||
uni.navigateTo({
|
||||
url: '/limo/notification/notification'
|
||||
});
|
||||
},
|
||||
getUserIdFromUserData(userData) {
|
||||
if (userData == null || userData === '') {
|
||||
return '';
|
||||
}
|
||||
const userId = userData.userId != null && userData.userId !== ''
|
||||
? userData.userId
|
||||
: userData.UserId;
|
||||
return userId != null && userId !== '' ? userId : '';
|
||||
},
|
||||
parseNotificationCount(res) {
|
||||
if (res == null) {
|
||||
return 0;
|
||||
}
|
||||
const count = res.count ?? res.Count ?? res.data?.count ?? res.data?.Count;
|
||||
return Number(count) || 0;
|
||||
},
|
||||
async fetchNotificationCount() {
|
||||
this.userData = uni.getStorageSync('userData');
|
||||
const userId = this.getUserIdFromUserData(this.userData);
|
||||
if (!userId) {
|
||||
this.notificationCount = 0;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await countNotification({ userId });
|
||||
this.notificationCount = this.parseNotificationCount(res);
|
||||
console.log('[Dashboard] notification count res=', res, 'notificationCount=', this.notificationCount);
|
||||
} catch (error) {
|
||||
console.error('[Dashboard] countNotification failed', error);
|
||||
this.notificationCount = 0;
|
||||
}
|
||||
},
|
||||
startNotificationCountTimer() {
|
||||
if (!this.notificationCountTimer) {
|
||||
this.notificationCountTimer = setInterval(() => {
|
||||
if (this.isDashboardActive) {
|
||||
this.fetchNotificationCount();
|
||||
}
|
||||
}, 30000);
|
||||
}
|
||||
},
|
||||
stopNotificationCountTimer() {
|
||||
if (this.notificationCountTimer) {
|
||||
clearInterval(this.notificationCountTimer);
|
||||
this.notificationCountTimer = null;
|
||||
}
|
||||
},
|
||||
formatNumber(num) {
|
||||
return num?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") || "0";
|
||||
},
|
||||
normalizeDashboardRecord(record) {
|
||||
record = record || {};
|
||||
return {
|
||||
@@ -169,9 +269,6 @@
|
||||
userSegment: record.userSegment ?? record.UserSegment,
|
||||
};
|
||||
},
|
||||
formatNumber(num) {
|
||||
return num?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") || "0";
|
||||
},
|
||||
async getTodoDashboardByuserId() {
|
||||
uni.showLoading({
|
||||
title: this.$t("common.loading")
|
||||
@@ -181,10 +278,6 @@
|
||||
let params = {};
|
||||
requestBody = JSON.stringify(params);
|
||||
const res = await getTodoDashboard(params);
|
||||
this.dashboardData = [];
|
||||
this.dataAsOf = "";
|
||||
this.userSegment = null;
|
||||
this.MFValue = this.IMValue = this.NFROValue = this.MRIValue = "0";
|
||||
if (res.data != null && res.success == true) {
|
||||
const records = Array.isArray(res.data.records)
|
||||
? res.data.records
|
||||
@@ -194,6 +287,7 @@
|
||||
if (records.length > 0) {
|
||||
this.dashboardData = records.map((record) => this.normalizeDashboardRecord(record));
|
||||
this.showDashboardView = true;
|
||||
|
||||
// 设置用户类型
|
||||
this.userSegment = this.dashboardData[0].userSegment;
|
||||
this.hasTargetValue = this.dashboardData[0].targetValue !== null && this.dashboardData[0].targetValue !== undefined;
|
||||
@@ -258,7 +352,7 @@
|
||||
}else if(res.errorCode == 'INVOKE_TODODASHBOARD_API_ERROR'){
|
||||
this.dataNull = this.$t("todo.invokeError");
|
||||
}else {
|
||||
if(String(res.errorCode || res.code || '').toUpperCase().indexOf('NO RECORD') != -1){
|
||||
if(res.errorCode.toUpperCase().indexOf('NO RECORD') != -1){
|
||||
this.dataNull = this.$t("common.noRecord");
|
||||
}else{
|
||||
this.dataNull = this.$t("todo.returnError");
|
||||
@@ -282,6 +376,12 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
notificationBadgeText() {
|
||||
if (this.notificationCount > 99) {
|
||||
return '99+';
|
||||
}
|
||||
return String(this.notificationCount);
|
||||
},
|
||||
getShowAchievement() {
|
||||
return function(record) {
|
||||
if (record.type == "Achievement" && record.itemName !=="MF Turnover" && record.itemName !=="IM Turnover"
|
||||
@@ -375,4 +475,39 @@
|
||||
.im-text-gold {
|
||||
color: #cfa34f;
|
||||
}
|
||||
|
||||
.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>
|
||||
|
||||
Reference in New Issue
Block a user