<?php
// +----------------------------------------------------------------------
// | [RhaPHP System] Copyright (c) 2017-2020 http://www.rhaphp.com/
// +----------------------------------------------------------------------
// | [RhaPHP] 并不是自由软件,你可免费使用,未经许可不能去掉RhaPHP相关版权
// +----------------------------------------------------------------------
// | Author: Geeson <qimengkeji@vip.qq.com>
// +----------------------------------------------------------------------

namespace app\miniapp\controller;


class Index extends Base
{

    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub


    }
    //基础的数据分析，
    public function index($type = 'getVisittrendTrendByDay')
    {
        $obj = getMiniProgramObj();
        $result = $obj->$type();
        if ($type == 'getVisittrendTrendByDay') {
            $result['list'] = isset($result['list']) ? $result['list'] : [];
            $week = $obj->getVisittrendTrendByweek();
            $month = $obj->getVisittrendTrendByMonth();
            $result['week'] = isset($week['list']) ? $week['list'] : [];
            $result['month'] = isset($month['list']) ? $month['list'] : [];
            $this->assign('data2', $result);
        }
        if ($type == 'getDailyRetainInfo') {
            $week = $obj->getDailyRetainInfoByweek();
            $month = $obj->getDailyRetainInfoByMonth();
            $array = [];
            $array[] = $result;
            $array[] = $week;
            $array[] = $month;
            $this->assign('data2', $array);
        }
        if ($type == 'getVisitDistribution') {
            if(isset($result['list']) && empty($result)){
                //.......
            }
        }
        $this->assign('data', isset($result['list']) ? $result['list'] : []);
        $this->assign('type', $type);
        $this->assign('menu_title', '数据分析');
        return view();
    }


}