123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- <template>
-
- <view class="container">
- <image src="/static/resource/images/BG.png" class="top-background"></image>
- <view class="top-box flex-row flex-around">
- <view style="visibility: hidden" class="stat-box">
- <view class="stat-value">
- {{ tools.toFixed(total_mil, 0) }}
- <text class="stat-tip">KM</text>
- </view>
- <view class="stat-name">累计里程</view>
- </view>
- <view style="visibility: hidden" class="stat-box">
- <view class="stat-value">
- {{ runing_day }}
- <text class="stat-tip">天</text>
- </view>
- <view class="stat-name">陪伴时间</view>
- </view>
- </view>
- <view class="name-box flex-row flex-start">
- <view class="name-i"></view>
- <view class="name-text">{{ name }}</view>
- </view>
- <view class="mil-chart">
-
- </view>
- <view class="info-box">
- <view class="info-line flex-row flex-around">
- <view class="info-item">
- <view class="flex-row">
- <image src="/static/resource/images/t1.png" class="info-img"></image>
- <view class="info-value">
- {{ day_mil }}
- </view>
- <view class="info-tip">KM</view>
- </view>
- <view class="info-name">行驶里程</view>
- </view>
- <view class="info-item">
- <view class="flex-row">
- <image src="/static/resource/images/t2.png" class="info-img"></image>
- <view class="info-value">
- {{ tools.formatSeconds(runing_time)[0] }}
- </view>
- <view class="info-tip">{{ tools.formatSeconds(runing_time)[2] }}</view>
- <view v-if="tools.formatSeconds(runing_time).length > 3" class="info-value">
- {{ tools.formatSeconds(runing_time)[3] }}
- </view>
- <view v-if="tools.formatSeconds(runing_time).length > 3" class="info-tip">{{ tools.formatSeconds(runing_time)[5] }}</view>
- </view>
- <view class="info-name">行驶时间</view>
- </view>
- </view>
- <view class="info-line flex-row flex-around">
- <view class="info-item">
- <view class="flex-row">
- <image src="/static/resource/images/t3.png" class="info-img"></image>
- <view class="info-value">
- {{ runing_time == 0 ? 0 : tools.toFixed((day_mil * 3600) / runing_time, 2) }}
- </view>
- <view class="info-tip">KM/H</view>
- </view>
- <view class="info-name">平均速度</view>
- </view>
- <view class="info-item">
- <view class="flex-row">
- <image src="/static/resource/images/t4.png" class="info-img"></image>
- <view class="info-value">
- {{ max_speed }}
- </view>
- <view class="info-tip">KM/H</view>
- </view>
- <view class="info-name">最高速度</view>
- </view>
- </view>
- </view>
- <view style="height: 100rpx"></view>
- <view class="bottom-box flex-row flex-around">
- <view class="bottom-item" @tap="selectType" :data-type="0">
- <view class="bottom-name">天</view>
- <view :class="'bottom-tip ' + (type == 0 ? 'bottom-select' : '')"></view>
- </view>
- <view class="bottom-item" @tap="selectType" :data-type="1">
- <view class="bottom-name">周</view>
- <view :class="'bottom-tip ' + (type == 1 ? 'bottom-select' : '')"></view>
- </view>
- <view class="bottom-item" @tap="selectType" :data-type="2">
- <view class="bottom-name">月</view>
- <view :class="'bottom-tip ' + (type == 2 ? 'bottom-select' : '')"></view>
- </view>
- </view>
-
- {{ macid }}
- {{ name }}
- {{ name ? value+'km':'' }}
- </view>
- </template>
- <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
- <script>
- var config = require('../../common/config.js');
- var http = require('../../common/http.js');
- var common = require('../../common/common.js');
- var storage = require('../../common/storage.js');
- export default {
- components: {
-
- },
- data() {
- return {
- macid: '',
- type: 0,
- milList: [],
- name: '',
- day_mil: 0,
- runing_time: 0,
- max_speed: 0,
- runing_day: 0,
- total_mil: 0,
- ecMilBar: {
- lazyLoad: true
- }
- };
- },
-
- onLoad: function (options) {
- if (!options.macid) {
- uni.navigateBack({
- delta: 1
- });
- }
- this.setData({
- macid: options.macid
- });
- },
-
- onReady: function () {},
-
- onShow: function () {
- this.loadMileage();
- },
-
- onHide: function () {},
-
- onUnload: function () {},
-
- onPullDownRefresh: function () {},
-
- onReachBottom: function () {},
-
- onShareAppMessage: function () {},
- methods: {
- loadMileage() {
- common.loading();
- http.postApi(
- config.API_BATTERY_MILLIST,
- {
- macid: this.macid,
- type: this.type,
- page: 1,
- size: 8
- },
- (resp) => {
- if (resp.data.code === 200) {
- uni.hideLoading();
- this.setData({
- milList: resp.data.data.list,
- runing_day: resp.data.data.runing_day,
- total_mil: resp.data.data.total_mil,
- name: resp.data.data.list.length > 0 ? this.timeName(resp.data.data.list[0].time) : '',
- day_mil: resp.data.data.list.length > 0 ? parseFloat(resp.data.data.list[0].day_mil) : 0,
- runing_time: resp.data.data.list.length > 0 ? parseInt(resp.data.data.list[0].runing_time) : 0,
- max_speed: resp.data.data.list.length > 0 ? parseFloat(resp.data.data.list[0].max_speed) : 0
- });
- this.initMilBar();
- } else {
- common.simpleToast(resp.data.msg);
- }
- }
- );
- },
- initMilBar() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- monthName(m) {
- var months = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
- return months[parseInt(m) - 1];
- },
- timeName(time) {
- switch (this.type) {
- case 0:
- return common.DateFormat(new Date(time * 1000), 'MM-dd');
- case 1:
- return common.DateFormat(new Date(time * 1000), 'MM-dd') + '~' + common.DateFormat(new Date((parseInt(time) + 604800) * 1000), 'MM-dd');
- case 2:
- return this.monthName(common.DateFormat(new Date(time * 1000), 'M'));
- }
- },
- timeLabel(time) {
- switch (this.type) {
- case 0:
- return common.DateFormat(new Date(time * 1000), 'dd');
- case 1:
- return common.DateFormat(new Date(time * 1000), 'dd') + '~' + common.DateFormat(new Date((parseInt(time) + 604800) * 1000), 'dd');
- case 2:
- return this.monthName(common.DateFormat(new Date(time * 1000), 'M'));
- }
- },
- setMilBarOptions() {
- this.milBarChart.setOption({
- color: ['#07C58A'],
- grid: {
- top: '5%',
- left: '12%',
- right: '5%',
- bottom: '2%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- axisLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontStyle: 'italic',
- fontWeight: 500,
- fontFamily: 'DIN',
- fontSize: 10
- },
- data: this.milList.map((p) => this.timeLabel(p.time)).reverse()
- },
- yAxis: {
- type: 'value',
- splitNumber: 3,
- axisLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
-
- formatter: function (value, index) {
- if (index % 2 == 0) {
- if (value == 0) {
- return '0';
- } else {
- return value.toString() + 'KM';
- }
- }
- return '';
- },
- fontStyle: 'italic',
- fontWeight: 500,
- fontFamily: 'DIN',
- fontSize: 10
- },
- splitLine: {
- lineStyle: {
- type: 'dashed'
- }
- }
- },
- series: [
- {
- data: this.milList.map((p) => parseFloat(p.day_mil)).reverse(),
- type: 'bar',
- itemStyle: {
- color: '#07C58A',
- barBorderRadius: [10, 10, 0, 0]
- },
- barWidth: '50%',
- barMaxWidth: '20'
- }
- ]
-
- });
- },
- selectType(e) {
- if (e.currentTarget.dataset.type != this.type) {
- this.setData({
- type: e.currentTarget.dataset.type
- });
- this.loadMileage();
- }
- }
- }
- };
- </script>
- <style>
- @import './mileage.css';
- </style>
|