|
@@ -10,6 +10,15 @@ Page({
|
|
frameStyle: { useTop: true, name: '用户管理', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '用户管理', leftArrow: true, useBar: false },
|
|
// 主体高度
|
|
// 主体高度
|
|
infoHeight: '',
|
|
infoHeight: '',
|
|
|
|
+ // 选项卡
|
|
|
|
+ tabs: {
|
|
|
|
+ active: 'a',
|
|
|
|
+ list: [
|
|
|
|
+ { title: '管理员', name: 'a' },
|
|
|
|
+ { title: '团队创建人', name: 'b' },
|
|
|
|
+ { title: '个人用户', name: 'c' },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
list: [],
|
|
list: [],
|
|
// 弹框
|
|
// 弹框
|
|
dialog: { title: '详细信息', show: false, type: '1' },
|
|
dialog: { title: '详细信息', show: false, type: '1' },
|
|
@@ -25,6 +34,12 @@ Page({
|
|
back: function () {
|
|
back: function () {
|
|
wx.navigateBack({ url: '/pages/me/index' })
|
|
wx.navigateBack({ url: '/pages/me/index' })
|
|
},
|
|
},
|
|
|
|
+ // 选项卡
|
|
|
|
+ tabsChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'tabs.active': e.detail.name })
|
|
|
|
+ that.watchLogin()
|
|
|
|
+ },
|
|
// 添加用户
|
|
// 添加用户
|
|
toAdd: function () {
|
|
toAdd: function () {
|
|
wx.navigateTo({ url: `/pages/user/detail` })
|
|
wx.navigateTo({ url: `/pages/user/detail` })
|
|
@@ -58,12 +73,22 @@ Page({
|
|
// 删除
|
|
// 删除
|
|
toDel: async function (e) {
|
|
toDel: async function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
- let { id } = e.currentTarget.dataset;
|
|
|
|
- const arr = await app.$delete(`/courtAdmin/api/user/${id}`);
|
|
|
|
- if (arr.errcode == '0') {
|
|
|
|
- wx.showToast({ title: `删除信息成功`, icon: 'error', duration: 2000 });
|
|
|
|
- that.watchLogin();
|
|
|
|
- }
|
|
|
|
|
|
+ const { id } = e.currentTarget.dataset;
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '是否确认删除该条数据?',
|
|
|
|
+ async success(res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ const arr = await app.$delete(`/courtAdmin/api/user/${id}`);
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
|
|
|
|
+ that.watchLogin()
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
// 选择状态
|
|
// 选择状态
|
|
statusChange: function (e) {
|
|
statusChange: function (e) {
|
|
@@ -107,11 +132,15 @@ Page({
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: function () {
|
|
watchLogin: function () {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ let active = that.data.tabs.active;
|
|
|
|
+ let type = active == 'a' ? '0' : active == 'b' ? '1' : '2';
|
|
wx.getStorage({
|
|
wx.getStorage({
|
|
key: 'token',
|
|
key: 'token',
|
|
success: async res => {
|
|
success: async res => {
|
|
- const arr = await app.$get(`/courtAdmin/api/user`);
|
|
|
|
- if (arr.errcode == '0') this.setData({ list: arr.data })
|
|
|
|
|
|
+ const arr = await app.$get(`/courtAdmin/api/user`, { type: type });
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ that.setData({ list: arr.data })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
fail: res => {
|
|
fail: res => {
|
|
wx.redirectTo({ url: '/pages/login/index', })
|
|
wx.redirectTo({ url: '/pages/login/index', })
|