electricity_bill_calc_wx/pages/member/components/memberManage/index.js
2024-04-09 10:43:58 +08:00

71 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { approveUser, getApproveList, getUserInfo, removeUser } from "../../../../service/user"
import { alertInfo, alertSuccess, wxModal } from "../../../../utils/index";
import request from "../../../../utils/request"
const { OK } = request;
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
list: []
},
lifetimes: {
attached: function() {
// this.setData({
// list: []
// })
this.init();
}
},
/**
* 组件的方法列表
*/
methods: {
async init() {
const result = await getApproveList(1)
const { code, message, data } = result;
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({
list: data
})
},
async setAdmin(e) {
const { user, tenement } = e.currentTarget.dataset;
await wxModal({ content: `你的管理员身份将转交给${user.name}` })
const { code, message } = await approveUser({ userId: user.id, type: 2, tenement })
if (code !== OK) {
alertInfo(message)
return;
}
wx.switchTab({
url: '/pages/home/index',
})
alertSuccess("转交成功")
},
async remove(e) {
const { user, tenement } = e.currentTarget.dataset;
await wxModal({ content: `将移除${user.name}` })
const { code, message } = await removeUser(user.id, tenement)
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已移除")
this.init()
}
}
})