electricity_bill_calc_wx/pages/member/components/approveMember/index.js
2024-03-21 09:38:10 +08:00

63 lines
1.4 KiB
JavaScript

import { approveUser, getApproveList } 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()
this.setData({
list: result.data
})
},
async agree(e) {
const { user } = e.currentTarget.dataset;
await wxModal({ content: `同意${user.nickName}的申请?` })
const { code, message } = await approveUser({ userId: user.id, type: 1 })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已同意")
this.init()
},
async disAgree(e) {
const { user } = e.currentTarget.dataset;
await wxModal({ content: `拒绝${user.nickName}的申请?` })
const { code, message } = await approveUser({ userId: user.id, type: 0 })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已拒绝")
this.init()
}
}
})