纸通宝SAAS仓库
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.
 

151 lines
4.7 KiB

// xtends//statics/index/index.js
import Scene from '../../../pages/index/scene'
import uCharts from '../../libs/u-charts';
import { getSummaryReport } from "../../../api/saas"
const math = require('../../../utils/math')
import util from '../../../utils/util'
const app = getApp()
// var that;
// var canvaColumn = null;
// var windowWidth = 0;
Scene({
/**
* 页面的初始数据
*/
data: {
// cWidth: '',
// cHeight: '',
form1: {},
form2: {},
percent: 85,
show: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// that = this
// windowWidth = wx.getSystemInfoSync().windowWidth
// this.data.cWidth = windowWidth - this.rpx2px(100)
// // math.divide
// this.data.cHeight = this.rpx2px(400)
// this.getServerData()
wx.showLoading({ title: '加载中', mask: true })
var min = new Date()
min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate())
min.setHours(0, 0, 0)
var minDate = min.getTime()
var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
max.setHours(0, 0, 0)
var maxDate = max.getTime()
var today = new Date()
today.setHours(0, 0, 0)
var vdate = [today.getTime(), maxDate]
var vdateString = util.formatDate(new Date(), 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D')
this.data.form1.dimensionDateStart = util.formatDate(today, 'Y-M-D')
this.data.form1.dimensionDateEnd = util.formatDate(max, 'Y-M-D')
this.data.form2.startTime = util.formatDate(today, 'Y-M-D') + ' 00:00:00'
this.data.form2.endTime = util.formatDate(max, 'Y-M-D') + ' 00:00:00'
this.setData({ minDate, maxDate, vdate, vdateString })
this.fetchSummaryInfo(this.data.form1)
},
fetchSummaryInfo: function(form){
getSummaryReport(form).then(result => {
// this.setData({ })
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
})
},
showCalendar: function(e){
console.log(e.currentTarget.id)
this.setData({ show: true })
},
onClose: function() {
this.setData({ show: false })
},
onSelect: function({detail}) {
var start = new Date(detail[0])
var end = new Date(detail[1])
var vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D')
this.data.form.startTime = util.formatDate(start, 'Y-M-D') + ' 00:00:00'
this.data.form.endTime = util.formatDate(end, 'Y-M-D') + ' 00:00:00'
this.setData({ show: false, vdateString })
wx.showLoading({ title: '加载中', mask: true })
this.fetchStatisticsInfo()
},
// rpx2px: function(rpx) {
// return rpx / 750 * windowWidth;
// },
// getServerData: function() {
// wx.request({
// url: 'https://www.ucharts.cn/data.json',
// success: function (res) {
// let Column = { categories: [], series: [] };
// Column.categories = res.data.data.Pie.categories;
// Column.series = res.data.data.Pie.series;
// // 自定义标签颜色和字体大小
// // Column.series[1].textColor = 'red';
// // Column.series[1].textSize = 18;
// that.showColumn("canvasColumn", Column);
// },
// fail: () => {
// console.log("请点击右上角【详情】,启用不校验合法域名");
// },
// })
// },
// showColumn(canvasId, chartData) {
// let ctx = wx.createCanvasContext(canvasId, this);
// canvaColumn = new uCharts({
// type: 'ring',
// context: ctx,
// // fontSize: 11,
// background: '#FFFFFF',
// pixelRatio: 1,
// // animation: true,
// // categories: chartData.categories,
// series: chartData.series,
// color: [ "#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc" ],
// dataLabel: true,
// width: that.data.cWidth,
// height: that.data.cHeight,
// legend: {
// show: false,
// position: "right",
// float: "center",
// padding: 5,
// margin: 5,
// fontSize: 13,
// fontColor: "#666666",
// lineHeight: 25,
// hiddenColor: "#CECECE",
// itemGap: 10
// },
// extra: {
// ring: {
// ringWidth: 30,
// centerColor: "#FFFFFF",
// activeOpacity: 0.5,
// activeRadius: 10,
// offsetAngle: 0,
// customRadius: 0,
// labelWidth: 15,
// border: true,
// borderWidth: 3,
// borderColor: "#FFFFFF",
// linearType: "none"
// }
// }
// });
// },
// touchColumn(e) {
// canvaColumn.showToolTip(e, {
// formatter: function (item) {
// console.log(item)
// return item.name + ':' + item.data
// }
// })
// }
})