重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* Purpose: artistApi supports index.js by holding or executing the artist api page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const artistApi = require('../../api/nail-artist')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
canCreate: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入美甲师管理')) {
|
||||
return
|
||||
}
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('user:create') || permissionCodes.includes('nail_artist:edit')
|
||||
})
|
||||
this.loadArtists()
|
||||
},
|
||||
|
||||
async loadArtists() {
|
||||
try {
|
||||
const list = await artistApi.listNailArtists()
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
list: (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status text page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
displayStatusText: Number(item.status) === 0 ? '休息中' : '营业中'
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
/**
|
||||
* Purpose: title supports index.js by holding or executing the title page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
title: error.message || '美甲师列表加载失败',
|
||||
/**
|
||||
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle create page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentArtist')
|
||||
navigation.navigate('/pages/artist-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
mode: 'create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const artist = event.currentTarget.dataset.artist
|
||||
setTempRecord('currentArtist', artist)
|
||||
navigation.navigate('/pages/artist-form/index', {
|
||||
/**
|
||||
* Purpose: mode supports index.js by holding or executing the mode page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
mode: 'edit',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user id page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
userId: artist.userId
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user