yujian
2019-03-27 cdcbed9af813b2a02cdc01eefa24db8bec6b51a9
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
<template>
    <div class="allwai">
        
        <!--滚动框-->
        <scroller v-bind:style="'width:750px; height:'+winH+'px;padding-bottom:30px;'" offset-accuracy="10" @scroll="scrollforever">
            
            <!--顶部标识-->
            <div ref="sctop" style="width: 750px;margin-bottom: 30px;"></div>
            
            <!--卡片-->
            <div v-for="(item, index) in kapian" class="kadan canclick" @click="Click_url(item.a_href)">
                <!--图片-->
                <div class="kaimgsize"><image class="kaimgsize" v-bind:src="item.src" resize="cover"></image></div>
                <!--文字说明区域-->
                <div class="katextwai fboxRow Xbetween Ycenter" @click="Click_dan('分享')">
                    <div><text class="font_ell1 font_moremax">{{item.title}}</text></div>
                    <div class="kasharewai fboxRow Xend Ycenter"><image class="kasharesize" src="https://gd2.alicdn.com/bao/uploaded/i2/T14H1LFwBcXXXXXXXX_!!0-item_pic.jpg"></image></div>
                </div>
            </div>
            
        </scroller><!--滚动框结束-->
        
        <!--回到顶部-->
        <div v-if="show_back" class="backtop" @click="Click_backtop">
            <image class="backtopimg" src="https://gd2.alicdn.com/bao/uploaded/i2/T14H1LFwBcXXXXXXXX_!!0-item_pic.jpg"></image>
        </div>
        
    </div>
</template>
 
 
 
