11-mes-new/src/views/ChoicePart/index.vue
2022-11-08 16:43:08 +08:00

238 lines
6.2 KiB
Vue

<template>
<div class="choicepart-container">
<div class="choicepat-navbar">
<navbar :showhome="false" :show-title="true" />
</div>
<div class="choicepart-box">
<div
v-for="(item, index) in routeList"
:key="item.path"
class="choicepart-item"
@click="handelClick(item, index)"
>
<!-- :style="{ background: colorArr.colorList[index % 9] }" -->
<div class="choicepart-item-border">
<img :src="require(`../../assets/img/choicepart/${item.name}.png`)" alt="" />
</div>
<div class="choicepart-item-title" :title="item.meta.title">{{ item.meta.title }}</div>
</div>
</div>
</div>
</template>
<script>
// import db from '@/utils/indexDB'
import { mapGetters } from 'vuex'
// import { constantRoutes } from '@/router'
import { Navbar } from '@/layout/components'
import { downLoadBGP } from '@/api/user'
import store from '@/store'
import { blobToBase64 } from '@/utils/blobToBase64'
const colorList = ['#8080ff', '#ff8080', '#b004fb', '#ff409f', '#00caca', '#8080c0', '#cccc00', '#ff8040', '#0c4d9e']
const colorList1 = ['#b4b4ff', '#ffb4b4', '#c648fb', '#ff86c2', '#66f6f6', '#a2a2f3', '#ffff9a', '#ffc3a5', '#367cd4']
export default {
name: 'ChoicePart',
components: { Navbar },
data() {
return {
baseImg: require('../../assets/img/login-back.jpg'),
coverImgUrl: localStorage.getItem('backImg') || '',
rowNum: 1,
colorArr: {
colorList,
colorList1
},
windowWidth: 0,
dbConnect: null
}
},
computed: {
routeList() {
const cangoList = []
const permission_routes = store.getters.permission_routes
permission_routes.map(item => {
if (!item.hidden && item.meta) {
cangoList.push(item)
}
})
const formatList = cangoList.map((item, index) => {
return this.setIndex(item, index)
})
return formatList
},
...mapGetters(['language', 'dictList', 'dictObj'])
},
created() {
this.windowWidth = window.innerWidth
// this.dbConnect = db({
// DBName: 'back_img',
// version: '1.0',
// params: [
// { name: 'id', unique: true },
// { name: 'imgUrl', unique: true }
// ]
// })
// const request = this.dbConnect.openDB()
// request.onsuccess = () => {
// // const result = this.dbConnect.search('back_img', 'id', 1)
// }
},
mounted() {
console.log(this.dictList, this.dictObj)
this.getPic()
},
methods: {
getPic() {
// edit here
downLoadBGP().then(response => {
if (response.data.size) {
blobToBase64(response.data).then(res => {
this.coverImgUrl = res
localStorage.setItem('backImg', res)
// const result = this.dbConnect.search('back_img', 'id', 1)
// if (result.result) {
// this.dbConnect.update({
// id: 1,
// imgUrl: res
// })
// } else {
// this.dbConnect.add({
// id: 1,
// imgUrl: res
// })
// }
})
// this.coverImgUrl = response.data
// const temp = response.data.split('/')
// temp.splice(0, 2)
// this.coverImgUrl = 'http://zzdhg.mes.picaiba.com/' + temp.join('/')
}
})
},
resize() {},
handelClick(item, index) {
this.$store.dispatch('app/setChoicepart', index)
if (item.meta.unuse) {
this.$message.warning(this.$t('choisePart.module'))
} else {
this.toRouter(item)
}
},
toRouter(item) {
if (item.children) {
this.toRouter(item.children[0])
} else {
this.$router.push({ name: item.name })
}
},
setIndex(list, index) {
list.meta.routeIndex = index
if (list.children) {
list.children.map(item => {
this.setIndex(item, index)
})
}
return list
}
}
}
</script>
<style lang="scss" scoped>
.choicepart-container {
min-width: 100%;
min-height: 100vh;
// background: linear-gradient(-45deg, rgb(25, 25, 200), rgb(0, 100, 200));
background: url('../../assets/img/choicepart/choicepart-back.jpg') repeat;
background-size: 100% 100%;
overflow-x: scroll;
display: flex;
justify-content: center;
align-items: center;
.choicepart-box {
width: 1440px;
.choicepart-item {
display: inline-block;
width: 208px;
height: 258px;
margin: 40px;
background: url('../../assets/img/choicepart/choice-item-back.png') no-repeat;
background-size: 100% 100%;
// border: 1px dashed #fff;
// box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
top: 0;
border-radius: 5px;
overflow: hidden;
cursor: pointer;
position: relative;
img {
width: 208px;
height: 258px;
}
.choicepart-item-border {
height: 100%;
border-radius: 5px;
// padding: 0 5px;
line-height: 32px;
font-size: 28px;
font-weight: lighter;
color: #2c6bd8;
overflow: hidden;
}
.choicepart-item-title {
overflow: hidden;
padding: 0 10px;
text-overflow: ellipsis;
white-space: nowrap;
position: absolute;
bottom: 0;
left: 2px;
right: 2px;
text-align: center;
color: #fff;
font-size: 16px;
line-height: 48px;
height: 48px;
letter-spacing: 2px;
background-color: rgba($color: #0b58ff, $alpha: 0.45);
}
}
.choicepart-item:hover {
.choicepart-item-title {
background-color: rgba($color: #0b58ff, $alpha: 1);
}
}
}
.choicepat-navbar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 10;
}
}
::-webkit-scrollbar-track-piece {
//滚动条凹槽的颜色,还可以设置边框属性
background: rgba(255, 255, 255, 0.1);
}
::-webkit-scrollbar {
//滚动条的宽度
width: 9px;
height: 9px;
}
::-webkit-scrollbar-thumb {
//滚动条的设置
background-color: #dddddd;
background-clip: padding-box;
min-height: 28px;
border-radius: 9px;
}
::-webkit-scrollbar-thumb:hover {
background-color: #bbb;
}
</style>