MediaComponent.vue
2.48 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
<template>
<view class="layout">
<view class="bg">
<image :src="mediaBg" />
</view>
<view
class="content"
:style="{background:background}"
>
<view
class="title"
v-if="title"
>{{title}}</view>
<template v-if="views.length && views.length > 1">
<tabs
:list="views"
@tabclick="changeView"
ref="tabs"
/>
</template>
<view
class="canvas-box"
:style="canvasStyle"
>
<template v-for="(i,index) in views">
<view
:key="index"
v-show="viewIndex == index"
:class="['canvas-view', `${viewIndex == 0 ? 'left' : 'right'}`]"
>
<wnCanvas
:drawImage="i.detailUrl"
:drawStatus="penSwitch"
:canvasId="`c-${madiaId}-${index}`"
></wnCanvas>
</view>
</template>
</view>
</view>
</view>
</template>
<script type='text/ecmascript-6'>
import Tabs from './Tabs.vue'
export default {
components: { Tabs },
props: {
views: Array,
penSwitch: Boolean,
title: String,
madiaId: Number,
mediaBg: String,
background: String,
defaultIndex: {
type: Number,
default: 0
},
canvasStyle: String
},
name: 'MediaComponent',
data () {
return {
viewIndex: 0
}
},
watch: {
watchStatus: {
immediate: true,
handler (newval) {
this.$refs?.tabs?.tabClick(this.defaultIndex)
}
},
},
computed: {
watchStatus () {
return this.$store.state.user.historyStatus
},
},
mounted () {
this.$refs?.tabs?.tabClick(this.defaultIndex)
},
methods: {
changeView (index) {
this.viewIndex = index
},
}
}
</script>
<style scoped lang='scss'>
.layout {
padding-top: 192rpx;
position: relative;
.bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 240rpx;
image {
width: 100%;
height: 100%;
}
}
.content {
border-radius: 40rpx 40rpx 0 0;
background: linear-gradient(180deg, #f7f9fc 0%, #f7f9fc 100%);
overflow: hidden;
position: relative;
z-index: 1;
.title {
font-size: 40rpx;
line-height: 48rpx;
color: #1a1a1a;
padding: 32rpx 0;
text-align: center;
}
}
.canvas-box {
padding-top: 6rpx;
.left {
animation: show-view-left 0.3s;
}
.right {
animation: show-view-right 0.3s;
}
}
}
</style>