<style>
    /*通用样式*/
    .allwai { width: 750px; position: relative; background-color: #F1F1F1; }
    .canclick { transition-property: backgroundColor; transition-duration: 0.1s; transition-timing-function: linear; }
    .canclick:active { background-color: rgba(0, 0, 0, 0.2); }
    .bor { border-style: dashed; border-width: 1px; }
    
    .fboxRow { display: flex; flex-direction: row; }
    .fboxCol { display: flex; flex-direction: column; }
    .flex1 { flex: 1; }
    .flex2 { flex: 2; }
    .Xstart { justify-content: flex-start; }
    .Xcenter { justify-content: center; }
    .Xend { justify-content: flex-end;}
    .Xbetween { justify-content: space-between; }
    .Xaround { justify-content: space-around; }
    .Ystart { align-items: flex-start; }
    .Ycenter { align-items: center; }
    .Yend { align-items: flex-end; }
    .Ystretch { align-items: stretch; }
    
    .font_min { font-size: 23px; font-family: "微软雅黑"; color: #585858; }
    .font_normol { font-size: 27px; font-family: "微软雅黑"; color: #585858; }
    .font_moremax { font-size: 31px; font-family: "微软雅黑"; color: #585858; }
    .font_max { font-size: 35px; font-family: "微软雅黑"; color: #585858; }
    .font_ell1{ lines: 1; text-overflow: ellipsis; }
    .font_ell2{ lines: 2; text-overflow: ellipsis; }
    
    .font_red { color: #E60962; }
    .font_blue { color: #63759B; }
    .font_gray { color: #838383; }
    .font_white { color: white; }
    .bg_white{ background-color: white; }
    
    /*卡片外框*/
    .kadan{ width: 690px; margin-bottom: 30px; margin-left: 30px; background-color: white; overflow: hidden; }
    /*图片*/
    .kaimgsize{ width: 690px; height: 320px; }
    /*文字说明*/
    .katextwai{ width: 630px; height: 90px; margin-left: 30px; }
    /*分享按钮*/
    .kasharesize{ width: 55px; height: 55px; }
    .kasharewai{ width: 70px; height: 90px; }
    
    /*回到顶部*/
    .backtop{ width: 100px; height: 100px; position: fixed; right: 30px; bottom: 30px; border-radius: 50px; opacity: 0.7; }
    .backtopimg{ width: 100px; height: 100px; border-radius: 50px; }
</style>
 
 
 
<script>
        
    //弹框对象
    var modal = weex.requireModule('modal');
    var utilModule= weex.requireModule('utilModule');
     var stream = weex.requireModule('stream');
    //
    var th = null;
    
    export default {
        
        //数据信息
        data: {
            
            //页面信息
            winH: 1000, //屏幕高度
            show_back: false, //是否显示回到顶部小火箭
            
            //教程卡片组
            kapian: [
                { title: '花生日记功能介绍', src: "https://gd2.alicdn.com/bao/uploaded/i2/T14H1LFwBcXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka0.com", },
                { title: '首页特色模版', src: "https://gd1.alicdn.com/bao/uploaded/i1/TB1PXJCJFXXXXciXFXXXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka1.com", },
                { title: '如何搜索优惠券', src: "https://gd3.alicdn.com/bao/uploaded/i3/TB1x6hYLXXXXXazXVXXXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka2.com", },
                { title: '花生日记功能介绍', src: "https://gd2.alicdn.com/bao/uploaded/i2/T14H1LFwBcXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka0.com", },
                { title: '首页特色模版', src: "https://gd1.alicdn.com/bao/uploaded/i1/TB1PXJCJFXXXXciXFXXXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka1.com", },
                { title: '如何搜索优惠券', src: "https://gd3.alicdn.com/bao/uploaded/i3/TB1x6hYLXXXXXazXVXXXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka2.com", },
                { title: '花生日记功能介绍', src: "https://gd2.alicdn.com/bao/uploaded/i2/T14H1LFwBcXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka0.com", },
                { title: '首页特色模版', src: "https://gd1.alicdn.com/bao/uploaded/i1/TB1PXJCJFXXXXciXFXXXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka1.com", },
                { title: '如何搜索优惠券', src: "https://gd3.alicdn.com/bao/uploaded/i3/TB1x6hYLXXXXXazXVXXXXXXXXXX_!!0-item_pic.jpg", a_href: "https://www.ka2.com", }
            ],
            
        },
        
        //创建完成(猜的)
        created: function ()
        {
            th = this;
            //获取屏幕高度
            const dom = weex.requireModule('dom');
            dom.getComponentRect('viewport', function(res) { th.winH = res.size.height; });
            
            var params={"time":now()};
            params.sign=utilModule.getSign(JSON.stringfy(params))
            
            
            stream.fetch({
                    method: 'POST',
                    url: "http://192.168.1.122:8080/fanli/",
                 type:'json',
                 data:params
              }, function(ret) {
                if(!ret.ok){
                      me.postResult = "request failed";
                }else{
                      console.log('get:'+JSON.stringify(ret));
                      me.postResult = JSON.stringify(ret.data);
            }
          },function(response){
            console.log('get in progress:'+response.length);
            me.postResult = "bytes received:"+response.length;
          });
            
        },
        
        //事件定义
        methods: {
            
            //直接链接跳转点击,如 轮播图和广告
              Click_url: function (ev) 
              {
                  var urlthis = ev; //获取要跳转的链接
                  
                  //weex
                  utilModule.jumpWeb(urlthis);
                  
                  
                  
                  modal.toast({
                    message: '点击了链接:' + urlthis,
                    duration: 1
                });
            },
            
            //具体信息(如id)获取后跳转 点击
            Click_dan: function (ev)
            {
                var daninfo = ev; //获取该节点保留信息
                
                modal.toast({
                    message: '点击了节点:' + daninfo,
                    duration: 1
                });
            },
            
            //回到顶部小火箭 点击
            Click_backtop: function (ev)
            {
                //取消冒泡
                ev.stopPropagation();
                //回到顶部
                const dom = weex.requireModule('dom');
                dom.scrollToElement(th.$refs.sctop,{
                    offset: 0,
                    animated: true,
                });
            },
            
            //滚动框滚动中
            scrollforever: function (ev)
            {
                var viewH = th.winH; //可视高
                var scrollH = -ev.contentOffset.y; //滚动轴移动距离
                var allH = ev.contentSize.height; //总高度
                
                //显示回到顶部图标
                if (scrollH > 100) { th.show_back = true; }
                else { th.show_back = false; }
                
                //触底
                if ((viewH + scrollH) > (allH - 20))
                {
                    //弹框提示
                    modal.toast({
                        message: '触底',
                        duration: 1,
                    });
                }
            },
              
        },    
        
    }
    
</script>