功能:增加店长员工审核与登录提醒
This commit is contained in:
@@ -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' }) },
|
||||
|
||||
Reference in New Issue
Block a user