wl
2022-11-16 096f265df6dcf07df93806e2da461c2cad4a331f
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
// index.ts
// 获取应用实例
const message = getApp()
 
Page({
    data: {
        messageList: [],
        isShow: false,
        height: null,
        uid: wx.getStorageSync('id'),
        scrollTop: 0,
        isInput: 1,
        value: "",
        groupId:null,
    },
    // getDetail(e) {
    //     console.log(e)
    //     wx.navigateTo({
    //         url: '../cause/detail/index?id=' + e.currentTarget.id,
    //     })
    // },
groupMenber(){
    wx.navigateTo({
        url:'../message/member/index?id='+this.data.groupId
    })
},
publicty(){
wx.navigateTo({
    url:'../message/publicty/index?id='+this.data.groupId
})
},
banSpeech(){
    wx.navigateTo({
        url:'../message/Speech/index?id='+this.data.groupId
    })
},
cause(){
    wx.navigateTo({
        url:'../message/cause/index?id='+this.data.groupId
    })
},
chatRecords(){
    wx.navigateTo({
        url:'../message/records/index?id='+this.data.groupId
    })
},
    more() {
        console.log("进来了", this.data.scrollTop)
        if (this.data.isShow == false) {
            this.setData({
                isShow: true,
                height: 110
            })
         
        } else {
            this.setData({
                isShow: false,
                height: 50
            })
        }
 
    },
    sendMsg(){
        wx.request(
            {
                url: message.globalData.url + "/wx/group/manager/sendMsg",
                method: "GET",
                header: { 'token': wx.getStorageSync('token') },
                data: {
                    groupId: this.data.groupId,
                    id:wx.getStorageSync("id"),
                    msg:this.data.value
                },
                success: (res) => {
                    wx.request(
                        {
                            url: message.globalData.url + "/wx/message",
                            method: "GET",
                            header: { 'token': wx.getStorageSync('token') },
                            data: {
                                groupId: this.data.groupId
                            },
                            success: (res) => {
                                for (let index = 0; index < res.data.data.length; index++) {
                                    if (res.data.data[index].pic != null) {
                                        res.data.data[index].pic = message.globalData.imageUrl + "/img/" + res.data.data[index].pic;
                                    }
                                }
                                this.setData({
                                    messageList: res.data.data,
                                    value:""
                                })
                                console.log(this.data.messageList)
                                wx.setStorageSync('time',time)
                                wx.createSelectorQuery().select('#chat')
                                .boundingClientRect(function(rect){
                                    console.log('rectheight',rect);
                                    /* 将页面移动到最底部(用xxx的height定位) */
                                    wx.pageScrollTo({
                                      scrollTop: rect.height
                                    })
                                  }).exec()
                            }
                        })
                }
            }) 
    },
    inputWenzi: function (e) {
        this.setData({
            value: e.detail.value
        })
        if (this.data.value == "") {
            this.setData({
                isInput: 1
            })
        }
        if (this.data.value != "") {
            this.setData({
                isInput: 2
            })
        }
    },
 
    onLoad(e) {
        var date = new Date()
        var month = date.getMonth() + 1
        var day = date.getDate()
        var hours=date.getHours()
        var minutes=date.getMinutes()
        var secends=date.getSeconds()
        var time
        if (month < 10) {
            month = "0" + month
        }
        if (day < 10) {
            day = "0" + day
        }
        if (minutes < 10) {
            minutes = "0" + minutes
        }
        if (hours < 10) {
            hours = "0" + hours
        }
        if (secends < 10) {
            secends = "0" + secends
        }
        time = date.getFullYear() + "-" + month + "-" + day + " " + hours+":"+minutes+":"+secends
        wx.setStorageSync('time',time)
        this.data.groupId=e.id
        wx.request(
            {
                url: message.globalData.url + "/wx/message",
                method: "GET",
                header: { 'token': wx.getStorageSync('token') },
                data: {
                    groupId: e.id
                },
                success: (res) => {
                    for (let index = 0; index < res.data.data.length; index++) {
                        if (res.data.data[index].pic != null) {
                            res.data.data[index].pic = message.globalData.imageUrl + "/img/" + res.data.data[index].pic;
                        }
                    }
                    this.setData({
                        messageList: res.data.data
                    })
                    console.log(this.data.messageList)
                    wx.createSelectorQuery().select('#chat')
                    .boundingClientRect(function(rect){
                        console.log('rectheight',rect);
                        /* 将页面移动到最底部(用xxx的height定位) */
                        wx.pageScrollTo({
                          scrollTop: rect.height
                        })
                      }).exec()
                }
            })
    }
})