<template>
<view id="sensus">
    <view class="sensuspage">
        <!--<view class="sensus-detail"></view>-->
        <view class="sensus-item">
            <view>
                <span class="item-top sale-earning">￥{{order.money_sum_today || 0}}</span>
                <span>今日销售</span>
            </view>
            <view>
                <span class="item-top">{{order.agent_order_count_today || 0}}</span>
                <span>今日订单</span>
            </view>
            <view>
                <span class="item-top">{{order.user_count_today || 0}}</span>
                <span>今日新增会员</span>
            </view>
            <view>
                <span class="item-top sale-earning">￥{{order.money_sum_seven || 0}}</span>
                <span>近七天销售</span>
            </view>
            <view>
                <span class="item-top ">{{order.agent_order_count_seven || 0}}</span>
                <span>近七天订单</span>
            </view>
            <view>
                <span class="item-top">{{order.user_count_seven || 0}}</span>
                <span>近七天新增会员</span>
            </view>
            <view>
                <span class="item-top sale-earning">￥{{order.money_sum_month || 0}}</span>
                <span>近一月销售</span>
            </view>
            <view>
                <span class="item-top">{{order.agent_order_count_month || 0}}</span>
                <span>近一月订单</span>
            </view>
            <view>
                <span class="item-top">{{order.user_count_month || 0}}</span>
                <span>近一月新增会员</span>
            </view>
        </view>
        <view class="check-money" @tap="checkmoney">
            <button>查看收益明细</button>
        </view>
    </view>

</view>
</template>
<script>
import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';

export default {
  data() {
    return {
      info: {},
	  order:''
    };
  },

  onShow() {
    this.getsensus();
  },

  components: {},
  props: {},
  methods: {
    getsensus() {
      this.$http.get({
        api: 'api/distribution/statistics',
        header: {
          Authorization: this.$cookieStorage.get('user_token')
        }
      }).then(res => {
        if (res.statusCode == 200) {
          res = res.data;

          if (res.status) {
            // this.setData({
            //   order: res.data
            // });
			this.order=res.data;
          } else {
            wx.showModal({
              content: '请求失败，请稍后重试',
              showCancel: false
            });
          }
        } else {
          wx.showModal({
            content: '请求失败，请稍后重试',
            showCancel: false
          });
        }
      });
    },

    checkmoney(e) {
      wx.navigateTo({
        url: '/pages/distribution/myReceive/myReceive'
      });
    },

    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  },
  computed: {},
  watch: {}
};
</script>
<style rel="stylesheet/less" lang="less">
    @import "sensus";
</style>