123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // 搜索mixin
- export const searchUserMixin = {
- data () {
- return {
- isSearch: false, // 搜索展示
- searchList: null // 搜索结果
- }
- },
- methods: {
- searchUser (e, originList) {
- let val = e.target.value
- if (!val) {
- this.isSearch = false
- return
- }
- this.searchList = originList.filter(item => {
- let name = item.name || item.nick_name
- return name.indexOf(val) > -1
- })
- this.isSearch = true
- }
- }
- }
- // @人
- export const chatAtMixin = {
- data () {
- return {
- atInd: 0 // @人索引
- }
- },
- methods: {
- atPerson (name) {
- let el = this.$refs.chatInput
- let lastIndex = this.inputMsg.lastIndexOf('@')
- this.inputMsg = this.inputMsg.slice(0, lastIndex + 1) + `${name} `
- this.atInd = 0
- el.focus()
- },
- handleUp () {
- if (this.atInd > 0) {
- this.atInd--
- }
- },
- handleDown () {
- let membersLen = this.group.userCounts
- this.atInd < membersLen - 1 ? this.atInd++ : this.atInd = 0
- }
- }
- }
|