import db from '@/utils/localstorage'

export default {
  namespaced: true,
  state: {
    accessToken: db.get('ACCESS_TOKEN'),
    refreshToken: db.get('REFRESH_TOKEN'),
    token: db.get('TOKEN', ''),
    expireTime: db.get('EXPIRE_TIME', 0),
    user: db.get('USER'),
    permissions: db.get('PERMISSIONS') || [],
    // routes: db.get('USER_ROUTER') || []
    routes: [
      {
        path: '/management',
        name: '商家管理',
        meta: {
          title: '商家管理',
          icon: 'el-icon-office-building'
        },
        children: [
          {
            path: '/management',
            meta: {
              title: '商家列表'
            }
          },
          {
            path: '/apply',
            meta: {
              title: '入驻申请'
            }
          }
        ]
      },
      {
        path: '/',
        meta: {
          title: '平台装修',
          icon: 'el-icon-box'
        },
        children: [
          {
            path: '/applet',
            meta: {
              title: '小程序',
              icon: 'el-icon-s-shop'
            }
          },
          {
            path: '/custom',
            meta: {
              title: '自定义页面',
              icon: 'el-icon-edit-outline'
            }
          },
          {
            path: '/classification',
            meta: {
              title: '商品类别',
              icon: 'el-icon-s-order'
            }
          }
        ]
      },
      // {
      //   path: '/marketing',
      //   name: '营销活动',
      //   meta: {
      //     title: '营销活动',
      //     icon: 'el-icon-s-ticket'
      //   }
      // },
      {
        path: '/finance',
        meta: {
          title: '财务',
          icon: 'el-icon-coin'
        },
        children: [
          {
            path: '/finance/cash',
            name: '提现申请',
            meta: {
              title: '提现申请',
              icon: 'el-icon-s-finance'
            }
          },
          {
            path: '/finance/cash-deposit',
            name: '保证金',
            meta: {
              title: '保证金',
              icon: 'el-icon-money'
            }
          },
          {
            path: '/finance/overview',
            name: '财务概况',
            meta: {
              title: '财务概况',
              icon: 'el-icon-pie-chart'
            }
          }
        ]
      },
      {
        path: '/after-sale-service',
        meta: {
          title: '售后处理',
          icon: 'el-icon-service'
        },
        children: []
      },
      {
        path: '/menu',
        meta: {
          title: '菜单',
          icon: 'el-icon-menu'
        },
        children: [
          {
            path: '/menu/empower',
            name: '菜单赋权',
            meta: {
              title: '菜单赋权',
              icon: ''
            }
          }
        ]
      },
      {
        path: '/comment',
        meta: {
          title: '评论',
          icon: 'el-icon-s-comment'
        },
        children: [
          {
            path: '/comment/comment-manage',
            name: '评论管理',
            meta: {
              title: '评论管理',
              icon: ''
            }
          },
          {
            path: '/comment/sensitive-word',
            name: '敏感词管理',
            meta: {
              title: '敏感词管理',
              icon: ''
            }
          },
          {
            path: '/comment/keyword',
            name: '关键词管理',
            meta: {
              title: '关键词管理',
              icon: ''
            }
          }
        ]
      },
      {
        path: '/customer-manage',
        meta: {
          title: '客户管理',
          icon: 'el-icon-s-custom'
        },
        children: [
          {
            path: '/customer-manage/custom',
            name: '客户管理',
            meta: {
              title: '客户管理',
              icon: ''
            }
          },
          {
            path: '/customer-manage/label',
            name: '标签管理',
            meta: {
              title: '标签管理',
              icon: ''
            }
          }
        ]
      },
      {
        "sortValue": 1,
        "children": [{
          "sortValue": 0,
          "path": "/user/org",
          "name": "组织管理",
          "component": "ceres/user/org/Index",
          "meta": {
            "title": "组织管理",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 1,
          "path": "/user/station",
          "name": "岗位管理",
          "component": "ceres/user/station/Index",
          "meta": {
            "title": "岗位管理",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 2,
          "path": "/user/user",
          "name": "用户管理",
          "component": "ceres/user/user/Index",
          "meta": {
            "title": "用户管理",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }],
        "path": "/user",
        "name": "用户中心",
        "component": "Layout",
        "meta": {
          "title": "用户中心",
          "icon": "el-icon-user",
          "breadcrumb": true
        },
        "hidden": false,
        "alwaysShow": true
      }, {
        "sortValue": 10,
        "children": [{
          "sortValue": 1,
          "path": "/auth/role",
          "name": "角色管理",
          "component": "ceres/auth/role/Index",
          "meta": {
            "title": "角色管理",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 2,
          "path": "/auth/user",
          "name": "菜单配置",
          "component": "ceres/auth/menu/Index",
          "meta": {
            "title": "菜单配置",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }],
        "path": "/auth",
        "name": "权限管理",
        "component": "Layout",
        "meta": {
          "title": "权限管理",
          "icon": "el-icon-lock",
          "breadcrumb": true
        },
        "hidden": false,
        "alwaysShow": true
      }, {
        "sortValue": 12,
        "children": [{
          "sortValue": 1,
          "path": "/developer/application",
          "name": "应用管理",
          "component": "ceres/developer/application/Index",
          "meta": {
            "title": "应用管理",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 2,
          "path": "/developer/systemApi",
          "name": "接口查询",
          "component": "ceres/developer/systemApi/Index",
          "meta": {
            "title": "接口查询",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 3,
          "path": "/developer/optLog",
          "name": "操作日志",
          "component": "ceres/developer/optLog/Index",
          "meta": {
            "title": "操作日志",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 4,
          "path": "/developer/loginLog",
          "name": "登录日志",
          "component": "ceres/developer/loginLog/Index",
          "meta": {
            "title": "登录日志",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 5,
          "path": "/developer/db",
          "name": "数据库监控",
          "component": "ceres/developer/db/Index",
          "meta": {
            "title": "数据库监控",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 6,
          "path": "http://127.0.0.1:8760/api/gate/doc.html",
          "name": "接口文档",
          "component": "Layout",
          "meta": {
            "title": "接口文档",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 7,
          "path": "http://127.0.0.1:8848/nacos",
          "name": "注册&配置中心",
          "component": "Layout",
          "meta": {
            "title": "注册&配置中心",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 8,
          "path": "http://www.baidu.com",
          "name": "缓存监控",
          "component": "Layout",
          "meta": {
            "title": "缓存监控",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 10,
          "path": "http://127.0.0.1:8767/ceres-jobs-server",
          "name": "定时调度中心",
          "component": "Layout",
          "meta": {
            "title": "定时调度中心",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 11,
          "path": "http://127.0.0.1:8772/zipkin",
          "name": "链路调用监控",
          "component": "Layout",
          "meta": {
            "title": "链路调用监控",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }],
        "path": "/developer",
        "name": "开发者管理",
        "component": "Layout",
        "meta": {
          "title": "开发者管理",
          "icon": "el-icon-s-operation",
          "breadcrumb": true
        },
        "hidden": false,
        "alwaysShow": true
      }, {
        "sortValue": 13,
        "children": [{
          "sortValue": 1,
          "path": "/msgs/sendMsgs",
          "name": "消息推送",
          "component": "ceres/msgs/sendMsgs/Index",
          "meta": {
            "title": "消息推送",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }, {
          "sortValue": 2,
          "path": "/msgs/myMsgs",
          "name": "我的消息",
          "component": "ceres/msgs/myMsgs/Index",
          "meta": {
            "title": "我的消息",
            "icon": "",
            "breadcrumb": true
          },
          "hidden": false,
          "alwaysShow": false
        }],
        "path": "/msgs",
        "name": "消息中心",
        "component": "Layout",
        "meta": {
          "title": "消息中心",
          "icon": "el-icon-chat-line-square",
          "breadcrumb": true
        },
        "hidden": false,
        "alwaysShow": true
      }
    ]
  },
  mutations: {
    setAccessToken(state, val) {
      db.save('ACCESS_TOKEN', val)
      state.accessToken = val
    },
    setRefreshToken(state, val) {
      db.save('REFRESH_TOKEN', val)
      state.refreshToken = val
    },
    setToken(state, val) {
      db.save('TOKEN', val)
      state.token = val
    },
    setExpireTime(state, val) {
      db.save('EXPIRE_TIME', val)
      state.expireTime = val
    },
    setUser(state, val) {
      db.save('USER', val)
      state.user = val
    },
    setPermissions(state, val) {
      db.save('PERMISSIONS', val)
      state.permissions = val
    },
    setRoutes(state, val) {
      db.save('USER_ROUTER', val)
      state.routes = val
    }
  }
}
