list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <div class="battle-warp">
  3. <div class="map-card-wrap">
  4. <div class="map-card-wrap__info">
  5. <van-row class="map-card-wrap__info-box" :gutter="3" type="flex" justify="center">
  6. <van-col :span="6" class="item" v-for="(item, index) of cardList" :key="index">
  7. <div class="name">{{ item.name }}</div>
  8. <div class="value">{{ item.value }} <span class="unit">{{ item.unit }}</span></div>
  9. </van-col>
  10. </van-row>
  11. <div class="map-card-wrap__info-search">
  12. <van-dropdown-menu active-color="#1989fa">
  13. <van-dropdown-item v-model="tradeStatus" :options="tradeStatusList" />
  14. <van-dropdown-item v-model="runStatus" :options="runStatusList" />
  15. </van-dropdown-menu>
  16. <div><van-icon name="search" /></div>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="list-icon">
  21. <van-icon name="bars" size="30" style="margin-top: 10px;" />
  22. <div style="font-size: 12px;">列表</div>
  23. </div>
  24. <!--头部查询条件-->
  25. <!-- <div class="map-search">
  26. <div class="search-bar">
  27. <img src="@/assets/user.png" @click="userInfo" />
  28. <van-dropdown-menu>
  29. <van-dropdown-item v-model="finds.districtId" :options="districtList" @change="(value) => { initGasstationList(value, 'area') }" />
  30. <van-dropdown-item v-model="finds.gasType" :options="gasstationType" @change="initGasstationList" />
  31. </van-dropdown-menu>
  32. </div>
  33. <div class="search-icon" @click="searchGasstationList"><van-icon name="search" /></div>
  34. </div>-->
  35. <!--底部标签栏-->
  36. <!-- <van-tabbar v-model="active">
  37. <van-tabbar-item icon="gem-o" @click="meClickEvent">我的贡献</van-tabbar-item>
  38. <van-tabbar-item icon="plus" @click="gasstationClickEvent">新增站点</van-tabbar-item>
  39. <van-tabbar-item icon="chart-trending-o" @click.native="dataAnalysisEvent('open')">智能分析</van-tabbar-item>
  40. </van-tabbar>-->
  41. <!--地标文字-->
  42. <!-- <van-checkbox v-model="markerTitleStatus" shape="square" checked-color="#2765E2" @change="markerLabelEvent">地标文字</van-checkbox>-->
  43. <!--加气站列表-->
  44. <!-- <van-popup v-model="gasstationInfoStatus" position="right" :style="{ width: '100%', height: '100%' }">
  45. <div class="map-control-warp">
  46. <div class="map-card">
  47. <div class="card-control">
  48. <van-search v-model="filterGasstationName" show-action placeholder="请输入加气站">
  49. <template #action>
  50. <div @click="searchBackEvent">返回</div>
  51. </template>
  52. </van-search>
  53. <div class="map-list-pagination">共 {{pages.total}} 站点</div>
  54. <ul class="card-list" :style="{ height: (mapHeight - 55) + 'px'}">
  55. <li v-for="(item, index) of currGasstationList" :key="index" :class="'icon-' + (item.gasType || 2004)" @click="markerClickEvent(item)">
  56. <div class="title">
  57. <div>
  58. <span class="item-name text-overflow-ellipsis">{{gasstationNickName(item)}}</span>
  59. <span class="item-tag">[{{getGasstationTypeName(item.gasType)}}]</span>
  60. </div>
  61. <div class="item-type" v-if="item.gasType === 1001">自</div>
  62. <div class="item-type" v-else-if="item.gasType === 1002">合</div>
  63. <div class="item-type" v-else-if="item.gasType === 1003">盟</div>
  64. </div>
  65. <div class="address text-overflow-ellipsis">{{item.address}}</div>
  66. <div class="content">
  67. <span>
  68. <span class="text-bold-number">{{ (gasstationCheckType(item.gasType) ? item.offlineGasQty : (item.gasQty + item.offlineGasQty)) | formateZeroToBar('no') }}</span>吨<span class="time">({{ (gasstationCheckType(item.gasType) ? item.offlineGasQtyDate : item.gasQtyDate) | formateTData('date') }})</span>
  69. </span>
  70. <span>
  71. <span class="text-bold-number">{{ (gasstationCheckType(item.gasType) ? item.offlinePrice : item.price) | currency }}</span>/公斤<span class="time">({{ (gasstationCheckType(item.gasType) ? item.offlinePriceDate : item.priceDate) | formateTData('date') }})</span>
  72. </span>
  73. </div>
  74. </li>
  75. </ul>
  76. </div>
  77. </div>
  78. </div>
  79. </van-popup>-->
  80. <!--某个站点单击显示信息-->
  81. <!-- <van-popup v-model="currentWindow.markerWindowStatus" class="bmap-info-window-custom" round position="bottom">
  82. <marker-window v-if="currentWindow.markerWindowStatus" :rowData="currentWindow.data" :isNotDxStatus="gasstationCheckType(currentWindow.data.gasType)"></marker-window>
  83. </van-popup>-->
  84. <!--区域数据分析-->
  85. <!-- <van-popup v-model="markerDataAnalysisStatus" position="bottom">
  86. <area-data-analysis v-if="markerDataAnalysisStatus" :name="analysisDistrictName" :finds="finds"></area-data-analysis>
  87. </van-popup>-->
  88. </div>
  89. </template>
  90. <script>
  91. import 'vue-bmap-gl/dist/style.css'
  92. // import { $districtList, $userFindConfigAreaList } from '@/service/user'
  93. // import { $gasdataGasstationList } from '@/service/gasdata'
  94. import { currency, formateZeroToBar } from '@/utils/filters'
  95. // import { MarkerWindow, AreaDataAnalysis } from './components'
  96. import { mapJsonData } from '@/mock/map'
  97. export default {
  98. name: 'battle',
  99. // components: { MarkerWindow, AreaDataAnalysis },
  100. data() {
  101. return {
  102. mapStyle: {
  103. width: '100%',
  104. height: '100%'
  105. },
  106. center: [116.23228, 35.7127],
  107. zoom: 7,
  108. mapHeight: 400,
  109. cardList: [{
  110. name: '在线/总量',
  111. value: '55/100',
  112. unit: '辆'
  113. }, {
  114. name: '今日总里程',
  115. value: '600',
  116. unit: '公里'
  117. }, {
  118. name: '今日总耗能',
  119. value: '234.12',
  120. unit: '公斤'
  121. }, {
  122. name: '今日总减碳',
  123. value: '123.56',
  124. unit: '公斤'
  125. }],
  126. tradeStatus: 0,
  127. tradeStatusList: [
  128. { text: '全经营类型', value: 0 },
  129. { text: '自营', value: 1 },
  130. { text: '外协', value: 2 }
  131. ],
  132. runStatus: 0,
  133. runStatusList: [
  134. { text: '全行驶状态', value: 0 },
  135. { text: '行驶', value: 1 },
  136. { text: '静止', value: 2 },
  137. { text: '离线', value: 3 }
  138. ]
  139. }
  140. },
  141. watch: {},
  142. computed: {},
  143. created() {},
  144. mounted() {
  145. // 重置地图高度
  146. this.mapHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  147. },
  148. methods: {
  149. // 初始化数据
  150. initData() {
  151. // 初始化区域list
  152. this.initDistrictList()
  153. // 加气站list
  154. this.initGasstationList()
  155. // 获取地图经纬度数据
  156. this.pointList = mapJsonData('all')
  157. },
  158. districtToAreaList() {
  159. /* $userFindConfigAreaList({ districtId: this.finds.districtId }).then(response => {
  160. const tmpPointList = []
  161. const data = response || []
  162. const featuresList = this.pointList.features || []
  163. data.forEach(item => {
  164. for (let i = 0; i < featuresList.length; i++) {
  165. if (trim(featuresList[i].properties.name) === trim(item.areaName)) {
  166. const tmpCoordList = featuresList[i].geometry.coordinates || []
  167. tmpCoordList.forEach(coord => {
  168. tmpPointList.push(...new Set(coord))
  169. })
  170. break
  171. }
  172. }
  173. })
  174. this.polygon.path = tmpPointList
  175. }) */
  176. },
  177. markerLabelEvent() {
  178. this.$nextTick(() => {
  179. this.gasstationList.forEach(item => {
  180. item.markerStatus = !this.markerTitleStatus
  181. })
  182. })
  183. },
  184. initDistrictList() {
  185. /* $districtList({}).then(response => {
  186. const tmpRes = response || []
  187. let pointX = 0
  188. let pointY = 0
  189. tmpRes.forEach((item, index) => {
  190. item.value = item.districtId
  191. item.text = item.districtName
  192. item.points = this.points[item.districtName]
  193. pointX += item.points[0]
  194. pointY += item.points[1]
  195. })
  196. if (tmpRes.length > 0) {
  197. this.center = [pointX / tmpRes.length, pointY / tmpRes.length]
  198. }
  199. tmpRes.unshift({ value: '', text: '全区域', points: this.center })
  200. this.districtList = tmpRes
  201. }) */
  202. },
  203. setMapCenter(value) {
  204. this.districtList.forEach(item => {
  205. if (value === item.value) {
  206. this.center = item.points
  207. }
  208. })
  209. },
  210. initGasstationList(value = '', type = '') {
  211. // const params = this.finds
  212. if (type === 'area') {
  213. this.districtToAreaList()
  214. }
  215. // 设置中心位置
  216. this.setMapCenter(value)
  217. this.filterGasstationName = ''
  218. this.dataAnalysisEvent('close')
  219. /* $gasdataGasstationList(params).then(response => {
  220. const res = response || []
  221. // 通过接口获取的数据,不可变
  222. this.gasstationList = [...new Set(res)]
  223. // 可通过加气站名过来
  224. this.currGasstationList = [...new Set(res)]
  225. this.pages.total = this.gasstationList.length
  226. }) */
  227. },
  228. async dataAnalysisEvent(type) {
  229. if (type === 'open') {
  230. if (this.markerDataAnalysisStatus) return false
  231. this.markerDataAnalysisStatus = true
  232. } else {
  233. this.markerDataAnalysisStatus = false
  234. }
  235. },
  236. // 获取加气站类型
  237. getGasstationTypeName(type) {
  238. let name = '-'
  239. this.gasstationType.forEach(item => {
  240. if (type === item.value) {
  241. name = this.gasstationCheckType(type) ? item.text : '大象加气'
  242. }
  243. })
  244. return name
  245. },
  246. gasstationCheckType(type) {
  247. if (type === 2001 || type === 2002 || type === 2003 || type === 2004) {
  248. return true
  249. }
  250. return false
  251. },
  252. filterGasstationList(value) {
  253. this.currGasstationList = this.gasstationList.filter(item => item.nickName && item.nickName.indexOf(value) !== -1)
  254. },
  255. searchBackEvent() {
  256. this.gasstationInfoStatus = false
  257. },
  258. markerPopVisibleNode() {
  259. const dom = document.getElementsByClassName('BMap_bubble_pop')[0]
  260. const shadow = document.getElementsByClassName('shadow')[0]
  261. let currClass = dom.getAttribute('class')
  262. let currShadowClass = shadow.getAttribute('class')
  263. if (this.currentWindow.markerWindowStatus) {
  264. currClass = currClass.replace('bmap-info-window-hide', '')
  265. currShadowClass = currShadowClass.replace('bmap-info-window-hide', '')
  266. } else {
  267. currClass = currClass.concat(' bmap-info-window-hide')
  268. currShadowClass = currShadowClass.concat(' bmap-info-window-hide')
  269. }
  270. dom.setAttribute('class', currClass)
  271. shadow.setAttribute('class', currShadowClass)
  272. },
  273. mapMarkIcon(item) {
  274. // let imageURL = require('@/assets/battle/g_map_icon_default.png')
  275. //
  276. // if (item.gasType === 100 || item.gasType === 1001 || item.gasType === 1002 || item.gasType === 1003) {
  277. // imageURL = require('@/assets/battle/g_map_icon_1.png')
  278. // } else if (item.gasType === 2001) {
  279. // imageURL = require('@/assets/battle/g_map_icon_3.png')
  280. // } else if (item.gasType === 2002) {
  281. // imageURL = require('@/assets/battle/g_map_icon_2.png')
  282. // } else if (item.gasType === 2003) {
  283. // imageURL = require('@/assets/battle/g_map_icon_4.png')
  284. // } else if (item.gasType === 2004) {
  285. // imageURL = require('@/assets/battle/g_map_icon_default.png')
  286. // }
  287. // return { url: imageURL, size: [20, 26] }
  288. },
  289. // 点击某个点弹框
  290. markerClickEvent(item) {
  291. this.infoWindowClose(item)
  292. this.infoWindowOpen(item)
  293. },
  294. // 关闭窗口
  295. infoWindowClose(item) {
  296. this.currentWindow.markerWindowStatus = false
  297. },
  298. // 打开窗口
  299. infoWindowOpen(item) {
  300. this.currentWindow.markerWindowStatus = false
  301. // 统计图
  302. this.$nextTick(() => {
  303. this.currentWindow.data = item
  304. this.currentWindow.markerWindowStatus = true
  305. })
  306. },
  307. markerLabelContent(item) {
  308. let html = ''
  309. html += '<div class="marker-label-tag"><div class="title">' + this.gasstationNickName(item) + '</div><div class="detail"><div class="number"><span class="text-bold-number">' + formateZeroToBar(item.gasQty + item.offlineGasQty, 'no') + '</span> 吨</div><div class="money"><span class="text-bold-number">' + currency((this.gasstationCheckType(item.gasType) ? item.offlinePrice : item.price)) + '</span>/公斤</div></div></div>'
  310. return html
  311. },
  312. searchGasstationList() {
  313. this.gasstationInfoStatus = true
  314. },
  315. gasstationNickName(item) {
  316. return item.nickName || '-'
  317. },
  318. meClickEvent() {
  319. this.$router.push({ path: '/me' })
  320. },
  321. userInfo() {
  322. this.$router.push({ path: '/user' })
  323. },
  324. gasstationClickEvent() {
  325. this.$router.push({ path: '/form', query: { type: 'add' } })
  326. }
  327. }
  328. }
  329. </script>