Authored by 陈峰

commit

1 import Layout from './layout'; 1 import Layout from './layout';
2 import LayoutHeader from './layout-header'; 2 import LayoutHeader from './layout-header';
  3 +import LayoutScroll from './layout-scroll';
3 4
4 export default [ 5 export default [
5 Layout, 6 Layout,
6 LayoutHeader, 7 LayoutHeader,
  8 + LayoutScroll,
7 ]; 9 ];
@@ -26,7 +26,9 @@ export default { @@ -26,7 +26,9 @@ export default {
26 <style lang="scss" scoped> 26 <style lang="scss" scoped>
27 .layout-header { 27 .layout-header {
28 width: 100%; 28 width: 100%;
29 - height: 45PX; 29 + height: 44PX;
  30 + background-color: #444;
  31 + color: #fff;
30 overflow: hidden; 32 overflow: hidden;
31 display: flex; 33 display: flex;
32 34
@@ -50,7 +52,7 @@ export default { @@ -50,7 +52,7 @@ export default {
50 .title { 52 .title {
51 flex: 1; 53 flex: 1;
52 justify-content: center; 54 justify-content: center;
53 - font-size: 30px; 55 + font-size: 18PX;
54 } 56 }
55 57
56 .opts { 58 .opts {
  1 +<template>
  2 + <RecycleList ref="scroll" :on-fetch="onFetch" :options="scrollOption" @pulling-up="onPullingUp" @pulling-down="onPullingDown">
  3 + <template slot="item" slot-scope="{ data }">
  4 + <slot name="item" :data="data">
  5 + </slot>
  6 + </template>
  7 + </RecycleList>
  8 +</template>
  9 +
  10 +<script>
  11 +import {Scroll, RecycleList} from 'cube-ui';
  12 +
  13 +export default {
  14 + name: 'LayoutScroll',
  15 + props: {
  16 + onFetch: Function,
  17 + infinite: Boolean,
  18 + scrollOption: {
  19 + type: Object,
  20 + default() {
  21 + return {
  22 + pullDownRefresh: true,
  23 + observeDOM: false,
  24 + pullUpLoad: true
  25 + };
  26 + }
  27 + }
  28 + },
  29 + methods: {
  30 + onPullingUp(evt) {
  31 + this.$emit('pulling-up', evt);
  32 + },
  33 + onPullingDown(evt) {
  34 + this.$emit('pulling-down', evt);
  35 + },
  36 + },
  37 + components: {Scroll, RecycleList}
  38 +};
  39 +</script>
@@ -2,30 +2,14 @@ @@ -2,30 +2,14 @@
2 <div class="layout"> 2 <div class="layout">
3 <slot name="header" v-if="hasHeader"></slot> 3 <slot name="header" v-if="hasHeader"></slot>
4 <div class="layout-content"> 4 <div class="layout-content">
5 - <Scroll ref="scroll" :options="scrollOption" @pulling-up="onPullingUp" @pulling-down="onPullingDown">  
6 - <slot></slot>  
7 - </Scroll> 5 + <slot></slot>
8 </div> 6 </div>
9 </div> 7 </div>
10 </template> 8 </template>
11 9
12 <script> 10 <script>
13 -import {Scroll} from 'cube-ui';  
14 -  
15 export default { 11 export default {
16 name: 'Layout', 12 name: 'Layout',
17 - props: {  
18 - scrollOption: {  
19 - type: Object,  
20 - default() {  
21 - return {  
22 - pullDownRefresh: true,  
23 - observeDOM: false,  
24 - pullUpLoad: true  
25 - };  
26 - }  
27 - }  
28 - },  
29 data() { 13 data() {
30 return { 14 return {
31 hasHeader: false, 15 hasHeader: false,
@@ -36,15 +20,6 @@ export default { @@ -36,15 +20,6 @@ export default {
36 this.hasHeader = true; 20 this.hasHeader = true;
37 } 21 }
38 }, 22 },
39 - methods: {  
40 - onPullingUp(evt) {  
41 - this.$emit('pulling-up', evt);  
42 - },  
43 - onPullingDown(evt) {  
44 - this.$emit('pulling-down', evt);  
45 - },  
46 - },  
47 - components: {Scroll}  
48 }; 23 };
49 </script> 24 </script>
50 25
1 <template> 1 <template>
2 <Layout> 2 <Layout>
3 <LayoutHeader slot='header' title="推荐" :share="shareData"></LayoutHeader> 3 <LayoutHeader slot='header' title="推荐" :share="shareData"></LayoutHeader>
4 - <div class="article-content">  
5 - page-content  
6 - </div> 4 + <LayoutScroll :infinite="true" :on-fetch="onFetch">
  5 + <div class="article-item" slot="item" slot-scope="{ data }">
  6 + <div :id="data.id" class="item">
  7 + <div class="avatar" :style="{backgroundImage: 'url(' + (data.avatar || '') + ')'}"></div>
  8 + <div class="bubble">
  9 + <p>{{ data.name }}</p>
  10 + <div class="meta">
  11 + <time class="posted-date">{{ data.time }}</time>
  12 + </div>
  13 + </div>
  14 + </div>
  15 + </div>
  16 + </LayoutScroll>
7 </Layout> 17 </Layout>
8 </template> 18 </template>
9 19
10 <script> 20 <script>
11 - 21 +import {createNamespacedHelpers} from 'vuex';
12 import {Scroll, Loading} from 'cube-ui'; 22 import {Scroll, Loading} from 'cube-ui';
  23 +const {mapState, mapActions, mapMutations} = createNamespacedHelpers('article');
13 24
14 export default { 25 export default {
15 name: 'ArticlePage', 26 name: 'ArticlePage',
@@ -20,12 +31,28 @@ export default { @@ -20,12 +31,28 @@ export default {
20 data() { 31 data() {
21 return { 32 return {
22 list: [], 33 list: [],
  34 + shareData: {},
23 scrollOptions: { 35 scrollOptions: {
24 bounce: false 36 bounce: false
25 - } 37 + },
  38 + inx: 0
26 }; 39 };
27 }, 40 },
  41 + computed: {
  42 + ...mapState(['articleList']),
  43 + },
28 methods: { 44 methods: {
  45 + onFetch() {
  46 + const items = Array.from({length: 50}).map((v, i) => {
  47 + return {
  48 + name: 'chenfeng' + (i + 50 * this.inx)
  49 + }
  50 + })
  51 +
  52 + this.inx++;
  53 +
  54 + return Promise.resolve(items);
  55 + },
29 click() { 56 click() {
30 this.$refs.actionSheet.show(); 57 this.$refs.actionSheet.show();
31 setTimeout(() => { 58 setTimeout(() => {
@@ -46,31 +73,8 @@ export default { @@ -46,31 +73,8 @@ export default {
46 }; 73 };
47 </script> 74 </script>
48 75
49 -<style>  
50 - .page {  
51 - position: absolute;  
52 - top: 0;  
53 - left: 0;  
54 - right: 0;  
55 - bottom: 0;  
56 - background-color: gray;  
57 - }  
58 -  
59 - .content {  
60 - width: 100%;  
61 - height: 100vh;  
62 - background-color: white;  
63 - }  
64 -  
65 - .item {  
66 - background-color: white;  
67 - }  
68 -  
69 - .loading {  
70 - position: absolute;  
71 - left: 50%;  
72 - top: 50%;  
73 - transform: translate(-50%, -50%);  
74 - }  
75 - 76 +<style lang="scss" scoped>
  77 +.article-item {
  78 + height: 100px;
  79 +}
76 </style> 80 </style>
  1 +export default function() {
  2 + return {
  3 + state: {
  4 + articleList: []
  5 + }
  6 + };
  7 +}
@@ -36,7 +36,7 @@ if (!isDev) { @@ -36,7 +36,7 @@ if (!isDev) {
36 const getContext = (req) => { 36 const getContext = (req) => {
37 return { 37 return {
38 url: req.url, 38 url: req.url,
39 - title: 'BLK2!', 39 + title: '',
40 user: req.user, 40 user: req.user,
41 env: { 41 env: {
42 isApp: req.yoho.isApp, 42 isApp: req.yoho.isApp,