智慧保安互联网APP
zengh
2022-06-21 4efeb31d5b4921d7e851c256009486ad86bc70e2
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<template>
    <view class="container">
        
        <u-navbar style="position: relative;" :is-fixed="false" :border-bottom="true" :is-back="true"
            title="好友申请" back-icon-color="#fff" :background="{ background: '#0BB9C8' }" title-color="#fff">
        
        </u-navbar>
        
        <view class="main">
            <u-empty class="friendEmpty" v-if="requestList.length == 0" text="暂无好友申请" mode="list"></u-empty>
            <view class="requestr" v-for="(item, index) in requestList" :key="index">
 
                <view class="request-top">
                    <view @click="reject(item)" class="reject btn">拒绝</view>
                    <view class="header-img">
                        <image :src="item.avatar" mode="" class="header-img" />
                    </view>
                    <view @click="aggree(item)" class="aggree btn">同意</view>
                </view>
 
                <view class="request-center">
                    <view class="title">{{ item.realName }}</view>
                    <view class="time">{{ item.time | date }}</view>
                </view>
 
                <view class="notic">
                    <text>留言:</text>
                    <text>{{ item.bz }}</text>
                </view>
            </view>
 
        </view>
    </view>
</template>
 
<script>
    import datas from '@/debugdate/debugdate.js'
    import filter from '@/config/filter.js'
    import WxStorage from "../../static/lib/wxStorage.js"
    export default {
        onLoad(option) {
            this.friendApplication();
        },
        data() {
            return {
                requestList: []
            };
        },
 
        methods: {
            // 返回键
            backOne() {
                uni.navigateBack({
                    delta: 1
                })
            },
            _FriendRequest() {
                this.requestList = datas.firendsRequest()
            },
            friendApplication() {
                //获取所有好友申请
                uni.request({
                    url: this.$store.state.piAPI + "/friend/friendApplication",
                    method: "GET",
                    data: {
                        applicant: WxStorage.get("ids")
                    },
                    success: (res) => {
                        var resdata = res.data.data.records;
                        for (var i = 0; i < resdata.length; i++) {
                            if (resdata[i].avatar == null || resdata[i].avatar == "") {
                                resdata[i].avatar = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20191109%2F1d3d4d82715444c4b8284f65e3feed10.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1632484198&t=1f4086a5894cbf83b311fa37c276405c";
                            }
                        }
                        this.requestList = resdata;
                    }
                });
            },
            aggree(item) {
                var that = this;
                uni.request({
                    url: this.$store.state.piAPI + "/friend/submit",
                    method: "POST",
                    data: {
                        id: item.id,
                        type: 1
                    },
                    success: (res) => {
                        uni.showToast({
                            title: '操作成功',
                            icon: "none",
                            duration: 1000
                        });
                        that.friendApplication();
                    }
                });
            },
            reject(item) {
                var that = this;
                uni.request({
                    url: this.$store.state.piAPI + "/friend/submit",
                    method: "POST",
                    data: {
                        id: item.id,
                        type: 2
                    },
                    success: (res) => {
                        uni.showToast({
                            title: '操作成功',
                            icon: "none",
                            duration: 1000
                        });
                        that.friendApplication();
                    }
                });
            }
        },
        filters: {
            date(time) {
                return filter.date(time)
            }
        }
    }
</script>
 
<style lang="scss">
    @import '../../common/style/common.scss';
 
    .friendEmpty {
        position: absolute;
        margin: auto;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
    }
 
    .main {
        padding: 16rpx 32upx;
        background: rgba(255, 255, 255, .6);
 
        .requestr {
            margin-top: 112rpx;
            padding: 32upx;
            background: rgba(255, 255, 255, 1);
            border-radius: 20upx;
            box-shadow: 0px 24rpx 64rpx -8rpx rgba(0, 0, 0, .1);
 
            .request-top {
                display: flex;
                flex-direction: row;
 
                .btn {
                    flex: none;
                    width: 160rpx;
                    height: 64rpx;
                    background: rgba(255, 93, 91, .1);
                    border-radius: 40rpx;
                    text-align: center;
                    font-size: 32upx;
                    font-weight: 400;
                    line-height: 64rpx;
                }
 
                .reject {
                    color: rgba(255, 93, 91, 1);
                    background-color: rgba(255, 93, 91, .1);
                }
 
                .aggree {
                    color: rgba(39, 40, 50, 1);
                    background-color: rgba(255, 228, 49, 1);
                }
 
                .header-img {
                    margin-top: -52rpx;
                    flex: auto;
                    text-align: center;
 
                    image {
                        width: 144rpx;
                        height: 144rpx;
                        border-radius: 50%;
                    }
                }
 
            }
 
            .request-center {
                text-align: center;
                padding-top: 20rpx;
                padding-bottom: 40rpx;
 
                .title {
                    font-size: 36rpx;
                    font-weight: 500;
                    color: rgba(39, 40, 50, 1);
                    line-height: 50rpx;
                }
 
                .time {
                    font-size: 24upx;
                    color: rgba(39, 40, 50, 0.4);
                    line-height: 34rpx;
                }
 
            }
 
            .notic {
                font-size: 28upx;
                color: rgba(39, 40, 50, 1);
                line-height: 40rpx;
                padding: 10px 32upx;
                border-radius: 20upx;
                background: rgba(243, 244, 246, 1);
            }
        }
 
    }
</style>