Index.vue
5.9 KB
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
<template>
<div class='index'>
<div style="position: absolute;top: 0;width: 100%;" v-if="gcfg">
<van-notice-bar :text="gcfg.Indexotice" left-icon="volume-o" mode="closeable" color="white" :background="gcfg.BackgroundColor" />
<van-swipe :autoplay="3000" :indicator-color="gcfg.BackgroundColor">
<van-swipe-item v-for="(image, index) in bannerlist" :key="index">
<img class="topimg" @touchstart="touchEvent" @touchmove="touchEvent" @touchend="touchEvent" v-on:click="swipe_click(image.id)" :src="image.image" />
</van-swipe-item>
</van-swipe>
<div v-show="isShow">
<van-cell-group>
<van-cell icon="star" title="New" label="最新上架" title-class="tc-sel" :style="'color:'+ gcfg.BackgroundColor+';' " label-class="lc-sel" />
</van-cell-group>
<div class="panel-body" style="width: 100%; overflow:scroll;">
<div style="border: 1px #000000; margin: 0 13px 0;display: flex;">
<div v-for="(rd, index) in newData" :key="index" style="margin: 0 1em 1em 0;">
<router-link :to="'goods?id='+rd.goods_id">
<img class="recommend-img" v-lazy="rd.ImageFrist" />
<div class="onelist-hidden">{{rd.goods_name}}</div>
<div class="price" :style="'color:'+ gcfg.BackgroundColor+'!important;' ">¥{{rd.spec[0].goods_price}}</div>
</router-link>
</div>
</div>
</div>
<!-- 随机推荐 -->
<van-cell-group>
<van-cell icon="fire" title="Random" label="随机推荐" :style="'color:'+ gcfg.BackgroundColor+';' " title-class="tc-sel" label-class="lc-sel" />
</van-cell-group>
<div style="margin-bottom:18px;">
<vue-waterfall-easy ref="waterfall" :imgsArr="randomlist" @click="clickFn"
@scrollReachBottom="getData" srcKey="ImageFrist" height="680"
:mobileGap="12" >
<div class="img-info" slot-scope="props">
<p class="some-info">{{props.value.goods_name}}</p>
<p class="some-info" :style="'color:'+ gcfg.BackgroundColor+'!important;' ">¥{{props.value.spec[0].goods_price}}</p>
</div>
<div slot="waterfall-over"></div>
</vue-waterfall-easy>
</div>
<Copyright></Copyright>
</div>
</div>
<BottomTabbar :curactive="0" v-if="gcfg"></BottomTabbar>
<cube-view></cube-view>
</div>
</template>
<script>
import CubeView from '@/components/TP/cube-view'
import BottomTabbar from '@/components/TP/BottomTabbar'
import Copyright from '@/components/TP/Copyright'
import * as util from '@/utils/network'
import vueWaterfallEasy from 'vue-waterfall-easy'
export default {
name: 'app',
components: {
CubeView,
BottomTabbar,
Copyright,
vueWaterfallEasy
},
data() {
return {
bannerlist: [],
newData:[],
randomlist: [],
Indexotice: '',
isShow:true,
lastTouchModel:'',
CanClick:false,
gcfg:[],
}
},
methods: {
getData(){
this.$refs.waterfall.waterfallOver()
},
clickFn(event, { index, value }) {
// 阻止a标签跳转
event.preventDefault()
// 只有当点击到图片时才进行操作
if (event.target.tagName.toLowerCase() == 'img') {
//console.log('img clicked',index, value)
this.$router.push({path: 'goods', query: {id: value.goods_id}})
}
},
touchEvent:function(e){
if(this.lastTouchModel == 'touchstart' && e.type == 'touchend'){
//此时为点击
//console.log('touchclick')
this.CanClick = true
}
this.lastTouchModel = e.type
},
swipe_click: function(imgid){
if(this.CanClick){
this.$router.push({path: 'news', query: {id: imgid }})
this.CanClick = false
}
},
axios_Request: function() {
var url = "/addons/litestore/api.index/index"
let that = this;
//这里直接调用网络接口
util.get(url, { },
function(result) {
that.bannerlist = result['data']['bannerlist']
that.newData = result['data']['NewList']
that.randomlist = result['data']['Randomlist']
},
);
},
},
created: function() {
this.axios_Request();
if(this.$router.currentRoute.path=="/goods"||this.$router.currentRoute.path=="/news"){
this.isShow = false
}
this.gcfg = this.$store.getters.getGcfg
},
watch:{
$route(to,from) {
if((to.path=="/goods"||to.path=="/news")
&& from.path=="/"){
this.isShow = false
}
console.log(from);
if((from.path=="/goods" || from.path=="/news")
&& to.path=="/"){
this.isShow = true
}
},
"$store.state.gcfg": function(){
this.gcfg = this.$store.getters.getGcfg
},
},
}
</script>
<style>
.index .img-info{
padding: 6px 10px;
}
.index .some-info{
margin: 0;
font-size: 0.9em;
text-align: center;
}
.index .price{
text-align: center;
margin-top: 0.2em;
}
.index .onelist-hidden{
overflow:hidden;
height: 1.2em;
color:black;
text-align: center;
}
.index .van-swipe-item img.topimg {
display: block;
height: 100%;
width: 100%;
}
.index .lc-sel {
color: black;
font-size: 1.2em;
font-weight: bolder;
margin-left: -1.2em;
}
.index .recommend-img {
height: auto;
max-height: 8em;
}
.index .recommend-img:last-child {
margin: 0 1em 0 0;
}
.index .img-group {
position: relative;
display: inline-block;
width: 50%;
margin-bottom: 13px;
}
.index .img-tip {
position: absolute;
width: 66%;
height: 95%;
top: 3px;
margin-left: 5px;
text-align: center;
}
.index .img-tip img{
max-width: 100%;
max-height: 98%;
border-top-right-radius: 3em;
}
.index .img-group .img-tip span{
color: white;
font-size: 0.68em;
width: 100%;
position: absolute;
left: 0;
bottom: 2px;
background-color: black;
opacity: 0.68;
border-radius: 4px;
}
.index .newlist-c{
display: flex;
margin: 8px;
flex-direction: row;
flex-wrap: wrap;
}
.vue-waterfall-easy-container .vue-waterfall-easy a.img-inner-box {
box-shadow: 0 1px 3px rgb(200, 143, 232)!important;
}
[class*=van-hairline]::after {
border-bottom-width: 0!important;
}
</style>