friends.vue
3.68 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>
<v-layout column justify-center align-center id="Friends">
<v-flex>
<div id="SearchBlock">
<input v-model="search" type="search" id="searchInput" @input='getData' placeholder="搜索"/>
</div>
<h3 id="FriendTitle">全部好友({{count}})</h3>
<v-card id="FriendList" flat >
<v-list class="list">
<v-list-tile class="ListItem" v-for="(item, index) in friendList" :key="index" @click.native="$router.push(`/userRecord?id=${item.id}`)">
<v-list-tile-content class="ListItemAvatar">
<img v-if="item.headimgurl" :src="item.headimgurl" alt="" />
<i v-if="!item.headimgurl" class="material-icons icon iconfont icon-face"></i>
<span>{{item.name}}</span>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-card>
</v-flex>
</v-layout>
</template>
<script>
import {wechatShareSetting} from '@/helper'
export default {
async asyncData({store, query, app, redirect}) {
let {data} = await app.$axios.get(`/friend/list?userId=${store.state.user.id}`)
if (data.success) {
return {friendList: data.list, count: data.count}
} else {
store.dispatch('displayMessage', data.msg)
return {friendList: [], count: 0}
}
},
data:() => ({
search: '',
}),
mounted() {
wechatShareSetting(this.$axios, this.$store)
},
methods: {
async getData() {
let {data} = await this.$axios.get(`/friend/list?userId=${this.$store.state.user.id}&search=${this.search}`)
if (data.success) {
this.friendList = data.list
this.count = data.count
} else {
this.$store.dispatch('displayMessage', data.msg)
}
}
}
}
</script>
<style lang="scss" scoped>
#Friends {
#SearchBlock {
width: 100vw;
padding: 0.9rem 0.7rem;
#searchInput {
background-color: $menu-grey;
border: 1px solid #979797;
border-radius: 0.5rem;
width: 100%;
height: 2rem;
text-align: center;
outline: none;
color: $light-gold;
}
::-moz-placeholder { color: $light-gold; opacity: 0.5; line-height: 2rem;}
::-webkit-input-placeholder { color:$light-gold; opacity: 0.5; line-height: 2rem; }
:-ms-input-placeholder { color:$light-gold; opacity: 0.5; line-height: 2rem; }
}
#FriendTitle {
display: block;
font-size: 1.1rem;
width: calc(100vw - 1rem);
color: $light-gold;
border-left: 0.15rem solid $light-gold;
padding-left: 0.75rem;
margin-left: 1rem;
margin-bottom: 1.7rem;
}
#FriendList {
width: 100vw;
.list {
background-color: $toolbar-grey;
padding: 0 0.8rem;
.ListItem {
height: 3rem;
&:nth-child(1) {
/deep/ .list__tile {
border-top: none;
}
}
/deep/ .list__tile {
height: 3rem;
color: $light-gold;
padding: 0;
border-top: 0.1rem solid #586C80;
}
.ListItemAvatar {
flex-direction: row;
height: 3rem;
align-items: center;
justify-content: flex-start;
span {
height: 3rem;
font-size: 1.1rem;
font-weight: bold;
line-height: 3rem;
margin-left: 1.2rem;
}
img {
height: 80%;
display: block
}
i {
color: $light-gold;
display: block;
width: 2.4rem;
text-align: center;
}
}
}
}
}
}
</style>