ChartMap.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div>
  3. <common ref="common" @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content vongi-yjcsdat">
  6. <div class="lifeRecord">
  7. <div class="lifeTime" @click="selectDate" style="z-index: 100;">
  8. <div id='result' class="ui-alert"></div>
  9. <span v-text="listForm.day"></span>
  10. </div>
  11. <div class="lifeMap" id="container">
  12. <amap ref="amap"></amap>
  13. </div>
  14. </div>
  15. </div>
  16. <loading :visible="isLoading"></loading>
  17. </div>
  18. </template>
  19. <script>
  20. require('$project/assets/js/mui.picker.min.js');
  21. import * as API_Health from '@/apis/Master/health'
  22. import Common from '$project/components/Common.vue'
  23. import Loading from '$project/components/Loading.vue'
  24. import TopHeader from '$project/components/TopHeader.vue'
  25. import NavMenu from '@/components/NavMenu.vue'
  26. import {
  27. mapGetters,
  28. mapMutations
  29. } from 'vuex'
  30. import {
  31. currentTimeStamp,
  32. parseUnixTime
  33. } from '$project/utils'
  34. import Amap from '$project/components/Amap.vue'
  35. export default {
  36. name: 'MasterHealthChartMap',
  37. components: {
  38. Common,
  39. Loading,
  40. TopHeader,
  41. NavMenu,
  42. Amap
  43. },
  44. data() {
  45. return {
  46. isLoading: false,
  47. pageTitle: '',
  48. listForm: {
  49. //names: this.$route.query.type,
  50. day: ''
  51. },
  52. typeList: '',
  53. chartsList: [],
  54. }
  55. },
  56. created() {
  57. if (this.$route.query.title) {
  58. this.pageTitle = this.$route.query.title;
  59. } else {
  60. this.pageTitle = '活动轨迹';
  61. }
  62. this.listForm.day = parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}');
  63. this.typeList = ['lbs'];
  64. },
  65. methods: {
  66. //获取图表数据
  67. getChartList() {
  68. this.isLoading = true;
  69. API_Health.getLbsList(this.listForm).then(response => {
  70. this.isLoading = false;
  71. this.chartsList = response;
  72. this.setEcharts();
  73. }).catch(error => {
  74. this.isLoading = false;
  75. mui.toast(error);
  76. })
  77. },
  78. //设置echart数据
  79. setEcharts() {
  80. var mapList = [];
  81. var list = this.chartsList[this.typeList[0]] ? this.chartsList[this.typeList[0]] : [];
  82. for (var j = 0; j < list.length; j++) {
  83. mapList.push({
  84. longtitude: list[j]['value'].split(',')[0],
  85. latitude: list[j]['value'].split(',')[1],
  86. });
  87. }
  88. this.initMap(mapList);
  89. },
  90. //赋地图数据
  91. initMap(list) {
  92. var pointArr = [];
  93. list.forEach(function(item, index) {
  94. pointArr.push([item.longtitude, item.latitude])
  95. })
  96. this.pointArr = pointArr;
  97. //触发组件显示地图
  98. this.$refs.amap.init(this.pointArr.reverse());
  99. },
  100. //选择时间
  101. selectDate() {
  102. var _this = this;
  103. var picker = new mui.DtPicker({
  104. "type": "date",
  105. "beginYear": 2020,
  106. "endYear": 2040,
  107. "endDate": new Date(),
  108. "value": _this.listForm.day
  109. });
  110. picker.show(function(rs) {
  111. _this.listForm.day = rs.text;
  112. _this.getChartList();
  113. picker.dispose();
  114. });
  115. },
  116. asynCallBack() {},
  117. },
  118. mounted() {
  119. this.getChartList();
  120. },
  121. destroyed() {
  122. },
  123. computed: {
  124. ...mapGetters({
  125. openId: 'wx_openid',
  126. token: 'token',
  127. person_data: 'person_data',
  128. person_popedom: 'person_popedom',
  129. menu_list: 'menu_list',
  130. common_menu_list: 'common_menu_list',
  131. persion_home_model: 'persion_home_model'
  132. })
  133. }
  134. }
  135. </script>
  136. <style scoped src="$project/assets/css/pension.css"></style>
  137. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  138. <style src="$project/assets/css/iconfont.css"></style>
  139. <style src="$project/assets/css/mui.picker.min.css"></style>
  140. <style scoped>
  141. .lifeMap {
  142. height: calc(100vh - 44px);
  143. }
  144. .lifeMap img {
  145. width: 100%;
  146. height: auto;
  147. }
  148. .lifeRecord {
  149. height: calc(100vh - 44px);
  150. }
  151. .lifeTime {
  152. background: #fff;
  153. width: 160px;
  154. height: 40px;
  155. position: absolute;
  156. border-radius: 20px;
  157. line-height: 40px;
  158. text-align: center;
  159. box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  160. left: 50%;
  161. margin-left: -80px;
  162. font-size: 16px;
  163. top: 80px;
  164. }
  165. </style>