Open Dreampie opened 9 years ago
//登录 $http.post('/api/v1.0/sessions', {username: username, password: password, rememberMe: rememberMe}, (rep)-> data.ferror = false data.loading = false #返回的user数据 $state.user = rep try localStorage.setItem('username', username) //把菜单权限存到localStorage localStorage.setItem("permissions", stateman.user.permissions) catch e data.password = null component.$update() #跳转 $state.go("app.order"); )
//app模块的菜单数据 菜单组件 <app-menu ref="appMenu" menus={menus} state={@(this.$state)}></app-menu> config: (data)-> data.menus = [ {url: '/', name: '首页', icon: 'home', state: 'app.index'} ] try permissions = localStorage.getItem("permissions") catch e if permissions permissions=permissions.split(",") for permission in permissions switch permission when 'P_ORDER' then data.menus.push({url: '/order', name: '订单', icon: 'table', state: 'app.order'}) when 'P_SALE' then data.menus.push({url: '/sale', name: '销售', icon: 'strikethrough', state: 'app.sale'}) when 'P_FINANCE' then data.menus.push({url: '/finance', name: '财务', icon: 'yen', state: 'app.finance'}) when 'P_SETTING' then data.menus.push({url: '/setting', name: '设置', icon: 'configure', state: 'app.setting'})