# gd-signature-c

> ### 插件说明 - umd模块化规范

Latest version **1.0.9** (published 2020-08-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install gd-signature-c
pnpm add gd-signature-c
yarn add gd-signature-c
bun add gd-signature-c
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2020-08-21 |
| First published | 2020-08-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.6 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | caohao |

## Links

- npm: https://www.npmjs.com/package/gd-signature-c
- npm.io page: https://npm.io/package/gd-signature-c

## Dependencies (5)

- [jquery](https://npm.io/package/jquery.md) ^3.5.1
- [pdfjs-dist](https://npm.io/package/pdfjs-dist.md) 2.4.456
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.10.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.10.2
- [@babel/runtime-corejs2](https://npm.io/package/@babel/runtime-corejs2.md) ^7.10.2

## Recent versions

- 1.0.9 (latest) — 2020-08-21
- 1.0.8 — 2020-08-21
- 1.0.7 — 2020-08-18
- 1.0.6 — 2020-08-16
- 1.0.5 — 2020-08-16
- 1.0.4 — 2020-08-16
- 1.0.3 — 2020-08-16
- 1.0.2 — 2020-08-16
- 1.0.1 — 2020-08-16

## README

<!--
 * @Author: your name
 * @Date: 2020-06-10 09:31:36
 * @LastEditTime: 2020-08-18 14:17:28
 * @LastEditors: 韩振东
 * @Description: In User Settings Edit
 * @FilePath: \test\README.md
--> 
### 插件说明
- umd模块化规范

### 插件依赖(动态加载，如果用户环境有这两个插件，则不加载)
- jq
- pdf.js

###### 使用方法
- 标签引用
``` html
<script src="https://cdn.jsdelivr.net/npm/gd-signature"></script> 
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gd-signature/dist/static/css/index.css">
```

- npm包
```shell
 # 模块化引入
 npm i gd-signature -S
```

- 使用方式
```js
import GDsignature from 'gd-signature' // const GDsignature = require('gd-signature')
import 'gd-signature/dist/static/css/index.css'
```
- 自定义主题
```js
import GDsignature from 'gd-signature' // const GDsignature = require('gd-signature')
import 'gd-signature/dist/static/css/index.less'
```
html下修改主题使用方式
```html
<script src="xxx/main.bundle.js"></script>
    <link rel="stylesheet/less" type="text/css" type="less" href="xxx/static/css/index.less">
    <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.5.3/less.min.js"></script>
    <script>
        less.modifyVars({
            '@--color-primary': '#DE2921'//主题修改为红色
        });
    </script>
```

- 3: 实例化插件

```js
var baseUrl = 'http://123.129.207.18:9111/app-server-paas' // 使用者内得业务api地址 用来获取token和sign
var signature = new GDsignature.manual({
baseUrl: 'https://open.aiosign.com/api', // paas-api接口 写死这个地址就好
auto_close:true,// 签章成功后是否自动关闭签章 默认falase
showClose: false, // 是否显示关闭按钮，默认为true
VerifyCode:true, // 是否开启签章验证码校验，默认为true
authSign: false, //使用认证服务器签章-默认为false
authBaseUrl: 'http://192.168.2.199:8099/', //认证服务器地址-authSign为true时必须传
flowId: '744918968410198016', //认证服务器需要的流程id-authSign为true时必须传
// 本实例用得axios 用户可根据自己需要使用$.ajax或者fetch
 // getToken方法返回一个promise  reslove()为token得值
getToken() {
    return new Promise((reslove, reject) => {
    axios
        .post(`${baseUrl}/getToken`)
        .then(res => {
            reslove(res.data.data.access_token)
        })
        .catch(err => {
            reject()
        })
    })
},

// 本实例用得axios 用户可根据自己需要使用$.ajax或者fetch
// getSign方法返回一个promise  reslove()为sign得值
getSign(body) {
    return new Promise((reslove, reject) => {
    axios
        .post(`${baseUrl}/getSign`, body.data, {
        headers: {
            Authentication: body.token
        }
        })
        .then(res => {
            reslove(res.data.data.sign)
        })
        .catch(err => {
            console.log(err)
            reject()
        })
    })
}
})
```

- 4: 调用插件api开始签章

```js
// 用户可根据自己业务场景 （例:点击某个按钮之后 调用下面方法）
signature.start({
    preview: true, 是否预览模式，默认为签章模式
    contract_id: contract_id, // 合同id
    user_id: userId,// 用户id
    success: function(res) {
        console.log(res) // 签章成功回调
    },
    error: function(err) {
        console.log(err) // 签章失败回调
    }
})

```
- 5: 拒签操作

```js
// 用户可根据自己业务场景-扩展拒签操作-
signature.start({
    preview: true, 是否预览模式，默认为签章模式
    contract_id: contract_id, // 合同id
    user_id: userId,// 用户id
    success: function(res) {
        console.log(res) // 签章成功回调
    },
    //加入此回调，证明业务需要拒签，需要自己业务实现
    refuseSign: function(re) {
                console.log('re', re);
    },
    error: function(err) {
        console.log(err) // 签章失败回调
    }
})

```

---
_Source: https://npm.io/package/gd-signature-c · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
