功能:增加店长员工审核与登录提醒

This commit is contained in:
2026-10-12 16:45:42 +08:00
parent 247472fcae
commit e4aff0803a
23 changed files with 769 additions and 24 deletions
+36 -1
View File
@@ -5,6 +5,7 @@ const auth = require('../../utils/auth')
const { uploadProfileImage } = require('../../utils/upload')
const { normalizeAvatar } = require('../../utils/profile-card')
const profileCache = require('../../utils/profile-cache')
const employeesApi = require('../../api/employees')
function canCreateAppointment() {
const app = getApp()
@@ -110,6 +111,7 @@ Page({
},
async refreshAccountPrompts() {
let shouldShowProfilePrompt = false
try {
const profile = await profileCache.getProfile()
const session = auth.getSession()
@@ -119,14 +121,47 @@ Page({
const missingNickname = !String(profile.nickname || '').trim() || String(profile.nickname).startsWith('微信用户')
const avatar = normalizeAvatar(profile.avatar)
const skipped = wx.getStorageSync(auth.PROFILE_PROMPT_SKIPPED_KEY) === '1'
shouldShowProfilePrompt = !skipped && (missingNickname || !avatar)
this.setData({
phoneBannerVisible: Number(profile.phoneVerified) !== 1 && dismissed !== today,
profilePromptVisible: !skipped && (missingNickname || !avatar),
profilePromptVisible: false,
profileForm: { nickname: missingNickname ? '' : profile.nickname, avatar }
})
} catch (error) {
// 资料提醒失败不影响规划数据。
}
const navigatedToReview = await this.showEmployeeReviewNotice()
if (!navigatedToReview) {
this.setData({ profilePromptVisible: shouldShowProfilePrompt })
}
},
async showEmployeeReviewNotice() {
const app = getApp()
const userInfo = app.globalData.userInfo || {}
if (Number(userInfo.type) !== 2 || app.globalData.reviewNoticeShown) return false
let summary
try {
summary = await employeesApi.reviewSummary()
} catch (error) {
return false
}
if (!summary.noticeEnabled || Number(summary.pendingCount || 0) <= 0) return false
app.globalData.reviewNoticeShown = true
const result = await new Promise(resolve => {
wx.showModal({
title: '有员工申请待审核',
content: `当前有 ${summary.pendingCount} 条员工加入申请,是否立即处理?`,
cancelText: '稍后处理',
confirmText: '立即审核',
success: resolve,
fail: () => resolve({ confirm: false })
})
})
if (!result.confirm) return false
app.globalData.openEmployeeReview = true
wx.switchTab({ url: '/pages/employees/index' })
return true
},
openAccountSettings() { wx.navigateTo({ url: '/pages/account-settings/index' }) },
+18 -2
View File
@@ -7,9 +7,12 @@ global.wx = {
getStorageSync: () => '',
setStorageSync: () => {},
removeStorageSync: () => {},
showToast: () => {}
showToast: () => {},
showModal: ({ success }) => success({ confirm: false }),
switchTab: () => {}
}
global.getApp = () => ({ globalData: { userInfo: {} } })
const appMock = { globalData: { userInfo: {} } }
global.getApp = () => appMock
let definition
global.Page = value => { definition = value }
@@ -69,6 +72,19 @@ async function run() {
assert.strictEqual(calendarRequests, 1)
resolveCalendar({ artists: [], appointments: [], daySummaries: [] })
await Promise.all([requestOne, requestTwo])
const employeesApi = require('../../api/employees')
const noticePage = createPage()
appMock.globalData.userInfo = { type: 2 }
appMock.globalData.reviewNoticeShown = false
employeesApi.reviewSummary = async () => ({ pendingCount: 2, noticeEnabled: true })
let switched = false
global.wx.showModal = ({ success }) => success({ confirm: true })
global.wx.switchTab = ({ url }) => { switched = url === '/pages/employees/index' }
assert.strictEqual(await noticePage.showEmployeeReviewNotice(), true)
assert.strictEqual(switched, true)
assert.strictEqual(appMock.globalData.reviewNoticeShown, true)
assert.strictEqual(appMock.globalData.openEmployeeReview, true)
}
run().catch(error => {