123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- var wxCharts = require('../../../utils/wxcharts.js');
- var data = require('../../../utils/util.js');
- const api = require('../../../utils/api.js');
- var ringChart = null;
- Page({
- data: {
- },
- bindDateChange(e) {
- this.setData({
- startdata: e.detail.value
- })
- this.req(e.detail.value,this.data.enddata)
- },
- bindendDateChange(e){
- this.setData({
- enddata: e.detail.value
- })
- this.req(this.data.startdata, e.detail.value)
- },
- touchHandler: function (e) {
- console.log(ringChart.getCurrentDataIndex(e));
- },
- onLoad(options){
- },
- req: function (start,end){
- let that = this
- wx.showLoading({
- title: '正在加载',
- })
- wx.request({
- url: api.selfInfo,
- data: {
- loginId: wx.getStorageSync('loginId'),
- start: start,
- end: end
- },
- success(res) {
- // res.data.data.nomalInTimes=130
- // res.data.data.nomalOutTimes = 40
- // res.data.data.laterTimes = 50
- // res.data.data.UnreturnedTimes = 20
- wx.hideLoading()
- that.setData({
- data: res.data.data
- })
- ringChart.updateData({
- title: {
- name: '汇总'
- },
- subtitle: {
- color: '#333333'
- },
- series: [{
- name: '正常进入',
- data: res.data.data.nomalInTimes,
- stroke: false,
- color: '#6282f4'
- }, {
- name: '正常外出',
- data: res.data.data.nomalOutTimes,
- stroke: false,
- color: '#ed5c68'
- }, {
- name: '晚归',
- data: res.data.data.laterTimes,
- stroke: false,
- color: '#89c997'
- }, {
- name: '未归寝',
- data: res.data.data.UnreturnedTimes,
- stroke: false,
- color: '#f29b76'
- }],
- });
- }
- })
- },
- onReady: function (e) {
- let that=this
- this.setData({
- enddata:data.formatDate(),
- checkenddate: data.formatDate(),
- startdata: data.getDateStr(data.formatDate(),-30)
- })
- var windowWidth = 320;
- try {
- var res = wx.getSystemInfoSync();
- windowWidth = res.windowWidth;
- } catch (e) {
- console.error('getSystemInfoSync failed!');
- }
- ringChart = new wxCharts({
- animation: true,
- canvasId: 'ringCanvas',
- type: 'ring',
- extra: {
- ringWidth: 25,
- pie: {
- offsetAngle: -45
- }
- },
- title: {
- name: '汇总',
- color: '#333',
- fontSize: 18
- },
- subtitle: {
- name: '',
- color: '#6282f4',
- fontSize: 15
- },
- series: [{
- name: '正常进入',
- data: 0,
- stroke: false,
- color:'#6282f4'
- }, {
- name: '正常外出',
- data: 0,
- stroke: false,
- color:'#ed5c68'
- }, {
- name: '晚归',
- data: 0,
- stroke: false,
- color:'#89c997'
- }, {
- name: '未归寝',
- data: 0,
- stroke: false,
- color:'#f29b76'
- }],
- disablePieStroke: true,
- width: 200,
- height: 200,
- dataLabel: false,
- legend: false,
- background: '#fff',
- padding: 0
- });
- ringChart.addEventListener('renderComplete', () => {
- console.log('renderComplete');
- });
- setTimeout(() => {
- ringChart.stopAnimation();
- }, 500);
- this.data.startdata = data.getDateStr(data.formatDate(), -30)
- this.data.enddata = data.formatDate()
- this.req(this.data.startdata, this.data.enddata)
- this.setData({
- user: wx.getStorageSync('user')
- })
- }
- });
|