实现首页轮播图和分布地图

main
HZXhuang 2 years ago
parent e5ca9f21e9
commit 480cd70bf5

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

@ -0,0 +1,218 @@
<template>
<div id="worldMapChart" class="mapStyle" :style="{margin: 'auto', height: height, width: '100%'}"></div>
</template>
<script>
import jsonData from "../../assets/data/hunan_map.json"
export default {
name: "DistributeMap",
props: {
height: {
type: String,
default: "200px",
},
width: {
type: String,
default: "300px",
required: false
}
},
data() {
return {
screenWidth: 1536,
dataList: [
{
name: "常德市",
value: 3,
per: 0
},
{
name: "郴州市",
value: 4,
per: 0
},
{
name: "衡阳市",
value: 1,
per: 0
},
{
name: "怀化市",
value: 1,
per: 0
},{
name: "娄底市",
value: 4,
per: 0
},
{
name: "邵阳市",
value: 2,
per: 0
},
{
name: "湘潭市",
value: 1,
per: 0
},
{
name: "湘西土家族苗族自治州",
value: 6,
per: 0
},
{
name: "益阳市",
value: 1,
per: 0
},
{
name: "永州市",
value: 1,
per: 0
},
{
name: "岳阳市",
value: 0,
per: 0
},
{
name: "张家界市",
value: 1,
per: 0
},
{
name: "长沙市",
value: 1,
per: 0
},
{
name: "株洲市",
value: 2,
per: 0
},
]
}
},
methods: {
initWorldMapChart(){
let sum = 0
this.dataList.map((item)=>{
sum += item.value;
})
for(let i = 0; i < this.dataList.length; i++){
this.dataList[i].per = Math.round(this.dataList[i].value / sum * 100)
}
this.option = {
tooltip: {
//
formatter: function(params) {
return (
params.name + " 共" + params.value + "个,占:"+
params.data.per+"%"
);
},
backgroundColor: 'rgba(19, 25, 47, 0.6)',
borderColor: 'deepskyblue',
textStyle: {
color: 'white', //
fontSize: this.screenWidth * 0.01
}
},
visualMap: {
textStyle: {
color: '#b5bb94',
fontSize: this.screenWidth * 0.009
},
itemHeight: this.screenWidth * 0.092,
itemWidth: this.screenWidth * 0.0131,
min: 0,
max: 100,
left: 65,
top: 250,
text: ["高(百分比)", "低"], //
inRange: {
color: [
//
"#efecec",
"#a693be",
"#8b75a6",
"#6e5e8d",
"#663d74",
"#2f1136", //
"#f091a1",
"#e782a0",
"#e16c96",
"#eb3c70", //
],
//
},
show: true, //
},
geo: {
map: 'world', //
roam: true, //
zoom: 1, //
label: {
show: false,//
fontSize: this.screenWidth * 0.0066,
color: "rgba(201,174,174,0.7)",
},
nameMap:{
"常德": "常德市",
"郴州": "郴州市",
"衡阳": "衡阳市",
"怀化": "怀化市",
"娄底": "娄底市",
"邵阳": "邵阳市",
"湘潭": "湘潭市",
"湘西": "湘西土家族苗族自治州",
"益阳": "益阳市",
"永州": "永州市",
"岳阳": "岳阳市",
"张家界": "张家界市",
"长沙": "长沙市",
"株洲": "株洲市",
},
emphasis: {
borderColor: "rgba(0, 0, 0, 0.2)",
itemStyle:{ //
areaColor: "skyblue", //
shadowOffsetX: 0,
shadowOffsetY: 0,
shadowBlur: 20,
borderWidth: 0,
shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
},
//
series: [
{
name: "地级市",
type: "map",
geoIndex: 0,
data: this.dataList,
},
],
}
this.worldMapChart = this.$echarts.init(document.getElementById("worldMapChart"));
this.$echarts.registerMap('world', jsonData)
this.worldMapChart.setOption(this.option);
},
},
mounted() {
this.initWorldMapChart()
window.addEventListener('resize', ()=>{
this.screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
this.worldMapChart.resize();
})
}
}
</script>
<style scoped>
</style>

@ -0,0 +1,95 @@
<template>
<div>
<el-form :inline="true" :model="search_data" class="user-search">
<el-form-item label="搜索:">
<el-select size="medium" v-model="search_data" placeholder="请选择地区" @change="updateChart">
<el-option
v-for="item in emotionOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="">
<el-input size="small"
v-model="search_data.searchCountry"
placeholder="请输入评论所属的国家"
@keypress.enter.native="search"
clearable
>
</el-input>
</el-form-item>
<el-form-item label="">
<el-input size="small"
v-model="search_data.searchPlatform"
placeholder="请输入评论所属的平台"
@keypress.enter.native="search"
clearable
>
</el-input>
</el-form-item>
<el-form-item label="">
<el-input size="small"
v-model="search_data.searchContent"
placeholder="请输入评论的内容"
@keypress.enter.native="search"
clearable
>
</el-input>
</el-form-item>
</el-form>
<!--列表-->
<el-table size="small" :data="list_data" highlight-current-row v-loading="loading"
border element-loading-text="拼命加载中" @selection-change="handleSelectionChange" style="width: 100%;">
<el-table-column sortable prop="id" label="ID" width="80">
</el-table-column>
<el-table-column prop="name" label="名称" width="100">
</el-table-column>
<el-table-column prop="category" label="类别" width="140">
</el-table-column>
<el-table-column prop="type" label="类型" width="140">
</el-table-column>
<el-table-column prop="releaseTime" label="公布时间" width="120">
</el-table-column>
<el-table-column prop="applicant" label="申报地区或单位" width="100">
</el-table-column>
<el-table-column prop="protectionUnit" label="保护单位" width="100">
</el-table-column>
</el-table>
<!-- 分页组件 -->
<!-- <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>-->
</div>
</template>
<script>
export default {
// eslint-disable-next-line vue/multi-word-component-names
name: "Search",
data() {
return {
search_data: {
},
list_data: [
{
id: 1,
name: "土家族织锦技艺",
category: "传统技艺",
releaseTime: "2006",
type: "新增项目",
applicant: "湖南省湘西土家族苗族自治州",
protectionUnit: "湘西土家族苗族自治州非物质文化遗产保护中心"
}
]
}
}
}
</script>
<style scoped>
</style>

@ -1,6 +1,6 @@
<template>
<div>
<el-carousel :interval="2000" type="card" height="300px" indicator-position="outside">
<el-carousel :interval="6000" height="500px" indicator-position="outside">
<el-carousel-item v-for="item in show_images" :key="item.id" align="center">
<img :src="item.path" class="banner_img"/>
</el-carousel-item>
@ -16,25 +16,18 @@ export default {
show_images: [
{
id: 1,
path: require('../../assets/img/banner_img1.jpg')
path: require('../../assets/img/banner1.png')
},
{
id: 2,
path: require('../../assets/img/banner_img2.jpg')
path: require('../../assets/img/banner2.png')
},
{
id: 3,
path: require('../../assets/img/banner_img3.jpg')
path: require('../../assets/img/banner3.png')
},{
id: 4,
path: require('../../assets/img/banner_img4.jpg')
},{
id: 5,
path: require('../../assets/img/banner_img5.jpg')
},
{
id: 6,
path: require('../../assets/img/banner_img6.jpg')
path: require('../../assets/img/banner4.gif')
},
]
}
@ -43,26 +36,10 @@ export default {
</script>
<style scoped>
.banner_img {
height: 300px;
width: 100%;
border-radius: 30px;
height: 500px;
border-radius: 20px;
}
.el-carousel__item h3 {
color: #475669;
font-size: 18px;
opacity: 0.75;
line-height: 300px;
margin: 0;
}
.el-carousel__item:nth-child(2n) {
background-color: #99a9bf;
}
.el-carousel__item:nth-child(2n+1) {
background-color: #d3dce6;
}
</style>

@ -69,7 +69,16 @@ const router = new Router({
// 对路由进行权限控制
// 全局路由拦截器 前置路由守卫
router.beforeEach((to, from, next) => {
next()
console.log("111")
if (to.matched.length !== 0) {
next()
} else {
console.log("222")
next({
path: "/home",
query: {redirect: to.fullPath}
})
}
})
// 全局后置路由守卫——初始化的时候被调用、每次路由切换后被调用

@ -1,9 +1,15 @@
<template>
<div>
<el-row style="display: flex; justify-content: center">
<el-col :span="17" :xs="24" align="center">
<!-- <slide-show></slide-show>-->
轮播图
<el-col :span="14" :xs="24" align="center">
<slide-show></slide-show>
</el-col>
</el-row>
<el-row style="display: flex; justify-content: center">
<el-col :span="16" :xs="24" align="center">
<el-card class="box-card grid-content" shadow="always">
</el-card>
</el-col>
</el-row>
<el-row :gutter="40">
@ -49,24 +55,23 @@
</el-col>
<el-col :span="14" :xs="24" :sm="24" :lg="14">
<el-card class="box-card grid-content" shadow="always" align="center">
<div class="card-title">湖南省传统技艺类非物质文化遗产分布地图</div>
<distribute-map height="550px"></distribute-map>
</el-card>
</el-col>
</el-row>
<el-row :gutter="40" type="flex" justify="center">
<el-col :span="18" :xs="24" :sm="24" :lg="18" style="margin-top: 20px">
</el-col>
</el-row>
</div>
</template>
<script>
import SlideShow from "@/components/user/SlideShow";
import DistributeMap from "@/components/user/DistributeMap";
export default {
name: "HomePage",
components: {
SlideShow,
DistributeMap
},
data() {
return {

Loading…
Cancel
Save