This commit is contained in:
@@ -31,7 +31,15 @@ Page({
|
||||
reviewPendingCount: 0,
|
||||
reviewLoading: false,
|
||||
reviewError: '',
|
||||
reviewingId: ''
|
||||
reviewingId: '',
|
||||
associationSheetVisible: false,
|
||||
associationLoading: false,
|
||||
associationError: '',
|
||||
associationApplicationId: '',
|
||||
associationArtists: [],
|
||||
associationItems: [],
|
||||
associationKeyword: '',
|
||||
associationSelectedId: ''
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -73,7 +81,7 @@ Page({
|
||||
const data = await employeesApi.reviewApplications()
|
||||
const applications = (Array.isArray(data) ? data : []).map(item => ({
|
||||
...item,
|
||||
applicantNickname: item.applicantNickname || '待审核美甲师',
|
||||
applicantDisplayName: item.applicantNickname || '待审核美甲师',
|
||||
applicantAvatar: item.applicantAvatar || '',
|
||||
applicantMaskedPhone: item.applicantMaskedPhone || '',
|
||||
applicationTimeText: formatApplicationTime(item.createTime)
|
||||
@@ -88,10 +96,124 @@ Page({
|
||||
|
||||
async approveApplication(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id || this.data.reviewingId) return
|
||||
const result = await confirmModal({ title: '通过美甲师申请', content: '确认允许该美甲师加入当前门店吗?' })
|
||||
if (!result.confirm) return
|
||||
await this.submitReview(id, () => employeesApi.approveApplication(id), '申请已通过')
|
||||
if (!id || this.data.reviewingId || this.data.associationLoading) return
|
||||
this.setData({
|
||||
associationApplicationId: String(id),
|
||||
associationKeyword: '',
|
||||
associationSelectedId: '',
|
||||
associationSheetVisible: true
|
||||
})
|
||||
await this.loadApprovalArtists()
|
||||
},
|
||||
|
||||
async loadApprovalArtists() {
|
||||
const applicationId = this.data.associationApplicationId
|
||||
if (!applicationId || this.data.associationLoading) return
|
||||
this.setData({ associationLoading: true, associationError: '' })
|
||||
try {
|
||||
const application = this.data.reviewApplications.find(item => String(item.id) === String(applicationId))
|
||||
const data = await employeesApi.unboundArtists(applicationId)
|
||||
const artists = (Array.isArray(data) ? data : []).map(item => ({
|
||||
id: item.userId || item.id,
|
||||
name: item.nickname || item.name || '未命名美甲师',
|
||||
avatar: item.avatar || ''
|
||||
}))
|
||||
const selectedId = application && application.targetArtistUserId
|
||||
? String(application.targetArtistUserId)
|
||||
: ''
|
||||
this.setData({
|
||||
associationArtists: artists,
|
||||
associationSelectedId: selectedId,
|
||||
associationItems: this.filterApprovalArtists(artists, this.data.associationKeyword)
|
||||
})
|
||||
if (!artists.length) {
|
||||
this.setData({ associationSheetVisible: false })
|
||||
await confirmModal({
|
||||
title: '暂时无法通过',
|
||||
content: '当前门店没有未关联微信的美甲师档案,请先新增美甲师,再审核这条申请。',
|
||||
confirmText: '知道了',
|
||||
showCancel: false
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
this.setData({ associationError: error.message || '未关联美甲师加载失败' })
|
||||
} finally {
|
||||
this.setData({ associationLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
filterApprovalArtists(artists, keywordValue) {
|
||||
const keyword = String(keywordValue || '').trim().toLowerCase()
|
||||
return (artists || [])
|
||||
.filter(item => !keyword || String(item.name || '').toLowerCase().includes(keyword))
|
||||
.map(item => ({
|
||||
id: item.id,
|
||||
title: item.name,
|
||||
subtitle: '当前门店 · 尚未关联微信登录',
|
||||
avatar: item.avatar,
|
||||
badge: '可关联'
|
||||
}))
|
||||
},
|
||||
|
||||
onApprovalSearch(event) {
|
||||
const associationKeyword = event.detail.value || ''
|
||||
this.setData({
|
||||
associationKeyword,
|
||||
associationItems: this.filterApprovalArtists(this.data.associationArtists, associationKeyword)
|
||||
})
|
||||
},
|
||||
|
||||
closeApprovalAssociation() {
|
||||
if (this.data.associationLoading || this.data.reviewingId) return
|
||||
this.setData({ associationSheetVisible: false })
|
||||
},
|
||||
|
||||
async selectApprovalArtist(event) {
|
||||
const artist = event.detail && event.detail.item
|
||||
const applicationId = this.data.associationApplicationId
|
||||
const application = this.data.reviewApplications.find(item => String(item.id) === String(applicationId))
|
||||
if (!artist || !application || this.data.reviewingId) return
|
||||
this.setData({ associationSelectedId: String(artist.id) })
|
||||
},
|
||||
|
||||
async confirmApprovalAssociation() {
|
||||
const applicationId = this.data.associationApplicationId
|
||||
const application = this.data.reviewApplications.find(item => String(item.id) === String(applicationId))
|
||||
const artist = this.data.associationArtists.find(item => String(item.id) === String(this.data.associationSelectedId))
|
||||
if (!artist || !application || this.data.reviewingId) {
|
||||
wx.showToast({ title: '请选择要关联的美甲师', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const useApplicantNickname = application.applicantNickname
|
||||
? await this.askProfileAdoption('昵称', application.applicantNickname)
|
||||
: false
|
||||
const useApplicantAvatar = application.applicantAvatar
|
||||
? await this.askProfileAdoption('头像', '已通过内容审核的申请头像')
|
||||
: false
|
||||
const summary = [
|
||||
`关联到:${artist.name || '所选美甲师'}`,
|
||||
useApplicantNickname ? '采用申请昵称' : '保留门店姓名',
|
||||
useApplicantAvatar ? '采用申请头像' : '保留门店头像'
|
||||
].join('\n')
|
||||
const confirmed = await confirmModal({ title: '确认关联并通过', content: summary, confirmText: '确认通过' })
|
||||
if (!confirmed.confirm) return
|
||||
|
||||
this.setData({ associationSheetVisible: false })
|
||||
await this.submitReview(applicationId, () => employeesApi.approveApplication(applicationId, {
|
||||
targetArtistUserId: artist.id,
|
||||
useApplicantNickname,
|
||||
useApplicantAvatar
|
||||
}), '申请已通过')
|
||||
},
|
||||
|
||||
askProfileAdoption(field, value) {
|
||||
return confirmModal({
|
||||
title: `采用申请${field}?`,
|
||||
content: field === '昵称' ? `申请昵称为“${value}”,采用后会替换门店员工姓名。` : '采用后会替换门店员工当前头像。',
|
||||
confirmText: `采用申请${field}`,
|
||||
cancelText: `保留门店${field}`
|
||||
}).then(result => Boolean(result.confirm))
|
||||
},
|
||||
|
||||
async rejectApplication(event) {
|
||||
|
||||
Reference in New Issue
Block a user