index.js 974 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. this.inputMsg += `${name} `
  35. this.atInd = 0
  36. el.focus()
  37. },
  38. handleUp () {
  39. if (this.atInd > 0) {
  40. this.atInd--
  41. }
  42. },
  43. handleDown () {
  44. let membersLen = this.group.userCounts
  45. this.atInd < membersLen - 1 ? this.atInd++ : this.atInd = 0
  46. }
  47. }
  48. }