You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

trajectory-map.vue 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="charts-box">
  3. <qiun
  4. type="map"
  5. :chartData="state.chartData"
  6. :opts="state.opts"
  7. :canvas2d="true"
  8. canvasId="pVNxVgTQDlKlgMCPbMtJrifnZlluhrNf"
  9. />
  10. </view>
  11. <view class="describe">
  12. <view>
  13. <view class="all">您共到访过<text class="num">5</text>个城市</view>
  14. <view>您的足迹已踏遍1500%的国土超过了99%的九州ETC用户</view>
  15. </view>
  16. <image class="car" src="../../../static/image/home-on.png" mode="aspectFit"></image>
  17. </view>
  18. </template>
  19. <script lang="ts" setup>
  20. import { reactive } from "vue";
  21. import {request} from "@/utils/network/request.js";
  22. import {stringToJson} from "@/utils/network/encryption.js";
  23. import { onLoad,onMounted} from "@dcloudio/uni-app";
  24. import mapChina from "@/datas/mapChina.json";
  25. import {mapData,mapColor} from "@/datas/mapData.js";
  26. import qiun from "./qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue";
  27. const state = reactive({
  28. mapArr:[],//后端传过来的省
  29. lastData:[],
  30. chartData: {},
  31. opts: { //["贵州省","海南省"] #EE6666
  32. color: ["#1890FF","#1890FF","#1890FF","#1890FF","#1890FF",
  33. "#1890FF","#1890FF","#1890FF","#1890FF","#1890FF",
  34. "#1890FF","#1890FF","#1890FF","#1890FF","#1890FF",
  35. "#1890FF","#1890FF","#1890FF","#1890FF","#1890FF",
  36. "#1890FF","#1890FF","#1890FF","#1890FF","#1890FF",
  37. "#1890FF","#1890FF","#1890FF","#1890FF","#1890FF",
  38. "#1890FF","#1890FF","#1890FF","#1890FF","#1890FF"],
  39. padding: [0,0,0,0],
  40. dataLabel: true,
  41. fontSize:9,
  42. enableScroll: false,
  43. extra: {
  44. map: {
  45. active:false,
  46. border: true,
  47. borderWidth: 1,
  48. borderColor: "#666666",
  49. fillOpacity: 0.6,
  50. activeBorderColor: "#F04864",
  51. activeFillColor: "#FACC14",
  52. activeFillOpacity: 1
  53. }
  54. }
  55. }
  56. })
  57. onLoad((option : any) => {
  58. getServerData();
  59. state.mapArr=option.data.split(",");
  60. console.log("option",option.data.split(","))
  61. dealData();
  62. })
  63. const getServerData=()=>{
  64. console.log("111")
  65. //模拟从服务器获取数据时的延时
  66. setTimeout(() => {
  67. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  68. let res = {series:mapChina.features};
  69. console.log("111")
  70. state.chartData = JSON.parse(JSON.stringify(res));
  71. console.log("state.chartData",state.chartData)
  72. }, 500);
  73. }
  74. const dealData=()=>{
  75. for(var i=0;i<state.mapArr.length;i++){
  76. console.log(mapColor[mapData[state.mapArr[i]]])
  77. state.lastData.push(mapColor[mapData[state.mapArr[i]]])
  78. }
  79. console.log("lastData",state.lastData)
  80. changeColor();
  81. }
  82. const changeColor=()=>{
  83. for(var i=0;i<state.lastData.length;i++){
  84. state.opts.color[state.lastData[i]]="#EE6666"
  85. }
  86. console.log("state.opts.color",state.opts.color)
  87. }
  88. </script>
  89. <style scoped>
  90. .charts-box {
  91. width: 100%;
  92. height: 300px;
  93. }
  94. .describe{
  95. display: flex;
  96. width: 90%;
  97. margin: 20rpx auto;
  98. padding: 30rpx 30rpx 60rpx 30rpx;
  99. box-sizing: border-box;
  100. background-color: #f6f6f6;
  101. border-radius: 20rpx;
  102. font-size: 30rpx;
  103. }
  104. .describe>view{
  105. flex: 5;
  106. }
  107. .describe>image{
  108. flex: 3;
  109. }
  110. .car{
  111. width: 150rpx;
  112. height: 150rpx;
  113. display: inline-block;
  114. }
  115. .all{
  116. font-size: 36rpx;
  117. margin-bottom: 20rpx;
  118. margin-left: 20rpx;
  119. }
  120. .num{
  121. font-size: 38rpx;
  122. font-weight: bold;
  123. }
  124. </style>