king
2018-09-29 31573a0912c1971a9043b3f9294f643c7d60a2aa
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
<template>
  <div class="home-view">
    <div class="weui-search-bar">
      <div class="weui-search-bar__form" @click="jumpMenu()">
        <label class="weui-search-bar__label">
          <i class="weui-icon-search"></i>
          <span>{{dict.search}}</span>
        </label>
      </div>
    </div>
    <swiper-component v-if="swiperData" :swiperSource="swiperData" :swiperConfig="swiperConfig" @swiperjump="swiperJumpMenu"></swiper-component>
    <nav-grid-component v-if="navGrids" class="border-bottom-5" :grids="navGrids" @navgridjump="navgridJumpMenu"></nav-grid-component>
    <goods-list-component v-for="(item, index) in goods" :key="index" :goods="item" @goodslistjump="goodslistJumpMenu"></goods-list-component>
    <bottom-line-component v-if="message" :message="message"></bottom-line-component>
    <tab-bar-component v-if="tabMenu" :menu="tabMenu"></tab-bar-component>
  </div>
</template>
 
<script>
import {dict} from '../store/dictionary'
import {mainmenu} from '../store/menulist'
import {homeData} from '../store/mockdata'
import swiperComponent from '../components/swiperComponent'
import navGridComponent from '../components/navGridComponent'
import goodsListComponent from '../components/goodsListComponent'
import bottomLineComponent from '../components/bottomLineComponent'
import tabBarComponent from '../components/tabBarComponent'
export default {
  name: 'home',
  components: { swiperComponent, navGridComponent, goodsListComponent, tabBarComponent, bottomLineComponent },
  data () {
    return {
      dict: dict,
      swiperConfig: {
        loop: true,
        autoplay: 3000,
        pagination: '.swiper-pagination',
        paginationClickable: true
      },
      swiperData: null,
      goods: null,
      navGrids: null,
      tabMenu: null,
      message: null
    }
  },
  methods: {
    jumpMenu () {
      this.$router.push({name: 'goods', params: {header: 'search'}})
    },
    swiperJumpMenu (message) {
      this.$router.push({name: message.view, params: {type: message.value}})
    },
    navgridJumpMenu (message) {
      this.$router.push({name: message.view, params: {type: message.value}})
    },
    goodslistJumpMenu (message) {
      if (message.view === 'goods') {
        this.$router.push({name: message.view, params: {type: message.type, header: message.header}})
      } else if (message.view === 'goodsdetail') {
        this.$router.push({name: message.view, params: {id: message.id}})
      }
    }
  },
  mounted: function () {
    this.tabMenu = mainmenu.map(item => {
      if (item.view === this.$route.name) {
        item.active = true
      } else {
        item.active = false
      }
      return item
    })
    setTimeout(() => {
      this.swiperData = JSON.parse(JSON.stringify(homeData.swiperData))
    }, 500)
    setTimeout(() => {
      this.navGrids = JSON.parse(JSON.stringify(homeData.navGrids))
    }, 1000)
    setTimeout(() => {
      this.goods = JSON.parse(JSON.stringify(homeData.goods))
      this.tabMenu[2].badge = 3
      this.message = dict.bottomtip
    }, 2000)
 
    $('body').bind('touchmove', () => {
      if ($(document).scrollTop() >= 140) {
        $('.weui-search-bar').css({background: '#FFFFFF', opacity: 1})
      } else {
        $('.weui-search-bar').css({background: 'transparent', opacity: 0.8})
      }
    })
    $('body').bind('touchend', () => {})
    // let loading = false  //状态标记
    // $(document.body).infinite().on('infinite', () => {
    //   if(loading) return;
    //   loading = true;
    //   setTimeout(function() {
    //     $("#list").append("<p> 我是新加载的内容 </p>")
    //     loading = false
    //   }, 1500);   //模拟延迟
    // })
  }
}
</script>
 
<style scoped>
.home-view {
  overflow: hidden;
  padding-bottom: 50px;
}
.weui-search-bar {
  position: fixed;
  top: 0px;
  z-index: 100;
  width: 100%;
  padding: 5px 10px;
  opacity: 0.8;
  max-width: 41.2rem;
  background: transparent;
}
.weui-search-bar:before {
  border: none;
}
.weui-search-bar:after {
  border: none;
}
.weui-search-bar__form {
  background: transparent;
  height: 30px;
}
.weui-search-bar__form:after {
  border-radius: 35px;
}
.weui-search-bar__label {
  border-radius: 20px;
}
</style>