index.vue
4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<template>
<div :class="['layoutIndex', `page-type-${tabIndex}`]">
<search :placeholder="tabIndex == 0 ? '姓名、手机号、车牌号' : '输入员工姓名'" :keyword="keyWord" @search="searchkeyWord"></search>
<template v-if="list.length > 0">
<scroll-view class="content" @ReachBottom="onReachBottom" ref="scrollView">
<template v-for="(item, index) in list">
<div :key="index" class="item flex" @click="goTo(item)">
<template>
<div class="avatar">
<img :src="tabIndex == 0 ? item.avatar : item.thumbAvatar" alt="" v-if="item.avatar || item.thumbAvatar" />
<div v-else class="sprite-icon icon-avatar"></div>
</div>
<div class="info">
<div class="phone flex text-hide">
{{ item.groupNickName }}
<template v-if="tabIndex == 0">
<div class="wx">
<template v-if="item.type == 1">@微信</template>
<template v-if="item.type == 2">@企微</template>
</div>
</template>
<div class="sprite-icon icon-identifier" v-if="tabIndex == 1 && item.isLord == 0"></div>
</div>
<template v-if="tabIndex == 1">
<div class="time">进群时间:{{ item.joinTime }}</div>
</template>
<div class="tag-wrap flex" v-else>
<template v-if="item.labels&&item.labels.length > 0">
<div class="tag" v-for="tag in item.labels.slice(0, 3)" :key="tag.labelId">{{ tag.labelValue }}</div>
</template>
</div>
</div>
<!-- isMyCustomer 是否是我的客户 0是 -1否 -->
<template v-if="item.isMyCustomer == 0 && tabIndex == 0">
<div class="mark">我的客户</div>
</template>
<div class="sprite-icon icon-arrow" v-if="tabIndex == 0"></div>
</template>
</div>
</template>
</scroll-view>
</template>
<template v-else>
<empty description="暂无数据" />
</template>
</div>
</template>
<script type='text/ecmascript-6'>
import { ssoApi, wxConfig } from '@/api'
import { Toast } from 'vant'
export default {
name: '',
data() {
return {
tabIndex: this.index,
list: this.tableData
}
},
props: {
index: {
type: Number,
default: 0
},
keyWord: {
type: String,
default: ''
},
tableData: {
type: Array,
default: () => []
}
},
watch: {
index(n) {
this.tabIndex = n
},
tableData: {
handler(e) {
this.list = e
},
deep: true
}
},
created() {
this.getuserInfo()
},
mounted() {
this.initWx()
},
methods: {
//初始化微信接口
initWx() {
wxConfig.init(['openEnterpriseChat']).then(() => {})
},
getuserInfo() {
ssoApi.getuserInfo().then(res => {
this.workUserId = res.data.workUserId
})
},
searchkeyWord(e) {
// this.keyWord = e
this.$emit('searchkeyWord', e)
},
change(e) {
this.tabIndex = e
},
onReachBottom() {
// console.log('触底')
this.$refs.scrollView.loading = false
this.$refs.scrollView.finished = true
},
goTo(data) {
if (!data.id && this.tabIndex == 0) {
Toast('该用户尚未成为企业微信客户,请先添加为客户')
return
}
if (this.tabIndex == 0) this.$router.push({ name: 'customer.detail', query: { id: data.userId, customerId: data.isMyCustomer, isTrue: true } })
if (this.tabIndex == 1 && this.workUserId != data.userId) {
let seach = {
userIds: [data.userId], //参与会话的企业成员列表,格式为userid1;userid2;...,用分号隔开。
externalUserIds: [data.userId], // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
groupName: '', // 会话名称。单聊时该参数传入空字符串""即可。
chatId: ''
}
wxConfig.openEnterpriseChat(seach).then(res => {})
}
}
}
}
</script>
<style scoped lang='scss'>
@import '@/assets/css/customer.scss';
</style>