125 lines
2.4 KiB
JavaScript
125 lines
2.4 KiB
JavaScript
// pages/mine/staff/shopstaff.js
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
curShopId: '',
|
|
shopStaffList: [],
|
|
currentPage: 1,
|
|
isCellOpen: false,
|
|
isRefreshing: false
|
|
},
|
|
onOpen() {
|
|
this.setData({
|
|
isCellOpen: true
|
|
})
|
|
},
|
|
onClose(event) {
|
|
let _self = this
|
|
const {
|
|
position,
|
|
instance
|
|
} = event.detail;
|
|
switch (position) {
|
|
case 'right':
|
|
case 'cell':
|
|
instance.close();
|
|
_self.setData({
|
|
isCellOpen: false
|
|
})
|
|
break;
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
curShopId: options.shopId
|
|
})
|
|
this.getStaffList(this.data.curShopId)
|
|
},
|
|
//获取店铺员工列表
|
|
getStaffList(id) {
|
|
let _self = this
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
app.http.get(app.urls.getStaffList.format({
|
|
shopId: id
|
|
}), {
|
|
header: {
|
|
token: app.globalData.token
|
|
}
|
|
})
|
|
.then(res => {
|
|
wx.hideLoading({})
|
|
_self.setData({
|
|
isRefreshing: false
|
|
})
|
|
_self.setData({
|
|
shopStaffList: res.data
|
|
})
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading({})
|
|
})
|
|
|
|
},
|
|
//审核员工
|
|
doVerify(e) {
|
|
|
|
},
|
|
//删除员工
|
|
doDelItem(e) {
|
|
let _self = this
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '确定要删除该职员吗?',
|
|
success(res) {
|
|
if (res.confirm) {
|
|
wx.showLoading({
|
|
title: '删除中...',
|
|
})
|
|
app.http.delete(app.urls.delStaff.format({
|
|
ids: e.currentTarget.dataset.key.staffId
|
|
}), {
|
|
header: {
|
|
token: app.globalData.token
|
|
}
|
|
})
|
|
.then(res => {
|
|
wx.hideLoading({})
|
|
wx.showToast({
|
|
title: '删除成功',
|
|
})
|
|
_self.dorefreshList()
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading({})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
showStaffDetail(e) {
|
|
if (!this.data.isCellOpen) {
|
|
console.log(e)
|
|
}
|
|
},
|
|
//修改员工信息
|
|
doEditItem(e) {
|
|
console.log(e)
|
|
},
|
|
|
|
dorefreshList() {
|
|
this.setData({
|
|
currentPage: 1,
|
|
isRefreshing: true
|
|
})
|
|
this.getStaffList(this.data.curShopId)
|
|
},
|
|
}) |