// pages/manager/thedata/vorder.js
var wxCharts = require('../../../wx-charts/dist/wxcharts-min.js');
const app = getApp()
var sever = require("../../../api.js").sever;
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    chartTitle: '订单状态统计图',
    examine:0,
    make:0,
    making:0,
    send:0,
    sending:0,
    expected:0,
  },
  

  /**
   * 组件的方法列表
   */
  methods: {
    backhome: function () {
      wx.reLaunch({
        url: '/page/homePage/homePage',
      })
    },
    list:function(e){
      var a = e.currentTarget.id
      console.log(a)
      wx.navigateTo({
        url: 'vorder-list?id='+a,
      })
    },
    onShow:function(){
      var that = this
      app.request({
        url:sever+'getprogress',
        data:{
          store_id:wx.getStorageSync('user').store_id
        },
        method:'get',
        success:function(res){
          console.log(res.data.data.count)
          var c = res.data.data.count
          for (var i = 0; i < c.length;i++){
            if(c[i].status == 0){
              that.setData({
                examine:c[i].total
              })
            }
            if (c[i].status == 1) {
              that.setData({
                make: c[i].total
              })
            }
            if (c[i].status == 2) {
              that.setData({
                making: c[i].total
              })
            }
            if (c[i].status == 3) {
              that.setData({
                send: c[i].total
              })
            }
            if (c[i].status == 4) {
              that.setData({
                sending: c[i].total
              })
            }
            if (c[i].expected == 1) {
              that.setData({
                expected: c[i].total
              })
            }
          }
          new wxCharts({
            canvasId: 'columnCanvas',
            type: 'column',
            categories: ['待审核', '待生产', '生产中', '待发货', '未签收', '逾期'],
            series: [{
              name: '成交量',
              data: [that.data.examine, that.data.make, that.data.making, that.data.send, that.data.sending, that.data.expected]
            },],
            // yAxis: {
            //   format: function (val) {
            //     return val + '单';
            //   }
            // },
            width: 320,
            height: 200
          });
        }
      })
      
    }
  }
})
