admin
2018-12-25 4cb15e222cd7d099d533ccbeb7f9a8cd99bf180c
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html>
 
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge"/>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title>邀请人数</title>
        <!--下拉刷新组件-->
        <link rel="stylesheet" type="text/css" href="css/mescroll.min.css"/>
        <script src="js/mescroll.min.js" type="text/javascript" charset="utf-8"></script>
        <!--其它框架-->
        <link rel="stylesheet" type="text/css" href="css/DOUI.min.css"/>
        <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/DOUI.min.js" type="text/javascript" charset="utf-8"></script>
        <style type="text/css">
            /*顶部选择导航*/
            .topwai { width: 100%; height: 3.5rem; background-color: white; border-bottom: 0.2rem solid #F1F1F1; overflow: hidden; }
            .top_xian { width: 30%; height: 3px; position: absolute; left: 35%; bottom: 0.3rem; }
            /*文字被选中*/
            .top_ziOK { color: #F14242; }
            /*线条被选中*/
            .top_xianOK{ background-color: #F14242; }
            
            /*内容滚动外框*/
            .scroll_wai{ width: 100%; overflow: hidden; }
            /*好友单框*/
            .you_dan{ width: 94%; padding: 0.3rem 3%; background-color: white; margin-bottom: 1px; color: #666666; }
            /*头像*/
            .you_img{ width: 2.6rem; height: 2.6rem; margin-right: 1rem; border-radius: 50%; display: block; }
        </style>
    </head>
 
    <body>
        
        <!--先隐藏全部-->
        <script type="text/javascript">
            $("body").addClass("displayNone");
        </script>
            
        <div class="allwai fboxCol">
    
            <!--顶部选择导航-->
            <div id="topwai" class="topwai fboxRow">
                <!--一度好友-->
                <div class="flex1 fboxCol Xcenter Ycenter canclick" name="0" style="position: relative;">
                    <!--文字-->
                    <div class="font_normol" v-bind:class='index_top==0?"top_ziOK":""'   >一级队员({{num_1}})</div>
                    <!--下面的线-->
                    <div class="top_xian" v-bind:class='index_top==0?"top_xianOK":""'></div>
                </div>
                <!--二度好友-->
                <div class="flex1 fboxCol Xcenter Ycenter canclick" name="1" style="position: relative;">
                    <!--文字-->
                    <div class="font_normol" v-bind:class='index_top==1?"top_ziOK":""'  >二级队员({{num_2}})</div>
                    <!--下面的线-->
                    <div class="top_xian" v-bind:class='index_top==1?"top_xianOK":""'></div>
                </div>
            </div>
    
            <!--列表-->
            <div id="listwai" class="flex1 scroll_wai">
                
                <!--下拉刷新插件-->
                <div id="mescroll" class="mescroll">
        
                    <!--一级好友列表-->
                    <div v-if="index_top == 0" style="width: 100%;">
                        <!--Vue循环添加-->
                        <div v-for="item in one.list" class="you_dan fboxRow Ycenter">
                            <!--头像-->
                            <img class="you_img" v-bind:src="item.portrait"/>
                            <!--昵称-->
                            <div class="font_normol">{{item.nickName}}</div>
                            <!--空白区域-->
                            <div class="flex1"></div>
                            <!--是否登录-->
                            <div v-if="item.valid == false" class="font_min top_ziOK">未登录用户</div>
                            <div v-if="item.valid == true" class="font_min font_green">邀请成功</div>
                        </div>
                        <!--没有好友时的图片提示-->
                        <div v-if='one.list.length<=0' style="width:34%;height:auto;margin-left:33%;margin-top:50%;">
                            <img style="width:100%;height:auto;" src="img/no_people_hcj.png"/>
                        </div>
                    </div>
        
                    <!--二级好友列表-->
                    <div v-if="index_top == 1" style="width: 100%;">
                        <!--Vue循环添加-->
                        <div v-for="item in two.list" class="you_dan fboxRow Ycenter">
                            <!--头像-->
                            <img class="you_img" v-bind:src="item.portrait"/>
                            <!--昵称-->
                            <div class="font_normol">{{item.nickName}}</div>
                            <!--空白区域-->
                            <div class="flex1"></div>
                            <!--是否登录-->
                            <div v-if="item.valid == false" class="font_min top_ziOK">未登录用户</div>
                            <div v-if="item.valid == true" class="font_min font_green">邀请成功</div>
                        </div>
                        <!--没有好友时的图片提示-->
                        <div v-if='two.list.length<=0' style="width:34%;height:auto;margin-left:33%;margin-top:50%;">
                            <img style="width:100%;height:auto;" src="img/no_people_hcj.png"/>
                        </div>
                    </div>
                
                </div><!--下拉刷新插件结束-->
            
            </div>
                
        </div>
        
    </body>
 
    <script type="text/javascript">
        
        //========================== 页面数据 ================================
        var topdata = null; //顶部导航数据
        var listdata = null; //列表数据
//        alert("s");
//        var uid = "343448";
        var uid= yestv.getUid();
        if(uid == null || uid == '0')
        {
            yestv.toast("请登录后再试");    
        //    return false;
        }
        
        // Vue顶部导航数据
        topdata = new Vue({
            el: '#topwai',
            data: 
            {
                index_top: 0, // 顶部所选下标
                num_1: 0, // 一级队员数量
                num_2: 0, // 二级队员数量
            },
            watch: 
            {
                //更改列表数据中的下标
                index_top: function () 
                { 
                    //更改顶部下标
                    listdata.index_top = topdata.index_top;
                    //当前是一级队员
                    if (topdata.index_top == 0) { listdata.one.yema = 1; getYiji(); }
                    //当前是一级队员
                    else if (topdata.index_top == 1) { listdata.two.yema = 1; getEr(); }
                },
            },
        });
        
        // Vue列表数据
        listdata = new Vue({
            el: '#listwai',
            data: 
            {
                index_top: 0, // 顶部所选下标
                // 一级队员
                one: {
                    yema: 1, // 当前页码
                    yemamax: 1, // 最大页码数
                    pagesize: 20, // 每页数量
                    list: [], // 数据组
                },
                // 二级队员
                two: {
                    yema: 1, // 当前页码
                    yemamax: 1, // 最大页码数
                    pagesize: 20, // 每页数量
                    list: [], // 数据组
                },
            },
        });
        
        
        
        //========================== 页面事件 ==================================
        //下拉刷新事件实例
        var mescroll = new MeScroll("mescroll", {
            down: { auto: false, callback: downCallback },
            up: { use: false }
        });
        //下拉刷新回调
        function downCallback ()
        {
            console.log("已经触发下拉刷新");
            //当前是一级队员
            if (topdata.index_top == 0) { listdata.one.yema = 1; getYiji(); }
            //当前是一级队员
            else if (topdata.index_top == 1) { listdata.two.yema = 1; getEr(); }
        }
        
        //顶部导航选项点击  改变顶部下标
        $("#topwai>div").click(function() { topdata.index_top = $(this).attr("name"); });
        
        //列表框到达底部
        var timeold = 0;
        $("#mescroll").scroll(function()
        {
            var timenew = new Date().getTime();
            var viewH = $(this).height(); //可见高
            var allH = $(this)[0].scrollHeight; //总高度
            var scrollH = $(this).scrollTop(); //滚动了多远
            
            if (timenew - timeold > 500) 
            {
                timeold = timenew;
                //到底判定
                if ((viewH + scrollH) > (allH - 100)) 
                {
                    if (listdata.index_top == 0) 
                    {
                        if (listdata.one.yema < listdata.one.yemamax) { listdata.one.yema++; getYiji(); }
                        else { console.log("已到达底部"); }
                    }
                    else if (listdata.index_top == 1)
                    {
                        if (listdata.two.yema < listdata.two.yemamax) { listdata.two.yema++; getEr(); }
                        else { console.log("已到达底部"); }
                    }
                }
            }
        });
        
        
        
        //========================== 数据请求 ==================================
        // 邀请到的队员数量统计
        getNumyao();
        function getNumyao ()
        {
            //数据准备
            var myurl = "../../client/findThreeFriendsCount";
            var mydata = { id: uid };
            //数据请求
            doui.AjaxPost(myurl, mydata, function(res)
            {
                res=JSON.parse(res);
                if (res.code != 0) { doui.showToast(res.msg); }
                else
                {
                    var count1 = res.data.count1;
                    var count2 = res.data.count2;
                    topdata.num_1 = count1;
                    topdata.num_2 = count2;
                }
            });
        }
        
        // 一级数据请求
        getYiji();
        function getYiji () 
        {
            doui.showLoading("获取队员");
            //数据准备
            var myurl = "../../client/findThreeFriends";
            var mydata = { id: uid, type: 1, page: listdata.one.yema };
            //数据请求
            doui.AjaxPost(myurl, mydata, function(res)
            {
                res=JSON.parse(res); doui.hideLoading();
                if (res.code != 0) { doui.showToast(res.msg); mescroll.endErr(); }
                else
                {
                    setTimeout(function () { mescroll.endSuccess(); }, 800);
                    //保存最大页码数
                    listdata.one.yemamax = res.data.pages;
                    //改变列表组
                    if (listdata.one.yema <= 1) { listdata.one.list = res.data.list; }
                    else { listdata.one.list = listdata.one.list.concat(res.data.list); }
                }
            });
        }
        
        //二级数据请求
        function getEr () 
        {
            doui.showLoading("获取队员");
            //数据准备
            var myurl = "../../client/findThreeFriends";
            var mydata = { id: uid, type: 2, page: listdata.two.yema };
            //数据请求
            doui.AjaxPost(myurl, mydata, function(res)
            {
                res=JSON.parse(res); doui.hideLoading();
                if (res.code != 0) { doui.showToast(res.msg); mescroll.endErr(); }
                else
                {
                    setTimeout(function () { mescroll.endSuccess(); }, 800);
                    //保存最大页码数
                    listdata.two.yemamax = res.data.pages;
                    //改变列表组
                    if (listdata.two.yema <= 1) { listdata.two.list = res.data.list; }
                    else { listdata.two.list.concat(res.data.list); }
                }
            });
        }
        
        $("body").removeClass("displayNone");
        
    </script>
 
</html>