110 lines
2.2 KiB
JavaScript
110 lines
2.2 KiB
JavaScript
// pages/mine/manage/shopposition.js
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
positionList: [],
|
|
currentPage: 1,
|
|
curShopId: '',
|
|
isAddSuccess: false,
|
|
isRefreshing: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
curShopId: options.shopId
|
|
})
|
|
this.getPositionList(options.shopId)
|
|
},
|
|
getPositionList(id) {
|
|
let _self = this
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
app.http.get(app.urls.getPositionList, {
|
|
header: {
|
|
token: app.globalData.token
|
|
},
|
|
data: {
|
|
page: _self.data.currentPage
|
|
}
|
|
})
|
|
.then(res => {
|
|
wx.hideLoading({})
|
|
_self.setData({
|
|
isRefreshing: false
|
|
})
|
|
_self.setData({
|
|
positionList: res.data
|
|
})
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading({})
|
|
})
|
|
},
|
|
toAddPosition() {
|
|
wx.navigateTo({
|
|
url: './addposition?shopId=' + this.data.curShopId,
|
|
})
|
|
},
|
|
doDelPositon(e) {
|
|
let _self = this
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '确定要删除该职位吗?',
|
|
success(res) {
|
|
if (res.confirm) {
|
|
wx.showLoading({
|
|
title: '删除中...',
|
|
})
|
|
app.http.delete(app.urls.doDelPositon.format({
|
|
ids: e.currentTarget.dataset.item.positionId
|
|
}), {
|
|
header: {
|
|
token: app.globalData.token
|
|
}
|
|
})
|
|
.then(res => {
|
|
wx.hideLoading({})
|
|
wx.showToast({
|
|
title: '删除成功',
|
|
})
|
|
_self.dorefreshList()
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading({})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
//刷新页面
|
|
dorefreshList() {
|
|
this.setData({
|
|
currentPage: 1,
|
|
isRefreshing: true
|
|
})
|
|
this.getPositionList(this.data.curShopId)
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
let _self = this
|
|
if (_self.data.isAddSuccess) {
|
|
_self.setData({
|
|
isAddSuccess: false
|
|
})
|
|
//刷新页面
|
|
this.dorefreshList()
|
|
}
|
|
},
|
|
|
|
}) |