import {getTalkSessionList,addFriend,getFriendsList,delFriend,updateFriend,getFriendsApplyList,
  applyFriend,isFriend,getConversation,getChatRecords,addGroup,getGroupMembers,searchFriend,getFriendInfo,
  getGroupList,getGroupInfo,joinGroup,getGroupChatRecords,delGroup,updateGroup,
  getTopicsList,addTopic,getTopicInfo,updateTopic,delTopic,addReply,getTopicReply,topicType,
  topicStatus,updateGroupMembers,quitGroup,applyTopic
} from '@/api/chat'

const state = {

}

const mutations = {

}

const actions = {
  //1.已有好友的情况 start ---------------------------------------->
  //1.1 获取消息列表 - 刘佳伟
  // getTalkSessionList({commit},data) {
  //   return new Promise((resolve, reject) => {
  //     getTalkSessionList(data).then(response => {
  //       resolve(response)
  //     }).catch(error => {
  //       reject(error)
  //     })
  //   })
  // },
  //1.1 添加好友
  addFriend({commit},data) {
    return new Promise((resolve, reject) => {
      addFriend(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //1.2 好友列表
  getFriendsList({commit},data) {
    return new Promise((resolve, reject) => {
      getFriendsList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //1.3 删除好友
  delFriend({commit},data) {
    return new Promise((resolve, reject) => {
      delFriend(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //1.4 编辑好友信息
  updateFriend({commit},data) {
    return new Promise((resolve, reject) => {
      updateFriend(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //1.5 搜索用户
  searchFriend({commit},data) {
    return new Promise((resolve, reject) => {
      searchFriend(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //1.6 获取好友信息
  getFriendInfo({commit},data) {
    return new Promise((resolve, reject) => {
      getFriendInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //1.已有好友的情况 end ---------------------------------------->

  //2.没有好友的情况 start ---------------------------------------->
  //2.1 编辑好友信息
  getFriendsApplyList({commit},data) {
    return new Promise((resolve, reject) => {
      getFriendsApplyList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  applyFriend({commit},data) {
    return new Promise((resolve, reject) => {
      applyFriend(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //2.没有好友的情况 start ---------------------------------------->

  //3.搜索好友 start ---------------------------------------->
  isFriend({commit},data) {
    return new Promise((resolve, reject) => {
      isFriend(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //3.搜索好友 end ---------------------------------------->

  //4.会话关系 start ------------------------------------->
  getConversation({commit},data) {
    return new Promise((resolve, reject) => {
      getConversation(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getChatRecords({commit},data) {
    return new Promise((resolve, reject) => {
      getChatRecords(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //4.会话关系 end ------------------------------------->

  //5.群聊 start ------------------------------------->
  addGroup({commit},data) {
    return new Promise((resolve, reject) => {
      addGroup(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getGroupMembers({commit},data) {
    return new Promise((resolve, reject) => {
      getGroupMembers(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getGroupList({commit},data) {
    return new Promise((resolve, reject) => {
      getGroupList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getGroupInfo({commit},data) {
    return new Promise((resolve, reject) => {
      getGroupInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  joinGroup({commit},data) {
    return new Promise((resolve, reject) => {
      joinGroup(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getGroupChatRecords({commit},data) {
    return new Promise((resolve, reject) => {
      getGroupChatRecords(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  delGroup({commit},data) {
    return new Promise((resolve, reject) => {
      delGroup(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  updateGroup({commit},data) {
    return new Promise((resolve, reject) => {
      updateGroup(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  updateGroupMembers({commit},data) {
    return new Promise((resolve, reject) => {
      updateGroupMembers(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  quitGroup({commit},data) {
    return new Promise((resolve, reject) => {
      quitGroup(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  //5.群聊 end ------------------------------------->

  //6.商圈 start ------------------------------------->
  getTopicsList({commit},data) {
    return new Promise((resolve, reject) => {
      getTopicsList(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  addTopic({commit},data) {
    return new Promise((resolve, reject) => {
      addTopic(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getTopicInfo({commit},data) {
    return new Promise((resolve, reject) => {
      getTopicInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  updateTopic({commit},data) {
    return new Promise((resolve, reject) => {
      updateTopic(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  delTopic({commit},data) {
    return new Promise((resolve, reject) => {
      delTopic(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  addReply({commit},data) {
    return new Promise((resolve, reject) => {
      addReply(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getTopicReply({commit},data) {
    return new Promise((resolve, reject) => {
      getTopicReply(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  topicType({commit},data) {
    return new Promise((resolve, reject) => {
      topicType(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  topicStatus({commit},data) {
    return new Promise((resolve, reject) => {
      topicStatus(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  applyTopic({commit},data) {
    return new Promise((resolve, reject) => {
      applyTopic(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
  //6.商圈 end ------------------------------------->
}


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