index.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // 搜索mixin
  2. export const searchUserMixin = {
  3. data () {
  4. return {
  5. isSearch: false, // 搜索展示
  6. searchList: null // 搜索结果
  7. }
  8. },
  9. methods: {
  10. searchUser (e, originList) {
  11. let val = e.target.value
  12. if (!val) {
  13. this.isSearch = false
  14. return
  15. }
  16. this.searchList = originList.filter(item => {
  17. let name = item.name || item.nick_name
  18. return name.indexOf(val) > -1
  19. })
  20. this.isSearch = true
  21. }
  22. }
  23. }
  24. // @人
  25. export const chatAtMixin = {
  26. data () {
  27. return {
  28. atInd: 0 // @人索引
  29. }
  30. },
  31. methods: {
  32. atPerson (name) {
  33. let el = this.$refs.chatInput
  34. let lastIndex = this.inputMsg.lastIndexOf('@')
  35. this.inputMsg = this.inputMsg.slice(0, lastIndex + 1) + `${name} `
  36. this.atInd = 0
  37. el.focus()
  38. },
  39. handleUp () {
  40. if (this.atInd > 0) {
  41. this.atInd--
  42. }
  43. },
  44. handleDown () {
  45. let membersLen = this.group.userCounts
  46. this.atInd < membersLen - 1 ? this.atInd++ : this.atInd = 0
  47. }
  48. }
  49. }