pipe-ng-library

This project was generated with Angular CLI version 6.0.0.

Usage no npm install needed!

<script type="module">
  import pipeNgLibrary from 'https://cdn.skypack.dev/pipe-ng-library';
</script>

README

PipeNgLibrary

This project was generated with Angular CLI version 6.0.0.

usage

Download and install the package. npm install --save pipe-ng-library Once installed, import the ServiceModule in your application root module.

1: 引用DecodeService(解码) DeviceService(端) PermissionService(权限) 需先引入模块ServiceModule(import { ServiceModule } from 'pipe-ng-library';)

DecodeService
用decode方法,并传入需要解码的字符串decodeValue, decode(decodeValue)

DeviceService 调用device方法, 返回值:移动端true, pc端 false

PermissionService 调用 getPermission方法 ,传入token和需要返回的权限codeList(如['user_management', 'user_center']),验证接口为线上生产环境,getPermission(token, codeList, 'master'); 返回值为对应codeList权限的object, 传入的第三个参数为环境变量'dev'、'test'、'master',默认为'master' per.getPermission(token, perList).then(res => {console.log(res)});

LogoutService 调用logout, 传入token 和 环境变量(环境变量'dev'、'test'、'master',默认为'master'), 登出后跳到登录页

login

import the LoginModule in your application root module.

add <pipe-login [baseUrl]="baseUrl" [loginData]="loginData" [environment]="'test'" (loginSuccess)="loginSuccess($event)" (casBack)="casBack($event)" (loginFailed)="loginFailed($event)" [tip]="tip" [isInput]="false" [btnText]="'登录'" [customerType]="'B'" [btnDisabled]="true" (btnDisabledChange)="btnDisabledChange($event)"> in your application html

baseUrl 当前网站登录页地址,比如 ‘http://localhost:4200/login’ 。

loginSuccess登录成功后触发事件,返回token,username,password,loginSuccess(obj){ alert(obj);}

loginData 初始化用户名和密码 {username: '', password: ''}

loginFailed 登录失败返回错误信息

tip boolean类型 是否显示默认错误提示

casBack cas登录返回函数

isInput boolean类型 是否采用默认的输入框,默认为true(显示),点击登录按钮提交的是loginData绑定的值

btnText 按钮文字, 默认为‘登录’

environment 环境变量 dev(dev环境) test(test环境) master (master环境)

customerType 园区企业 B 运营方(能源服务商)ESP 监管方(园区管委会) ACP

btnDisabled 禁用登录按钮 默认为false, true是为禁用,并且会为按钮添加 p-btn-disabled的类名

btnDisabledChange 登录按钮禁用时点击事件

form-input

import the FormInputModule in your application root module.

add <form-input [placeholder]="'请输入姓名'" [(inputValue)]="formvalue" [pattern]="'[0-9A-Za-z]{2,16}'" [error]="true" [required]="true" [width]="300" [warmTip]="'请输入姓名'"> in your application html

inputValue 提供输入框数据双向绑定

pattern 输入框正则匹配

error 是否强制显示错误格式 ,默认为 false

warmTip 错误显示提示文字

userWarmTip 自定义验证错误信息 优先warmTip 长度为0时显示warmTip 否则显示 userWarmTip