添加转卖动画

This commit is contained in:
zyronon 2019-08-04 01:57:12 +08:00
parent 1fdcaeb56e
commit de74c9d1d7
10 changed files with 94 additions and 38 deletions

5
package-lock.json generated
View File

@ -12965,6 +12965,11 @@
"animate.css": "^3.7.0" "animate.css": "^3.7.0"
} }
}, },
"vuex": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.1.tgz",
"integrity": "sha512-ER5moSbLZuNSMBFnEBVGhQ1uCBNJslH9W/Dw2W7GZN23UQA69uapP5GTT9Vm8Trc0PzBSVt6LzF3hGjmv41xcg=="
},
"watchpack": { "watchpack": {
"version": "1.6.0", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz",

View File

@ -13,7 +13,7 @@
"pinyin": "^2.9.0", "pinyin": "^2.9.0",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-router": "^3.0.7", "vue-router": "^3.0.7",
"vueg": "^1.4.5" "vuex": "^3.1.1"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^3.0.3", "@vue/cli-plugin-babel": "^3.0.3",

View File

@ -1,6 +1,6 @@
<template> <template>
<div id="app"> <div id="app">
<transition name="slide-fade"> <transition :name="$store.state.pageAnim">
<router-view></router-view> <router-view></router-view>
</transition> </transition>
</div> </div>
@ -10,22 +10,24 @@
export default { export default {
name: 'app', name: 'app',
data() { data() {
return { return {}
transitionName: 'fold-left'
}
}, },
watch: { watch: {
'$route'(to, from) { $route(to, from) {
//indexpointList let rootRouters = ['/', '/home', '/attention', '/message', '/me']
// console.log(to) // "/pointList" if (rootRouters.indexOf(to.path) !== -1 && rootRouters.indexOf(from.path) !== -1) {
// console.log(from) // /index this.$store.commit('setPageAnim', 'none')
// if (to.path === '/me') { return
// this.transitionName = 'fold-right' }
// } else { let routers = ['/', '/home', '/attention', '/message', '/me', '/myCard', '/chooseCountry']
// this.transitionName = 'fold-left' //
// } if (routers.indexOf(to.path) > routers.indexOf(from.path)) {
this.$store.commit('setPageAnim', 'go')
} else {
this.$store.commit('setPageAnim', 'back')
}
}
} }
},
} }
</script> </script>
@ -35,17 +37,47 @@
height: 100%; height: 100%;
} }
/* 可以设置不同的进入和离开动画 */
/* 设置持续时间和动画函数 */ .go-enter {
.slide-fade-enter-active { left: 100%;
transition: all .3s ease;
} }
.slide-fade-leave-active {
transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0); .go-enter-to {
left: 0;
} }
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ { .go-leave {
transform: translateX(10px); left: 0;
opacity: 0;
} }
.go-leave-to {
left: -100%;
}
.go-enter-active, .go-leave-active {
transition: all .3s;
}
.back-enter {
left: -100%;
}
.back-enter-to {
left: 0;
}
.back-leave {
left: 0;
}
.back-leave-to {
left: 100%;
}
.back-enter-active, .back-leave-active {
transition: all .3s;
}
</style> </style>

View File

