智慧保安互联网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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<template>
    <view class="registerUser">
 
        <view class="group-chat-box" id="groupChatBox" :style="{ height: swiperHeight + 'px' }">
 
            <u-form :model="form" ref="uForm">
 
                <u-checkbox-group @change="checkboxGroupChange" :wrap='true' :size="40">
 
                    <u-checkbox v-model="item.checked" v-for="(item, index) in friend" :key="index"
                        :name="item.friendid" shape="circle"
                        style="padding: 16rpx 0; height: 92rpx; position: relative; box-sizing: border-box;">
 
                        <view class="head-wrap">
                            <image
                                :src="item.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' : item.avatar" />
                        </view>
 
                        <view style="margin-left: 106rpx">
                            {{item.realName}}
                        </view>
 
                    </u-checkbox>
                </u-checkbox-group>
 
            </u-form>
 
        </view>
 
 
        <view class="establish-box">
 
            <u-button class="submit" type='primary' @click="submit">
                立即创建
            </u-button>
 
        </view>
 
    </view>
</template>
 
<script>
    import WxStorage from "../../../static/lib/wxStorage.js"
    export default {
        data() {
            return {
                friend: [],
                form: {
                    groupname: '',
                    groupcontent: '',
                    groupnotice: '',
                    groupmember: '',
                },
                swiperHeight: 0
            }
        },
        onReady() {
            this.$refs.uForm.setRules(this.rules);
            let that = this;
            uni.getSystemInfo({
                success(e) {
                    console.log(e);
                    let {
                        windowWidth,
                        windowHeight,
                        safeArea
                    } = e;
                    const query = uni.createSelectorQuery().in(that);
                    query
                        .select('#groupChatBox')
                        .boundingClientRect(data => {
                    
                            that.swiperHeight = (safeArea.bottom - 58);
                    
                        })
                        .exec();
                }
            });
        },
        onLoad() {
            this.getFriend();
        },
        methods: {
            submit() {
                var that = this;
                var d = that.form;
                if (d.groupmember == "") {
                    uni.showToast({
                        title: '请至少选择一个群成员',
                        icon: "none",
                        duration: 1000
                    });
                    return;
                }
                d.time = that.currTime();
                d.groupid = WxStorage.get("ids");
                uni.request({
                    url: that.$store.state.piAPI + "/chatgroup/submit",
                    method: "POST",
                    data: d,
                    success: (res) => {
                        uni.showToast({
                            title: '创建成功',
                            icon: "none",
                            duration: 1000
                        });
 
                        uni.switchTab({
                            url: '/pages/groupChat/groupChat?'
                        });
                    }
                });
            },
            currTime() {
                var date = new Date();
                var Y = date.getFullYear() + '-';
                var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
                var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                return Y + M + D + h + m + s;
            },
            checkboxGroupChange(e) {
                var arr = "";
                for (var i = 0; i < e.length; i++) {
                    arr += e[i] + ",";
                }
                var obj = arr.substr(0, arr.length - 1);
                this.form.groupmember = obj;
            },
            getFriend() {
                var that = this;
                uni.request({
                    url: this.$store.state.piAPI + "/friend/page?current=1&size=9999",
                    method: "get",
                    data: {
                        applicant: WxStorage.get("ids")
                    },
                    success: (res) => {
                        var resdata = res.data.data.records;
 
                        that.friend = resdata;
 
                        var str = '';
                        resdata.forEach((item, index) => {
 
                            if (index > 2) return;
 
                            str += item.realName + '、';
 
                        })
 
                        this.form.groupname = (str.substr(0, str.length - 1) + '···')
                    }
                })
            }
        }
    }
</script>
 
<style lang="scss">
    @import '../../../common/style/common.scss';
    
    .warp {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
    }
 
    .rect {
        text-align: center;
        width: 120px;
        height: 120px;
    }
 
    .submit {
        border: none;
        width: 94%;
        height: 86rpx;
        line-height: 86rpx;
        box-sizing: border-box;
        border-radius: 15rpx;
        color: #ffffff;
        font-size: 38rpx;
 
    }
 
    .registerUser {
        background: #f7f7f7;
 
        .group-chat-box {
            padding: 0 1.2rem;
            box-sizing: border-box;
            overflow-y: auto;
        }
 
        .establish-box {
            position: relative;
            height: 116rpx;
            background: #fff;
            text-align: center;
 
            uni-button {
                margin: 0;
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                margin: auto;
            }
 
        }
    }
 
    .head-wrap {
        position: absolute;
        top: 0;
        left: 66rpx;
        bottom: 0;
        right: auto;
        margin: auto;
        width: 66rpx;
        height: 66rpx;
        border-radius: 50%;
        background: #e7e7e7;
 
        uni-image {
            width: 66rpx;
            height: 66rpx;
            border-radius: 50%;
 
            vertical-align: middle;
        }
    }
</style>