-
Notifications
You must be signed in to change notification settings - Fork 0
/
gants.vue
164 lines (155 loc) · 4.02 KB
/
gants.vue
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
<template>
<view class="bg">
<view class="indexapp">
<view class="newbg">
<new-nav></new-nav>
</view>
</view>
<view class="content_1_bg">
<view class="_title">$100,000 GRANTS</view>
<view class="_desc">
The DBOOK team will raise $100,000 to support these creators, hoping to help them overcome the financial
pressures of their early literary endeavors, and we'd love to help you create more resources if you have
a great book.
</view>
<view class="_welcome">
<div id="welcome" class="welcome" loops="0"></div>
</view>
</view>
<bottom></bottom>
<div id="yyzCanvas" class="yyzCanvas" loops="0" v-if="loading"></div>
</view>
</template>
<script>
import bottom from '@/components/newbottom.vue';
import newNav from '@/components/newnav.vue';
import SVGA from "svgaplayerweb"
export default {
components: {
bottom,
newNav
},
data() {
return {
svgaInfo: '/static/index/welcome.svga',
svgaLoad: '/static/index/loading.svga',
screenWidth: null,
loading: true
};
},
watch: {
//监听页面屏幕宽度
screenWidth: function(n, o) {
if (n < 1150) {
uni.reLaunch({
url: '/mgants'
})
}
}
},
mounted() {
let that = this;
//网页可见区域宽
that.screenWidth = document.body.clientWidth;
//使用window.onresize方法获取屏幕尺寸;
window.onresize = () => {
return (() => {
that.screenWidth = document.body.clientWidth;
})()
}
that.playSvg();
//3秒关闭页面loading动画
setTimeout(function() {
that.loading = false;
}, 1500);
},
methods: {
playSvg() {
//一定要使用$nextTick,等到页面加载完成再处理数据,否则会找不到页面元素,报Undefind的错误
const that = this
that.$nextTick(() => {
const player = new SVGA.Player('#welcome')
const parser = new SVGA.Parser('#welcome')
//这里使用动态加载的方式,加载tableData返回的svga源(例如:http://a.svga)
parser.load(that.svgaInfo, function(videoItem) {
player.setVideoItem(videoItem);
player.startAnimation();
player.clearsAfterStop = true; //player有很多属性,根据需要设置
player.onFinished(function() {
alert("动画停止了!!!")
});
})
const lPlayer = new SVGA.Player('#yyzCanvas')
const lParser = new SVGA.Parser('#yyzCanvas')
//这里使用动态加载的方式,加载tableData返回的svga源(例如:http://a.svga)
lParser.load(that.svgaLoad, function(videoItem) {
lPlayer.setVideoItem(videoItem);
lPlayer.startAnimation();
lPlayer.clearsAfterStop = true; //lPlayer有很多属性,根据需要设置
lPlayer.onFinished(function() {
alert("动画停止了!!!")
});
})
})
},
}
}
</script>
<style scoped lang="scss">
.bg {
background-color: #fff;
font-size: 15px;
color: #000000;
.yyzCanvas {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 200000;
background-color: #24180e;
opacity: 1;
}
.indexapp {
width: 100%;
margin: 0 auto;
height: 5rem;
background-image: url('/static/index/grantsbg.png');
background-repeat: no-repeat;
background-position: center 0;
background-size: cover;
.newbg {
width: 100%;
margin: 0 auto;
}
}
.content_1_bg {
width: 100%;
max-width: 1150px;
margin: .65rem auto 0;
height: auto;
overflow: hidden;
background-color: #fff;
text-align: center;
._welcome {
margin: 0.5rem auto;
width: 12.1rem;
height: 6.4rem;
max-width: 1150px;
}
._title {
font-size: 100rpx;
font-family: Alibaba PuHuiTi;
font-weight: 800;
text-align: center;
}
._desc {
line-height: .3rem;
font-family: PingFang SC;
font-weight: 400;
text-align: center;
margin-top: .2rem;
}
}
}
</style>