@ -1,6 +1,6 @@
<template> <template>
<div id='BaseHeader'> <div id='BaseHeader'>
<svg v-if="isShowLeftBtn" @click="$emit('back')" t="1564765917375" class="icon left" viewBox="0 0 1024 1024" <svg v-if="isShowLeftBtn" @click="back()" t="1564765917375" class="icon left" viewBox="0 0 1024 1024"
version="1.1" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
p-id="16292" width="32" height="32"> p-id="16292" width="32" height="32">
@ -36,7 +36,12 @@
}, },
computed: {}, computed: {},
methods: {} methods: {
back(){
this.$store.commit('setPageAnim','back')
window.history.back()
}
}
} }
</script> </script>

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
import App from './App.vue' import App from './App.vue'
import Icon from 'vue-svg-icon/Icon.vue' import Icon from 'vue-svg-icon/Icon.vue'
import VueRouter from 'vue-router' import VueRouter from 'vue-router'
import vueg from 'vueg' import Vuex from 'vuex'
import './assets/scss/index.scss' import './assets/scss/index.scss'
import Index from './pages/home/Index' import Index from './pages/home/Index'
@ -21,6 +21,7 @@ Vue.config.productionTip = false
Vue.component('icon', Icon) Vue.component('icon', Icon)
Vue.component('BaseHeader', BaseHeader) Vue.component('BaseHeader', BaseHeader)
Vue.use(VueRouter) Vue.use(VueRouter)
Vue.use(Vuex)
const router = new VueRouter({ const router = new VueRouter({
mode: 'hash', mode: 'hash',
@ -36,7 +37,17 @@ const router = new VueRouter({
{ path: '/myCard', component: MyCard }, { path: '/myCard', component: MyCard },
] ]
}) })
Vue.use(vueg, router) // 传入实例化后的router, Options为可选的插件配置
const store = new Vuex.Store({
state: {
pageAnim: 'none'
},
mutations: {
setPageAnim(state, states) {
state.pageAnim = states
}
}
})
Vue.mixin({ Vue.mixin({
methods: { methods: {
@ -63,7 +74,9 @@ Vue.mixin({
} }
}) })
new Vue({ new Vue({
render: h => h(App), render: h => h(App),
store,
router router
}).$mount('#app') }).$mount('#app')

View File

@ -97,12 +97,12 @@
<style scoped lang="scss"> <style scoped lang="scss">
#attention { #attention {
position: fixed;
/*background: rgb(222434);*/ /*background: rgb(222434);*/
/*background: #161822;*/ /*background: #161822;*/
// //
background: #2e3244; background: #2e3244;
color: #b8b9c1; color: #b8b9c1;
position: relative;
.items { .items {
>.item { >.item {
border-bottom: 1px solid #494950; border-bottom: 1px solid #494950;

View File

@ -397,6 +397,7 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
#home-index { #home-index {
position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;

View File

@ -677,6 +677,7 @@
$left-bg-color: #333; $left-bg-color: #333;
$right-bg-color: #2e3244; $right-bg-color: #2e3244;
.Me { .Me {
position: fixed;
font-size: 1.6rem; font-size: 1.6rem;
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@ -4,7 +4,7 @@
<div class="header pt15p"> <div class="header pt15p">
<div class="title"> <div class="title">
<p class="tac fb c-white ">消息</p> <p class="tac fb c-white ">消息</p>
<span>联系人</span> <span @click="nav('/myCard')">联系人</span>
</div> </div>
</div> </div>
<div class="line mt20p"></div> <div class="line mt20p"></div>
@ -82,10 +82,12 @@
<style scoped lang="scss"> <style scoped lang="scss">
#Message { #Message {
position: fixed;
font-size: 1.6rem; font-size: 1.6rem;
background: #2e3244; background: #2e3244;
color: #b8b9c1; color: #b8b9c1;
height: 100%; height: 100%;
width: 100vw;
.header { .header {
.title { .title {

View File

@ -1,6 +1,6 @@
<template> <template>
<div id='MyCard'> <div id='MyCard'>
<BaseHeader @back="back"> <BaseHeader >
<svg t="1564765646732" class="icon" viewBox="0 0 1024 1024" version="1.1" <svg t="1564765646732" class="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
p-id="15320" width="32" height="32"> p-id="15320" width="32" height="32">
@ -31,7 +31,6 @@
</div> </div>
</div> </div>
</div> </div>
</transition>
</template> </template>
<script> <script>
export default { export default {
@ -47,18 +46,16 @@
}, },
computed: {}, computed: {},
methods: { methods: {
back() {
window.history.back()
}
} }
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
#MyCard { #MyCard {
width: 100%; width: 100vw;
height: 100%; height: 100%;
position: relative; position: fixed;
.content { .content {
padding: 20px; padding: 20px;