toggle-channel.vue
3.25 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
<template>
<div class="bg" :style="bgStyle">
<div v-for="item in channel" :key="item.id" :class="item.en" @click="changeChannel(item.id)"><b>{{item.cn}}</b><span>{{item.en && item.en.toUpperCase()}}</span></div>
</div>
</template>
<style>
.bg {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
transition: all 0.6s ease 0s;
transform: translate(100%, 0);
background: resolve("me/channel_default_bg.jpg") no-repeat;
background-size: 100% 100%;
div {
font-family: "BrownStd-Bold", "PingFang SC", Helvetica, Roboto, "Heiti SC", "\9ED1\4F53", Arial;
color: #fff;
background: #000;
text-align: left;
width: 680px;
height: 105px;
line-height: 105px;
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
border: none;
font-size: 38px;
padding-left: 240px;
span {
font-size: 26px;
margin-left: 20px;
}
}
}
.bg-animation {
transform: translate(0, 0);
}
.men {
width: 680px;
height: 105px;
position: absolute;
bottom: 260px;
left: 50%;
transform: translate(-50%, -50%);
border: none;
}
.women {
width: 680px;
height: 105px;
position: absolute;
bottom: 120px;
left: 50%;
transform: translate(-50%, -50%);
border: none;
}
</style>
<script>
'use strict';
import $ from 'jquery';
import util from 'common/util';
import cookie from 'yoho-cookie';
export default {
props: ['curChannel'],
data() {
return {
channel: [
{
id: 0,
cn: '男士',
en: 'men'
},
{
id: 1,
cn: '女士',
en: 'women'
}
],
bgStyle: {}
};
},
created() {
this.getResource();
},
methods: {
changeChannel(val) {
const opt = {
path: '/'
};
this.$emit('cv', val);
cookie.set('_Channel', this.channel[val].en, opt);
cookie.set('_ChannelIndex', val, opt);
},
bgChange(src) {
return `background: url(${src})`;
},
getResource() {
$.get('/channel/resources.json', {
contentCode: '5e673b5352171c1a32736ebedb3d077c'
}).then(ret => {
if (ret[0]) {
let data = ret[0].data;
let src = util.getImgUrl(data.list[0].src, data.imageWidth, data.imageHeight);
this.bgStyle = {
background: `url(${src}) no-repeat`,
backgroundSize: '100% 100%'
};
}
});
}
}
};
</script>