Files
oil-client-wechat/pages/userManagement/userManagement.js
2025-12-19 11:20:59 +08:00

173 lines
3.8 KiB
JavaScript

const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
current: 1,
size: 10,
nvabarData: {
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
title: "站员管理", //导航栏 中间的标题
},
stationName: "",
list: [],
// 此页面 页面内容距最顶部的距离
height: app.globalData.height * 2 + 20,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getUserPage();
const company = wx.getStorageSync("cooperation").company;
this.setData({
stationName: company,
});
},
getUserPage: function () {
var that = this;
wx.request({
url:
app.globalData.devUrl +
`/zx/user/page/${wx.getStorageSync("cooperation").id}`,
method: `GET`,
header: {
"content-type": "application/x-www-form-urlencoded",
},
success: function (res) {
if (res.data.code == "0000") {
that.setData({
list: res.data.data,
});
} else {
wx.showModal({
title: "提示",
content: res.data.msg,
showCancel: false,
});
}
wx.stopPullDownRefresh()
},
error: function () {
console.log(res);
},
fail: function (data) {
wx.showModal({
title: "提示",
content: "网络传输异常",
showCancel: false,
});
},
});
},
editBtn(e) {
const { user } = e.currentTarget.dataset;
var queryBean = JSON.stringify(user);
wx.navigateTo({
url: "../updateUser/updateUser?queryBean=" + queryBean,
});
},
createBtnHandle() {
wx.navigateTo({
url: "../updateUser/updateUser?queryBean=0",
});
},
deleteBtnHandle(params) {
const that = this;
wx.request({
url: app.globalData.devUrl + `/zx/user/create-or-update/user`,
method: `post`,
header: {
"content-type": "application/x-www-form-urlencoded",
},
data: {
...params,
},
success: function (res) {
if (res.data.code == "0000") {
wx.showModal({
title: "提示",
content: "操作成功",
showCancel: false,
});
that.getUserPage();
}
},
error: function () {
console.log(res);
},
fail: function (data) {
wx.showModal({
title: "提示",
content: "网络传输异常",
showCancel: false,
});
},
});
},
deleteBtn(e) {
const that = this;
wx.showModal({
title: "提示",
content: "你确定删除该用户?",
success(res) {
if (res.confirm) {
console.log("用户点击确定");
const { user } = e.currentTarget.dataset;
let params = {};
params.id = user.id;
params.cooId = wx.getStorageSync("cooperation").id;
params.parentUserId = wx.getStorageSync("cooperation").userId;
params.name = user.name;
params.phone = user.phone;
params.deleteFlag = 1;
params.userType = 1;
that.deleteBtnHandle(params);
}
},
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getUserPage();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.getUserPage();
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});