1.安装
npm install micro-ui-y --save

2.引用
import {_utils} from 'micro-ui-y'

3.utils API 属性

// _Platform 平台
_utils._Platform.equipment;//判断是否是Pc 浏览器还是手机  返回值 ： PC  APP
_utils._Platform.is_weixn();//是否时微信浏览器打开的  返回值 : true false


// _Cache 缓存
_utils._Cache.setCookie(key, value, exdays=1);//设置cookie 只能字符串  对象也需转字符串
_utils._Cache.getCookie(key);//获取cookie

_utils._Cache.setLocal(key, value);//设置localStorage 只能字符串  对象也需转字符串
_utils._Cache.getLocal(key);//获取localStorage

_utils._Cache.setSession(key, value);//设置sessionStorage 只能字符串  对象也需转字符串
_utils._Cache.getSession(key);//获取sessionSession


// _Tree 树
_utils._Tree.renderTree(treeArr = [], idName = "id", fIdName = "fId");//根据结构id和fId生成树
_utils._Tree.getTreeList(treeArr = [], idName = "id", fIdName = "fId");//根据结构id和fId生成树
_utils._Tree.getFId(tree, id, idName = "id", childList = 'childList');//获取根据id获取fid
getCId 待补上
_utils._Tree.getSearch(value, tree, searchName = "orgName", childList = "subList");//根据输入值搜索树结果
renderDepartmentStaff 待补上

// _Date 日期
_utils._Date.formatTen(num);//个位转十位
_utils._Date.yearType(year);//判断平年 闰年
_utils._Date.monthMaxDay(year, month);//获取某月份最后一天
_utils._Date.getMonthMaxDay(year, month);//获取某月份最后一天
_utils._Date.format(date, type);//转换日期格式，type类型有："yyyy-MM-dd","yyyy/MM/dd","yyyy.MM.dd","yyyy-MM-dd HH:mm:ss"
_utils._Date.getWeek(date, type = "cn");//根据日期获取当前一周日期，type cn:"中国标准日期 周一到周日"  en:"美国标准日期 周日到周六"






4. 使用方式
import React, {Component} from "react";
import {_utils} from "micro-ui-y";

class TestUtils extends Component {
    constructor(props) {
        super(props);
        this.state = {}
    };

    render() {


        //测试平台
        let equipment = _utils._Platform.equipment;//判断是否是Pc 浏览器还是手机  返回值 ： PC  APP
        let is_weixn = _utils._Platform.is_weixn();//是否时微信浏览器打开的  返回值 : true false
        console.log("equipment:", equipment);
        console.log("is_weixn:", is_weixn);




        //测试缓存 cookie Local Session
        _utils._Cache.setCookie("name", "古福艳");//设置cookie 只能字符串  对象也需转字符串
        let name = _utils._Cache.getCookie("name");//获取cookie
        console.log("getCookie-name:", name);

        _utils._Cache.setLocal("userinfo", JSON.stringify({name: "古福艳"}));//设置localStorage 只能字符串  对象也需转字符串
        let userinfo = _utils._Cache.getLocal("userinfo");//获取localStorage
        console.log("getLocal-userinfo:", userinfo);

        _utils._Cache.setSession("userinfo", JSON.stringify({name: "张三", age: 24}));//设置sessionStorage 只能字符串  对象也需转字符串
        let person = _utils._Cache.getSession("userinfo");//获取sessionSession
        console.log("getSession-person:", person);





        /*测试树*/
        let dept2 = [
            {
                "fId": 1001,
                "orgId": 1021,
                "orgName": "业务二部1"
            },

            {
                "fId": 1001,
                "orgId": 1024,
                "orgName": "业务二部4"
            },
            {
                "fId": 1001,
                "orgId": 1022,
                "orgName": "业务二部2"
            },
            {
                "fId": 1001,
                "orgId": 1023,
                "orgName": "业务二部3"
            },
            {
                "fId": 0,
                "orgId": 1001,
                "orgName": "业务一部"
            },
            {
                "fId": 1021,
                "orgId": 1031,
                "orgName": "业务二部3"
            },
            {
                "fId": 1021,
                "orgId": 1032,
                "orgName": "业务二部3"
            },
            {
                "fId": 1021,
                "orgId": 1033,
                "orgName": "业务二部3"
            },
            {
                "fId": 0,
                "orgId": 2001,
                "orgName": "拓展一部"
            },
            {
                "fId": 2001,
                "orgId": 2011,
                "orgName": "拓展一部1"
            },
        ];
        console.log("修改前的树:", dept2);
        let tree = _utils._Tree.renderTree(dept2, "orgId", "fId");
        console.log("修改后的树renderTree:", tree);

        let tree2 = _utils._Tree.renderTree(dept2, "orgId", "fId");
        console.log("修改后的树getTreeList:", tree2);

        let fids = _utils._Tree.getFId(tree, 1032, "orgId");
        console.log("根据id查找父类id:", fids);

        //getCId   待完善

        let searchData = _utils._Tree.getSearch("一", tree2, "orgName", "childList");
        console.log("根据输入值搜索树结果:", searchData);





        //测试日期
        let num = _utils._Date.formatTen(3);//个位转十位
        let yearType = _utils._Date.yearType(2019);//判断 平年 闰年
        let monthMaxDay = _utils._Date.monthMaxDay(2019, 1);//获取某月份的最大天数，月份传 1-12
        let getMonthMaxDay = _utils._Date.getMonthMaxDay(2019, 1);//获取某月份的最大天数，方法二
        let date = _utils._Date.format(new Date(), "yyyy-MM-dd HH:mm:ss"); //日期转换类型,类型有：yyyy-MM-dd，yyyy/MM/dd，yyyy.MM.dd，yyyy-MM-dd HH:mm:ss
        let getWeek = _utils._Date.getWeek(new Date(), "en");//获取某天日日期的那一周，type传 en(日-六)  cn(一-日)
        console.log("个位转十位:", num);
        console.log("判断平年/闰年:", yearType);
        console.log("获取某月份的最大天数:", monthMaxDay);
        console.log("日期转换类型 yyyy-MM-dd HH:mm:ss", date);
        console.log("获取某天的那一周:", getWeek);




        return (
            <div>
               请打开控制台查看日志
            </div>
        )
    };
}

export  default  TestUtils



5.help
@Date 2019-06-28
@Author fuyan Gu
@Email 1303928929@qq.com




