Commit 542b52da by gyy

缓存

parent 8499a687
<template>
<div class="container">
<div v-for="item in unpayList">{{item.name}}</div>
<div @click="toDetail">详情</div>
<div class="pagination-container">
<el-pagination
:current-page="pagination.page"
:page-sizes="[10,20,30, 50]"
:page-size="pagination.size"
:total="total"
background
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</div>
</template>
<script>
import requestApi from '../../../../assets/js/requestApi.js'
export default {
data() {
return {
total: 80,
pagination: {
page: 1,
size: 10
},
unpayList: []
}
},
methods: {
getList: async function () {
let param = {
storeId: 25,
categoryId: 0,
pageNo: this.pagination.page,
pageSize: this.pagination.size
}
let obj = await requestApi.getList(this, param)
this.unpayList = obj.data.result
},
handleSizeChange(val) {
this.pagination.size = val
this.getList()
},
handleCurrentChange(val) {
this.pagination.page = val
this.getList()
},
toDetail() {
this.$router.push({
path: 'laps-detail'
})
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
}
},
mounted() {
this.getList()
console.log('00')
}
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.pagination.page = 1
// this.pagination.size = 10
// this.getList()
// }
// }
}
</script>
<style scoped>
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>
<template>
<section class="container">
<h1 class="title">
{{$route.name}}
</h1>
<page></page>
</section>
</template>
<script>
import page from './components/page.vue'
export default {
name: 'good-laps-goods-search',
components: {
page
},
methods: {}
}
</script>
<style scoped>
</style>
<template> <template>
<div class="container"> <section class="container">
<div>{{count}}</div> <nuxt-link to="goods-search">返回</nuxt-link>
<button @click="b">plus</button> </section>
</div>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {}
count: 1 },
} methods: {
},
methods: {
b() {
this.count++
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.title
{
margin: 50px 0;
}
</style> </style>
<template>
<div>
<div @click="toDetail">详情</div>
<div>{{count}}</div>
<button @click="add">plus</button>
</div>
</template>
<script>
export default {
data() {
return {
count: 1
}
},
methods: {
add() {
this.count++
},
toDetail() {
this.$router.push({
path: 'order-detail'
})
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
}
}
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.count = 1
// }
// }
}
</script>
<style>
</style>
<template> <template>
<section class="container"> <section class="container">
<h1 class="title"> <nuxt-link to="package-search">返回</nuxt-link>
{{$route.name}}
</h1>
</section> </section>
</template> </template>
<script>
export default {
data() {
return {}
},
methods: {
}
}
</script>
<style scoped> <style scoped>
.title .title
{ {
......
...@@ -3,9 +3,21 @@ ...@@ -3,9 +3,21 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<zj></zj>
</section> </section>
</template> </template>
<script>
import zj from './component/zj.vue'
export default {
name: 'order-package-package-search',
components: {
zj
},
methods: {}
}
</script>
<style scoped> <style scoped>
.title .title
{ {
......
...@@ -3,12 +3,21 @@ ...@@ -3,12 +3,21 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<page></page>
</section> </section>
</template> </template>
<style scoped> <script>
.title import page from './components/page.vue'
{ export default {
margin: 50px 0; name: 'sys-homepage-ads',
components: {
page
},
methods: {}
} }
</script>
<style scoped>
</style> </style>
<template>
<div class="container">
<div v-for="item in unpayList">{{item.name}}</div>
<div @click="toDetail">详情</div>
<div class="pagination-container">
<el-pagination
:current-page="pagination.page"
:page-sizes="[10,20,30, 50]"
:page-size="pagination.size"
:total="total"
background
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</div>
</template>
<script>
import requestApi from '../../../../assets/js/requestApi.js'
export default {
data() {
return {
total: 80,
pagination: {
page: 1,
size: 10
},
unpayList: []
}
},
methods: {
getList: async function () {
let param = {
storeId: 25,
categoryId: 0,
pageNo: this.pagination.page,
pageSize: this.pagination.size
}
let obj = await requestApi.getList(this, param)
this.unpayList = obj.data.result
},
handleSizeChange(val) {
this.pagination.size = val
this.getList()
},
handleCurrentChange(val) {
this.pagination.page = val
this.getList()
},
toDetail() {
this.$router.push({
path: 'home-detail'
})
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
}
},
mounted() {
this.getList()
console.log('00')
}
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.pagination.page = 1
// this.pagination.size = 10
// this.getList()
// }
// }
}
</script>
<style scoped>
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>
<template>
<section class="container">
<nuxt-link to="ads">返回</nuxt-link>
</section>
</template>
<script>
export default {
data() {
return {}
},
methods: {
}
}
</script>
<style scoped>
.title
{
margin: 50px 0;
}
</style>
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
<script> <script>
import requestApi from '../../../../assets/js/requestApi.js' import requestApi from '../../../../assets/js/requestApi.js'
export default { export default {
name: 'aaa',
data() { data() {
return { return {
total: 80, total: 80,
...@@ -53,18 +52,26 @@ export default { ...@@ -53,18 +52,26 @@ export default {
this.$router.push({ this.$router.push({
path: 'detail' path: 'detail'
}) })
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
} }
}, },
mounted() { mounted() {
this.getList() this.getList()
console.log('00') console.log('00')
},
activated() {
this.pagination.page = 1
this.pagination.size = 10
this.getList()
console.log('------')
} }
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.pagination.page = 1
// this.pagination.size = 10
// this.getList()
// }
// }
} }
</script> </script>
......
...@@ -3,16 +3,11 @@ ...@@ -3,16 +3,11 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<zj></zj>
</section> </section>
</template> </template>
<script> <script>
import zj from './components/zj.vue'
export default { export default {
components: {
zj
},
methods: {} methods: {}
} }
</script> </script>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script> <script>
import page from './components/page.vue' import page from './components/page.vue'
export default { export default {
name: 'managers', name: 'sys-usr-managers',
components: { components: {
page page
}, },
......
const getters = { const getters = {
sVisitedViews: state => state.systemTags.sVisitedViews, visitedViews: state => state.tagView.visitedViews,
sCachedViews: state => state.systemTags.sCachedViews, cachedViews: state => state.tagView.cachedViews
gVisitedViews: state => state.goodsTags.gVisitedViews,
gCachedViews: state => state.goodsTags.gCachedViews,
oVisitedViews: state => state.orderTags.oVisitedViews,
oCachedViews: state => state.orderTags.oCachedViews,
fVisitedViews: state => state.financalTags.fVisitedViews,
fCachedViews: state => state.financalTags.fCachedViews
} }
export default getters export default getters
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import systemTags from './modules/system-tags'
import usrAuth from './modules/usr-auth' import usrAuth from './modules/usr-auth'
import goodsTags from './modules/goods-tags' import tagView from './modules/tagView'
import orderTags from './modules/order-tags'
import financalTags from './modules/financal-tags'
import getters from './getters' import getters from './getters'
Vue.use(Vuex) Vue.use(Vuex)
...@@ -14,10 +11,7 @@ const store = () => { ...@@ -14,10 +11,7 @@ const store = () => {
return new Vuex.Store({ return new Vuex.Store({
modules: { modules: {
usrAuth, usrAuth,
systemTags, tagView
goodsTags,
orderTags,
financalTags
}, },
getters getters
}) })
......
const financalTags = {
state: {
fVisitedViews: [],
fCachedViews: []
},
mutations: {
F_ADD_VISITED_VIEWS: (state, view) => {
if (state.fVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.fVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.fCachedViews.push(view.name)
}
},
F_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.fVisitedViews.entries()) {
if (v.path === view.path) {
state.fVisitedViews.splice(i, 1)
break
}
}
for (const i of state.fCachedViews) {
if (i === view.name) {
const index = state.fCachedViews.indexOf(i)
state.fCachedViews.splice(index, 1)
break
}
}
},
F_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.fVisitedViews.entries()) {
if (v.path === view.path) {
state.fVisitedViews = state.fVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.fCachedViews) {
if (i === view.name) {
const index = state.fCachedViews.indexOf(i)
state.fCachedViews = state.fCachedViews.slice(index, index + 1)
break
}
}
},
F_DEL_ALL_VIEWS: state => {
state.fVisitedViews = []
state.fCachedViews = []
}
},
actions: {
fAddVisitedViews({ commit }, view) {
commit('F_ADD_VISITED_VIEWS', view)
},
fDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('F_DEL_VISITED_VIEWS', view)
resolve([...state.fVisitedViews])
})
},
fDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('F_DEL_OTHERS_VIEWS', view)
resolve([...state.fVisitedViews])
})
},
fDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('F_DEL_ALL_VIEWS')
resolve([...state.fVisitedViews])
})
}
}
}
export default financalTags
const goodsTags = {
state: {
gVisitedViews: [],
gCachedViews: []
},
mutations: {
G_ADD_VISITED_VIEWS: (state, view) => {
if (state.gVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.gVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.gCachedViews.push(view.name)
}
},
G_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.gVisitedViews.entries()) {
if (v.path === view.path) {
state.gVisitedViews.splice(i, 1)
break
}
}
for (const i of state.gCachedViews) {
if (i === view.name) {
const index = state.gCachedViews.indexOf(i)
state.gCachedViews.splice(index, 1)
break
}
}
},
G_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.gVisitedViews.entries()) {
if (v.path === view.path) {
state.gVisitedViews = state.gVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.gCachedViews) {
if (i === view.name) {
const index = state.gCachedViews.indexOf(i)
state.gCachedViews = state.gCachedViews.slice(index, index + 1)
break
}
}
},
G_DEL_ALL_VIEWS: state => {
state.gVisitedViews = []
state.gCachedViews = []
}
},
actions: {
gAddVisitedViews({ commit }, view) {
commit('G_ADD_VISITED_VIEWS', view)
},
gDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('G_DEL_VISITED_VIEWS', view)
resolve([...state.gVisitedViews])
})
},
gDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('G_DEL_OTHERS_VIEWS', view)
resolve([...state.gVisitedViews])
})
},
gDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('G_DEL_ALL_VIEWS')
resolve([...state.gVisitedViews])
})
}
}
}
export default goodsTags
const orderTags = {
state: {
oVisitedViews: [],
oCachedViews: []
},
mutations: {
O_ADD_VISITED_VIEWS: (state, view) => {
if (state.oVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.oVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.oCachedViews.push(view.name)
}
},
O_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.oVisitedViews.entries()) {
if (v.path === view.path) {
state.oVisitedViews.splice(i, 1)
break
}
}
for (const i of state.oCachedViews) {
if (i === view.name) {
const index = state.oCachedViews.indexOf(i)
state.oCachedViews.splice(index, 1)
break
}
}
},
O_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.oVisitedViews.entries()) {
if (v.path === view.path) {
state.oVisitedViews = state.oVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.oCachedViews) {
if (i === view.name) {
const index = state.oCachedViews.indexOf(i)
state.oCachedViews = state.oCachedViews.slice(index, index + 1)
break
}
}
},
O_DEL_ALL_VIEWS: state => {
state.oVisitedViews = []
state.oCachedViews = []
}
},
actions: {
oAddVisitedViews({ commit }, view) {
commit('O_ADD_VISITED_VIEWS', view)
},
oDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('O_DEL_VISITED_VIEWS', view)
resolve([...state.oVisitedViews])
})
},
oDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('O_DEL_OTHERS_VIEWS', view)
resolve([...state.oVisitedViews])
})
},
oDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('O_DEL_ALL_VIEWS')
resolve([...state.oVisitedViews])
})
}
}
}
export default orderTags
const systemTags = {
state: {
sVisitedViews: [],
sCachedViews: []
},
mutations: {
S_ADD_VISITED_VIEWS: (state, view) => {
if (state.sVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.sVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.sCachedViews.push(view.name)
}
},
S_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.sVisitedViews.entries()) {
if (v.path === view.path) {
state.sVisitedViews.splice(i, 1)
break
}
}
for (const i of state.sCachedViews) {
if (i === view.name) {
const index = state.sCachedViews.indexOf(i)
state.sCachedViews.splice(index, 1)
break
}
}
},
S_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.sVisitedViews.entries()) {
if (v.path === view.path) {
state.sVisitedViews = state.sVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.sCachedViews) {
if (i === view.name) {
const index = state.sCachedViews.indexOf(i)
state.sCachedViews = state.sCachedViews.slice(index, index + 1)
break
}
}
},
S_DEL_ALL_VIEWS: state => {
state.sVisitedViews = []
state.sCachedViews = []
}
},
actions: {
sAddVisitedViews({ commit }, view) {
commit('S_ADD_VISITED_VIEWS', view)
},
sDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('S_DEL_VISITED_VIEWS', view)
resolve([...state.sVisitedViews])
})
},
sDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('S_DEL_OTHERS_VIEWS', view)
resolve([...state.sVisitedViews])
})
},
sDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('S_DEL_ALL_VIEWS')
resolve([...state.sVisitedViews])
})
}
}
}
export default systemTags
const tagView = {
state: {
visitedViews: [],
cachedViews: []
},
mutations: {
F_ADD_VISITED_VIEWS: (state, view) => {
if (state.visitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.visitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.cachedViews.push(view.name)
}
},
F_DEL_ALL_VIEWS: state => {
state.visitedViews = []
state.cachedViews = []
}
},
actions: {
addVisitedViews({ commit }, view) {
commit('F_ADD_VISITED_VIEWS', view)
},
delAllViews({ commit, state }) {
return new Promise(resolve => {
commit('F_DEL_ALL_VIEWS')
resolve([...state.visitedViews])
})
}
}
}
export default tagView
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment