import {getUserList,getUserInfo,createUser,verifyUserInfo,getUser,
  upUserStatus,updateUser,resetPassword
} from '@/api/userMember'

const state = {

}

const mutations = {

}

const actions = {
  //1.用户管理 start ---------------------------------------->
  //获取用户列表
  getUserList({commit},data) {
    return new Promise((resolve, reject) => {
      getUserList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取用户信息
  getUserInfo({commit},data) {
    return new Promise((resolve, reject) => {
      getUserInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //创建用户
  createUser({commit},data) {
    return new Promise((resolve, reject) => {
      createUser(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //验证用户是否存在
  verifyUserInfo({commit},data) {
    return new Promise((resolve, reject) => {
      verifyUserInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //获取用户信息
  getUser({commit},data) {
    return new Promise((resolve, reject) => {
      getUser(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //修改用户账号状态
  upUserStatus({commit},data) {
    return new Promise((resolve, reject) => {
      upUserStatus(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //修改用户信息
  updateUser({commit},data) {
    return new Promise((resolve, reject) => {
      updateUser(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //修改用户密码
  resetPassword({commit},data) {
    return new Promise((resolve, reject) => {
      resetPassword(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
  //用户管理管理 end ---------------------------------------->
}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}
