浏览代码

提交代码

wzy 1 年之前
父节点
当前提交
a3709d1080
共有 45 个文件被更改,包括 7863 次插入347 次删除
  1. 8 11
      components/capsule/capsule.vue
  2. 305 0
      components/keyboard/keyboard.vue
  3. 96 0
      components/modal/modal.vue
  4. 3 1
      config/index.js
  5. 6 0
      config/modules/home.js
  6. 11 0
      config/modules/login.js
  7. 11 0
      config/modules/order.js
  8. 0 7
      config/modules/shop.js
  9. 5 0
      main.js
  10. 6 0
      package-lock.json
  11. 6 6
      package.json
  12. 38 5
      pages.json
  13. 115 11
      pages/login/index.vue
  14. 87 0
      pages/tabbar/index/data.js
  15. 249 0
      pages/tabbar/index/index.scss
  16. 56 232
      pages/tabbar/index/index.vue
  17. 197 0
      pages/tabbar/order/index.scss
  18. 146 2
      pages/tabbar/order/index.vue
  19. 246 0
      pages_module/orderVerifica/index.vue
  20. 310 0
      pages_module/scanCode/index.vue
  21. 139 0
      pages_module/scanCoupons/index.vue
  22. 277 0
      pages_module/testCode/index.vue
  23. 二进制
      static/image/code/keyboard.png
  24. 二进制
      static/image/code/photo.png
  25. 二进制
      static/image/home/1.png
  26. 二进制
      static/image/home/2.png
  27. 二进制
      static/image/home/3.png
  28. 二进制
      static/image/home/4.png
  29. 二进制
      static/image/home/tobe_1.png
  30. 二进制
      static/image/home/tobe_2.png
  31. 二进制
      static/image/home/tobe_3.png
  32. 二进制
      static/image/home/tobe_4.png
  33. 二进制
      static/image/home/tobe_5.png
  34. 二进制
      static/image/home/tobe_6.png
  35. 二进制
      static/image/home/tobe_7.png
  36. 二进制
      static/image/home/tobe_8.png
  37. 二进制
      static/image/keyboard/delete.png
  38. 二进制
      static/image/keyboard/shift (1).png
  39. 二进制
      static/image/keyboard/shift-icon.png
  40. 二进制
      static/image/keyboard/shift-icon2.png
  41. 二进制
      static/image/order/empty.png
  42. 29 0
      utils/index.js
  43. 5374 0
      utils/jsencrypt.js
  44. 82 72
      utils/request.js
  45. 61 0
      utils/rsaEncrypt.js

+ 8 - 11
components/capsule/capsule.vue

@@ -1,11 +1,7 @@
 <template>
-    <view class="capsule" :style="{ backgroundColor: bgColor, paddingTop: top  }">
-        <view class="title" v-if="showBorder" :style="{ height: height, paddingLeft: titleLeft, display: isSecurity ? 'none' : 'block' }"
-            @click="handleClick">
-            <view class="icon" v-if="showIcon">
-                <tui-icon name="arrowleft" :size="28" color="#000"></tui-icon>
-            </view>
-            <text>{{ title }}</text>
+    <view class="capsule" :style="{ backgroundColor: bgColor, paddingTop: top + 'px'  }">
+        <view class="title" v-if="showBorder" :style="{ height: height, paddingLeft: titleLeft, display: isSecurity ? 'none' : 'block' }">
+            <slot name="top"></slot>
         </view>
     </view>
 </template>
@@ -18,7 +14,7 @@ export default {
         let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
         console.log(menuButtonInfo);
         this.height = menuButtonInfo.height + 'px'
-        this.top = menuButtonInfo.top + 'px'
+        this.top = menuButtonInfo.top
         //  获取整个页面的宽度
         uni.getSystemInfo({
             success: res => {
@@ -62,10 +58,11 @@ export default {
             titleLeft: null,
         }
     },
+    mounted () {
+        //  计算该组件的高度并返回给父组件
+      this.$emit('getHeight', this.top)  
+    },
     methods: {
-        handleClick() {
-            this.$emit('click')
-        }
     }
 }
 </script>

+ 305 - 0
components/keyboard/keyboard.vue

@@ -0,0 +1,305 @@
+<template>
+    <view class="keyboard">
+        <view class="number-board" v-if="isBoard">
+            <view class="number-left">
+                <view class="left-top">
+                    <view v-for="item in leftItems" :key="item" class="left-item"
+                        :class="item == '清空' ? 'empty' : ''" @click="singleWord(item)">{{ item }}</view>
+                </view>
+            </view>
+            <view class="number-right">
+                <view class="right-top" @click="deleteOneWord">
+                    <tui-icon name="deletekey" :size="30" color="#ACACAC"></tui-icon>
+                </view>
+                <view class="right-bottom" :style="{ backgroundColor: iptValue == '' ? '#FFD2BE' : '' }">验劵</view>
+            </view>
+        </view>
+        <view class="eng-board" v-else>
+            <view class="eng-topOne">
+                <view class="eng-box" v-for="item in engBoardList.one" :key="item" @click="singleWord(item)">{{ item }}
+                </view>
+            </view>
+            <view class="eng-topTwo">
+                <view class="eng-box" v-for="item in engBoardList.two" :key="item" @click="singleWord(item)">{{ item }}
+                </view>
+            </view>
+            <view class="eng-topThree">
+                <view class="eng-switch" @click="changeUpper">
+                    <template v-if="isUpper">
+                        <image class="" src="@/static/image/keyboard/shift-icon2.png" />
+                    </template>
+                    <template v-else>
+                        <image class="" src="@/static/image/keyboard/shift-icon.png" />
+                    </template>
+                </view>
+                <view class="box-list">
+                    <view class="eng-box" v-for="item in engBoardList.three" :key="item" @click="singleWord(item)">{{
+            item }}</view>
+                </view>
+                <view class="delete" @click="deleteOneWord">
+                    <image class="" src="@/static/image/keyboard/delete.png" />
+                </view>
+            </view>
+            <view class="eng-topFour">
+                <view class="eng-number" @click="changeBoard">123</view>
+                <view class="eng-coupons" :style="{ backgroundColor: iptValue == '' ? '#FFD2BE' : '' }">验劵</view>
+                <view class="eng-empty" @click="deleteAll">清空</view>
+            </view>
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    props: {
+        iptValue: {
+            type: String,
+            default: ''
+        }
+    },
+    computed: {
+        engBoardList() {
+            let objBig = {
+                one: ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'],
+                two: ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'],
+                three: ['Z', 'X', 'C', 'V', 'B', 'N', 'M']
+            }
+            let objSmall = {
+                one: ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],
+                two: ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'],
+                three: ['z', 'x', 'c', 'v', 'b', 'n', 'm']
+            }
+            if (this.isUpper) {
+                return objBig
+            } else {
+                return objSmall
+            }
+        }
+    },
+    data() {
+        return {
+            leftItems: [1, 2, 3, 4, 5, 6, 7, 8, 9, 'ABC', 0, '清空'],
+            //  控制数字键盘以及英文键盘切换
+            isBoard: true,
+            //  控制切换大小写
+            isUpper: true
+        }
+    },
+    methods: {
+        //  手机震动
+        handleTouchEnd() {
+            // #ifdef MP-WEIXIN
+            wx.vibrateShort({ type: 'light' })
+            // #endif
+        },
+        //  切换大小写
+        changeUpper() {
+            this.isUpper = !this.isUpper
+        },
+        //  数字键盘点击事件
+        singleWord(val) {
+            this.handleTouchEnd()
+            if (val == 'ABC') {
+                this.changeBoard()
+            } else if (val == '清空') {
+                this.deleteAll()
+                return
+            }
+            this.$emit('single', val)
+        },
+        //  删除单个字符
+        deleteOneWord() {
+            this.handleTouchEnd()
+            this.$emit('deleteOne')
+        },
+        //  删除全部字符
+        deleteAll() {
+            this.handleTouchEnd()
+            this.$emit('deleteAll')
+        },
+
+        changeBoard() {
+            this.isBoard = !this.isBoard
+        }
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+.keyboard {
+    .number-board {
+        @include flex(center);
+
+        .number-left {
+            flex: 1;
+
+            .left-top {
+                @include flex(null, null, 6rpx);
+                flex-wrap: wrap;
+            }
+
+            .left-item {
+                width: 184rpx;
+                height: 148rpx;
+                background-color: #FFFFFF;
+                color: #666666;
+                font-weight: 700;
+                font-size: 40rpx;
+                @include flex(center);
+                transition: all .1s ease;
+
+                &:active {
+                    background-color: #cacaca;
+                }
+
+                /* &.active {
+                    background-image: linear-gradient(to bottom, #007AFF, #0F83FF);
+                } */
+            }
+
+            .empty {
+                color: #ACACAC;
+            }
+        }
+
+        .number-right {
+            width: 184rpx;
+            height: 604rpx;
+            box-sizing: border-box;
+            @include flex(center, column, 6rpx);
+
+            .right-top {
+                width: 184rpx;
+                height: 148rpx;
+                background-color: #FFFFFF;
+                @include flex(center);
+            }
+
+            .right-bottom {
+                flex: 1;
+                background-color: $primary-color;
+                @include flex(center);
+                width: 184rpx;
+                color: #FFFFFF;
+            }
+        }
+    }
+
+    .eng-board {
+        .eng-topOne {
+            @include flex(space-between, null, 12rpx);
+        }
+
+        .eng-box {
+            width: 64rpx;
+            height: 84rpx;
+            background-color: #FFFFFF;
+            color: #333333;
+            font-size: 30rpx;
+            @include flex(center);
+            border-radius: 16rpx;
+            font-weight: 700;
+            transition: all .1s ease;
+
+            &:active {
+                box-shadow: inset 0 0 10rpx rgba(0, 0, 0, 0.3);
+                background-color: #cacaca;
+            }
+        }
+
+        /* .eng-box {
+            width: 64rpx;
+            height: 84rpx;
+            background-color: #FFFFFF;
+            color: #333333;
+            font-size: 30rpx;
+            @include flex(center);
+            border-radius: 16rpx;
+            font-weight: 700;
+            transition: all .1s ease;
+            transform-origin: center;
+
+            &:active {
+                background-color: #cacaca;
+                transform: scale(0.98);
+            }
+        } */
+
+        .eng-topTwo {
+            margin-top: 20rpx;
+            @include flex(center, null, 12rpx);
+        }
+
+        .eng-topThree {
+            margin-top: 20rpx;
+            @include flex(space-between, null, 12rpx);
+
+            .eng-switch {
+                width: 84rpx;
+                height: 84rpx;
+                border-radius: 16rpx;
+                background-color: #FFFFFF;
+                @include flex(center);
+
+                image {
+                    width: 42rpx;
+                    height: 34rpx;
+                }
+            }
+
+            .box-list {
+                @include flex(center, null, 12rpx);
+            }
+
+            .delete {
+                width: 84rpx;
+                height: 84rpx;
+                border-radius: 16rpx;
+                background-color: #FFFFFF;
+                @include flex(center);
+
+                image {
+                    width: 56rpx;
+                    height: 36rpx;
+                }
+            }
+        }
+
+        .eng-topFour {
+            margin-top: 20rpx;
+            @include flex(space-between);
+
+            .eng-number {
+                width: 190rpx;
+                height: 84rpx;
+                background-color: #FFFFFF;
+                font-size: 28rpx;
+                font-weight: 600;
+                @include flex(center);
+                border-radius: 16rpx;
+                color: #333333;
+            }
+
+            .eng-coupons {
+                width: 300rpx;
+                height: 84rpx;
+                @include flex(center);
+                color: #FFFFFF;
+                background-color: $primary-color;
+                border-radius: 16rpx;
+            }
+
+            .eng-empty {
+                width: 190rpx;
+                height: 84rpx;
+                background-color: #FFFFFF;
+                font-size: 28rpx;
+                font-weight: 600;
+                @include flex(center);
+                border-radius: 16rpx;
+                color: #333333;
+            }
+        }
+    }
+}
+</style>

+ 96 - 0
components/modal/modal.vue

@@ -0,0 +1,96 @@
+<template>
+    <view class="modal">
+    <tui-modal :show="showModal" custom padding="0rpx" width="546rpx" @cancel="closeModal">
+        <view class="modal-container">
+            <view class="close-modal">
+                <tui-icon name="shut" color="#999999" @click="closeModal"></tui-icon>
+            </view>
+            <view class="modal-title">温馨提示</view>
+            <view class="modal-prompt">
+                <span v-for="item in promptList" :key="item">{{ item }}</span>
+            </view>
+            <view class="modal-btn" v-if="showBtn">
+                <button @click="closeModal">取消</button>
+                <button>注册开店</button>
+            </view>
+        </view>
+    </tui-modal>
+</view>
+</template>
+
+<script>
+export default {
+    props: {
+        showModal: {
+            type: Boolean,
+            default: false
+        },
+        promptList:{
+            type: Array,
+            default: () => {
+                return []
+            }
+        },
+        showBtn: {
+            type: Boolean,
+            default: false
+        }
+    },
+    data() {
+        return {
+        };
+    },
+    methods: {
+        closeModal(){
+            this.$emit('closeModal')
+        }
+    },
+};
+</script>
+
+<style lang="scss" scoped>
+    .modal-container{
+    position: relative;
+    padding: 44rpx 0 32rpx;
+    .close-modal{
+        position: absolute;
+        top: 25rpx;
+        right: 25rpx;
+    }
+    .modal-title{
+        font-size: 36rpx;
+        color: #3D3D3D;
+        text-align: center;
+        margin-bottom:34rpx;
+    }
+    .modal-prompt{
+        @include flex(center, column);
+        font-size: 28rpx;
+        color: #666666;
+    }
+    .modal-btn{
+        margin-top: 24rpx;
+        padding: 0 58rpx;
+        box-sizing: border-box;
+        @include flex(space-between);
+        button{
+            width: 190rpx;
+            height: 76rpx;
+            font-size: 28rpx;
+            text-align: center;
+            line-height: 76rpx;
+            border-radius: 16rpx;
+            margin: 0;
+            &:first-of-type{
+                border: 1rpx solid #999999;
+                color: #999999;
+                background-color:#FFFFFF; 
+            }
+            &:last-of-type{
+                color: #FFFFFF;
+                background-color: $primary-color;
+            }
+        }
+    }
+}
+</style>

+ 3 - 1
config/index.js

@@ -1,2 +1,4 @@
 //  导出所有模块的请求
-// export * from "./module/shop"
+export * from "./modules/login"
+export * from "./modules/home"
+export * from "./modules/order"

+ 6 - 0
config/modules/home.js

@@ -0,0 +1,6 @@
+import { request, request1 } from "@/utils/request.js";
+
+// 获取店铺详情
+export function getShopDetail(data) {
+  return request("/shop/getById",data,'POST');
+}

+ 11 - 0
config/modules/login.js

@@ -0,0 +1,11 @@
+import { request, request1 } from "@/utils/request.js";
+
+//  登陆接口
+export function login(data) {
+  return request1(`/business/login`, data, "POST");
+}
+
+//  获取验证码
+export function getCode(data) {
+  return request1(`/business/getCode`, data, "POST");
+}

+ 11 - 0
config/modules/order.js

@@ -0,0 +1,11 @@
+import { request, request1 } from "@/utils/request.js";
+
+// 订单管理查询
+export function orderGetAll(data) {
+  return request(`/order/getAll`, data, "POST");
+}
+
+// 获取订单详情
+export function orderGetById(data) {
+  return request(`/order/getById`, data, "POST");
+}

+ 0 - 7
config/modules/shop.js

@@ -1,7 +0,0 @@
-import { request } from '@/utils/request.js'
-
-
-//  获取该分类下的商品列表
-// export function getProductList(params) {
-//     return NET.request(`/classify/getClaasifyProducts`, params, "GET");
-// }

+ 5 - 0
main.js

@@ -3,6 +3,11 @@ import App from './App'
 // #ifndef VUE3
 import Vue from 'vue'
 import './uni.promisify.adaptor'
+//  将工具函数挂载到原型上面去
+import { showToast,loading } from '@/utils/index'
+Vue.prototype.$showToast = showToast
+Vue.prototype.$loading = loading
+//  挂载 Vuex
 import store from './store'
 Vue.config.productionTip = false
 App.mpType = 'app'

+ 6 - 0
package-lock.json

@@ -0,0 +1,6 @@
+{
+  "name": "tf-business",
+  "lockfileVersion": 2,
+  "requires": true,
+  "packages": {}
+}

+ 6 - 6
package.json

@@ -6,7 +6,7 @@
         "browser": "chrome",
         "env": {
           "UNI_PLATFORM": "h5",
-          "UNI_BASE_URL": "https://mtrappapi.tfcliao.com"
+          "UNI_BASE_URL": "https://nsbusinessapi.tuanfengkeji.cn"
         },
         "define": {
           "DEV-H5": true
@@ -17,7 +17,7 @@
         "browser": "chrome",
         "env": {
           "UNI_PLATFORM": "h5",
-          "UNI_BASE_URL": "https://mtrappapi.tfcliao.com"
+          "UNI_BASE_URL": "https://nsbusinessapi.tuanfengkeji.cn"
         },
         "define": {
           "DEV-H5": true
@@ -28,7 +28,7 @@
         "browser": "chrome",
         "env": {
           "UNI_PLATFORM": "h5",
-          "UNI_BASE_URL": "https://mtrappapitest.tfcliao.com"
+          "UNI_BASE_URL": "https://nsbusinessapitest.tuanfengkeji.cn"
         },
         "define": {
           "DEV-H5": true
@@ -38,7 +38,7 @@
         "title": "开发版微信",
         "env": {
           "UNI_PLATFORM": "mp-weixin",
-          "UNI_BASE_URL": "https://mtrappapi.tfcliao.com"
+          "UNI_BASE_URL": "https://nsbusinessapi.tuanfengkeji.cn"
         },
         "define": {
           "MP-DINGTALK": true
@@ -48,7 +48,7 @@
         "title": "正式版微信",
         "env": {
           "UNI_PLATFORM": "mp-weixin",
-          "UNI_BASE_URL": "https://mtrappapi.tfcliao.com"
+          "UNI_BASE_URL": "https://nsbusinessapi.tuanfengkeji.cn"
         },
         "define": {
           "MP-DINGTALK": true
@@ -58,7 +58,7 @@
         "title": "测试版微信",
         "env": {
           "UNI_PLATFORM": "mp-weixin",
-          "UNI_BASE_URL": "https://mtrappapitest.tfcliao.com"
+          "UNI_BASE_URL": "https://nsbusinessapitest.tuanfengkeji.cn"
         },
         "define": {
           "MP-DINGTALK": true

+ 38 - 5
pages.json

@@ -9,16 +9,16 @@
     //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
 
     {
-      "path": "pages/tabbar/index/index",
+      "path": "pages/login/index",
       "style": {
-        "navigationBarTitleText": "首页",
+        "navigationBarTitleText": "登陆",
         "navigationStyle": "custom"
       }
     },
     {
-      "path": "pages/login/index",
+      "path": "pages/tabbar/index/index",
       "style": {
-        "navigationBarTitleText": "登陆",
+        "navigationBarTitleText": "首页",
         "navigationStyle": "custom"
       }
     },
@@ -26,7 +26,8 @@
     {
       "path": "pages/tabbar/order/index",
       "style": {
-        "navigationBarTitleText": "订单"
+        "navigationBarTitleText": "订单",
+        "navigationStyle": "custom"
       }
     },
     {
@@ -36,6 +37,38 @@
       }
     }
   ],
+  "subpackages":[
+    {
+      "root": "pages_module",
+			"name":"pages_module",
+      "pages":[
+        {
+					"path": "scanCode/index",
+					"style": {
+						"navigationBarTitleText": "扫码验劵",
+						"enablePullDownRefresh": true,
+						"navigationStyle":"custom"
+					}
+				},
+        {
+					"path": "scanCoupons/index",
+					"style": {
+						"navigationBarTitleText": "输码验劵",
+						"enablePullDownRefresh": true,
+						"navigationStyle":"custom"
+					}
+				},
+        {
+					"path": "orderVerifica/index",
+					"style": {
+						"navigationBarTitleText": "订单核销",
+						"enablePullDownRefresh": true,
+						"navigationStyle":"custom"
+					}
+				}
+      ]
+    }
+  ],
   "globalStyle": {
     "navigationBarTextStyle": "black",
     "navigationBarTitleText": "uni-app",

+ 115 - 11
pages/login/index.vue

@@ -8,7 +8,7 @@
             </view>
             <view class="login-ipt">
                 <view class="ipt-list">
-                    <tui-input placeholder="请输入您的账号" v-model="loginAccount.account" :inputBorder="true"
+                    <tui-input placeholder="请输入您的账号" v-model="loginAccount.username" :inputBorder="true"
                         :radius="16"></tui-input>
                     <view class="password" v-show="idx == 0">
                         <tui-input :type="!showIcon ? 'text' : 'password'" placeholder="请输入您的密码"
@@ -49,15 +49,17 @@
                 </view>
             </view>
             <view class="btn-list">
-                <view class="login-btn">登陆</view>
+                <view class="login-btn" @click="landing">登陆</view>
                 <view class="register-btn">注册开店</view>
             </view>
         </view>
-
+        <modal :showModal="modal" :promptList="promptList" @closeModal="closeModal" :showBtn="showBtn"></modal>
     </view>
 </template>
 
 <script>
+import { login, getCode } from '@/config/index.js'
+import JM from '@/utils/rsaEncrypt.js'
 export default {
     data() {
         return {
@@ -73,19 +75,33 @@ export default {
                 }
             ],
             loginAccount: {
-                account: '',
+                username: '',
+                rememberMe: false,
+                //  验证码
+                code: '',
+                //  密码
                 password: '',
-                code: ''
             },
+            //  弹框显示
+            modal: false,
+            //  弹框显示的内容
+            promptList: [],
+            //  控制按钮显示
+            showBtn: false,
             showIcon: true,
+            //  控制是否同意协议
             protocolTrue: false,
             //  控制获取验证码成功
             successVal: 0,
             //  控制获取验证码失败
-            resetVal: 0
+            resetVal: 0,
         }
     },
     methods: {
+        //  关闭弹框
+        closeModal() {
+            this.modal = false
+        },
         changeIdx(index) {
             this.idx = index
         },
@@ -97,9 +113,93 @@ export default {
         radioClick(flag) {
             this.protocolTrue = flag
         },
-        getVerify() {
-            console.log("获取验证码");
-            this.successVal++
+        async getVerify() {
+            const phoneCodeVerification = /^[1][3-9][0-9]{9}$/
+            if (!phoneCodeVerification.test(this.loginAccount.username)) {
+                this.$showToast('请输入正确的账号!')
+                this.resetVal++
+                return
+            }
+            let res = await getCode({ phone: this.loginAccount.username });
+            if (res.message == "") {
+                this.successVal++
+            } else {
+                this.resetVal++
+            }
+        },
+        //  登录
+        landing() {
+            const phoneCodeVerification = /^[1][3-9][0-9]{9}$/
+            if (!phoneCodeVerification.test(this.loginAccount.username)) {
+                this.$showToast('请输入正确的账号!')
+                this.resetVal++
+                return
+            }
+            if (!this.protocolTrue) {
+                this.$showToast('请勾选同意用户协议。')
+                this.resetVal++
+                return
+            }
+            if (this.idx == 0) {
+                this.passwordLogin()
+            }
+            if (this.idx == 1) {
+                this.codeLogin()
+            }
+        },
+        //  密码登录的处理逻辑
+        async passwordLogin() {
+            let obj = {
+                username: JM.encrypt(this.loginAccount.username),
+                password: JM.encrypt(this.loginAccount.password),
+                rememberMe: false
+            }
+            this.getLogin(obj)
+        },
+        //  验证码登录的处理逻辑
+        async codeLogin() {
+            if (this.loginAccount.code == '') {
+                this.$showToast('请输入验证码')
+                return
+            }
+            let codeObj = {
+                username: JM.encrypt(this.loginAccount.username),
+                code: JM.encrypt(this.loginAccount.code),
+                rememberMe: false
+            }
+            this.getLogin(codeObj)
+        },
+        //  具体登陆接口调用
+        async getLogin(data) {
+            //  全局的加载状态显示
+            this.$loading.show("登录中");
+            try {
+                let res = await login(data);
+
+                if (res.code != '' && res.message == '用户未注册') {
+                    this.modal = true
+                    this.promptList = ['您的账户未注册店铺', '请重新输入']
+                    this.showBtn = true
+                    return
+                } else if (res.code != '') {
+                    this.modal = true
+                    this.promptList = [res.message, '请重新输入']
+                    this.showBtn = false
+                    return
+                }
+                //  将数据存储到本地
+                uni.setStorageSync("storage_info", res.data);
+                uni.setStorageSync("storage_key", res.data.token);
+                // 跳转到首页
+                uni.switchTab({
+                    url: "/pages/tabbar/index/index",
+                });
+
+            } catch (error) {
+                console.log(error);
+            } finally {
+                this.$loading.hide();
+            }
         }
     },
 }
@@ -135,10 +235,12 @@ export default {
 
             .ipt-list {
                 @include flex(center, column, 24rpx);
-                .password{
+
+                .password {
                     width: 100%;
                 }
-                .code{
+
+                .code {
                     width: 100%;
                 }
             }
@@ -184,4 +286,6 @@ export default {
         }
     }
 }
+
+/* 弹框样式 */
 </style>

+ 87 - 0
pages/tabbar/index/data.js

@@ -0,0 +1,87 @@
+
+export const toolList = [
+    {
+        title: "扫码验劵",
+        img: require('@/static/image/home/1.png'),
+        background:'linear-gradient(143deg, #FFA78F -6%, #F23E2C 152%)',
+        url: '/pages_module/scanCode/index',
+    },
+    {
+        title: "输码验劵",
+        background:'linear-gradient(143deg, #1E99FE -6%, #5788FB 152%)',
+        img: require('@/static/image/home/2.png'),
+        url:'/pages_module/scanCoupons/index'
+    },
+    {
+        title: "核销明细",
+        background:'linear-gradient(143deg, #9B78F6 -6%, #7548FD 152%)',
+        img: require('@/static/image/home/3.png')
+    },
+    {
+        title: "收款记录",
+        background:'linear-gradient(143deg, #17CFEB -6%, #5799FB 152%)',
+        img: require('@/static/image/home/4.png')
+    },
+]
+
+export const tobeList = [
+    {
+        title:'经营数据',
+        img: require('@/static/image/home/tobe_1.png'),
+    },
+    {
+        title:'商品管理',
+        img: require('@/static/image/home/tobe_2.png'),
+    },
+    {
+        title:'订单管理',
+        img: require('@/static/image/home/tobe_3.png'),
+    },
+    {
+        title:'财务对账',
+        img: require('@/static/image/home/tobe_4.png'),
+    },
+    {
+        title:'收款账户',
+        img: require('@/static/image/home/tobe_5.png'),
+    },
+    {
+        title:'活动中心',
+        img: require('@/static/image/home/tobe_6.png'),
+    },
+    {
+        title:'会员管理',
+        img: require('@/static/image/home/tobe_7.png'),
+    },
+    {
+        title:'更多',
+        img: require('@/static/image/home/tobe_8.png'),
+    },
+]
+
+export const statisticsList =  [
+    {
+        title: "今日成交金额",
+        price: "16500元",
+        proportion: "16",
+        state: 0
+    },
+    {
+        title: "今日成交订单量",
+        price: "60单",
+        proportion: "20",
+        state: 0
+    },
+    {
+        title: "今日核销金额",
+        price: "14200元",
+        proportion: "16",
+        state: 1
+    },
+    {
+        title: "今日成交订单量",
+        price: "0",
+        proportion: "16",
+        state: 2
+    },
+]

+ 249 - 0
pages/tabbar/index/index.scss

@@ -0,0 +1,249 @@
+.home {
+  width: 100vw;
+  height: 100vh;
+  background-color: rgb(247, 247, 247);
+  position: relative;
+  /* z-index: -1; */
+
+  .bg-box {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100vw;
+    height: 654rpx;
+    z-index: 1;
+    background: linear-gradient(
+      136deg,
+      rgba(239, 83, 14, 0.63) 13%,
+      rgba(239, 83, 14, 0.27) 54%
+    );
+  }
+
+  .header-top {
+    margin-left: 32rpx;
+    position: relative;
+    z-index: 2;
+    @include flex(flex-start, null, 12rpx);
+
+    .shop-title {
+      font-size: 36rpx;
+      color: #000;
+    }
+
+    .shop-state {
+      width: 148rpx;
+      height: 48rpx;
+      border-radius: 24rpx;
+      background-color: #fff;
+      box-sizing: border-box;
+      padding: 0 16rpx;
+      @include flex(space-between, null, 6rpx);
+
+      text {
+        font-size: 24rpx;
+      }
+    }
+  }
+  .main {
+    position: relative;
+    z-index: 2;
+    border-radius: 36rpx 36rpx 0 0;
+    margin-top: 30rpx;
+    padding: 28rpx 0;
+    box-sizing: border-box;
+    width: 100%;
+    height: 479rpx;
+    background: rgba(255, 255, 255, 0.8);
+    .main-tool {
+      width: 100%;
+      margin-top: 28rpx;
+      .tool-list {
+        @include flex(center);
+        .tool-item {
+          flex: 1;
+          @include flex(center,column,10rpx);
+          .item-img{
+            width: 100rpx;
+            height: 100rpx;
+            border-radius: 50%;
+            @include flex(center);
+            image{
+                width: 50rpx;
+                height: 50rpx;
+                display: block;
+            }
+          }
+          .item-text{
+            font-size: 28rpx;
+            color: #666666;
+          }
+        }
+      }
+      .tube-list{
+        @include flex(center);
+        flex-wrap: wrap;
+        margin-top: 40rpx;
+        .tube-item{
+            width: 25%;
+            @include flex(center,column,10rpx);
+            margin-top: 20rpx;
+            image{
+                width: 40rpx;
+                height: 40rpx;
+            }
+            text{
+                font-size: 24rpx;
+                color: #666666;
+            }
+        }
+      }
+    }
+  }
+
+  // .header-content {
+  // 	position: relative;
+  // 	z-index: 2;
+  // 	width: 694rpx;
+  // 	height: 294rpx;
+  // 	margin: 60rpx auto 40rpx;
+  // 	background: rgba(255, 255, 255, 0.5);
+  // 	border-radius: 32rpx;
+  // }
+
+  // .main-tool {
+  // 	position: relative;
+  // 	z-index: 2;
+
+  // 	.tool-list {
+  // 		padding: 40rpx 60rpx 50rpx;
+  // 		background-color: #fff;
+  // 		height: 208rpx;
+  // 		width: 100%;
+  // 		border-radius: 28px 28px 0px 0px;
+  // 		box-sizing: border-box;
+  // 		@include flex(space-between, null, 60rpx);
+
+  // 		.tool-item {
+  // 			@include flex(center, column, 10rpx);
+
+  // 			image {
+  // 				width: 48rpx;
+  // 				height: 48rpx;
+  // 			}
+
+  // 			text {
+  // 				color: #666666;
+  // 				font-size: 28rpx;
+  // 			}
+  // 		}
+  // 	}
+  // }
+
+  .summarize-box {
+    padding: 0 32rpx;
+    box-sizing: border-box;
+    @include flex(space-between);
+    margin: 32rpx 0;
+
+    .summarize-left {
+      font-size: 36rpx;
+      color: #3d3d3d;
+    }
+
+    .summarize-right {
+      @include flex(center, null);
+      font-size: 28rpx;
+      color: #999999;
+    }
+  }
+
+  .statistics-list {
+    @include flex(space-between, null, 18rpx);
+    flex-wrap: wrap;
+    padding: 0 12rpx;
+    box-sizing: border-box;
+
+    .statistics-item {
+      width: 354rpx;
+      height: 286rpx;
+      padding: 32rpx;
+      box-sizing: border-box;
+      background-color: #fff;
+      border-radius: 28rpx;
+
+      .statistics-trans {
+        color: #666666;
+        font-size: 28rpx;
+        margin-bottom: 24rpx;
+      }
+
+      .statistics-price {
+        @include flex(space-between);
+
+        .price {
+          color: #333333;
+          font-size: 36rpx;
+        }
+
+        .text {
+          margin-right: 10rpx;
+          color: #666666;
+          font-size: 24rpx;
+        }
+      }
+
+      .proportion {
+        @include flex(flex-end);
+        margin: 20rpx 0 12rpx;
+
+        .proportion-box {
+          @include flex(center, null, 5rpx);
+
+          text {
+            font-size: 28rpx;
+          }
+
+          image {
+            width: 20rpx;
+            height: 28rpx;
+            display: block;
+          }
+        }
+      }
+
+      .chart-img {
+        width: 100%;
+        height: 80rpx;
+
+        image {
+          width: 100%;
+          height: 100%;
+        }
+      }
+
+      .empty {
+        position: relative;
+        width: 100%;
+        height: 135rpx;
+
+        .left {
+          position: absolute;
+          right: 25rpx;
+          top: 20rpx;
+          width: 28rpx;
+          height: 5rpx;
+          background-color: #666666;
+        }
+
+        .bottom {
+          width: 100%;
+          position: absolute;
+          left: 0;
+          bottom: 0;
+          height: 5rpx;
+          background-color: #666666;
+        }
+      }
+    }
+  }
+}

+ 56 - 232
pages/tabbar/index/index.vue

@@ -1,23 +1,42 @@
 <template>
 	<view class="home">
-		<capsule></capsule>
+		<capsule @getHeight="getCapusleHeight"></capsule>
 		<view class="bg-box"></view>
-		<view class="header-top" :style="{ height: menuButtonHeight }">
-			<view class="shop-title">麦乐鸡烤肉店</view>
+		<view class="header-top" :style="{ height: menuButtonHeight + 'px' }">
+			<view class="shop-title">{{ shopInfo.shopName }}</view>
 			<view class="shop-state">
 				<tui-icon style="height: 36rpx;" name="circle-fill" color="rgb(70,208,88)" :size="20"></tui-icon>
 				<text>营业中</text>
 			</view>
 		</view>
-		<view class="header-content"></view>
+		<view class="main" :style="{ height: mainHeight + 'px' }">
+			<view class="main-tool">
+				<view class="tool-list">
+					<view class="tool-item" v-for="item in toolList" :key="item.title" @click="scanCode(item.url)">
+						<view class="item-img" :style="{ background: item.background }">
+							<image class="" :src="item.img" />
+						</view>
+						<view class="item-text">{{ item.title }}</view>
+					</view>
+				</view>
+				<view class="tube-list">
+					<view class="tube-item" v-for="item in tobeList" :key="item.title">
+						<image :src="item.img" />
+						<text>{{ item.title }}</text>
+					</view>
+				</view>
+			</view>
+			<view class="main-container"></view>
+		</view>
+		<!-- <view class="header-content"></view>
 		<view class="main-tool">
 			<view class="tool-list">
-				<view class="tool-item" v-for="item in toolList" :key="item.title">
+				<view class="tool-item" v-for="item in toolList" :key="item.title" @click="scanCode(item.url)">
 					<image :src="item.img" alt="" />
 					<text>{{ item.title }}</text>
 				</view>
 			</view>
-		</view>
+		</view> -->
 		<view class="summarize-box">
 			<view class="summarize-left">经营概括</view>
 			<view class="summarize-right">
@@ -61,252 +80,57 @@
 </template>
 
 <script>
+import { getShopDetail } from '@/config/index.js'
+import { toolList, tobeList, statisticsList } from './data'
 export default {
 	created() {
 		//  获取胶囊的高度
 		// #ifdef MP-WEIXIN
 		let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
-		this.menuButtonHeight = menuButtonInfo.height + 'px'
+		this.menuButtonHeight = menuButtonInfo.height
 		// #endif
+
+		//  请求获取店铺的信息
+		this.getShop()
 	},
 	data() {
 		return {
 			//  胶囊的高度
 			menuButtonHeight: null,
-			toolList: [
-				{
-					title: "扫码验劵",
-					img: require('@/static/image/home/1.png')
-				},
-				{
-					title: "输码验劵",
-					img: require('@/static/image/home/2.png')
-				},
-				{
-					title: "核销明细",
-					img: require('@/static/image/home/3.png')
-				},
-				{
-					title: "收款记录",
-					img: require('@/static/image/home/4.png')
-				},
-			],
-			statisticsList: [
-				{
-					title: "今日成交金额",
-					price: "16500元",
-					proportion: "16",
-					state: 0
-				},
-				{
-					title: "今日成交订单量",
-					price: "60单",
-					proportion: "20",
-					state: 0
-				},
-				{
-					title: "今日核销金额",
-					price: "14200元",
-					proportion: "16",
-					state: 1
-				},
-				{
-					title: "今日成交订单量",
-					price: "0",
-					proportion: "16",
-					state: 2
-				},
-			]
+			toolList: toolList,
+			tobeList: tobeList,
+			statisticsList: statisticsList,
+			// 店铺信息
+			shopInfo: {},
+			//  动态计算 main 的高度
+			mainHeight: 0
 		}
 	},
 	onLoad() {
 
 	},
 	methods: {
-
+		getCapusleHeight(e) {
+			this.mainHeight = 327 - e - this.menuButtonHeight + 16
+			console.log(this.mainHeight);
+		},
+		//  获取店铺详情
+		async getShop() {
+			let { data } = await getShopDetail({});
+			this.shopInfo = data
+			//  将店铺存到本地
+			uni.setStorageSync('shopInfo', data)
+		},
+		// 扫码
+		scanCode(url) {
+			uni.navigateTo({
+				url: url
+			});
+		}
 	}
 }
 </script>
 
 <style lang="scss" scoped>
-.home {
-	width: 100vw;
-	height: 100vh;
-	background-color: rgb(247, 247, 247);
-	position: relative;
-	z-index: -2;
-
-	.bg-box {
-		position: absolute;
-		top: 0;
-		left: 0;
-		width: 100vw;
-		height: 654rpx;
-		z-index: -1;
-		background: linear-gradient(136deg, rgba(239, 83, 14, 0.63) 13%, rgba(239, 83, 14, 0.27) 54%);
-	}
-
-	.header-top {
-		margin-left: 32rpx;
-		@include flex(flex-start, null, 12rpx);
-
-		.shop-title {
-			font-size: 36rpx;
-			color: #000;
-		}
-
-		.shop-state {
-			width: 148rpx;
-			height: 48rpx;
-			border-radius: 24rpx;
-			background-color: #fff;
-			box-sizing: border-box;
-			padding: 0 16rpx;
-			@include flex(space-between, null, 6rpx);
-
-			text {
-				font-size: 24rpx;
-			}
-		}
-	}
-
-	.header-content {
-		width: 694rpx;
-		height: 294rpx;
-		margin: 60rpx auto 40rpx;
-		background: rgba(255, 255, 255, 0.5);
-		border-radius: 32rpx;
-	}
-
-	.main-tool {
-		.tool-list {
-			padding: 40rpx 60rpx 50rpx;
-			background-color: #fff;
-			height: 208rpx;
-			width: 100%;
-			border-radius: 28px 28px 0px 0px;
-			box-sizing: border-box;
-			@include flex(space-between, null, 60rpx);
-
-			.tool-item {
-				@include flex(center, column, 10rpx);
-
-				image {
-					width: 48rpx;
-					height: 48rpx;
-				}
-
-				text {
-					color: #666666;
-					font-size: 28rpx;
-				}
-			}
-		}
-	}
-
-	.summarize-box {
-		padding: 0 32rpx;
-		box-sizing: border-box;
-		@include flex(space-between);
-		margin: 32rpx 0;
-
-		.summarize-left {
-			font-size: 36rpx;
-			color: #3D3D3D;
-		}
-
-		.summarize-right {
-			@include flex(center, null);
-			font-size: 28rpx;
-			color: #999999;
-		}
-	}
-
-	.statistics-list {
-		@include flex(space-between, null, 18rpx);
-		flex-wrap: wrap;
-		padding: 0 12rpx;
-		box-sizing: border-box;
-
-		.statistics-item {
-			width: 354rpx;
-			height: 286rpx;
-			padding: 32rpx;
-			box-sizing: border-box;
-			background-color: #fff;
-			border-radius: 28rpx;
-
-			.statistics-trans {
-				color: #666666;
-				font-size: 28rpx;
-				margin-bottom: 24rpx;
-			}
-
-			.statistics-price {
-				@include flex(space-between);
-
-				.price {
-					color: #333333;
-					font-size: 36rpx;
-				}
-
-				.text {
-					margin-right: 10rpx;
-					color: #666666;
-					font-size: 24rpx
-				}
-			}
-
-			.proportion {
-				@include flex(flex-end);
-				margin: 20rpx 0 12rpx;
-
-				.proportion-box {
-					@include flex(center, null, 5rpx);
-
-					text {
-						font-size: 28rpx;
-					}
-
-					image {
-						width: 20rpx;
-						height: 28rpx;
-						display: block;
-					}
-				}
-			}
-
-			.chart-img {
-				width: 100%;
-				height: 80rpx;
-
-				image {
-					width: 100%;
-					height: 100%;
-				}
-			}
-			.empty{
-				position: relative;
-				width: 100%;
-				height: 135rpx;
-				.left{
-					position: absolute;
-					right: 25rpx;
-					top: 20rpx;
-					width: 28rpx;
-					height: 5rpx;
-					background-color: #666666;
-				}
-				.bottom{
-					width: 100%;
-					position: absolute;
-					left: 0;
-					bottom: 0;
-					height: 5rpx;
-					background-color: #666666;
-				}
-			}
-		}
-	}
-}
+@import './index.scss';
 </style>

+ 197 - 0
pages/tabbar/order/index.scss

@@ -0,0 +1,197 @@
+.order {
+  width: 100vw;
+  min-height: 100vh;
+  background-color: rgb(247, 247, 247);
+
+  .order-box {
+    width: 100%;
+    height: 100%;
+    @include flex(center);
+  }
+
+  .order-top {
+    width: 100%;
+    padding: 28rpx 32rpx 0rpx;
+    box-sizing: border-box;
+    background-color: #ffffff;
+
+    .search-box {
+      width: auto;
+      height: 80rpx;
+      border-radius: 300rpx;
+      background-color: #f1f1f1;
+      line-height: 80rpx;
+      padding-left: 84rpx;
+      box-sizing: border-box;
+      color: #999999;
+      position: relative;
+      font-size: 28rpx;
+
+      .search-icon {
+        position: absolute;
+        top: 50%;
+        transform: translateY(-50%);
+        left: 36rpx;
+      }
+    }
+
+    .order-state {
+      margin-top: 54rpx;
+
+      .scroll-X {
+        white-space: nowrap;
+
+        .scroll-item {
+          display: inline-block;
+          padding-bottom: 16rpx;
+          margin-left: 36rpx;
+          font-size: 28rpx;
+          color: #999999;
+
+          &:first-of-type {
+            margin-left: 0;
+          }
+        }
+
+        .act {
+          color: $primary-color;
+          position: relative;
+
+          &::after {
+            content: "";
+            position: absolute;
+            left: 0;
+            bottom: 0;
+            width: 100%;
+            height: 4rpx;
+            background-color: $primary-color;
+            border-radius: 20rpx;
+          }
+        }
+      }
+    }
+  }
+
+  .order-container {
+    padding: 0 32rpx 32rpx;
+
+    .order-list {
+      .order-item {
+        width: auto;
+        margin-top: 32rpx;
+        padding: 32rpx;
+        box-sizing: border-box;
+        background-color: #ffffff;
+        border-radius: 16rpx;
+        display: flex;
+        justify-content: center;
+        gap: 24rpx;
+        flex-direction: column;
+        .order-number {
+          width: 100%;
+          @include flex(space-between);
+
+          .number {
+            font-size: 32rpx;
+            font-weight: 700;
+          }
+
+          .number-icon {
+            color: #999999;
+            @include flex(center);
+            font-size: 28rpx;
+            text {
+              padding-bottom: 2rpx;
+            }
+          }
+        }
+        .text-info {
+          font-size: 28rpx;
+          color: #999999;
+        }
+        .commodity-list {
+          width: 100%;
+          display: flex;
+          justify-content: center;
+          gap: 12rpx;
+          flex-direction: column;
+          .commodity-item {
+            display: flex;
+            justify-content: space-between;
+            .item-left {
+              display: flex;
+              gap: 12rpx;
+              .left-image {
+                width: 124rpx;
+                height: 124rpx;
+                image {
+                  width: 100%;
+                  height: 100%;
+                  border-radius: 12rpx;
+                }
+              }
+              .left-text {
+                display: flex;
+                flex-direction: column;
+                gap: 6rpx;
+                .text-title {
+                  color: #333333;
+                  font-size: 28rpx;
+                }
+                .text-price {
+                  font-size: 24rpx;
+                  color: #999999;
+                }
+              }
+            }
+            .item-right {
+              color: #333333;
+              font-size: 28rpx;
+            }
+          }
+        }
+        .gifts {
+          @include flex(space-between);
+          font-size: 28rpx;
+          color: #333333;
+          .gifs-right {
+            color: #ea1717;
+          }
+        }
+        .all-price {
+          color: #333333;
+          font-size: 28rpx;
+        }
+        .border-box {
+          width: 100%;
+          height: 2rpx;
+          background-color: #d8d8d8;
+        }
+        .order-state {
+          text-align: end;
+          color: #999999;
+          font-size: 28rpx;
+          margin-top: 3rpx;
+        }
+      }
+    }
+  }
+  .order-empty{
+    position: fixed;
+    top: 41%;
+    left: 50%;
+    transform: translate(-50%);
+    @include flex(center,column,32rpx);
+    font-size: 32rpx;
+    image{
+      width: 460rpx;
+      height: 460rpx;
+    }
+    .empty-title{
+      color: #666666;
+    }
+    .empty-info{
+      color: #999999;
+    }
+  }
+}

+ 146 - 2
pages/tabbar/order/index.vue

@@ -1,13 +1,157 @@
 <template>
-  <div class="order">这里是订单页面</div>
+  <div class="order">
+    <capsule :showBorder="true" bgColor="#FFFFFF">
+      <template v-slot:top>
+        <view class="order-box">订单列表</view>
+      </template>
+    </capsule>
+    <view class="order-top">
+      <view class="search-box">
+        <view class="search-icon">
+          <tui-icon name="search-2" :size="18" color="#999999"></tui-icon>
+        </view>
+        <text>请输入订单号/手机号</text>
+      </view>
+      <view class="order-state">
+        <scroll-view scroll-x="true" class="scroll-X">
+          <view class="scroll-item" v-for="(item, index) in orderState" :key="index"
+            :class="item.state == orderIdx ? 'act' : ''" @click="changeState(item.state)">{{ item.title }}</view>
+        </scroll-view>
+      </view>
+    </view>
+    <view class="order-container" v-if="orderList.length > 0">
+      <view class="order-list">
+        <view class="order-item" v-for="item in orderList" :key="item.orderId">
+          <view class="order-number">
+            <view class="number">订单编号:{{ item.orderFormid }}</view>
+            <view class="number-icon">
+              <text>详情</text>
+              <tui-icon name="arrowright" :size="20" color="#999999" style="padding: 0;"></tui-icon>
+            </view>
+          </view>
+          <view class="text-info">用户昵称:{{ item.customerName }}</view>
+          <view class="text-info">用户手机号:{{ item.customerPhone }}</view>
+          <view class="commodity-list">
+            <view class="commodity-item" v-for="item2 in item.products" :key="item2.orderProductId">
+              <view class="item-left">
+                <view class="left-image">
+                  <image :src="item2.image" />
+                </view>
+                <view class="left-text">
+                  <view class="text-title">{{ item2.productName }}</view>
+                  <template v-if="item2.productName == '扫码付款商品'">
+                    <view class="text-price">扫码付款商品</view>
+                  </template>
+                  <template v-else>
+                    <view class="text-price">小份</view>
+                  <view class="text-price">x1</view>
+                  </template>
+                </view>
+              </view>
+              <view class="item-right">¥{{ item2.productPrice }}</view>
+            </view>
+          </view>
+          <view class="gifts">
+            <view class="gifs-left">赠送代金券</view>
+            <view class="gifs-right">¥1 x 1</view>
+          </view>
+          <view class="all-price">总价¥{{ item.price }},优惠¥99.99,实付¥100</view>
+          <view class="border-box"></view>
+          <view class="order-state">
+            <text v-if="item.state == 1">待付款</text>
+            <text v-if="item.state == 2">待发货</text>
+            <text v-if="item.state == 3">待收货</text>
+            <text v-if="item.state == 4">已完成</text>
+            <text v-if="item.state == 5">交易关闭(已取消)</text>
+            <text v-if="item.state == 6">待成团</text>
+            <text v-if="item.state == 7">待售后</text>
+            <text v-if="item.state == 8" :style="{color:'#EA1717'}">待核销(未付款)</text>
+            <text v-if="item.state == 9">待核销(已付款)</text>
+            <text v-if="item.state == 10">已核销</text>
+          </view>
+        </view>
+      </view>
+    </view>
+    <view class="order-empty" v-else>
+      <image src="@/static/image/order/empty.png"  />
+       <view class="empty-title">暂无订单信息</view>
+       <view class="empty-info">有订单信息您会在这边看到的</view>
+    </view>
+  </div>
 </template>
 
 <script>
+import { orderGetAll } from '@/config/index.js'
 export default {
+  created() {
+    this.getOrderList()
+  },
+  data() {
+    return {
+      orderState: [
+        {
+          title: '全部',
+          state: ''
+        },
+        {
+          title: '未付款',
+          state:8
+        },
+        {
+          title: '已付款',
+          state:9
+        },
+        {
+          title: '已核销',
+          state:10
+        },
+        {
+          title: '已取消',
+          state:5
+        },
+        {
+          title: '售后订单',
 
+        },
+      ],
+      orderIdx: 0,
+      // 请求订单参数
+      serachParams: {
+        afterState: "",
+        dates: [],
+        page: 1,
+        pageSize: 10,
+        search: "",
+        searchType: "1",
+        state: ""
+      },
+      orderList: []
+    }
+  },
+  methods: {
+    // 状态修改
+    changeState(state) {
+      this.orderIdx = state
+      this.serachParams.state = state
+      //  请求新的数据
+      this.getOrderList()
+    },
+    //  获取订单列表
+    async getOrderList() {
+      this.$loading.show("加载中!");
+      try {
+        let { data } = await orderGetAll(this.serachParams);
+        console.log(data);
+        this.orderList = data.list
+      } catch (error) {
+      } finally {
+        this.$loading.hide();
+      }
+    },
+  }
 }
 </script>
 
 <style lang="scss" scoped>
-
+@import './index.scss';
 </style>

+ 246 - 0
pages_module/orderVerifica/index.vue

@@ -0,0 +1,246 @@
+<template>
+    <view class="orderVerifica">
+        <capsule :showBorder="true">
+            <template v-slot:top>
+                <view class="shop-top">
+                    <view class="back-icon" @click="backClick">
+                        <tui-icon name="arrowleft" :size="36" color="#000"></tui-icon>
+                    </view>
+                    <view class="shop-name">订单核销</view>
+                </view>
+            </template>
+        </capsule>
+        <view class="order-number">订单编号:139529738377368</view>
+        <view class="verifica-container">
+            <view class="verifica-info">
+                <view class="info-state">订单状态:(待核销已付款)</view>
+                <view class="info-state">商户:麦乐鸡烤肉店 </view>
+                <view class="info-price">
+                    <view class="all-price">
+                        商品总价:¥<text>199.99</text>
+                    </view>
+                    <view class="all-price">
+                        实付款:¥<text>198.99</text>
+                    </view>
+                </view>
+            </view>
+            <view class="verifica-product">
+                <view class="verifica-time">
+                    <text>创建时间</text>
+                    <text>2024-06-01 11:29:42</text>
+                </view>
+                <view class="commodity-list">
+                    <view class="commodity-item">
+                        <view class="item-left">
+                            <view class="left-image">
+                                <image
+                                    src="https://img2.baidu.com/it/u=1700149007,2105278410&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400" />
+                            </view>
+                            <view class="left-text">
+                                <view class="text-title">嘿嘿嘿</view>
+                                <!-- <template v-if="item2.productName == '扫码付款商品'">
+                                    <view class="text-price">扫码付款商品</view>
+                                </template> -->
+                                <template>
+                                    <view class="text-price">小份</view>
+                                    <view class="text-price">x1</view>
+                                </template>
+                            </view>
+                        </view>
+                        <view class="item-right">¥99.00</view>
+                    </view>
+                </view>
+                <view class="gifts">
+                    <view class="gifs-left">赠送代金券</view>
+                    <view class="gifs-right">¥1 x 1</view>
+                </view>
+                <view class="verifica-code">
+                    <text>核销码</text>
+                    <text>4561-JFHXDKHGM8</text>
+                </view>
+            </view>
+            <view class="verifica-btn">
+                <view class="btn">确认核销</view>
+            </view>
+        </view>
+    </view>
+</template>
+
+<script>
+import { orderGetById } from '@/config/index.js'
+export default {
+    onLoad(props){
+        console.log(props);
+        this.orderId = props.orderId
+        this.getOrderDetail()
+    },
+    data() {
+        return {
+            //  订单详情
+            orderDetail:{},
+            orderId:null
+        }
+    },
+    methods: {
+        // 获取订单详情
+        async getOrderDetail(){
+            try {
+                let res = await orderGetById({orderId:this.orderId})
+                console.log(res);
+            } catch (error) {
+                
+            }
+        },
+        backClick() {
+            uni.navigateBack()
+        }
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.orderVerifica {
+    .shop-top {
+        width: 100%;
+        height: 100%;
+        position: relative;
+        z-index: 999;
+        @include flex(center);
+
+        .back-icon {
+            position: absolute;
+            left: 0;
+            top: 50%;
+            transform: translateY(-50%);
+        }
+
+        .shop-name {
+            color: #000;
+        }
+    }
+
+    .order-number {
+        margin: 32rpx 0;
+        color: #999999;
+        font-size: 28rpx;
+        padding-left: 32rpx;
+    }
+
+    .verifica-container {
+        padding: 0 60rpx;
+
+        .verifica-info {
+            display: flex;
+            flex-direction: column;
+            gap: 12rpx;
+            color: #3D3D3D;
+            font-size: 28rpx;
+            font-weight: 600;
+            padding-bottom: 20rpx;
+            border-bottom: 2rpx solid #D8D8D8;
+
+            text {
+                color: #EA1717;
+            }
+
+            .info-price {
+                @include flex(space-between);
+            }
+        }
+
+        .verifica-product {
+            padding: 12rpx 0 20rpx;
+            border-bottom: 2rpx solid #D8D8D8;
+
+            .verifica-time {
+                @include flex(space-between);
+                color: #999999;
+                font-size: 24rpx;
+            }
+
+            .commodity-list {
+                width: 100%;
+                display: flex;
+                justify-content: center;
+                gap: 12rpx;
+                flex-direction: column;
+                margin: 20rpx 0 36rpx;
+
+                .commodity-item {
+                    display: flex;
+                    justify-content: space-between;
+
+                    .item-left {
+                        display: flex;
+                        gap: 12rpx;
+
+                        .left-image {
+                            width: 124rpx;
+                            height: 124rpx;
+
+                            image {
+                                width: 100%;
+                                height: 100%;
+                                border-radius: 12rpx;
+                            }
+                        }
+
+                        .left-text {
+                            display: flex;
+                            flex-direction: column;
+                            gap: 6rpx;
+
+                            .text-title {
+                                color: #333333;
+                                font-size: 28rpx;
+                            }
+
+                            .text-price {
+                                font-size: 24rpx;
+                                color: #999999;
+                            }
+                        }
+                    }
+
+                    .item-right {
+                        color: #333333;
+                        font-size: 28rpx;
+                    }
+                }
+            }
+
+            .gifts {
+                @include flex(space-between);
+                font-size: 28rpx;
+                color: #333333;
+
+                .gifs-right {
+                    color: #ea1717;
+                }
+            }
+
+            .verifica-code {
+                color: #3D3D3D;
+                font-size: 28rpx;
+                @include flex(space-between);
+                margin-top: 32rpx;
+            }
+        }
+        .verifica-btn{
+            padding-top: 72rpx;
+            display: flex;
+            justify-content: flex-end;
+            .btn{
+                width: 246rpx;
+                height: 88rpx;
+                text-align: center;
+                line-height: 88rpx;
+                color: #FFFFFF;
+                font-size: 28rpx;
+                border-radius: 50rpx;
+                background: linear-gradient(180deg, #FE4B1E 0%, #FB8857 100%);
+            }
+        }
+    }
+}
+</style>

+ 310 - 0
pages_module/scanCode/index.vue

@@ -0,0 +1,310 @@
+<template>
+    <view class="scanCode">
+        <capsule :showBorder="true">
+            <template v-slot:top>
+                <view class="shop-top">
+                    <view class="back-icon" @click="backClick">
+                        <tui-icon name="arrowleft" :size="42" color="#FFFFFF"></tui-icon>
+                    </view>
+                    <view class="shop-name">{{ shopInfo.shopName }}</view>
+                </view>
+            </template>
+        </capsule>
+        <view class="scanning">
+            <view class="scan-box">
+                <view class="border-box"></view>
+                <view class="border-box2"></view>
+                <view class="border-box3"></view>
+                <view class="border-box4"></view>
+                <camera class="scan-camera" @scancode="onScancode" mode="scanCode" device-position="back" flash="auto">
+                    <cover-view class="scan-animation" :animation="animation"></cover-view>
+                </camera>
+            </view>
+            <view class="scab-txt">将二维码/条码放到取景框中,即可自动扫描</view>
+        </view>
+        <view class="btn-list">
+            <view class="btn" @click="goCoupons">
+                <image src="@/static/image/code/keyboard.png" />
+                <text>输码验劵</text>
+            </view>
+            <view class="btn" @click="openAlbum">
+                <image src="@/static/image/code/photo.png" />
+                <text>打开相册</text>
+            </view>
+        </view>
+        <modal :showModal="modal" :promptList="promptList" @closeModal="closeModal" :showBtn="false"></modal>
+    </view>
+</template>
+
+<script>
+var animation = uni.createAnimation({
+    timingFunction: "linear",
+    delay: 0
+});
+export default {
+    created() {
+        //  获取本地存储的店铺数据
+        this.shopInfo = uni.getStorageSync('shopInfo');
+        this.getOrderIdFromUrl('https://test.tuanfengkeji.cn/TFShop_Uni_H5/#/pages/jump/jump?orderId=4979&type=verification&code=4979~JFHXQSZD4F')
+    },
+    onShow() {
+        this.lineAnimation()
+    },
+    data() {
+        return {
+            //  扫描线动画
+            animation: {},
+            shopInfo: {},
+            // 控制框显示
+            modal: false,
+            //  弹框显示的内容
+            promptList: [],
+        }
+    },
+    methods: {
+        lineAnimation() {
+            this.animation = animation;
+            let that = this;
+            let scode = true;
+            this.timer = setInterval(
+                function () {
+                    if (scode) {
+                        animation.translateY(260).step({
+                            duration: 1500,
+                        });
+                        scode = !scode;
+                    } else {
+                        animation.translateY(-10).step({
+                            duration: 1500,
+                        });
+                        scode = !scode;
+                    }
+                    that.animation = animation.export();
+                }.bind(this),
+                1500
+            );
+        },
+        //  关闭弹框
+        //  关闭弹框
+        closeModal() {
+            this.modal = false
+        },
+        // 相机初始化完成回调函数
+        onCameraInitDone() {
+            // setInterval(() => {
+            // 	this.$refs.camera.scanCode();
+            // }, 1000);
+        },
+        /**扫码成功*/
+        onScancode(e) {
+            // uni.showModal({
+            //     title: '提示',
+            //     content: e,
+            // });
+            console.log(e.detail.result);
+            this.getOrderIdFromUrl(e.detail.result)
+        },
+        //  获取订单
+        getOrderIdFromUrl(url) {
+            try {
+                let march = url.match(/orderId=(\d+)/)
+                //  传递值过去
+                uni.navigateTo({
+                    url: '/pages_module/orderVerifica/index?orderId=' + march[1]
+                })
+            } catch (error) {
+                this.modal = true
+                this.promptList = ['此二维码/条码无效', '请扫描正常的二维码/条码']
+            }
+        },
+        //  打开相册
+        openAlbum() {
+            uni.chooseImage({
+                count: 1, // 最多可以选择的图片张数
+                sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
+                sourceType: ['album'], // 选择图片的来源,相册
+                success: function (res) {
+                    // console.log(res,res.tempFiles[0].path);
+                    uni.scanCode({
+                        path: res.tempFiles[0].path,
+                        success: function (res) {
+                            console.log('二维码内容为:' + res.result)
+                        },
+                        fail: function (res) {
+                            console.log('识别二维码失败')
+                        }
+                    })
+                }
+            })
+        },
+        // 去到输入验劵
+        goCoupons() {
+            uni.navigateTo({
+                url: '/pages_module/scanCoupons/index'
+            })
+        },
+        backClick() {
+            uni.navigateBack()
+        }
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+%btn {
+    width: 55rpx;
+    height: 13rpx;
+    background-color: #fff;
+    position: relative;
+}
+
+%btnAfter {
+    content: '';
+    position: absolute;
+    width: 13rpx;
+    height: 55rpx;
+    background-color: #fff;
+}
+
+.scanCode {
+    width: 100vw;
+    height: 100vh;
+    background: url("https://jufeng-shop-1317254189.cos.ap-guangzhou.myqcloud.com/1717469011005-bg.png") center;
+    background-size: 100% 100%;
+    position: relative;
+
+    .shop-top {
+        width: 100%;
+        height: 100%;
+        position: relative;
+        z-index: 999;
+        @include flex(center);
+
+        .back-icon {
+            position: absolute;
+            left: 0;
+            top: 50%;
+            transform: translateY(-50%);
+        }
+
+        .shop-name {
+            color: #FFFFFF;
+        }
+    }
+
+    .scanning {
+        width: 100%;
+        position: absolute;
+        top: 50%;
+        left: 50%;
+        transform: translate(-50%, -50%);
+        @include flex(center, column, 30rpx);
+
+        .scan-box {
+            width: 452rpx;
+            height: 452rpx;
+            position: relative;
+
+            .border-box {
+                @extend %btn;
+                position: absolute;
+                left: -5rpx;
+                top: -5rpx;
+
+                &::after {
+                    @extend %btnAfter;
+                    left: -2rpx;
+                    top: 0;
+                }
+            }
+
+            .border-box2 {
+                @extend %btn;
+                position: absolute;
+                right: -5rpx;
+                top: -5rpx;
+
+                &::after {
+                    @extend %btnAfter;
+                    right: -2rpx;
+                    top: 0;
+                }
+            }
+
+            .border-box3 {
+                @extend %btn;
+                position: absolute;
+                right: -5rpx;
+                bottom: -5rpx;
+
+                &::after {
+                    @extend %btnAfter;
+                    right: -2rpx;
+                    bottom: 0;
+                }
+            }
+
+            .border-box4 {
+                @extend %btn;
+                position: absolute;
+                left: -5rpx;
+                bottom: -5rpx;
+
+                &::after {
+                    @extend %btnAfter;
+                    left: -2rpx;
+                    bottom: 0;
+                }
+            }
+
+            .scan-camera {
+                width: 100%;
+                height: 100%;
+            }
+
+            .scan-animation {
+                position: absolute;
+                top: 5%;
+                left: 0;
+                width: 100%;
+                height: 3rpx;
+                background-color: $primary-color;
+                border-radius: 50%;
+            }
+        }
+
+        .scab-txt {
+            font-size: 28rpx;
+            color: #FFFFFF;
+        }
+    }
+
+    .btn-list {
+        position: absolute;
+        left: 50%;
+        bottom: 104rpx;
+        transform: translateX(-50%);
+        @include flex(center, null, 60rpx);
+
+        .btn {
+            width: 276rpx;
+            height: 108rpx;
+            background: rgba(255, 255, 255, 0.4);
+            @include flex(center, null, 22rpx);
+            border-radius: 24rpx;
+
+            image {
+                width: 44rpx;
+                height: 36rpx;
+                display: block;
+            }
+
+            text {
+                font-size: 36rpx;
+                color: #E6E4E5;
+            }
+        }
+    }
+
+}
+</style>

+ 139 - 0
pages_module/scanCoupons/index.vue

@@ -0,0 +1,139 @@
+<template>
+    <view class="scanCoupons">
+        <capsule :showBorder="true" bgColor="#FFFFFF">
+            <template v-slot:top>
+                <view class="shop-top">
+                    <view class="back-icon" @click="backClick">
+                        <tui-icon name="arrowleft" :size="42" color="#000000"></tui-icon>
+                    </view>
+                    <view class="shop-name">{{ shopInfo.shopName }}</view>
+                </view>
+            </template>
+        </capsule>
+        <view class="seat"></view>
+        <view class="ipt">
+            <view class="ipt-box">
+                <template v-if="iptValue == ''">
+                    <view class="ipt-empty">请输入劵码</view>
+                </template>
+                <template v-else>
+                    <view class="ipt-code">{{ iptValue }}</view>
+                </template>
+            </view>
+        </view>
+        <view class="footer">
+            <keyboard :iptValue='iptValue' @single="singleWord" @deleteOne="deleteOne" @deleteAll="this.iptValue = ''">
+            </keyboard>
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    created() {
+        //  获取本地存储的店铺数据
+        this.shopInfo = uni.getStorageSync('shopInfo')
+    },
+    data() {
+        return {
+            shopInfo: {},
+            iptValue: '',
+        }
+    },
+    methods: {
+        backClick() {
+            uni.navigateBack()
+        },
+        //  修改单个验劵码
+        singleWord(val) {
+            this.iptValue = `${this.iptValue}${val}`
+        },
+        //  删除单个字符
+        deleteOne() {
+            this.iptValue = this.iptValue.slice(0, this.iptValue.length - 1)
+        },
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.scanCoupons {
+    width: 100%;
+    height: 100vh;
+    background-color: rgb(241, 241, 241);
+
+    .shop-top {
+        width: 100%;
+        height: 100%;
+        position: relative;
+        z-index: 999;
+        @include flex(center);
+
+        .back-icon {
+            position: absolute;
+            left: 0;
+            top: 50%;
+            transform: translateY(-50%);
+        }
+
+        .shop-name {
+            color: #000000;
+        }
+    }
+
+    .seat {
+        width: 100%;
+        height: 30rpx;
+        background-color: #FFFFFF;
+    }
+
+    .ipt {
+        margin-top: 50rpx;
+        width: 100%;
+
+        .ipt-box {
+            width: 686rpx;
+            height: 108rpx;
+            background-color: #FFFFFF;
+            margin: 0 auto;
+            box-sizing: border-box;
+            padding: 32rpx 0 32rpx 38rpx;
+            border-radius: 16rpx;
+
+            .ipt-empty {
+                color: #999999;
+                font-size: 36rpx;
+                position: relative;
+
+                &::after {
+                    content: '';
+                    width: 6rpx;
+                    height: 80%;
+                    background-color: #EF530E;
+                    position: absolute;
+                    left: -14rpx;
+                    top: 60%;
+                    transform: translateY(-60%);
+                }
+            }
+
+            .ipt-code {
+                width: 100%;
+                overflow-x: scroll;
+                color: #333333;
+                font-size: 36rpx;
+            }
+        }
+    }
+
+    .footer {
+        position: fixed;
+        left: 0;
+        bottom: 0;
+        width: 100%;
+        /*  底部安全区域 */
+        padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
+        padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
+    }
+}
+</style>

+ 277 - 0
pages_module/testCode/index.vue

@@ -0,0 +1,277 @@
+<!-- 扫一扫 -->
+<template>
+	<view class="scan-view">
+		<view class="status_bar">
+			<!-- 这里是状态栏 -->
+		</view>
+		<!-- <u-navbar  :title="userInfo.channelname " :background="'#000'" :title-color="'#fff'" :border-bottom="false"></u-navbar> -->
+		<!-- 自定义导航栏 -->
+		<view class="nav-bar">
+			<view class="left" @click="onClickBack">
+				<text class="fwhfont icon-icon-chevron-left" style="font-size: 50rpx;"></text>
+			</view>
+			<view class="title">
+				<text class="title-text">{{ userInfo.channelname }}</text>
+			</view>
+		</view>
+		<u-toast ref="uToast" />
+		<view class="scan-border">
+			<view
+				style="width: 500rpx;height: 600rpx;border: 1rpx solid #ccc;margin-bottom: 120rpx;position: relative;">
+				<view class="Bordertop">
+					<view style="width: 44rpx;height: 10rpx;background-color: #FBCC04;"></view>
+					<view style="width: 44rpx;height: 10rpx;background-color:  #FBCC04;"></view>
+				</view>
+				<view class="Borderright">
+					<view style="width: 10rpx;height: 44rpx;background-color:  #FBCC04;"></view>
+					<view style="width:10rpx;height: 44rpx;background-color:  #FBCC04;position: absolute;bottom: 0rpx;">
+					</view>
+				</view>
+				<view class="Borderbottom">
+					<view style="width: 44rpx;height: 10rpx;background-color:  #FBCC04;"></view>
+					<view style="width: 44rpx;height: 10rpx;background-color:  #FBCC04;"></view>
+				</view>
+				<view class="Borderleft">
+					<view style="width: 10rpx;height: 44rpx;background-color:  #FBCC04;"></view>
+					<view
+						style="width: 10rpx;height: 44rpx;background-color:  #FBCC04;position: absolute;bottom: 0rpx;">
+					</view>
+				</view>
+				<!-- bindscancode="onScancode" @initdone="onCameraInitDone" -->
+				<camera class="scan-camera" @scancode="onScancode" @error="onError" mode="scanCode"
+					device-position="back" flash="auto">
+					<cover-view class="scan-animation" :animation="animation"></cover-view>
+				</camera>
+			</view>
+			<view class="scanText">将二维码/条码放到取景框内,即可自动扫描</view>
+			<view class="footerButton">
+				<view class="btns">
+					<text class="fwhfont icon-jianpan" style="padding-right: 20rpx;"></text>
+					<text>输码</text>
+				</view>
+				<view class="btns">
+					<text class="fwhfont icon-icon-list" style="padding-right: 20rpx;"></text>
+					<text>记录</text>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+<script>
+var animation = uni.createAnimation({
+	timingFunction: "linear",
+	delay: 0
+});
+export default {
+	data() {
+		return {
+			animation: {},
+
+		};
+	},
+
+	onShow() {
+		this.lineAnimation()
+	},
+	methods: {
+
+		/**扫码线条动画*/
+		lineAnimation() {
+			this.animation = animation;
+			let that = this;
+			let scode = true;
+			this.timer = setInterval(
+				function () {
+					if (scode) {
+						animation.translateY(260).step({
+							duration: 1500,
+						});
+						scode = !scode;
+					} else {
+						animation.translateY(-10).step({
+							duration: 1500,
+						});
+						scode = !scode;
+					}
+					that.animation = animation.export();
+				}.bind(this),
+				1500
+			);
+		},
+		// 相机初始化完成回调函数
+		onCameraInitDone() {
+			// setInterval(() => {
+			// 	this.$refs.camera.scanCode();
+			// }, 1000);
+		},
+		onError() {
+			this.$toast('扫码错误')
+		},
+
+		onClickBack() {
+			uni.navigateBack();
+		},
+		/**扫码成功*/
+		onScancode(e) {
+			uni.showModal({
+				title: '提示',
+				content: '这是一个模态弹窗',
+			});
+			console.log(e);
+		},
+
+	},
+
+	onUnload() {
+
+	},
+};
+</script>
+<style lang="scss" scoped>
+page {
+	background-color: black;
+}
+
+.status_bar {
+	height: var(--status-bar-height);
+	width: 100%;
+}
+
+.scan-view {
+	width: 100%;
+	height: 100%;
+	display: flex;
+	flex-direction: column;
+	position: fixed;
+	align-items: center;
+	justify-content: space-around;
+	background-color: #000;
+}
+
+.Bordertop {
+	display: flex;
+	justify-content: space-between;
+	position: absolute;
+	z-index: 99;
+	width: 100%;
+	top: -2rpx;
+}
+
+.Borderleft {
+	left: -2rpx;
+	z-index: 99;
+	position: absolute;
+	height: 100%;
+}
+
+.Borderright {
+	z-index: 99;
+	position: absolute;
+	right: -2rpx;
+	height: 100%;
+}
+
+.Borderbottom {
+	display: flex;
+	z-index: 99;
+	justify-content: space-between;
+	position: absolute;
+	width: 100%;
+	bottom: -6rpx;
+}
+
+.scan-border {
+	width: 100%;
+	height: 75%;
+	/* border: 6rpx solid #08FDFE; */
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+
+	.scan-camera {
+		width: 100%;
+		height: 100%;
+		border-radius: 6rpx;
+	}
+}
+
+.scan-animation {
+	position: absolute;
+	top: 4%;
+	left: 2%;
+	width: 480rpx;
+	height: 2rpx;
+	background-color: #FBCC04;
+	border-radius: 50%;
+}
+
+.footerButton {
+	width: 100%;
+	margin-top: 100rpx;
+	display: flex;
+	justify-content: space-around;
+	align-items: center;
+
+	.btns {
+		color: #ebebeb;
+		display: flex;
+		justify-content: space-around;
+		align-items: center;
+		margin: 10rpx;
+		padding: 20rpx;
+		background-color: #333333;
+		border-radius: 20rpx;
+	}
+}
+
+.scanText {
+	position: absolute;
+	bottom: 32%;
+	// left: 15%;
+	color: #ebebeb;
+}
+
+/* 导航栏样式 */
+.nav-bar {
+	display: flex;
+	justify-content: space-between;
+	align-items: center;
+	position: fixed;
+	top: 3%;
+	left: 0;
+	width: 100%;
+	height: 110rpx;
+	padding: 0 10px;
+	box-sizing: border-box;
+	z-index: 999;
+	margin-top: 22rpx;
+}
+
+/* 左侧按钮样式 */
+.left {
+	display: flex;
+	justify-content: center;
+	align-items: center;
+	color: #000;
+	background: #fff;
+	border-radius: 60rpx;
+}
+
+/* 标题样式 */
+.title {
+	flex: 1;
+	display: flex;
+	align-items: center;
+	margin-left: 26rpx;
+}
+
+/* 标题文字样式 */
+.title-text {
+	max-width: 200px;
+	overflow: hidden;
+	text-overflow: ellipsis;
+	white-space: nowrap;
+	color: #FFFFFF;
+	font-size: 36rpx;
+}
+</style>

二进制
static/image/code/keyboard.png


二进制
static/image/code/photo.png


二进制
static/image/home/1.png


二进制
static/image/home/2.png


二进制
static/image/home/3.png


二进制
static/image/home/4.png


二进制
static/image/home/tobe_1.png


二进制
static/image/home/tobe_2.png


二进制
static/image/home/tobe_3.png


二进制
static/image/home/tobe_4.png


二进制
static/image/home/tobe_5.png


二进制
static/image/home/tobe_6.png


二进制
static/image/home/tobe_7.png


二进制
static/image/home/tobe_8.png


二进制
static/image/keyboard/delete.png


二进制
static/image/keyboard/shift (1).png


二进制
static/image/keyboard/shift-icon.png


二进制
static/image/keyboard/shift-icon2.png


二进制
static/image/order/empty.png


+ 29 - 0
utils/index.js

@@ -0,0 +1,29 @@
+/**
+ * 提示框
+ * @param {string} title 显示的标题
+ * @param {string} icon 显示的 icon
+ * @param {number} icon 显示的毫秒数
+ */
+export const showToast = (title, icon = "none", time = 2000) => {
+  uni.showToast({
+    title: title,
+    icon: icon,
+    duration: time,
+  });
+};
+
+/**
+ * 显示隐藏加载的 loading 状态
+ * @param {string} title 显示的标题
+ */
+
+export const loading = {
+  show(title) {
+    uni.showLoading({
+      title: title || "加载中",
+    });
+  },
+  hide() {
+    uni.hideLoading();
+  },
+};

+ 5374 - 0
utils/jsencrypt.js

@@ -0,0 +1,5374 @@
+(function (global, factory) {
+	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+	typeof define === 'function' && define.amd ? define(['exports'], factory) :
+	(factory((global.JSEncrypt = {})));
+}(this, (function (exports) { 'use strict';
+
+var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
+function int2char(n) {
+    return BI_RM.charAt(n);
+}
+//#region BIT_OPERATIONS
+// (public) this & a
+function op_and(x, y) {
+    return x & y;
+}
+// (public) this | a
+function op_or(x, y) {
+    return x | y;
+}
+// (public) this ^ a
+function op_xor(x, y) {
+    return x ^ y;
+}
+// (public) this & ~a
+function op_andnot(x, y) {
+    return x & ~y;
+}
+// return index of lowest 1-bit in x, x < 2^31
+function lbit(x) {
+    if (x == 0) {
+        return -1;
+    }
+    var r = 0;
+    if ((x & 0xffff) == 0) {
+        x >>= 16;
+        r += 16;
+    }
+    if ((x & 0xff) == 0) {
+        x >>= 8;
+        r += 8;
+    }
+    if ((x & 0xf) == 0) {
+        x >>= 4;
+        r += 4;
+    }
+    if ((x & 3) == 0) {
+        x >>= 2;
+        r += 2;
+    }
+    if ((x & 1) == 0) {
+        ++r;
+    }
+    return r;
+}
+// return number of 1 bits in x
+function cbit(x) {
+    var r = 0;
+    while (x != 0) {
+        x &= x - 1;
+        ++r;
+    }
+    return r;
+}
+//#endregion BIT_OPERATIONS
+
+var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+var b64pad = "=";
+function hex2b64(h) {
+    var i;
+    var c;
+    var ret = "";
+    for (i = 0; i + 3 <= h.length; i += 3) {
+        c = parseInt(h.substring(i, i + 3), 16);
+        ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
+    }
+    if (i + 1 == h.length) {
+        c = parseInt(h.substring(i, i + 1), 16);
+        ret += b64map.charAt(c << 2);
+    }
+    else if (i + 2 == h.length) {
+        c = parseInt(h.substring(i, i + 2), 16);
+        ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
+    }
+    while ((ret.length & 3) > 0) {
+        ret += b64pad;
+    }
+    return ret;
+}
+// convert a base64 string to hex
+function b64tohex(s) {
+    var ret = "";
+    var i;
+    var k = 0; // b64 state, 0-3
+    var slop = 0;
+    for (i = 0; i < s.length; ++i) {
+        if (s.charAt(i) == b64pad) {
+            break;
+        }
+        var v = b64map.indexOf(s.charAt(i));
+        if (v < 0) {
+            continue;
+        }
+        if (k == 0) {
+            ret += int2char(v >> 2);
+            slop = v & 3;
+            k = 1;
+        }
+        else if (k == 1) {
+            ret += int2char((slop << 2) | (v >> 4));
+            slop = v & 0xf;
+            k = 2;
+        }
+        else if (k == 2) {
+            ret += int2char(slop);
+            ret += int2char(v >> 2);
+            slop = v & 3;
+            k = 3;
+        }
+        else {
+            ret += int2char((slop << 2) | (v >> 4));
+            ret += int2char(v & 0xf);
+            k = 0;
+        }
+    }
+    if (k == 1) {
+        ret += int2char(slop << 2);
+    }
+    return ret;
+}
+
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+/* global Reflect, Promise */
+
+var extendStatics = function(d, b) {
+    extendStatics = Object.setPrototypeOf ||
+        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+    return extendStatics(d, b);
+};
+
+function __extends(d, b) {
+    extendStatics(d, b);
+    function __() { this.constructor = d; }
+    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+}
+
+// Hex JavaScript decoder
+// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
+var decoder;
+var Hex = {
+    decode: function (a) {
+        var i;
+        if (decoder === undefined) {
+            var hex = "0123456789ABCDEF";
+            var ignore = " \f\n\r\t\u00A0\u2028\u2029";
+            decoder = {};
+            for (i = 0; i < 16; ++i) {
+                decoder[hex.charAt(i)] = i;
+            }
+            hex = hex.toLowerCase();
+            for (i = 10; i < 16; ++i) {
+                decoder[hex.charAt(i)] = i;
+            }
+            for (i = 0; i < ignore.length; ++i) {
+                decoder[ignore.charAt(i)] = -1;
+            }
+        }
+        var out = [];
+        var bits = 0;
+        var char_count = 0;
+        for (i = 0; i < a.length; ++i) {
+            var c = a.charAt(i);
+            if (c == "=") {
+                break;
+            }
+            c = decoder[c];
+            if (c == -1) {
+                continue;
+            }
+            if (c === undefined) {
+                throw new Error("Illegal character at offset " + i);
+            }
+            bits |= c;
+            if (++char_count >= 2) {
+                out[out.length] = bits;
+                bits = 0;
+                char_count = 0;
+            }
+            else {
+                bits <<= 4;
+            }
+        }
+        if (char_count) {
+            throw new Error("Hex encoding incomplete: 4 bits missing");
+        }
+        return out;
+    }
+};
+
+// Base64 JavaScript decoder
+// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
+var decoder$1;
+var Base64 = {
+    decode: function (a) {
+        var i;
+        if (decoder$1 === undefined) {
+            var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+            var ignore = "= \f\n\r\t\u00A0\u2028\u2029";
+            decoder$1 = Object.create(null);
+            for (i = 0; i < 64; ++i) {
+                decoder$1[b64.charAt(i)] = i;
+            }
+            for (i = 0; i < ignore.length; ++i) {
+                decoder$1[ignore.charAt(i)] = -1;
+            }
+        }
+        var out = [];
+        var bits = 0;
+        var char_count = 0;
+        for (i = 0; i < a.length; ++i) {
+            var c = a.charAt(i);
+            if (c == "=") {
+                break;
+            }
+            c = decoder$1[c];
+            if (c == -1) {
+                continue;
+            }
+            if (c === undefined) {
+                throw new Error("Illegal character at offset " + i);
+            }
+            bits |= c;
+            if (++char_count >= 4) {
+                out[out.length] = (bits >> 16);
+                out[out.length] = (bits >> 8) & 0xFF;
+                out[out.length] = bits & 0xFF;
+                bits = 0;
+                char_count = 0;
+            }
+            else {
+                bits <<= 6;
+            }
+        }
+        switch (char_count) {
+            case 1:
+                throw new Error("Base64 encoding incomplete: at least 2 bits missing");
+            case 2:
+                out[out.length] = (bits >> 10);
+                break;
+            case 3:
+                out[out.length] = (bits >> 16);
+                out[out.length] = (bits >> 8) & 0xFF;
+                break;
+        }
+        return out;
+    },
+    re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,
+    unarmor: function (a) {
+        var m = Base64.re.exec(a);
+        if (m) {
+            if (m[1]) {
+                a = m[1];
+            }
+            else if (m[2]) {
+                a = m[2];
+            }
+            else {
+                throw new Error("RegExp out of sync");
+            }
+        }
+        return Base64.decode(a);
+    }
+};
+
+// Big integer base-10 printing library
+// Copyright (c) 2014 Lapo Luchini <lapo@lapo.it>
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
+var max = 10000000000000; // biggest integer that can still fit 2^53 when multiplied by 256
+var Int10 = /** @class */ (function () {
+    function Int10(value) {
+        this.buf = [+value || 0];
+    }
+    Int10.prototype.mulAdd = function (m, c) {
+        // assert(m <= 256)
+        var b = this.buf;
+        var l = b.length;
+        var i;
+        var t;
+        for (i = 0; i < l; ++i) {
+            t = b[i] * m + c;
+            if (t < max) {
+                c = 0;
+            }
+            else {
+                c = 0 | (t / max);
+                t -= c * max;
+            }
+            b[i] = t;
+        }
+        if (c > 0) {
+            b[i] = c;
+        }
+    };
+    Int10.prototype.sub = function (c) {
+        // assert(m <= 256)
+        var b = this.buf;
+        var l = b.length;
+        var i;
+        var t;
+        for (i = 0; i < l; ++i) {
+            t = b[i] - c;
+            if (t < 0) {
+                t += max;
+                c = 1;
+            }
+            else {
+                c = 0;
+            }
+            b[i] = t;
+        }
+        while (b[b.length - 1] === 0) {
+            b.pop();
+        }
+    };
+    Int10.prototype.toString = function (base) {
+        if ((base || 10) != 10) {
+            throw new Error("only base 10 is supported");
+        }
+        var b = this.buf;
+        var s = b[b.length - 1].toString();
+        for (var i = b.length - 2; i >= 0; --i) {
+            s += (max + b[i]).toString().substring(1);
+        }
+        return s;
+    };
+    Int10.prototype.valueOf = function () {
+        var b = this.buf;
+        var v = 0;
+        for (var i = b.length - 1; i >= 0; --i) {
+            v = v * max + b[i];
+        }
+        return v;
+    };
+    Int10.prototype.simplify = function () {
+        var b = this.buf;
+        return (b.length == 1) ? b[0] : this;
+    };
+    return Int10;
+}());
+
+// ASN.1 JavaScript decoder
+var ellipsis = "\u2026";
+var reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
+var reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
+function stringCut(str, len) {
+    if (str.length > len) {
+        str = str.substring(0, len) + ellipsis;
+    }
+    return str;
+}
+var Stream = /** @class */ (function () {
+    function Stream(enc, pos) {
+        this.hexDigits = "0123456789ABCDEF";
+        if (enc instanceof Stream) {
+            this.enc = enc.enc;
+            this.pos = enc.pos;
+        }
+        else {
+            // enc should be an array or a binary string
+            this.enc = enc;
+            this.pos = pos;
+        }
+    }
+    Stream.prototype.get = function (pos) {
+        if (pos === undefined) {
+            pos = this.pos++;
+        }
+        if (pos >= this.enc.length) {
+            throw new Error("Requesting byte offset " + pos + " on a stream of length " + this.enc.length);
+        }
+        return ("string" === typeof this.enc) ? this.enc.charCodeAt(pos) : this.enc[pos];
+    };
+    Stream.prototype.hexByte = function (b) {
+        return this.hexDigits.charAt((b >> 4) & 0xF) + this.hexDigits.charAt(b & 0xF);
+    };
+    Stream.prototype.hexDump = function (start, end, raw) {
+        var s = "";
+        for (var i = start; i < end; ++i) {
+            s += this.hexByte(this.get(i));
+            if (raw !== true) {
+                switch (i & 0xF) {
+                    case 0x7:
+                        s += "  ";
+                        break;
+                    case 0xF:
+                        s += "\n";
+                        break;
+                    default:
+                        s += " ";
+                }
+            }
+        }
+        return s;
+    };
+    Stream.prototype.isASCII = function (start, end) {
+        for (var i = start; i < end; ++i) {
+            var c = this.get(i);
+            if (c < 32 || c > 176) {
+                return false;
+            }
+        }
+        return true;
+    };
+    Stream.prototype.parseStringISO = function (start, end) {
+        var s = "";
+        for (var i = start; i < end; ++i) {
+            s += String.fromCharCode(this.get(i));
+        }
+        return s;
+    };
+    Stream.prototype.parseStringUTF = function (start, end) {
+        var s = "";
+        for (var i = start; i < end;) {
+            var c = this.get(i++);
+            if (c < 128) {
+                s += String.fromCharCode(c);
+            }
+            else if ((c > 191) && (c < 224)) {
+                s += String.fromCharCode(((c & 0x1F) << 6) | (this.get(i++) & 0x3F));
+            }
+            else {
+                s += String.fromCharCode(((c & 0x0F) << 12) | ((this.get(i++) & 0x3F) << 6) | (this.get(i++) & 0x3F));
+            }
+        }
+        return s;
+    };
+    Stream.prototype.parseStringBMP = function (start, end) {
+        var str = "";
+        var hi;
+        var lo;
+        for (var i = start; i < end;) {
+            hi = this.get(i++);
+            lo = this.get(i++);
+            str += String.fromCharCode((hi << 8) | lo);
+        }
+        return str;
+    };
+    Stream.prototype.parseTime = function (start, end, shortYear) {
+        var s = this.parseStringISO(start, end);
+        var m = (shortYear ? reTimeS : reTimeL).exec(s);
+        if (!m) {
+            return "Unrecognized time: " + s;
+        }
+        if (shortYear) {
+            // to avoid querying the timer, use the fixed range [1970, 2069]
+            // it will conform with ITU X.400 [-10, +40] sliding window until 2030
+            m[1] = +m[1];
+            m[1] += (+m[1] < 70) ? 2000 : 1900;
+        }
+        s = m[1] + "-" + m[2] + "-" + m[3] + " " + m[4];
+        if (m[5]) {
+            s += ":" + m[5];
+            if (m[6]) {
+                s += ":" + m[6];
+                if (m[7]) {
+                    s += "." + m[7];
+                }
+            }
+        }
+        if (m[8]) {
+            s += " UTC";
+            if (m[8] != "Z") {
+                s += m[8];
+                if (m[9]) {
+                    s += ":" + m[9];
+                }
+            }
+        }
+        return s;
+    };
+    Stream.prototype.parseInteger = function (start, end) {
+        var v = this.get(start);
+        var neg = (v > 127);
+        var pad = neg ? 255 : 0;
+        var len;
+        var s = "";
+        // skip unuseful bits (not allowed in DER)
+        while (v == pad && ++start < end) {
+            v = this.get(start);
+        }
+        len = end - start;
+        if (len === 0) {
+            return neg ? -1 : 0;
+        }
+        // show bit length of huge integers
+        if (len > 4) {
+            s = v;
+            len <<= 3;
+            while (((+s ^ pad) & 0x80) == 0) {
+                s = +s << 1;
+                --len;
+            }
+            s = "(" + len + " bit)\n";
+        }
+        // decode the integer
+        if (neg) {
+            v = v - 256;
+        }
+        var n = new Int10(v);
+        for (var i = start + 1; i < end; ++i) {
+            n.mulAdd(256, this.get(i));
+        }
+        return s + n.toString();
+    };
+    Stream.prototype.parseBitString = function (start, end, maxLength) {
+        var unusedBit = this.get(start);
+        var lenBit = ((end - start - 1) << 3) - unusedBit;
+        var intro = "(" + lenBit + " bit)\n";
+        var s = "";
+        for (var i = start + 1; i < end; ++i) {
+            var b = this.get(i);
+            var skip = (i == end - 1) ? unusedBit : 0;
+            for (var j = 7; j >= skip; --j) {
+                s += (b >> j) & 1 ? "1" : "0";
+            }
+            if (s.length > maxLength) {
+                return intro + stringCut(s, maxLength);
+            }
+        }
+        return intro + s;
+    };
+    Stream.prototype.parseOctetString = function (start, end, maxLength) {
+        if (this.isASCII(start, end)) {
+            return stringCut(this.parseStringISO(start, end), maxLength);
+        }
+        var len = end - start;
+        var s = "(" + len + " byte)\n";
+        maxLength /= 2; // we work in bytes
+        if (len > maxLength) {
+            end = start + maxLength;
+        }
+        for (var i = start; i < end; ++i) {
+            s += this.hexByte(this.get(i));
+        }
+        if (len > maxLength) {
+            s += ellipsis;
+        }
+        return s;
+    };
+    Stream.prototype.parseOID = function (start, end, maxLength) {
+        var s = "";
+        var n = new Int10();
+        var bits = 0;
+        for (var i = start; i < end; ++i) {
+            var v = this.get(i);
+            n.mulAdd(128, v & 0x7F);
+            bits += 7;
+            if (!(v & 0x80)) { // finished
+                if (s === "") {
+                    n = n.simplify();
+                    if (n instanceof Int10) {
+                        n.sub(80);
+                        s = "2." + n.toString();
+                    }
+                    else {
+                        var m = n < 80 ? n < 40 ? 0 : 1 : 2;
+                        s = m + "." + (n - m * 40);
+                    }
+                }
+                else {
+                    s += "." + n.toString();
+                }
+                if (s.length > maxLength) {
+                    return stringCut(s, maxLength);
+                }
+                n = new Int10();
+                bits = 0;
+            }
+        }
+        if (bits > 0) {
+            s += ".incomplete";
+        }
+        return s;
+    };
+    return Stream;
+}());
+var ASN1 = /** @class */ (function () {
+    function ASN1(stream, header, length, tag, sub) {
+        if (!(tag instanceof ASN1Tag)) {
+            throw new Error("Invalid tag value.");
+        }
+        this.stream = stream;
+        this.header = header;
+        this.length = length;
+        this.tag = tag;
+        this.sub = sub;
+    }
+    ASN1.prototype.typeName = function () {
+        switch (this.tag.tagClass) {
+            case 0: // universal
+                switch (this.tag.tagNumber) {
+                    case 0x00:
+                        return "EOC";
+                    case 0x01:
+                        return "BOOLEAN";
+                    case 0x02:
+                        return "INTEGER";
+                    case 0x03:
+                        return "BIT_STRING";
+                    case 0x04:
+                        return "OCTET_STRING";
+                    case 0x05:
+                        return "NULL";
+                    case 0x06:
+                        return "OBJECT_IDENTIFIER";
+                    case 0x07:
+                        return "ObjectDescriptor";
+                    case 0x08:
+                        return "EXTERNAL";
+                    case 0x09:
+                        return "REAL";
+                    case 0x0A:
+                        return "ENUMERATED";
+                    case 0x0B:
+                        return "EMBEDDED_PDV";
+                    case 0x0C:
+                        return "UTF8String";
+                    case 0x10:
+                        return "SEQUENCE";
+                    case 0x11:
+                        return "SET";
+                    case 0x12:
+                        return "NumericString";
+                    case 0x13:
+                        return "PrintableString"; // ASCII subset
+                    case 0x14:
+                        return "TeletexString"; // aka T61String
+                    case 0x15:
+                        return "VideotexString";
+                    case 0x16:
+                        return "IA5String"; // ASCII
+                    case 0x17:
+                        return "UTCTime";
+                    case 0x18:
+                        return "GeneralizedTime";
+                    case 0x19:
+                        return "GraphicString";
+                    case 0x1A:
+                        return "VisibleString"; // ASCII subset
+                    case 0x1B:
+                        return "GeneralString";
+                    case 0x1C:
+                        return "UniversalString";
+                    case 0x1E:
+                        return "BMPString";
+                }
+                return "Universal_" + this.tag.tagNumber.toString();
+            case 1:
+                return "Application_" + this.tag.tagNumber.toString();
+            case 2:
+                return "[" + this.tag.tagNumber.toString() + "]"; // Context
+            case 3:
+                return "Private_" + this.tag.tagNumber.toString();
+        }
+    };
+    ASN1.prototype.content = function (maxLength) {
+        if (this.tag === undefined) {
+            return null;
+        }
+        if (maxLength === undefined) {
+            maxLength = Infinity;
+        }
+        var content = this.posContent();
+        var len = Math.abs(this.length);
+        if (!this.tag.isUniversal()) {
+            if (this.sub !== null) {
+                return "(" + this.sub.length + " elem)";
+            }
+            return this.stream.parseOctetString(content, content + len, maxLength);
+        }
+        switch (this.tag.tagNumber) {
+            case 0x01: // BOOLEAN
+                return (this.stream.get(content) === 0) ? "false" : "true";
+            case 0x02: // INTEGER
+                return this.stream.parseInteger(content, content + len);
+            case 0x03: // BIT_STRING
+                return this.sub ? "(" + this.sub.length + " elem)" :
+                    this.stream.parseBitString(content, content + len, maxLength);
+            case 0x04: // OCTET_STRING
+                return this.sub ? "(" + this.sub.length + " elem)" :
+                    this.stream.parseOctetString(content, content + len, maxLength);
+            // case 0x05: // NULL
+            case 0x06: // OBJECT_IDENTIFIER
+                return this.stream.parseOID(content, content + len, maxLength);
+            // case 0x07: // ObjectDescriptor
+            // case 0x08: // EXTERNAL
+            // case 0x09: // REAL
+            // case 0x0A: // ENUMERATED
+            // case 0x0B: // EMBEDDED_PDV
+            case 0x10: // SEQUENCE
+            case 0x11: // SET
+                if (this.sub !== null) {
+                    return "(" + this.sub.length + " elem)";
+                }
+                else {
+                    return "(no elem)";
+                }
+            case 0x0C: // UTF8String
+                return stringCut(this.stream.parseStringUTF(content, content + len), maxLength);
+            case 0x12: // NumericString
+            case 0x13: // PrintableString
+            case 0x14: // TeletexString
+            case 0x15: // VideotexString
+            case 0x16: // IA5String
+            // case 0x19: // GraphicString
+            case 0x1A: // VisibleString
+                // case 0x1B: // GeneralString
+                // case 0x1C: // UniversalString
+                return stringCut(this.stream.parseStringISO(content, content + len), maxLength);
+            case 0x1E: // BMPString
+                return stringCut(this.stream.parseStringBMP(content, content + len), maxLength);
+            case 0x17: // UTCTime
+            case 0x18: // GeneralizedTime
+                return this.stream.parseTime(content, content + len, (this.tag.tagNumber == 0x17));
+        }
+        return null;
+    };
+    ASN1.prototype.toString = function () {
+        return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + ((this.sub === null) ? "null" : this.sub.length) + "]";
+    };
+    ASN1.prototype.toPrettyString = function (indent) {
+        if (indent === undefined) {
+            indent = "";
+        }
+        var s = indent + this.typeName() + " @" + this.stream.pos;
+        if (this.length >= 0) {
+            s += "+";
+        }
+        s += this.length;
+        if (this.tag.tagConstructed) {
+            s += " (constructed)";
+        }
+        else if ((this.tag.isUniversal() && ((this.tag.tagNumber == 0x03) || (this.tag.tagNumber == 0x04))) && (this.sub !== null)) {
+            s += " (encapsulates)";
+        }
+        s += "\n";
+        if (this.sub !== null) {
+            indent += "  ";
+            for (var i = 0, max = this.sub.length; i < max; ++i) {
+                s += this.sub[i].toPrettyString(indent);
+            }
+        }
+        return s;
+    };
+    ASN1.prototype.posStart = function () {
+        return this.stream.pos;
+    };
+    ASN1.prototype.posContent = function () {
+        return this.stream.pos + this.header;
+    };
+    ASN1.prototype.posEnd = function () {
+        return this.stream.pos + this.header + Math.abs(this.length);
+    };
+    ASN1.prototype.toHexString = function () {
+        return this.stream.hexDump(this.posStart(), this.posEnd(), true);
+    };
+    ASN1.decodeLength = function (stream) {
+        var buf = stream.get();
+        var len = buf & 0x7F;
+        if (len == buf) {
+            return len;
+        }
+        // no reason to use Int10, as it would be a huge buffer anyways
+        if (len > 6) {
+            throw new Error("Length over 48 bits not supported at position " + (stream.pos - 1));
+        }
+        if (len === 0) {
+            return null;
+        } // undefined
+        buf = 0;
+        for (var i = 0; i < len; ++i) {
+            buf = (buf * 256) + stream.get();
+        }
+        return buf;
+    };
+    /**
+     * Retrieve the hexadecimal value (as a string) of the current ASN.1 element
+     * @returns {string}
+     * @public
+     */
+    ASN1.prototype.getHexStringValue = function () {
+        var hexString = this.toHexString();
+        var offset = this.header * 2;
+        var length = this.length * 2;
+        return hexString.substr(offset, length);
+    };
+    ASN1.decode = function (str) {
+        var stream;
+        if (!(str instanceof Stream)) {
+            stream = new Stream(str, 0);
+        }
+        else {
+            stream = str;
+        }
+        var streamStart = new Stream(stream);
+        var tag = new ASN1Tag(stream);
+        var len = ASN1.decodeLength(stream);
+        var start = stream.pos;
+        var header = start - streamStart.pos;
+        var sub = null;
+        var getSub = function () {
+            var ret = [];
+            if (len !== null) {
+                // definite length
+                var end = start + len;
+                while (stream.pos < end) {
+                    ret[ret.length] = ASN1.decode(stream);
+                }
+                if (stream.pos != end) {
+                    throw new Error("Content size is not correct for container starting at offset " + start);
+                }
+            }
+            else {
+                // undefined length
+                try {
+                    for (;;) {
+                        var s = ASN1.decode(stream);
+                        if (s.tag.isEOC()) {
+                            break;
+                        }
+                        ret[ret.length] = s;
+                    }
+                    len = start - stream.pos; // undefined lengths are represented as negative values
+                }
+                catch (e) {
+                    throw new Error("Exception while decoding undefined length content: " + e);
+                }
+            }
+            return ret;
+        };
+        if (tag.tagConstructed) {
+            // must have valid content
+            sub = getSub();
+        }
+        else if (tag.isUniversal() && ((tag.tagNumber == 0x03) || (tag.tagNumber == 0x04))) {
+            // sometimes BitString and OctetString are used to encapsulate ASN.1
+            try {
+                if (tag.tagNumber == 0x03) {
+                    if (stream.get() != 0) {
+                        throw new Error("BIT STRINGs with unused bits cannot encapsulate.");
+                    }
+                }
+                sub = getSub();
+                for (var i = 0; i < sub.length; ++i) {
+                    if (sub[i].tag.isEOC()) {
+                        throw new Error("EOC is not supposed to be actual content.");
+                    }
+                }
+            }
+            catch (e) {
+                // but silently ignore when they don't
+                sub = null;
+            }
+        }
+        if (sub === null) {
+            if (len === null) {
+                throw new Error("We can't skip over an invalid tag with undefined length at offset " + start);
+            }
+            stream.pos = start + Math.abs(len);
+        }
+        return new ASN1(streamStart, header, len, tag, sub);
+    };
+    return ASN1;
+}());
+var ASN1Tag = /** @class */ (function () {
+    function ASN1Tag(stream) {
+        var buf = stream.get();
+        this.tagClass = buf >> 6;
+        this.tagConstructed = ((buf & 0x20) !== 0);
+        this.tagNumber = buf & 0x1F;
+        if (this.tagNumber == 0x1F) { // long tag
+            var n = new Int10();
+            do {
+                buf = stream.get();
+                n.mulAdd(128, buf & 0x7F);
+            } while (buf & 0x80);
+            this.tagNumber = n.simplify();
+        }
+    }
+    ASN1Tag.prototype.isUniversal = function () {
+        return this.tagClass === 0x00;
+    };
+    ASN1Tag.prototype.isEOC = function () {
+        return this.tagClass === 0x00 && this.tagNumber === 0x00;
+    };
+    return ASN1Tag;
+}());
+
+// Copyright (c) 2005  Tom Wu
+// Bits per digit
+var dbits;
+// JavaScript engine analysis
+var canary = 0xdeadbeefcafe;
+var j_lm = ((canary & 0xffffff) == 0xefcafe);
+//#region
+var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
+var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
+//#endregion
+// (public) Constructor
+var BigInteger = /** @class */ (function () {
+    function BigInteger(a, b, c) {
+        if (a != null) {
+            if ("number" == typeof a) {
+                this.fromNumber(a, b, c);
+            }
+            else if (b == null && "string" != typeof a) {
+                this.fromString(a, 256);
+            }
+            else {
+                this.fromString(a, b);
+            }
+        }
+    }
+    //#region PUBLIC
+    // BigInteger.prototype.toString = bnToString;
+    // (public) return string representation in given radix
+    BigInteger.prototype.toString = function (b) {
+        if (this.s < 0) {
+            return "-" + this.negate().toString(b);
+        }
+        var k;
+        if (b == 16) {
+            k = 4;
+        }
+        else if (b == 8) {
+            k = 3;
+        }
+        else if (b == 2) {
+            k = 1;
+        }
+        else if (b == 32) {
+            k = 5;
+        }
+        else if (b == 4) {
+            k = 2;
+        }
+        else {
+            return this.toRadix(b);
+        }
+        var km = (1 << k) - 1;
+        var d;
+        var m = false;
+        var r = "";
+        var i = this.t;
+        var p = this.DB - (i * this.DB) % k;
+        if (i-- > 0) {
+            if (p < this.DB && (d = this[i] >> p) > 0) {
+                m = true;
+                r = int2char(d);
+            }
+            while (i >= 0) {
+                if (p < k) {
+                    d = (this[i] & ((1 << p) - 1)) << (k - p);
+                    d |= this[--i] >> (p += this.DB - k);
+                }
+                else {
+                    d = (this[i] >> (p -= k)) & km;
+                    if (p <= 0) {
+                        p += this.DB;
+                        --i;
+                    }
+                }
+                if (d > 0) {
+                    m = true;
+                }
+                if (m) {
+                    r += int2char(d);
+                }
+            }
+        }
+        return m ? r : "0";
+    };
+    // BigInteger.prototype.negate = bnNegate;
+    // (public) -this
+    BigInteger.prototype.negate = function () {
+        var r = nbi();
+        BigInteger.ZERO.subTo(this, r);
+        return r;
+    };
+    // BigInteger.prototype.abs = bnAbs;
+    // (public) |this|
+    BigInteger.prototype.abs = function () {
+        return (this.s < 0) ? this.negate() : this;
+    };
+    // BigInteger.prototype.compareTo = bnCompareTo;
+    // (public) return + if this > a, - if this < a, 0 if equal
+    BigInteger.prototype.compareTo = function (a) {
+        var r = this.s - a.s;
+        if (r != 0) {
+            return r;
+        }
+        var i = this.t;
+        r = i - a.t;
+        if (r != 0) {
+            return (this.s < 0) ? -r : r;
+        }
+        while (--i >= 0) {
+            if ((r = this[i] - a[i]) != 0) {
+                return r;
+            }
+        }
+        return 0;
+    };
+    // BigInteger.prototype.bitLength = bnBitLength;
+    // (public) return the number of bits in "this"
+    BigInteger.prototype.bitLength = function () {
+        if (this.t <= 0) {
+            return 0;
+        }
+        return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
+    };
+    // BigInteger.prototype.mod = bnMod;
+    // (public) this mod a
+    BigInteger.prototype.mod = function (a) {
+        var r = nbi();
+        this.abs().divRemTo(a, null, r);
+        if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) {
+            a.subTo(r, r);
+        }
+        return r;
+    };
+    // BigInteger.prototype.modPowInt = bnModPowInt;
+    // (public) this^e % m, 0 <= e < 2^32
+    BigInteger.prototype.modPowInt = function (e, m) {
+        var z;
+        if (e < 256 || m.isEven()) {
+            z = new Classic(m);
+        }
+        else {
+            z = new Montgomery(m);
+        }
+        return this.exp(e, z);
+    };
+    // BigInteger.prototype.clone = bnClone;
+    // (public)
+    BigInteger.prototype.clone = function () {
+        var r = nbi();
+        this.copyTo(r);
+        return r;
+    };
+    // BigInteger.prototype.intValue = bnIntValue;
+    // (public) return value as integer
+    BigInteger.prototype.intValue = function () {
+        if (this.s < 0) {
+            if (this.t == 1) {
+                return this[0] - this.DV;
+            }
+            else if (this.t == 0) {
+                return -1;
+            }
+        }
+        else if (this.t == 1) {
+            return this[0];
+        }
+        else if (this.t == 0) {
+            return 0;
+        }
+        // assumes 16 < DB < 32
+        return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
+    };
+    // BigInteger.prototype.byteValue = bnByteValue;
+    // (public) return value as byte
+    BigInteger.prototype.byteValue = function () {
+        return (this.t == 0) ? this.s : (this[0] << 24) >> 24;
+    };
+    // BigInteger.prototype.shortValue = bnShortValue;
+    // (public) return value as short (assumes DB>=16)
+    BigInteger.prototype.shortValue = function () {
+        return (this.t == 0) ? this.s : (this[0] << 16) >> 16;
+    };
+    // BigInteger.prototype.signum = bnSigNum;
+    // (public) 0 if this == 0, 1 if this > 0
+    BigInteger.prototype.signum = function () {
+        if (this.s < 0) {
+            return -1;
+        }
+        else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) {
+            return 0;
+        }
+        else {
+            return 1;
+        }
+    };
+    // BigInteger.prototype.toByteArray = bnToByteArray;
+    // (public) convert to bigendian byte array
+    BigInteger.prototype.toByteArray = function () {
+        var i = this.t;
+        var r = [];
+        r[0] = this.s;
+        var p = this.DB - (i * this.DB) % 8;
+        var d;
+        var k = 0;
+        if (i-- > 0) {
+            if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) {
+                r[k++] = d | (this.s << (this.DB - p));
+            }
+            while (i >= 0) {
+                if (p < 8) {
+                    d = (this[i] & ((1 << p) - 1)) << (8 - p);
+                    d |= this[--i] >> (p += this.DB - 8);
+                }
+                else {
+                    d = (this[i] >> (p -= 8)) & 0xff;
+                    if (p <= 0) {
+                        p += this.DB;
+                        --i;
+                    }
+                }
+                if ((d & 0x80) != 0) {
+                    d |= -256;
+                }
+                if (k == 0 && (this.s & 0x80) != (d & 0x80)) {
+                    ++k;
+                }
+                if (k > 0 || d != this.s) {
+                    r[k++] = d;
+                }
+            }
+        }
+        return r;
+    };
+    // BigInteger.prototype.equals = bnEquals;
+    BigInteger.prototype.equals = function (a) {
+        return (this.compareTo(a) == 0);
+    };
+    // BigInteger.prototype.min = bnMin;
+    BigInteger.prototype.min = function (a) {
+        return (this.compareTo(a) < 0) ? this : a;
+    };
+    // BigInteger.prototype.max = bnMax;
+    BigInteger.prototype.max = function (a) {
+        return (this.compareTo(a) > 0) ? this : a;
+    };
+    // BigInteger.prototype.and = bnAnd;
+    BigInteger.prototype.and = function (a) {
+        var r = nbi();
+        this.bitwiseTo(a, op_and, r);
+        return r;
+    };
+    // BigInteger.prototype.or = bnOr;
+    BigInteger.prototype.or = function (a) {
+        var r = nbi();
+        this.bitwiseTo(a, op_or, r);
+        return r;
+    };
+    // BigInteger.prototype.xor = bnXor;
+    BigInteger.prototype.xor = function (a) {
+        var r = nbi();
+        this.bitwiseTo(a, op_xor, r);
+        return r;
+    };
+    // BigInteger.prototype.andNot = bnAndNot;
+    BigInteger.prototype.andNot = function (a) {
+        var r = nbi();
+        this.bitwiseTo(a, op_andnot, r);
+        return r;
+    };
+    // BigInteger.prototype.not = bnNot;
+    // (public) ~this
+    BigInteger.prototype.not = function () {
+        var r = nbi();
+        for (var i = 0; i < this.t; ++i) {
+            r[i] = this.DM & ~this[i];
+        }
+        r.t = this.t;
+        r.s = ~this.s;
+        return r;
+    };
+    // BigInteger.prototype.shiftLeft = bnShiftLeft;
+    // (public) this << n
+    BigInteger.prototype.shiftLeft = function (n) {
+        var r = nbi();
+        if (n < 0) {
+            this.rShiftTo(-n, r);
+        }
+        else {
+            this.lShiftTo(n, r);
+        }
+        return r;
+    };
+    // BigInteger.prototype.shiftRight = bnShiftRight;
+    // (public) this >> n
+    BigInteger.prototype.shiftRight = function (n) {
+        var r = nbi();
+        if (n < 0) {
+            this.lShiftTo(-n, r);
+        }
+        else {
+            this.rShiftTo(n, r);
+        }
+        return r;
+    };
+    // BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
+    // (public) returns index of lowest 1-bit (or -1 if none)
+    BigInteger.prototype.getLowestSetBit = function () {
+        for (var i = 0; i < this.t; ++i) {
+            if (this[i] != 0) {
+                return i * this.DB + lbit(this[i]);
+            }
+        }
+        if (this.s < 0) {
+            return this.t * this.DB;
+        }
+        return -1;
+    };
+    // BigInteger.prototype.bitCount = bnBitCount;
+    // (public) return number of set bits
+    BigInteger.prototype.bitCount = function () {
+        var r = 0;
+        var x = this.s & this.DM;
+        for (var i = 0; i < this.t; ++i) {
+            r += cbit(this[i] ^ x);
+        }
+        return r;
+    };
+    // BigInteger.prototype.testBit = bnTestBit;
+    // (public) true iff nth bit is set
+    BigInteger.prototype.testBit = function (n) {
+        var j = Math.floor(n / this.DB);
+        if (j >= this.t) {
+            return (this.s != 0);
+        }
+        return ((this[j] & (1 << (n % this.DB))) != 0);
+    };
+    // BigInteger.prototype.setBit = bnSetBit;
+    // (public) this | (1<<n)
+    BigInteger.prototype.setBit = function (n) {
+        return this.changeBit(n, op_or);
+    };
+    // BigInteger.prototype.clearBit = bnClearBit;
+    // (public) this & ~(1<<n)
+    BigInteger.prototype.clearBit = function (n) {
+        return this.changeBit(n, op_andnot);
+    };
+    // BigInteger.prototype.flipBit = bnFlipBit;
+    // (public) this ^ (1<<n)
+    BigInteger.prototype.flipBit = function (n) {
+        return this.changeBit(n, op_xor);
+    };
+    // BigInteger.prototype.add = bnAdd;
+    // (public) this + a
+    BigInteger.prototype.add = function (a) {
+        var r = nbi();
+        this.addTo(a, r);
+        return r;
+    };
+    // BigInteger.prototype.subtract = bnSubtract;
+    // (public) this - a
+    BigInteger.prototype.subtract = function (a) {
+        var r = nbi();
+        this.subTo(a, r);
+        return r;
+    };
+    // BigInteger.prototype.multiply = bnMultiply;
+    // (public) this * a
+    BigInteger.prototype.multiply = function (a) {
+        var r = nbi();
+        this.multiplyTo(a, r);
+        return r;
+    };
+    // BigInteger.prototype.divide = bnDivide;
+    // (public) this / a
+    BigInteger.prototype.divide = function (a) {
+        var r = nbi();
+        this.divRemTo(a, r, null);
+        return r;
+    };
+    // BigInteger.prototype.remainder = bnRemainder;
+    // (public) this % a
+    BigInteger.prototype.remainder = function (a) {
+        var r = nbi();
+        this.divRemTo(a, null, r);
+        return r;
+    };
+    // BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
+    // (public) [this/a,this%a]
+    BigInteger.prototype.divideAndRemainder = function (a) {
+        var q = nbi();
+        var r = nbi();
+        this.divRemTo(a, q, r);
+        return [q, r];
+    };
+    // BigInteger.prototype.modPow = bnModPow;
+    // (public) this^e % m (HAC 14.85)
+    BigInteger.prototype.modPow = function (e, m) {
+        var i = e.bitLength();
+        var k;
+        var r = nbv(1);
+        var z;
+        if (i <= 0) {
+            return r;
+        }
+        else if (i < 18) {
+            k = 1;
+        }
+        else if (i < 48) {
+            k = 3;
+        }
+        else if (i < 144) {
+            k = 4;
+        }
+        else if (i < 768) {
+            k = 5;
+        }
+        else {
+            k = 6;
+        }
+        if (i < 8) {
+            z = new Classic(m);
+        }
+        else if (m.isEven()) {
+            z = new Barrett(m);
+        }
+        else {
+            z = new Montgomery(m);
+        }
+        // precomputation
+        var g = [];
+        var n = 3;
+        var k1 = k - 1;
+        var km = (1 << k) - 1;
+        g[1] = z.convert(this);
+        if (k > 1) {
+            var g2 = nbi();
+            z.sqrTo(g[1], g2);
+            while (n <= km) {
+                g[n] = nbi();
+                z.mulTo(g2, g[n - 2], g[n]);
+                n += 2;
+            }
+        }
+        var j = e.t - 1;
+        var w;
+        var is1 = true;
+        var r2 = nbi();
+        var t;
+        i = nbits(e[j]) - 1;
+        while (j >= 0) {
+            if (i >= k1) {
+                w = (e[j] >> (i - k1)) & km;
+            }
+            else {
+                w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
+                if (j > 0) {
+                    w |= e[j - 1] >> (this.DB + i - k1);
+                }
+            }
+            n = k;
+            while ((w & 1) == 0) {
+                w >>= 1;
+                --n;
+            }
+            if ((i -= n) < 0) {
+                i += this.DB;
+                --j;
+            }
+            if (is1) { // ret == 1, don't bother squaring or multiplying it
+                g[w].copyTo(r);
+                is1 = false;
+            }
+            else {
+                while (n > 1) {
+                    z.sqrTo(r, r2);
+                    z.sqrTo(r2, r);
+                    n -= 2;
+                }
+                if (n > 0) {
+                    z.sqrTo(r, r2);
+                }
+                else {
+                    t = r;
+                    r = r2;
+                    r2 = t;
+                }
+                z.mulTo(r2, g[w], r);
+            }
+            while (j >= 0 && (e[j] & (1 << i)) == 0) {
+                z.sqrTo(r, r2);
+                t = r;
+                r = r2;
+                r2 = t;
+                if (--i < 0) {
+                    i = this.DB - 1;
+                    --j;
+                }
+            }
+        }
+        return z.revert(r);
+    };
+    // BigInteger.prototype.modInverse = bnModInverse;
+    // (public) 1/this % m (HAC 14.61)
+    BigInteger.prototype.modInverse = function (m) {
+        var ac = m.isEven();
+        if ((this.isEven() && ac) || m.signum() == 0) {
+            return BigInteger.ZERO;
+        }
+        var u = m.clone();
+        var v = this.clone();
+        var a = nbv(1);
+        var b = nbv(0);
+        var c = nbv(0);
+        var d = nbv(1);
+        while (u.signum() != 0) {
+            while (u.isEven()) {
+                u.rShiftTo(1, u);
+                if (ac) {
+                    if (!a.isEven() || !b.isEven()) {
+                        a.addTo(this, a);
+                        b.subTo(m, b);
+                    }
+                    a.rShiftTo(1, a);
+                }
+                else if (!b.isEven()) {
+                    b.subTo(m, b);
+                }
+                b.rShiftTo(1, b);
+            }
+            while (v.isEven()) {
+                v.rShiftTo(1, v);
+                if (ac) {
+                    if (!c.isEven() || !d.isEven()) {
+                        c.addTo(this, c);
+                        d.subTo(m, d);
+                    }
+                    c.rShiftTo(1, c);
+                }
+                else if (!d.isEven()) {
+                    d.subTo(m, d);
+                }
+                d.rShiftTo(1, d);
+            }
+            if (u.compareTo(v) >= 0) {
+                u.subTo(v, u);
+                if (ac) {
+                    a.subTo(c, a);
+                }
+                b.subTo(d, b);
+            }
+            else {
+                v.subTo(u, v);
+                if (ac) {
+                    c.subTo(a, c);
+                }
+                d.subTo(b, d);
+            }
+        }
+        if (v.compareTo(BigInteger.ONE) != 0) {
+            return BigInteger.ZERO;
+        }
+        if (d.compareTo(m) >= 0) {
+            return d.subtract(m);
+        }
+        if (d.signum() < 0) {
+            d.addTo(m, d);
+        }
+        else {
+            return d;
+        }
+        if (d.signum() < 0) {
+            return d.add(m);
+        }
+        else {
+            return d;
+        }
+    };
+    // BigInteger.prototype.pow = bnPow;
+    // (public) this^e
+    BigInteger.prototype.pow = function (e) {
+        return this.exp(e, new NullExp());
+    };
+    // BigInteger.prototype.gcd = bnGCD;
+    // (public) gcd(this,a) (HAC 14.54)
+    BigInteger.prototype.gcd = function (a) {
+        var x = (this.s < 0) ? this.negate() : this.clone();
+        var y = (a.s < 0) ? a.negate() : a.clone();
+        if (x.compareTo(y) < 0) {
+            var t = x;
+            x = y;
+            y = t;
+        }
+        var i = x.getLowestSetBit();
+        var g = y.getLowestSetBit();
+        if (g < 0) {
+            return x;
+        }
+        if (i < g) {
+            g = i;
+        }
+        if (g > 0) {
+            x.rShiftTo(g, x);
+            y.rShiftTo(g, y);
+        }
+        while (x.signum() > 0) {
+            if ((i = x.getLowestSetBit()) > 0) {
+                x.rShiftTo(i, x);
+            }
+            if ((i = y.getLowestSetBit()) > 0) {
+                y.rShiftTo(i, y);
+            }
+            if (x.compareTo(y) >= 0) {
+                x.subTo(y, x);
+                x.rShiftTo(1, x);
+            }
+            else {
+                y.subTo(x, y);
+                y.rShiftTo(1, y);
+            }
+        }
+        if (g > 0) {
+            y.lShiftTo(g, y);
+        }
+        return y;
+    };
+    // BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
+    // (public) test primality with certainty >= 1-.5^t
+    BigInteger.prototype.isProbablePrime = function (t) {
+        var i;
+        var x = this.abs();
+        if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
+            for (i = 0; i < lowprimes.length; ++i) {
+                if (x[0] == lowprimes[i]) {
+                    return true;
+                }
+            }
+            return false;
+        }
+        if (x.isEven()) {
+            return false;
+        }
+        i = 1;
+        while (i < lowprimes.length) {
+            var m = lowprimes[i];
+            var j = i + 1;
+            while (j < lowprimes.length && m < lplim) {
+                m *= lowprimes[j++];
+            }
+            m = x.modInt(m);
+            while (i < j) {
+                if (m % lowprimes[i++] == 0) {
+                    return false;
+                }
+            }
+        }
+        return x.millerRabin(t);
+    };
+    //#endregion PUBLIC
+    //#region PROTECTED
+    // BigInteger.prototype.copyTo = bnpCopyTo;
+    // (protected) copy this to r
+    BigInteger.prototype.copyTo = function (r) {
+        for (var i = this.t - 1; i >= 0; --i) {
+            r[i] = this[i];
+        }
+        r.t = this.t;
+        r.s = this.s;
+    };
+    // BigInteger.prototype.fromInt = bnpFromInt;
+    // (protected) set from integer value x, -DV <= x < DV
+    BigInteger.prototype.fromInt = function (x) {
+        this.t = 1;
+        this.s = (x < 0) ? -1 : 0;
+        if (x > 0) {
+            this[0] = x;
+        }
+        else if (x < -1) {
+            this[0] = x + this.DV;
+        }
+        else {
+            this.t = 0;
+        }
+    };
+    // BigInteger.prototype.fromString = bnpFromString;
+    // (protected) set from string and radix
+    BigInteger.prototype.fromString = function (s, b) {
+        var k;
+        if (b == 16) {
+            k = 4;
+        }
+        else if (b == 8) {
+            k = 3;
+        }
+        else if (b == 256) {
+            k = 8;
+            /* byte array */
+        }
+        else if (b == 2) {
+            k = 1;
+        }
+        else if (b == 32) {
+            k = 5;
+        }
+        else if (b == 4) {
+            k = 2;
+        }
+        else {
+            this.fromRadix(s, b);
+            return;
+        }
+        this.t = 0;
+        this.s = 0;
+        var i = s.length;
+        var mi = false;
+        var sh = 0;
+        while (--i >= 0) {
+            var x = (k == 8) ? (+s[i]) & 0xff : intAt(s, i);
+            if (x < 0) {
+                if (s.charAt(i) == "-") {
+                    mi = true;
+                }
+                continue;
+            }
+            mi = false;
+            if (sh == 0) {
+                this[this.t++] = x;
+            }
+            else if (sh + k > this.DB) {
+                this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
+                this[this.t++] = (x >> (this.DB - sh));
+            }
+            else {
+                this[this.t - 1] |= x << sh;
+            }
+            sh += k;
+            if (sh >= this.DB) {
+                sh -= this.DB;
+            }
+        }
+        if (k == 8 && ((+s[0]) & 0x80) != 0) {
+            this.s = -1;
+            if (sh > 0) {
+                this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
+            }
+        }
+        this.clamp();
+        if (mi) {
+            BigInteger.ZERO.subTo(this, this);
+        }
+    };
+    // BigInteger.prototype.clamp = bnpClamp;
+    // (protected) clamp off excess high words
+    BigInteger.prototype.clamp = function () {
+        var c = this.s & this.DM;
+        while (this.t > 0 && this[this.t - 1] == c) {
+            --this.t;
+        }
+    };
+    // BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
+    // (protected) r = this << n*DB
+    BigInteger.prototype.dlShiftTo = function (n, r) {
+        var i;
+        for (i = this.t - 1; i >= 0; --i) {
+            r[i + n] = this[i];
+        }
+        for (i = n - 1; i >= 0; --i) {
+            r[i] = 0;
+        }
+        r.t = this.t + n;
+        r.s = this.s;
+    };
+    // BigInteger.prototype.drShiftTo = bnpDRShiftTo;
+    // (protected) r = this >> n*DB
+    BigInteger.prototype.drShiftTo = function (n, r) {
+        for (var i = n; i < this.t; ++i) {
+            r[i - n] = this[i];
+        }
+        r.t = Math.max(this.t - n, 0);
+        r.s = this.s;
+    };
+    // BigInteger.prototype.lShiftTo = bnpLShiftTo;
+    // (protected) r = this << n
+    BigInteger.prototype.lShiftTo = function (n, r) {
+        var bs = n % this.DB;
+        var cbs = this.DB - bs;
+        var bm = (1 << cbs) - 1;
+        var ds = Math.floor(n / this.DB);
+        var c = (this.s << bs) & this.DM;
+        for (var i = this.t - 1; i >= 0; --i) {
+            r[i + ds + 1] = (this[i] >> cbs) | c;
+            c = (this[i] & bm) << bs;
+        }
+        for (var i = ds - 1; i >= 0; --i) {
+            r[i] = 0;
+        }
+        r[ds] = c;
+        r.t = this.t + ds + 1;
+        r.s = this.s;
+        r.clamp();
+    };
+    // BigInteger.prototype.rShiftTo = bnpRShiftTo;
+    // (protected) r = this >> n
+    BigInteger.prototype.rShiftTo = function (n, r) {
+        r.s = this.s;
+        var ds = Math.floor(n / this.DB);
+        if (ds >= this.t) {
+            r.t = 0;
+            return;
+        }
+        var bs = n % this.DB;
+        var cbs = this.DB - bs;
+        var bm = (1 << bs) - 1;
+        r[0] = this[ds] >> bs;
+        for (var i = ds + 1; i < this.t; ++i) {
+            r[i - ds - 1] |= (this[i] & bm) << cbs;
+            r[i - ds] = this[i] >> bs;
+        }
+        if (bs > 0) {
+            r[this.t - ds - 1] |= (this.s & bm) << cbs;
+        }
+        r.t = this.t - ds;
+        r.clamp();
+    };
+    // BigInteger.prototype.subTo = bnpSubTo;
+    // (protected) r = this - a
+    BigInteger.prototype.subTo = function (a, r) {
+        var i = 0;
+        var c = 0;
+        var m = Math.min(a.t, this.t);
+        while (i < m) {
+            c += this[i] - a[i];
+            r[i++] = c & this.DM;
+            c >>= this.DB;
+        }
+        if (a.t < this.t) {
+            c -= a.s;
+            while (i < this.t) {
+                c += this[i];
+                r[i++] = c & this.DM;
+                c >>= this.DB;
+            }
+            c += this.s;
+        }
+        else {
+            c += this.s;
+            while (i < a.t) {
+                c -= a[i];
+                r[i++] = c & this.DM;
+                c >>= this.DB;
+            }
+            c -= a.s;
+        }
+        r.s = (c < 0) ? -1 : 0;
+        if (c < -1) {
+            r[i++] = this.DV + c;
+        }
+        else if (c > 0) {
+            r[i++] = c;
+        }
+        r.t = i;
+        r.clamp();
+    };
+    // BigInteger.prototype.multiplyTo = bnpMultiplyTo;
+    // (protected) r = this * a, r != this,a (HAC 14.12)
+    // "this" should be the larger one if appropriate.
+    BigInteger.prototype.multiplyTo = function (a, r) {
+        var x = this.abs();
+        var y = a.abs();
+        var i = x.t;
+        r.t = i + y.t;
+        while (--i >= 0) {
+            r[i] = 0;
+        }
+        for (i = 0; i < y.t; ++i) {
+            r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
+        }
+        r.s = 0;
+        r.clamp();
+        if (this.s != a.s) {
+            BigInteger.ZERO.subTo(r, r);
+        }
+    };
+    // BigInteger.prototype.squareTo = bnpSquareTo;
+    // (protected) r = this^2, r != this (HAC 14.16)
+    BigInteger.prototype.squareTo = function (r) {
+        var x = this.abs();
+        var i = r.t = 2 * x.t;
+        while (--i >= 0) {
+            r[i] = 0;
+        }
+        for (i = 0; i < x.t - 1; ++i) {
+            var c = x.am(i, x[i], r, 2 * i, 0, 1);
+            if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
+                r[i + x.t] -= x.DV;
+                r[i + x.t + 1] = 1;
+            }
+        }
+        if (r.t > 0) {
+            r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
+        }
+        r.s = 0;
+        r.clamp();
+    };
+    // BigInteger.prototype.divRemTo = bnpDivRemTo;
+    // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
+    // r != q, this != m.  q or r may be null.
+    BigInteger.prototype.divRemTo = function (m, q, r) {
+        var pm = m.abs();
+        if (pm.t <= 0) {
+            return;
+        }
+        var pt = this.abs();
+        if (pt.t < pm.t) {
+            if (q != null) {
+                q.fromInt(0);
+            }
+            if (r != null) {
+                this.copyTo(r);
+            }
+            return;
+        }
+        if (r == null) {
+            r = nbi();
+        }
+        var y = nbi();
+        var ts = this.s;
+        var ms = m.s;
+        var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
+        if (nsh > 0) {
+            pm.lShiftTo(nsh, y);
+            pt.lShiftTo(nsh, r);
+        }
+        else {
+            pm.copyTo(y);
+            pt.copyTo(r);
+        }
+        var ys = y.t;
+        var y0 = y[ys - 1];
+        if (y0 == 0) {
+            return;
+        }
+        var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
+        var d1 = this.FV / yt;
+        var d2 = (1 << this.F1) / yt;
+        var e = 1 << this.F2;
+        var i = r.t;
+        var j = i - ys;
+        var t = (q == null) ? nbi() : q;
+        y.dlShiftTo(j, t);
+        if (r.compareTo(t) >= 0) {
+            r[r.t++] = 1;
+            r.subTo(t, r);
+        }
+        BigInteger.ONE.dlShiftTo(ys, t);
+        t.subTo(y, y); // "negative" y so we can replace sub with am later
+        while (y.t < ys) {
+            y[y.t++] = 0;
+        }
+        while (--j >= 0) {
+            // Estimate quotient digit
+            var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
+            if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
+                y.dlShiftTo(j, t);
+                r.subTo(t, r);
+                while (r[i] < --qd) {
+                    r.subTo(t, r);
+                }
+            }
+        }
+        if (q != null) {
+            r.drShiftTo(ys, q);
+            if (ts != ms) {
+                BigInteger.ZERO.subTo(q, q);
+            }
+        }
+        r.t = ys;
+        r.clamp();
+        if (nsh > 0) {
+            r.rShiftTo(nsh, r);
+        } // Denormalize remainder
+        if (ts < 0) {
+            BigInteger.ZERO.subTo(r, r);
+        }
+    };
+    // BigInteger.prototype.invDigit = bnpInvDigit;
+    // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
+    // justification:
+    //         xy == 1 (mod m)
+    //         xy =  1+km
+    //   xy(2-xy) = (1+km)(1-km)
+    // x[y(2-xy)] = 1-k^2m^2
+    // x[y(2-xy)] == 1 (mod m^2)
+    // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
+    // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
+    // JS multiply "overflows" differently from C/C++, so care is needed here.
+    BigInteger.prototype.invDigit = function () {
+        if (this.t < 1) {
+            return 0;
+        }
+        var x = this[0];
+        if ((x & 1) == 0) {
+            return 0;
+        }
+        var y = x & 3; // y == 1/x mod 2^2
+        y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
+        y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
+        y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
+        // last step - calculate inverse mod DV directly;
+        // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
+        y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
+        // we really want the negative inverse, and -DV < y < DV
+        return (y > 0) ? this.DV - y : -y;
+    };
+    // BigInteger.prototype.isEven = bnpIsEven;
+    // (protected) true iff this is even
+    BigInteger.prototype.isEven = function () {
+        return ((this.t > 0) ? (this[0] & 1) : this.s) == 0;
+    };
+    // BigInteger.prototype.exp = bnpExp;
+    // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
+    BigInteger.prototype.exp = function (e, z) {
+        if (e > 0xffffffff || e < 1) {
+            return BigInteger.ONE;
+        }
+        var r = nbi();
+        var r2 = nbi();
+        var g = z.convert(this);
+        var i = nbits(e) - 1;
+        g.copyTo(r);
+        while (--i >= 0) {
+            z.sqrTo(r, r2);
+            if ((e & (1 << i)) > 0) {
+                z.mulTo(r2, g, r);
+            }
+            else {
+                var t = r;
+                r = r2;
+                r2 = t;
+            }
+        }
+        return z.revert(r);
+    };
+    // BigInteger.prototype.chunkSize = bnpChunkSize;
+    // (protected) return x s.t. r^x < DV
+    BigInteger.prototype.chunkSize = function (r) {
+        return Math.floor(Math.LN2 * this.DB / Math.log(r));
+    };
+    // BigInteger.prototype.toRadix = bnpToRadix;
+    // (protected) convert to radix string
+    BigInteger.prototype.toRadix = function (b) {
+        if (b == null) {
+            b = 10;
+        }
+        if (this.signum() == 0 || b < 2 || b > 36) {
+            return "0";
+        }
+        var cs = this.chunkSize(b);
+        var a = Math.pow(b, cs);
+        var d = nbv(a);
+        var y = nbi();
+        var z = nbi();
+        var r = "";
+        this.divRemTo(d, y, z);
+        while (y.signum() > 0) {
+            r = (a + z.intValue()).toString(b).substr(1) + r;
+            y.divRemTo(d, y, z);
+        }
+        return z.intValue().toString(b) + r;
+    };
+    // BigInteger.prototype.fromRadix = bnpFromRadix;
+    // (protected) convert from radix string
+    BigInteger.prototype.fromRadix = function (s, b) {
+        this.fromInt(0);
+        if (b == null) {
+            b = 10;
+        }
+        var cs = this.chunkSize(b);
+        var d = Math.pow(b, cs);
+        var mi = false;
+        var j = 0;
+        var w = 0;
+        for (var i = 0; i < s.length; ++i) {
+            var x = intAt(s, i);
+            if (x < 0) {
+                if (s.charAt(i) == "-" && this.signum() == 0) {
+                    mi = true;
+                }
+                continue;
+            }
+            w = b * w + x;
+            if (++j >= cs) {
+                this.dMultiply(d);
+                this.dAddOffset(w, 0);
+                j = 0;
+                w = 0;
+            }
+        }
+        if (j > 0) {
+            this.dMultiply(Math.pow(b, j));
+            this.dAddOffset(w, 0);
+        }
+        if (mi) {
+            BigInteger.ZERO.subTo(this, this);
+        }
+    };
+    // BigInteger.prototype.fromNumber = bnpFromNumber;
+    // (protected) alternate constructor
+    BigInteger.prototype.fromNumber = function (a, b, c) {
+        if ("number" == typeof b) {
+            // new BigInteger(int,int,RNG)
+            if (a < 2) {
+                this.fromInt(1);
+            }
+            else {
+                this.fromNumber(a, c);
+                if (!this.testBit(a - 1)) {
+                    // force MSB set
+                    this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
+                }
+                if (this.isEven()) {
+                    this.dAddOffset(1, 0);
+                } // force odd
+                while (!this.isProbablePrime(b)) {
+                    this.dAddOffset(2, 0);
+                    if (this.bitLength() > a) {
+                        this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
+                    }
+                }
+            }
+        }
+        else {
+            // new BigInteger(int,RNG)
+            var x = [];
+            var t = a & 7;
+            x.length = (a >> 3) + 1;
+            b.nextBytes(x);
+            if (t > 0) {
+                x[0] &= ((1 << t) - 1);
+            }
+            else {
+                x[0] = 0;
+            }
+            this.fromString(x, 256);
+        }
+    };
+    // BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
+    // (protected) r = this op a (bitwise)
+    BigInteger.prototype.bitwiseTo = function (a, op, r) {
+        var i;
+        var f;
+        var m = Math.min(a.t, this.t);
+        for (i = 0; i < m; ++i) {
+            r[i] = op(this[i], a[i]);
+        }
+        if (a.t < this.t) {
+            f = a.s & this.DM;
+            for (i = m; i < this.t; ++i) {
+                r[i] = op(this[i], f);
+            }
+            r.t = this.t;
+        }
+        else {
+            f = this.s & this.DM;
+            for (i = m; i < a.t; ++i) {
+                r[i] = op(f, a[i]);
+            }
+            r.t = a.t;
+        }
+        r.s = op(this.s, a.s);
+        r.clamp();
+    };
+    // BigInteger.prototype.changeBit = bnpChangeBit;
+    // (protected) this op (1<<n)
+    BigInteger.prototype.changeBit = function (n, op) {
+        var r = BigInteger.ONE.shiftLeft(n);
+        this.bitwiseTo(r, op, r);
+        return r;
+    };
+    // BigInteger.prototype.addTo = bnpAddTo;
+    // (protected) r = this + a
+    BigInteger.prototype.addTo = function (a, r) {
+        var i = 0;
+        var c = 0;
+        var m = Math.min(a.t, this.t);
+        while (i < m) {
+            c += this[i] + a[i];
+            r[i++] = c & this.DM;
+            c >>= this.DB;
+        }
+        if (a.t < this.t) {
+            c += a.s;
+            while (i < this.t) {
+                c += this[i];
+                r[i++] = c & this.DM;
+                c >>= this.DB;
+            }
+            c += this.s;
+        }
+        else {
+            c += this.s;
+            while (i < a.t) {
+                c += a[i];
+                r[i++] = c & this.DM;
+                c >>= this.DB;
+            }
+            c += a.s;
+        }
+        r.s = (c < 0) ? -1 : 0;
+        if (c > 0) {
+            r[i++] = c;
+        }
+        else if (c < -1) {
+            r[i++] = this.DV + c;
+        }
+        r.t = i;
+        r.clamp();
+    };
+    // BigInteger.prototype.dMultiply = bnpDMultiply;
+    // (protected) this *= n, this >= 0, 1 < n < DV
+    BigInteger.prototype.dMultiply = function (n) {
+        this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
+        ++this.t;
+        this.clamp();
+    };
+    // BigInteger.prototype.dAddOffset = bnpDAddOffset;
+    // (protected) this += n << w words, this >= 0
+    BigInteger.prototype.dAddOffset = function (n, w) {
+        if (n == 0) {
+            return;
+        }
+        while (this.t <= w) {
+            this[this.t++] = 0;
+        }
+        this[w] += n;
+        while (this[w] >= this.DV) {
+            this[w] -= this.DV;
+            if (++w >= this.t) {
+                this[this.t++] = 0;
+            }
+            ++this[w];
+        }
+    };
+    // BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
+    // (protected) r = lower n words of "this * a", a.t <= n
+    // "this" should be the larger one if appropriate.
+    BigInteger.prototype.multiplyLowerTo = function (a, n, r) {
+        var i = Math.min(this.t + a.t, n);
+        r.s = 0; // assumes a,this >= 0
+        r.t = i;
+        while (i > 0) {
+            r[--i] = 0;
+        }
+        for (var j = r.t - this.t; i < j; ++i) {
+            r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
+        }
+        for (var j = Math.min(a.t, n); i < j; ++i) {
+            this.am(0, a[i], r, i, 0, n - i);
+        }
+        r.clamp();
+    };
+    // BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
+    // (protected) r = "this * a" without lower n words, n > 0
+    // "this" should be the larger one if appropriate.
+    BigInteger.prototype.multiplyUpperTo = function (a, n, r) {
+        --n;
+        var i = r.t = this.t + a.t - n;
+        r.s = 0; // assumes a,this >= 0
+        while (--i >= 0) {
+            r[i] = 0;
+        }
+        for (i = Math.max(n - this.t, 0); i < a.t; ++i) {
+            r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
+        }
+        r.clamp();
+        r.drShiftTo(1, r);
+    };
+    // BigInteger.prototype.modInt = bnpModInt;
+    // (protected) this % n, n < 2^26
+    BigInteger.prototype.modInt = function (n) {
+        if (n <= 0) {
+            return 0;
+        }
+        var d = this.DV % n;
+        var r = (this.s < 0) ? n - 1 : 0;
+        if (this.t > 0) {
+            if (d == 0) {
+                r = this[0] % n;
+            }
+            else {
+                for (var i = this.t - 1; i >= 0; --i) {
+                    r = (d * r + this[i]) % n;
+                }
+            }
+        }
+        return r;
+    };
+    // BigInteger.prototype.millerRabin = bnpMillerRabin;
+    // (protected) true if probably prime (HAC 4.24, Miller-Rabin)
+    BigInteger.prototype.millerRabin = function (t) {
+        var n1 = this.subtract(BigInteger.ONE);
+        var k = n1.getLowestSetBit();
+        if (k <= 0) {
+            return false;
+        }
+        var r = n1.shiftRight(k);
+        t = (t + 1) >> 1;
+        if (t > lowprimes.length) {
+            t = lowprimes.length;
+        }
+        var a = nbi();
+        for (var i = 0; i < t; ++i) {
+            // Pick bases at random, instead of starting at 2
+            a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
+            var y = a.modPow(r, this);
+            if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
+                var j = 1;
+                while (j++ < k && y.compareTo(n1) != 0) {
+                    y = y.modPowInt(2, this);
+                    if (y.compareTo(BigInteger.ONE) == 0) {
+                        return false;
+                    }
+                }
+                if (y.compareTo(n1) != 0) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    };
+    // BigInteger.prototype.square = bnSquare;
+    // (public) this^2
+    BigInteger.prototype.square = function () {
+        var r = nbi();
+        this.squareTo(r);
+        return r;
+    };
+    //#region ASYNC
+    // Public API method
+    BigInteger.prototype.gcda = function (a, callback) {
+        var x = (this.s < 0) ? this.negate() : this.clone();
+        var y = (a.s < 0) ? a.negate() : a.clone();
+        if (x.compareTo(y) < 0) {
+            var t = x;
+            x = y;
+            y = t;
+        }
+        var i = x.getLowestSetBit();
+        var g = y.getLowestSetBit();
+        if (g < 0) {
+            callback(x);
+            return;
+        }
+        if (i < g) {
+            g = i;
+        }
+        if (g > 0) {
+            x.rShiftTo(g, x);
+            y.rShiftTo(g, y);
+        }
+        // Workhorse of the algorithm, gets called 200 - 800 times per 512 bit keygen.
+        var gcda1 = function () {
+            if ((i = x.getLowestSetBit()) > 0) {
+                x.rShiftTo(i, x);
+            }
+            if ((i = y.getLowestSetBit()) > 0) {
+                y.rShiftTo(i, y);
+            }
+            if (x.compareTo(y) >= 0) {
+                x.subTo(y, x);
+                x.rShiftTo(1, x);
+            }
+            else {
+                y.subTo(x, y);
+                y.rShiftTo(1, y);
+            }
+            if (!(x.signum() > 0)) {
+                if (g > 0) {
+                    y.lShiftTo(g, y);
+                }
+                setTimeout(function () { callback(y); }, 0); // escape
+            }
+            else {
+                setTimeout(gcda1, 0);
+            }
+        };
+        setTimeout(gcda1, 10);
+    };
+    // (protected) alternate constructor
+    BigInteger.prototype.fromNumberAsync = function (a, b, c, callback) {
+        if ("number" == typeof b) {
+            if (a < 2) {
+                this.fromInt(1);
+            }
+            else {
+                this.fromNumber(a, c);
+                if (!this.testBit(a - 1)) {
+                    this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
+                }
+                if (this.isEven()) {
+                    this.dAddOffset(1, 0);
+                }
+                var bnp_1 = this;
+                var bnpfn1_1 = function () {
+                    bnp_1.dAddOffset(2, 0);
+                    if (bnp_1.bitLength() > a) {
+                        bnp_1.subTo(BigInteger.ONE.shiftLeft(a - 1), bnp_1);
+                    }
+                    if (bnp_1.isProbablePrime(b)) {
+                        setTimeout(function () { callback(); }, 0); // escape
+                    }
+                    else {
+                        setTimeout(bnpfn1_1, 0);
+                    }
+                };
+                setTimeout(bnpfn1_1, 0);
+            }
+        }
+        else {
+            var x = [];
+            var t = a & 7;
+            x.length = (a >> 3) + 1;
+            b.nextBytes(x);
+            if (t > 0) {
+                x[0] &= ((1 << t) - 1);
+            }
+            else {
+                x[0] = 0;
+            }
+            this.fromString(x, 256);
+        }
+    };
+    return BigInteger;
+}());
+//#region REDUCERS
+//#region NullExp
+var NullExp = /** @class */ (function () {
+    function NullExp() {
+    }
+    // NullExp.prototype.convert = nNop;
+    NullExp.prototype.convert = function (x) {
+        return x;
+    };
+    // NullExp.prototype.revert = nNop;
+    NullExp.prototype.revert = function (x) {
+        return x;
+    };
+    // NullExp.prototype.mulTo = nMulTo;
+    NullExp.prototype.mulTo = function (x, y, r) {
+        x.multiplyTo(y, r);
+    };
+    // NullExp.prototype.sqrTo = nSqrTo;
+    NullExp.prototype.sqrTo = function (x, r) {
+        x.squareTo(r);
+    };
+    return NullExp;
+}());
+// Modular reduction using "classic" algorithm
+var Classic = /** @class */ (function () {
+    function Classic(m) {
+        this.m = m;
+    }
+    // Classic.prototype.convert = cConvert;
+    Classic.prototype.convert = function (x) {
+        if (x.s < 0 || x.compareTo(this.m) >= 0) {
+            return x.mod(this.m);
+        }
+        else {
+            return x;
+        }
+    };
+    // Classic.prototype.revert = cRevert;
+    Classic.prototype.revert = function (x) {
+        return x;
+    };
+    // Classic.prototype.reduce = cReduce;
+    Classic.prototype.reduce = function (x) {
+        x.divRemTo(this.m, null, x);
+    };
+    // Classic.prototype.mulTo = cMulTo;
+    Classic.prototype.mulTo = function (x, y, r) {
+        x.multiplyTo(y, r);
+        this.reduce(r);
+    };
+    // Classic.prototype.sqrTo = cSqrTo;
+    Classic.prototype.sqrTo = function (x, r) {
+        x.squareTo(r);
+        this.reduce(r);
+    };
+    return Classic;
+}());
+//#endregion
+//#region Montgomery
+// Montgomery reduction
+var Montgomery = /** @class */ (function () {
+    function Montgomery(m) {
+        this.m = m;
+        this.mp = m.invDigit();
+        this.mpl = this.mp & 0x7fff;
+        this.mph = this.mp >> 15;
+        this.um = (1 << (m.DB - 15)) - 1;
+        this.mt2 = 2 * m.t;
+    }
+    // Montgomery.prototype.convert = montConvert;
+    // xR mod m
+    Montgomery.prototype.convert = function (x) {
+        var r = nbi();
+        x.abs().dlShiftTo(this.m.t, r);
+        r.divRemTo(this.m, null, r);
+        if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) {
+            this.m.subTo(r, r);
+        }
+        return r;
+    };
+    // Montgomery.prototype.revert = montRevert;
+    // x/R mod m
+    Montgomery.prototype.revert = function (x) {
+        var r = nbi();
+        x.copyTo(r);
+        this.reduce(r);
+        return r;
+    };
+    // Montgomery.prototype.reduce = montReduce;
+    // x = x/R mod m (HAC 14.32)
+    Montgomery.prototype.reduce = function (x) {
+        while (x.t <= this.mt2) {
+            // pad x so am has enough room later
+            x[x.t++] = 0;
+        }
+        for (var i = 0; i < this.m.t; ++i) {
+            // faster way of calculating u0 = x[i]*mp mod DV
+            var j = x[i] & 0x7fff;
+            var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
+            // use am to combine the multiply-shift-add into one call
+            j = i + this.m.t;
+            x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
+            // propagate carry
+            while (x[j] >= x.DV) {
+                x[j] -= x.DV;
+                x[++j]++;
+            }
+        }
+        x.clamp();
+        x.drShiftTo(this.m.t, x);
+        if (x.compareTo(this.m) >= 0) {
+            x.subTo(this.m, x);
+        }
+    };
+    // Montgomery.prototype.mulTo = montMulTo;
+    // r = "xy/R mod m"; x,y != r
+    Montgomery.prototype.mulTo = function (x, y, r) {
+        x.multiplyTo(y, r);
+        this.reduce(r);
+    };
+    // Montgomery.prototype.sqrTo = montSqrTo;
+    // r = "x^2/R mod m"; x != r
+    Montgomery.prototype.sqrTo = function (x, r) {
+        x.squareTo(r);
+        this.reduce(r);
+    };
+    return Montgomery;
+}());
+//#endregion Montgomery
+//#region Barrett
+// Barrett modular reduction
+var Barrett = /** @class */ (function () {
+    function Barrett(m) {
+        this.m = m;
+        // setup Barrett
+        this.r2 = nbi();
+        this.q3 = nbi();
+        BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
+        this.mu = this.r2.divide(m);
+    }
+    // Barrett.prototype.convert = barrettConvert;
+    Barrett.prototype.convert = function (x) {
+        if (x.s < 0 || x.t > 2 * this.m.t) {
+            return x.mod(this.m);
+        }
+        else if (x.compareTo(this.m) < 0) {
+            return x;
+        }
+        else {
+            var r = nbi();
+            x.copyTo(r);
+            this.reduce(r);
+            return r;
+        }
+    };
+    // Barrett.prototype.revert = barrettRevert;
+    Barrett.prototype.revert = function (x) {
+        return x;
+    };
+    // Barrett.prototype.reduce = barrettReduce;
+    // x = x mod m (HAC 14.42)
+    Barrett.prototype.reduce = function (x) {
+        x.drShiftTo(this.m.t - 1, this.r2);
+        if (x.t > this.m.t + 1) {
+            x.t = this.m.t + 1;
+            x.clamp();
+        }
+        this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
+        this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
+        while (x.compareTo(this.r2) < 0) {
+            x.dAddOffset(1, this.m.t + 1);
+        }
+        x.subTo(this.r2, x);
+        while (x.compareTo(this.m) >= 0) {
+            x.subTo(this.m, x);
+        }
+    };
+    // Barrett.prototype.mulTo = barrettMulTo;
+    // r = x*y mod m; x,y != r
+    Barrett.prototype.mulTo = function (x, y, r) {
+        x.multiplyTo(y, r);
+        this.reduce(r);
+    };
+    // Barrett.prototype.sqrTo = barrettSqrTo;
+    // r = x^2 mod m; x != r
+    Barrett.prototype.sqrTo = function (x, r) {
+        x.squareTo(r);
+        this.reduce(r);
+    };
+    return Barrett;
+}());
+//#endregion
+//#endregion REDUCERS
+// return new, unset BigInteger
+function nbi() { return new BigInteger(null); }
+function parseBigInt(str, r) {
+    return new BigInteger(str, r);
+}
+// am: Compute w_j += (x*this_i), propagate carries,
+// c is initial carry, returns final carry.
+// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
+// We need to select the fastest one that works in this environment.
+// am1: use a single mult and divide to get the high bits,
+// max digit bits should be 26 because
+// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
+function am1(i, x, w, j, c, n) {
+    while (--n >= 0) {
+        var v = x * this[i++] + w[j] + c;
+        c = Math.floor(v / 0x4000000);
+        w[j++] = v & 0x3ffffff;
+    }
+    return c;
+}
+// am2 avoids a big mult-and-extract completely.
+// Max digit bits should be <= 30 because we do bitwise ops
+// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
+function am2(i, x, w, j, c, n) {
+    var xl = x & 0x7fff;
+    var xh = x >> 15;
+    while (--n >= 0) {
+        var l = this[i] & 0x7fff;
+        var h = this[i++] >> 15;
+        var m = xh * l + h * xl;
+        l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
+        c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
+        w[j++] = l & 0x3fffffff;
+    }
+    return c;
+}
+// Alternately, set max digit bits to 28 since some
+// browsers slow down when dealing with 32-bit numbers.
+function am3(i, x, w, j, c, n) {
+    var xl = x & 0x3fff;
+    var xh = x >> 14;
+    while (--n >= 0) {
+        var l = this[i] & 0x3fff;
+        var h = this[i++] >> 14;
+        var m = xh * l + h * xl;
+        l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
+        c = (l >> 28) + (m >> 14) + xh * h;
+        w[j++] = l & 0xfffffff;
+    }
+    return c;
+}
+if (j_lm && (navigator && navigator.appName == "Microsoft Internet Explorer")) {
+    BigInteger.prototype.am = am2;
+    dbits = 30;
+}
+else if (j_lm && (navigator && navigator.appName != "Netscape")) {
+    BigInteger.prototype.am = am1;
+    dbits = 26;
+}
+else { // Mozilla/Netscape seems to prefer am3
+    BigInteger.prototype.am = am3;
+    dbits = 28;
+}
+BigInteger.prototype.DB = dbits;
+BigInteger.prototype.DM = ((1 << dbits) - 1);
+BigInteger.prototype.DV = (1 << dbits);
+var BI_FP = 52;
+BigInteger.prototype.FV = Math.pow(2, BI_FP);
+BigInteger.prototype.F1 = BI_FP - dbits;
+BigInteger.prototype.F2 = 2 * dbits - BI_FP;
+// Digit conversions
+var BI_RC = [];
+var rr;
+var vv;
+rr = "0".charCodeAt(0);
+for (vv = 0; vv <= 9; ++vv) {
+    BI_RC[rr++] = vv;
+}
+rr = "a".charCodeAt(0);
+for (vv = 10; vv < 36; ++vv) {
+    BI_RC[rr++] = vv;
+}
+rr = "A".charCodeAt(0);
+for (vv = 10; vv < 36; ++vv) {
+    BI_RC[rr++] = vv;
+}
+function intAt(s, i) {
+    var c = BI_RC[s.charCodeAt(i)];
+    return (c == null) ? -1 : c;
+}
+// return bigint initialized to value
+function nbv(i) {
+    var r = nbi();
+    r.fromInt(i);
+    return r;
+}
+// returns bit length of the integer x
+function nbits(x) {
+    var r = 1;
+    var t;
+    if ((t = x >>> 16) != 0) {
+        x = t;
+        r += 16;
+    }
+    if ((t = x >> 8) != 0) {
+        x = t;
+        r += 8;
+    }
+    if ((t = x >> 4) != 0) {
+        x = t;
+        r += 4;
+    }
+    if ((t = x >> 2) != 0) {
+        x = t;
+        r += 2;
+    }
+    if ((t = x >> 1) != 0) {
+        x = t;
+        r += 1;
+    }
+    return r;
+}
+// "constants"
+BigInteger.ZERO = nbv(0);
+BigInteger.ONE = nbv(1);
+
+// prng4.js - uses Arcfour as a PRNG
+var Arcfour = /** @class */ (function () {
+    function Arcfour() {
+        this.i = 0;
+        this.j = 0;
+        this.S = [];
+    }
+    // Arcfour.prototype.init = ARC4init;
+    // Initialize arcfour context from key, an array of ints, each from [0..255]
+    Arcfour.prototype.init = function (key) {
+        var i;
+        var j;
+        var t;
+        for (i = 0; i < 256; ++i) {
+            this.S[i] = i;
+        }
+        j = 0;
+        for (i = 0; i < 256; ++i) {
+            j = (j + this.S[i] + key[i % key.length]) & 255;
+            t = this.S[i];
+            this.S[i] = this.S[j];
+            this.S[j] = t;
+        }
+        this.i = 0;
+        this.j = 0;
+    };
+    // Arcfour.prototype.next = ARC4next;
+    Arcfour.prototype.next = function () {
+        var t;
+        this.i = (this.i + 1) & 255;
+        this.j = (this.j + this.S[this.i]) & 255;
+        t = this.S[this.i];
+        this.S[this.i] = this.S[this.j];
+        this.S[this.j] = t;
+        return this.S[(t + this.S[this.i]) & 255];
+    };
+    return Arcfour;
+}());
+// Plug in your RNG constructor here
+function prng_newstate() {
+    return new Arcfour();
+}
+// Pool size must be a multiple of 4 and greater than 32.
+// An array of bytes the size of the pool will be passed to init()
+var rng_psize = 256;
+
+// Random number generator - requires a PRNG backend, e.g. prng4.js
+var rng_state;
+var rng_pool = null;
+var rng_pptr;
+// Initialize the pool with junk if needed.
+if (rng_pool == null) {
+    rng_pool = [];
+    rng_pptr = 0;
+    var t = void 0;
+    if (window && window.crypto && window.crypto.getRandomValues) {
+        // Extract entropy (2048 bits) from RNG if available
+        var z = new Uint32Array(256);
+        window.crypto.getRandomValues(z);
+        for (t = 0; t < z.length; ++t) {
+            rng_pool[rng_pptr++] = z[t] & 255;
+        }
+    }
+    // Use mouse events for entropy, if we do not have enough entropy by the time
+    // we need it, entropy will be generated by Math.random.
+    var onMouseMoveListener_1 = function (ev) {
+        this.count = this.count || 0;
+        if (this.count >= 256 || rng_pptr >= rng_psize) {
+            if (window.removeEventListener) {
+                window.removeEventListener("mousemove", onMouseMoveListener_1, false);
+            }
+            else if (window.detachEvent) {
+                window.detachEvent("onmousemove", onMouseMoveListener_1);
+            }
+            return;
+        }
+        try {
+            var mouseCoordinates = ev.x + ev.y;
+            rng_pool[rng_pptr++] = mouseCoordinates & 255;
+            this.count += 1;
+        }
+        catch (e) {
+            // Sometimes Firefox will deny permission to access event properties for some reason. Ignore.
+        }
+    };
+    if (window && window.addEventListener) {
+        window.addEventListener("mousemove", onMouseMoveListener_1, false);
+    }
+    else if (window && window.attachEvent) {
+        window.attachEvent("onmousemove", onMouseMoveListener_1);
+    }
+}
+function rng_get_byte() {
+    if (rng_state == null) {
+        rng_state = prng_newstate();
+        // At this point, we may not have collected enough entropy.  If not, fall back to Math.random
+        while (rng_pptr < rng_psize) {
+            var random = Math.floor(65536 * Math.random());
+            rng_pool[rng_pptr++] = random & 255;
+        }
+        rng_state.init(rng_pool);
+        for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) {
+            rng_pool[rng_pptr] = 0;
+        }
+        rng_pptr = 0;
+    }
+    // TODO: allow reseeding after first request
+    return rng_state.next();
+}
+var SecureRandom = /** @class */ (function () {
+    function SecureRandom() {
+    }
+    SecureRandom.prototype.nextBytes = function (ba) {
+        for (var i = 0; i < ba.length; ++i) {
+            ba[i] = rng_get_byte();
+        }
+    };
+    return SecureRandom;
+}());
+
+// Depends on jsbn.js and rng.js
+// function linebrk(s,n) {
+//   var ret = "";
+//   var i = 0;
+//   while(i + n < s.length) {
+//     ret += s.substring(i,i+n) + "\n";
+//     i += n;
+//   }
+//   return ret + s.substring(i,s.length);
+// }
+// function byte2Hex(b) {
+//   if(b < 0x10)
+//     return "0" + b.toString(16);
+//   else
+//     return b.toString(16);
+// }
+function pkcs1pad1(s, n) {
+    if (n < s.length + 22) {
+        console.error("Message too long for RSA");
+        return null;
+    }
+    var len = n - s.length - 6;
+    var filler = "";
+    for (var f = 0; f < len; f += 2) {
+        filler += "ff";
+    }
+    var m = "0001" + filler + "00" + s;
+    return parseBigInt(m, 16);
+}
+// PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
+function pkcs1pad2(s, n) {
+    if (n < s.length + 11) { // TODO: fix for utf-8
+        console.error("Message too long for RSA");
+        return null;
+    }
+    var ba = [];
+    var i = s.length - 1;
+    while (i >= 0 && n > 0) {
+        var c = s.charCodeAt(i--);
+        if (c < 128) { // encode using utf-8
+            ba[--n] = c;
+        }
+        else if ((c > 127) && (c < 2048)) {
+            ba[--n] = (c & 63) | 128;
+            ba[--n] = (c >> 6) | 192;
+        }
+        else {
+            ba[--n] = (c & 63) | 128;
+            ba[--n] = ((c >> 6) & 63) | 128;
+            ba[--n] = (c >> 12) | 224;
+        }
+    }
+    ba[--n] = 0;
+    var rng = new SecureRandom();
+    var x = [];
+    while (n > 2) { // random non-zero pad
+        x[0] = 0;
+        while (x[0] == 0) {
+            rng.nextBytes(x);
+        }
+        ba[--n] = x[0];
+    }
+    ba[--n] = 2;
+    ba[--n] = 0;
+    return new BigInteger(ba);
+}
+// "empty" RSA key constructor
+var RSAKey = /** @class */ (function () {
+    function RSAKey() {
+        this.n = null;
+        this.e = 0;
+        this.d = null;
+        this.p = null;
+        this.q = null;
+        this.dmp1 = null;
+        this.dmq1 = null;
+        this.coeff = null;
+    }
+    //#region PROTECTED
+    // protected
+    // RSAKey.prototype.doPublic = RSADoPublic;
+    // Perform raw public operation on "x": return x^e (mod n)
+    RSAKey.prototype.doPublic = function (x) {
+        return x.modPowInt(this.e, this.n);
+    };
+    // RSAKey.prototype.doPrivate = RSADoPrivate;
+    // Perform raw private operation on "x": return x^d (mod n)
+    RSAKey.prototype.doPrivate = function (x) {
+        if (this.p == null || this.q == null) {
+            return x.modPow(this.d, this.n);
+        }
+        // TODO: re-calculate any missing CRT params
+        var xp = x.mod(this.p).modPow(this.dmp1, this.p);
+        var xq = x.mod(this.q).modPow(this.dmq1, this.q);
+        while (xp.compareTo(xq) < 0) {
+            xp = xp.add(this.p);
+        }
+        return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq);
+    };
+    //#endregion PROTECTED
+    //#region PUBLIC
+    // RSAKey.prototype.setPublic = RSASetPublic;
+    // Set the public key fields N and e from hex strings
+    RSAKey.prototype.setPublic = function (N, E) {
+        if (N != null && E != null && N.length > 0 && E.length > 0) {
+            this.n = parseBigInt(N, 16);
+            this.e = parseInt(E, 16);
+        }
+        else {
+            console.error("Invalid RSA public key");
+        }
+    };
+    // RSAKey.prototype.encrypt = RSAEncrypt;
+    // Return the PKCS#1 RSA encryption of "text" as an even-length hex string
+    RSAKey.prototype.encrypt = function (text) {
+        var m = pkcs1pad2(text, (this.n.bitLength() + 7) >> 3);
+        if (m == null) {
+            return null;
+        }
+        var c = this.doPublic(m);
+        if (c == null) {
+            return null;
+        }
+        var h = c.toString(16);
+        if ((h.length & 1) == 0) {
+            return h;
+        }
+        else {
+            return "0" + h;
+        }
+    };
+    // RSAKey.prototype.setPrivate = RSASetPrivate;
+    // Set the private key fields N, e, and d from hex strings
+    RSAKey.prototype.setPrivate = function (N, E, D) {
+        if (N != null && E != null && N.length > 0 && E.length > 0) {
+            this.n = parseBigInt(N, 16);
+            this.e = parseInt(E, 16);
+            this.d = parseBigInt(D, 16);
+        }
+        else {
+            console.error("Invalid RSA private key");
+        }
+    };
+    // RSAKey.prototype.setPrivateEx = RSASetPrivateEx;
+    // Set the private key fields N, e, d and CRT params from hex strings
+    RSAKey.prototype.setPrivateEx = function (N, E, D, P, Q, DP, DQ, C) {
+        if (N != null && E != null && N.length > 0 && E.length > 0) {
+            this.n = parseBigInt(N, 16);
+            this.e = parseInt(E, 16);
+            this.d = parseBigInt(D, 16);
+            this.p = parseBigInt(P, 16);
+            this.q = parseBigInt(Q, 16);
+            this.dmp1 = parseBigInt(DP, 16);
+            this.dmq1 = parseBigInt(DQ, 16);
+            this.coeff = parseBigInt(C, 16);
+        }
+        else {
+            console.error("Invalid RSA private key");
+        }
+    };
+    // RSAKey.prototype.generate = RSAGenerate;
+    // Generate a new random private key B bits long, using public expt E
+    RSAKey.prototype.generate = function (B, E) {
+        var rng = new SecureRandom();
+        var qs = B >> 1;
+        this.e = parseInt(E, 16);
+        var ee = new BigInteger(E, 16);
+        for (;;) {
+            for (;;) {
+                this.p = new BigInteger(B - qs, 1, rng);
+                if (this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) {
+                    break;
+                }
+            }
+            for (;;) {
+                this.q = new BigInteger(qs, 1, rng);
+                if (this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) {
+                    break;
+                }
+            }
+            if (this.p.compareTo(this.q) <= 0) {
+                var t = this.p;
+                this.p = this.q;
+                this.q = t;
+            }
+            var p1 = this.p.subtract(BigInteger.ONE);
+            var q1 = this.q.subtract(BigInteger.ONE);
+            var phi = p1.multiply(q1);
+            if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
+                this.n = this.p.multiply(this.q);
+                this.d = ee.modInverse(phi);
+                this.dmp1 = this.d.mod(p1);
+                this.dmq1 = this.d.mod(q1);
+                this.coeff = this.q.modInverse(this.p);
+                break;
+            }
+        }
+    };
+    // RSAKey.prototype.decrypt = RSADecrypt;
+    // Return the PKCS#1 RSA decryption of "ctext".
+    // "ctext" is an even-length hex string and the output is a plain string.
+    RSAKey.prototype.decrypt = function (ctext) {
+        var c = parseBigInt(ctext, 16);
+        var m = this.doPrivate(c);
+        if (m == null) {
+            return null;
+        }
+        return pkcs1unpad2(m, (this.n.bitLength() + 7) >> 3);
+    };
+    // Generate a new random private key B bits long, using public expt E
+    RSAKey.prototype.generateAsync = function (B, E, callback) {
+        var rng = new SecureRandom();
+        var qs = B >> 1;
+        this.e = parseInt(E, 16);
+        var ee = new BigInteger(E, 16);
+        var rsa = this;
+        // These functions have non-descript names because they were originally for(;;) loops.
+        // I don't know about cryptography to give them better names than loop1-4.
+        var loop1 = function () {
+            var loop4 = function () {
+                if (rsa.p.compareTo(rsa.q) <= 0) {
+                    var t = rsa.p;
+                    rsa.p = rsa.q;
+                    rsa.q = t;
+                }
+                var p1 = rsa.p.subtract(BigInteger.ONE);
+                var q1 = rsa.q.subtract(BigInteger.ONE);
+                var phi = p1.multiply(q1);
+                if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
+                    rsa.n = rsa.p.multiply(rsa.q);
+                    rsa.d = ee.modInverse(phi);
+                    rsa.dmp1 = rsa.d.mod(p1);
+                    rsa.dmq1 = rsa.d.mod(q1);
+                    rsa.coeff = rsa.q.modInverse(rsa.p);
+                    setTimeout(function () { callback(); }, 0); // escape
+                }
+                else {
+                    setTimeout(loop1, 0);
+                }
+            };
+            var loop3 = function () {
+                rsa.q = nbi();
+                rsa.q.fromNumberAsync(qs, 1, rng, function () {
+                    rsa.q.subtract(BigInteger.ONE).gcda(ee, function (r) {
+                        if (r.compareTo(BigInteger.ONE) == 0 && rsa.q.isProbablePrime(10)) {
+                            setTimeout(loop4, 0);
+                        }
+                        else {
+                            setTimeout(loop3, 0);
+                        }
+                    });
+                });
+            };
+            var loop2 = function () {
+                rsa.p = nbi();
+                rsa.p.fromNumberAsync(B - qs, 1, rng, function () {
+                    rsa.p.subtract(BigInteger.ONE).gcda(ee, function (r) {
+                        if (r.compareTo(BigInteger.ONE) == 0 && rsa.p.isProbablePrime(10)) {
+                            setTimeout(loop3, 0);
+                        }
+                        else {
+                            setTimeout(loop2, 0);
+                        }
+                    });
+                });
+            };
+            setTimeout(loop2, 0);
+        };
+        setTimeout(loop1, 0);
+    };
+    RSAKey.prototype.sign = function (text, digestMethod, digestName) {
+        var header = getDigestHeader(digestName);
+        var digest = header + digestMethod(text).toString();
+        var m = pkcs1pad1(digest, this.n.bitLength() / 4);
+        if (m == null) {
+            return null;
+        }
+        var c = this.doPrivate(m);
+        if (c == null) {
+            return null;
+        }
+        var h = c.toString(16);
+        if ((h.length & 1) == 0) {
+            return h;
+        }
+        else {
+            return "0" + h;
+        }
+    };
+    RSAKey.prototype.verify = function (text, signature, digestMethod) {
+        var c = parseBigInt(signature, 16);
+        var m = this.doPublic(c);
+        if (m == null) {
+            return null;
+        }
+        var unpadded = m.toString(16).replace(/^1f+00/, "");
+        var digest = removeDigestHeader(unpadded);
+        return digest == digestMethod(text).toString();
+    };
+    return RSAKey;
+}());
+// Undo PKCS#1 (type 2, random) padding and, if valid, return the plaintext
+function pkcs1unpad2(d, n) {
+    var b = d.toByteArray();
+    var i = 0;
+    while (i < b.length && b[i] == 0) {
+        ++i;
+    }
+    if (b.length - i != n - 1 || b[i] != 2) {
+        return null;
+    }
+    ++i;
+    while (b[i] != 0) {
+        if (++i >= b.length) {
+            return null;
+        }
+    }
+    var ret = "";
+    while (++i < b.length) {
+        var c = b[i] & 255;
+        if (c < 128) { // utf-8 decode
+            ret += String.fromCharCode(c);
+        }
+        else if ((c > 191) && (c < 224)) {
+            ret += String.fromCharCode(((c & 31) << 6) | (b[i + 1] & 63));
+            ++i;
+        }
+        else {
+            ret += String.fromCharCode(((c & 15) << 12) | ((b[i + 1] & 63) << 6) | (b[i + 2] & 63));
+            i += 2;
+        }
+    }
+    return ret;
+}
+// https://tools.ietf.org/html/rfc3447#page-43
+var DIGEST_HEADERS = {
+    md2: "3020300c06082a864886f70d020205000410",
+    md5: "3020300c06082a864886f70d020505000410",
+    sha1: "3021300906052b0e03021a05000414",
+    sha224: "302d300d06096086480165030402040500041c",
+    sha256: "3031300d060960864801650304020105000420",
+    sha384: "3041300d060960864801650304020205000430",
+    sha512: "3051300d060960864801650304020305000440",
+    ripemd160: "3021300906052b2403020105000414",
+};
+function getDigestHeader(name) {
+    return DIGEST_HEADERS[name] || "";
+}
+function removeDigestHeader(str) {
+    for (var name_1 in DIGEST_HEADERS) {
+        if (DIGEST_HEADERS.hasOwnProperty(name_1)) {
+            var header = DIGEST_HEADERS[name_1];
+            var len = header.length;
+            if (str.substr(0, len) == header) {
+                return str.substr(len);
+            }
+        }
+    }
+    return str;
+}
+// Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
+// function RSAEncryptB64(text) {
+//  var h = this.encrypt(text);
+//  if(h) return hex2b64(h); else return null;
+// }
+// public
+// RSAKey.prototype.encrypt_b64 = RSAEncryptB64;
+
+/*!
+Copyright (c) 2011, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.com/yui/license.html
+version: 2.9.0
+*/
+var YAHOO = {};
+YAHOO.lang = {
+    /**
+     * Utility to set up the prototype, constructor and superclass properties to
+     * support an inheritance strategy that can chain constructors and methods.
+     * Static members will not be inherited.
+     *
+     * @method extend
+     * @static
+     * @param {Function} subc   the object to modify
+     * @param {Function} superc the object to inherit
+     * @param {Object} overrides  additional properties/methods to add to the
+     *                              subclass prototype.  These will override the
+     *                              matching items obtained from the superclass
+     *                              if present.
+     */
+    extend: function(subc, superc, overrides) {
+        if (! superc || ! subc) {
+            throw new Error("YAHOO.lang.extend failed, please check that " +
+                "all dependencies are included.");
+        }
+
+        var F = function() {};
+        F.prototype = superc.prototype;
+        subc.prototype = new F();
+        subc.prototype.constructor = subc;
+        subc.superclass = superc.prototype;
+
+        if (superc.prototype.constructor == Object.prototype.constructor) {
+            superc.prototype.constructor = superc;
+        }
+
+        if (overrides) {
+            var i;
+            for (i in overrides) {
+                subc.prototype[i] = overrides[i];
+            }
+
+            /*
+             * IE will not enumerate native functions in a derived object even if the
+             * function was overridden.  This is a workaround for specific functions
+             * we care about on the Object prototype.
+             * @property _IEEnumFix
+             * @param {Function} r  the object to receive the augmentation
+             * @param {Function} s  the object that supplies the properties to augment
+             * @static
+             * @private
+             */
+            var _IEEnumFix = function() {},
+                ADD = ["toString", "valueOf"];
+            try {
+                if (/MSIE/.test(navigator.userAgent)) {
+                    _IEEnumFix = function(r, s) {
+                        for (i = 0; i < ADD.length; i = i + 1) {
+                            var fname = ADD[i], f = s[fname];
+                            if (typeof f === 'function' && f != Object.prototype[fname]) {
+                                r[fname] = f;
+                            }
+                        }
+                    };
+                }
+            } catch (ex) {}            _IEEnumFix(subc.prototype, overrides);
+        }
+    }
+};
+
+/* asn1-1.0.13.js (c) 2013-2017 Kenji Urushima | kjur.github.com/jsrsasign/license
+ */
+
+/**
+ * @fileOverview
+ * @name asn1-1.0.js
+ * @author Kenji Urushima kenji.urushima@gmail.com
+ * @version asn1 1.0.13 (2017-Jun-02)
+ * @since jsrsasign 2.1
+ * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
+ */
+
+/**
+ * kjur's class library name space
+ * <p>
+ * This name space provides following name spaces:
+ * <ul>
+ * <li>{@link KJUR.asn1} - ASN.1 primitive hexadecimal encoder</li>
+ * <li>{@link KJUR.asn1.x509} - ASN.1 structure for X.509 certificate and CRL</li>
+ * <li>{@link KJUR.crypto} - Java Cryptographic Extension(JCE) style MessageDigest/Signature
+ * class and utilities</li>
+ * </ul>
+ * </p>
+ * NOTE: Please ignore method summary and document of this namespace. This caused by a bug of jsdoc2.
+ * @name KJUR
+ * @namespace kjur's class library name space
+ */
+var KJUR = {};
+
+/**
+ * kjur's ASN.1 class library name space
+ * <p>
+ * This is ITU-T X.690 ASN.1 DER encoder class library and
+ * class structure and methods is very similar to
+ * org.bouncycastle.asn1 package of
+ * well known BouncyCaslte Cryptography Library.
+ * <h4>PROVIDING ASN.1 PRIMITIVES</h4>
+ * Here are ASN.1 DER primitive classes.
+ * <ul>
+ * <li>0x01 {@link KJUR.asn1.DERBoolean}</li>
+ * <li>0x02 {@link KJUR.asn1.DERInteger}</li>
+ * <li>0x03 {@link KJUR.asn1.DERBitString}</li>
+ * <li>0x04 {@link KJUR.asn1.DEROctetString}</li>
+ * <li>0x05 {@link KJUR.asn1.DERNull}</li>
+ * <li>0x06 {@link KJUR.asn1.DERObjectIdentifier}</li>
+ * <li>0x0a {@link KJUR.asn1.DEREnumerated}</li>
+ * <li>0x0c {@link KJUR.asn1.DERUTF8String}</li>
+ * <li>0x12 {@link KJUR.asn1.DERNumericString}</li>
+ * <li>0x13 {@link KJUR.asn1.DERPrintableString}</li>
+ * <li>0x14 {@link KJUR.asn1.DERTeletexString}</li>
+ * <li>0x16 {@link KJUR.asn1.DERIA5String}</li>
+ * <li>0x17 {@link KJUR.asn1.DERUTCTime}</li>
+ * <li>0x18 {@link KJUR.asn1.DERGeneralizedTime}</li>
+ * <li>0x30 {@link KJUR.asn1.DERSequence}</li>
+ * <li>0x31 {@link KJUR.asn1.DERSet}</li>
+ * </ul>
+ * <h4>OTHER ASN.1 CLASSES</h4>
+ * <ul>
+ * <li>{@link KJUR.asn1.ASN1Object}</li>
+ * <li>{@link KJUR.asn1.DERAbstractString}</li>
+ * <li>{@link KJUR.asn1.DERAbstractTime}</li>
+ * <li>{@link KJUR.asn1.DERAbstractStructured}</li>
+ * <li>{@link KJUR.asn1.DERTaggedObject}</li>
+ * </ul>
+ * <h4>SUB NAME SPACES</h4>
+ * <ul>
+ * <li>{@link KJUR.asn1.cades} - CAdES long term signature format</li>
+ * <li>{@link KJUR.asn1.cms} - Cryptographic Message Syntax</li>
+ * <li>{@link KJUR.asn1.csr} - Certificate Signing Request (CSR/PKCS#10)</li>
+ * <li>{@link KJUR.asn1.tsp} - RFC 3161 Timestamping Protocol Format</li>
+ * <li>{@link KJUR.asn1.x509} - RFC 5280 X.509 certificate and CRL</li>
+ * </ul>
+ * </p>
+ * NOTE: Please ignore method summary and document of this namespace.
+ * This caused by a bug of jsdoc2.
+ * @name KJUR.asn1
+ * @namespace
+ */
+if (typeof KJUR.asn1 == "undefined" || !KJUR.asn1) KJUR.asn1 = {};
+
+/**
+ * ASN1 utilities class
+ * @name KJUR.asn1.ASN1Util
+ * @class ASN1 utilities class
+ * @since asn1 1.0.2
+ */
+KJUR.asn1.ASN1Util = new function() {
+    this.integerToByteHex = function(i) {
+        var h = i.toString(16);
+        if ((h.length % 2) == 1) h = '0' + h;
+        return h;
+    };
+    this.bigIntToMinTwosComplementsHex = function(bigIntegerValue) {
+        var h = bigIntegerValue.toString(16);
+        if (h.substr(0, 1) != '-') {
+            if (h.length % 2 == 1) {
+                h = '0' + h;
+            } else {
+                if (! h.match(/^[0-7]/)) {
+                    h = '00' + h;
+                }
+            }
+        } else {
+            var hPos = h.substr(1);
+            var xorLen = hPos.length;
+            if (xorLen % 2 == 1) {
+                xorLen += 1;
+            } else {
+                if (! h.match(/^[0-7]/)) {
+                    xorLen += 2;
+                }
+            }
+            var hMask = '';
+            for (var i = 0; i < xorLen; i++) {
+                hMask += 'f';
+            }
+            var biMask = new BigInteger(hMask, 16);
+            var biNeg = biMask.xor(bigIntegerValue).add(BigInteger.ONE);
+            h = biNeg.toString(16).replace(/^-/, '');
+        }
+        return h;
+    };
+    /**
+     * get PEM string from hexadecimal data and header string
+     * @name getPEMStringFromHex
+     * @memberOf KJUR.asn1.ASN1Util
+     * @function
+     * @param {String} dataHex hexadecimal string of PEM body
+     * @param {String} pemHeader PEM header string (ex. 'RSA PRIVATE KEY')
+     * @return {String} PEM formatted string of input data
+     * @description
+     * This method converts a hexadecimal string to a PEM string with
+     * a specified header. Its line break will be CRLF("\r\n").
+     * @example
+     * var pem  = KJUR.asn1.ASN1Util.getPEMStringFromHex('616161', 'RSA PRIVATE KEY');
+     * // value of pem will be:
+     * -----BEGIN PRIVATE KEY-----
+     * YWFh
+     * -----END PRIVATE KEY-----
+     */
+    this.getPEMStringFromHex = function(dataHex, pemHeader) {
+        return hextopem(dataHex, pemHeader);
+    };
+
+    /**
+     * generate ASN1Object specifed by JSON parameters
+     * @name newObject
+     * @memberOf KJUR.asn1.ASN1Util
+     * @function
+     * @param {Array} param JSON parameter to generate ASN1Object
+     * @return {KJUR.asn1.ASN1Object} generated object
+     * @since asn1 1.0.3
+     * @description
+     * generate any ASN1Object specified by JSON param
+     * including ASN.1 primitive or structured.
+     * Generally 'param' can be described as follows:
+     * <blockquote>
+     * {TYPE-OF-ASNOBJ: ASN1OBJ-PARAMETER}
+     * </blockquote>
+     * 'TYPE-OF-ASN1OBJ' can be one of following symbols:
+     * <ul>
+     * <li>'bool' - DERBoolean</li>
+     * <li>'int' - DERInteger</li>
+     * <li>'bitstr' - DERBitString</li>
+     * <li>'octstr' - DEROctetString</li>
+     * <li>'null' - DERNull</li>
+     * <li>'oid' - DERObjectIdentifier</li>
+     * <li>'enum' - DEREnumerated</li>
+     * <li>'utf8str' - DERUTF8String</li>
+     * <li>'numstr' - DERNumericString</li>
+     * <li>'prnstr' - DERPrintableString</li>
+     * <li>'telstr' - DERTeletexString</li>
+     * <li>'ia5str' - DERIA5String</li>
+     * <li>'utctime' - DERUTCTime</li>
+     * <li>'gentime' - DERGeneralizedTime</li>
+     * <li>'seq' - DERSequence</li>
+     * <li>'set' - DERSet</li>
+     * <li>'tag' - DERTaggedObject</li>
+     * </ul>
+     * @example
+     * newObject({'prnstr': 'aaa'});
+     * newObject({'seq': [{'int': 3}, {'prnstr': 'aaa'}]})
+     * // ASN.1 Tagged Object
+     * newObject({'tag': {'tag': 'a1',
+     *                    'explicit': true,
+     *                    'obj': {'seq': [{'int': 3}, {'prnstr': 'aaa'}]}}});
+     * // more simple representation of ASN.1 Tagged Object
+     * newObject({'tag': ['a1',
+     *                    true,
+     *                    {'seq': [
+     *                      {'int': 3},
+     *                      {'prnstr': 'aaa'}]}
+     *                   ]});
+     */
+    this.newObject = function(param) {
+        var _KJUR = KJUR,
+            _KJUR_asn1 = _KJUR.asn1,
+            _DERBoolean = _KJUR_asn1.DERBoolean,
+            _DERInteger = _KJUR_asn1.DERInteger,
+            _DERBitString = _KJUR_asn1.DERBitString,
+            _DEROctetString = _KJUR_asn1.DEROctetString,
+            _DERNull = _KJUR_asn1.DERNull,
+            _DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+            _DEREnumerated = _KJUR_asn1.DEREnumerated,
+            _DERUTF8String = _KJUR_asn1.DERUTF8String,
+            _DERNumericString = _KJUR_asn1.DERNumericString,
+            _DERPrintableString = _KJUR_asn1.DERPrintableString,
+            _DERTeletexString = _KJUR_asn1.DERTeletexString,
+            _DERIA5String = _KJUR_asn1.DERIA5String,
+            _DERUTCTime = _KJUR_asn1.DERUTCTime,
+            _DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime,
+            _DERSequence = _KJUR_asn1.DERSequence,
+            _DERSet = _KJUR_asn1.DERSet,
+            _DERTaggedObject = _KJUR_asn1.DERTaggedObject,
+            _newObject = _KJUR_asn1.ASN1Util.newObject;
+
+        var keys = Object.keys(param);
+        if (keys.length != 1)
+            throw "key of param shall be only one.";
+        var key = keys[0];
+
+        if (":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":" + key + ":") == -1)
+            throw "undefined key: " + key;
+
+        if (key == "bool")    return new _DERBoolean(param[key]);
+        if (key == "int")     return new _DERInteger(param[key]);
+        if (key == "bitstr")  return new _DERBitString(param[key]);
+        if (key == "octstr")  return new _DEROctetString(param[key]);
+        if (key == "null")    return new _DERNull(param[key]);
+        if (key == "oid")     return new _DERObjectIdentifier(param[key]);
+        if (key == "enum")    return new _DEREnumerated(param[key]);
+        if (key == "utf8str") return new _DERUTF8String(param[key]);
+        if (key == "numstr")  return new _DERNumericString(param[key]);
+        if (key == "prnstr")  return new _DERPrintableString(param[key]);
+        if (key == "telstr")  return new _DERTeletexString(param[key]);
+        if (key == "ia5str")  return new _DERIA5String(param[key]);
+        if (key == "utctime") return new _DERUTCTime(param[key]);
+        if (key == "gentime") return new _DERGeneralizedTime(param[key]);
+
+        if (key == "seq") {
+            var paramList = param[key];
+            var a = [];
+            for (var i = 0; i < paramList.length; i++) {
+                var asn1Obj = _newObject(paramList[i]);
+                a.push(asn1Obj);
+            }
+            return new _DERSequence({'array': a});
+        }
+
+        if (key == "set") {
+            var paramList = param[key];
+            var a = [];
+            for (var i = 0; i < paramList.length; i++) {
+                var asn1Obj = _newObject(paramList[i]);
+                a.push(asn1Obj);
+            }
+            return new _DERSet({'array': a});
+        }
+
+        if (key == "tag") {
+            var tagParam = param[key];
+            if (Object.prototype.toString.call(tagParam) === '[object Array]' &&
+                tagParam.length == 3) {
+                var obj = _newObject(tagParam[2]);
+                return new _DERTaggedObject({tag: tagParam[0],
+                    explicit: tagParam[1],
+                    obj: obj});
+            } else {
+                var newParam = {};
+                if (tagParam.explicit !== undefined)
+                    newParam.explicit = tagParam.explicit;
+                if (tagParam.tag !== undefined)
+                    newParam.tag = tagParam.tag;
+                if (tagParam.obj === undefined)
+                    throw "obj shall be specified for 'tag'.";
+                newParam.obj = _newObject(tagParam.obj);
+                return new _DERTaggedObject(newParam);
+            }
+        }
+    };
+
+    /**
+     * get encoded hexadecimal string of ASN1Object specifed by JSON parameters
+     * @name jsonToASN1HEX
+     * @memberOf KJUR.asn1.ASN1Util
+     * @function
+     * @param {Array} param JSON parameter to generate ASN1Object
+     * @return hexadecimal string of ASN1Object
+     * @since asn1 1.0.4
+     * @description
+     * As for ASN.1 object representation of JSON object,
+     * please see {@link newObject}.
+     * @example
+     * jsonToASN1HEX({'prnstr': 'aaa'});
+     */
+    this.jsonToASN1HEX = function(param) {
+        var asn1Obj = this.newObject(param);
+        return asn1Obj.getEncodedHex();
+    };
+};
+
+/**
+ * get dot noted oid number string from hexadecimal value of OID
+ * @name oidHexToInt
+ * @memberOf KJUR.asn1.ASN1Util
+ * @function
+ * @param {String} hex hexadecimal value of object identifier
+ * @return {String} dot noted string of object identifier
+ * @since jsrsasign 4.8.3 asn1 1.0.7
+ * @description
+ * This static method converts from hexadecimal string representation of
+ * ASN.1 value of object identifier to oid number string.
+ * @example
+ * KJUR.asn1.ASN1Util.oidHexToInt('550406') &rarr; "2.5.4.6"
+ */
+KJUR.asn1.ASN1Util.oidHexToInt = function(hex) {
+    var s = "";
+    var i01 = parseInt(hex.substr(0, 2), 16);
+    var i0 = Math.floor(i01 / 40);
+    var i1 = i01 % 40;
+    var s = i0 + "." + i1;
+
+    var binbuf = "";
+    for (var i = 2; i < hex.length; i += 2) {
+        var value = parseInt(hex.substr(i, 2), 16);
+        var bin = ("00000000" + value.toString(2)).slice(- 8);
+        binbuf = binbuf + bin.substr(1, 7);
+        if (bin.substr(0, 1) == "0") {
+            var bi = new BigInteger(binbuf, 2);
+            s = s + "." + bi.toString(10);
+            binbuf = "";
+        }
+    }
+    return s;
+};
+
+/**
+ * get hexadecimal value of object identifier from dot noted oid value
+ * @name oidIntToHex
+ * @memberOf KJUR.asn1.ASN1Util
+ * @function
+ * @param {String} oidString dot noted string of object identifier
+ * @return {String} hexadecimal value of object identifier
+ * @since jsrsasign 4.8.3 asn1 1.0.7
+ * @description
+ * This static method converts from object identifier value string.
+ * to hexadecimal string representation of it.
+ * @example
+ * KJUR.asn1.ASN1Util.oidIntToHex("2.5.4.6") &rarr; "550406"
+ */
+KJUR.asn1.ASN1Util.oidIntToHex = function(oidString) {
+    var itox = function(i) {
+        var h = i.toString(16);
+        if (h.length == 1) h = '0' + h;
+        return h;
+    };
+
+    var roidtox = function(roid) {
+        var h = '';
+        var bi = new BigInteger(roid, 10);
+        var b = bi.toString(2);
+        var padLen = 7 - b.length % 7;
+        if (padLen == 7) padLen = 0;
+        var bPad = '';
+        for (var i = 0; i < padLen; i++) bPad += '0';
+        b = bPad + b;
+        for (var i = 0; i < b.length - 1; i += 7) {
+            var b8 = b.substr(i, 7);
+            if (i != b.length - 7) b8 = '1' + b8;
+            h += itox(parseInt(b8, 2));
+        }
+        return h;
+    };
+
+    if (! oidString.match(/^[0-9.]+$/)) {
+        throw "malformed oid string: " + oidString;
+    }
+    var h = '';
+    var a = oidString.split('.');
+    var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
+    h += itox(i0);
+    a.splice(0, 2);
+    for (var i = 0; i < a.length; i++) {
+        h += roidtox(a[i]);
+    }
+    return h;
+};
+
+
+// ********************************************************************
+//  Abstract ASN.1 Classes
+// ********************************************************************
+
+// ********************************************************************
+
+/**
+ * base class for ASN.1 DER encoder object
+ * @name KJUR.asn1.ASN1Object
+ * @class base class for ASN.1 DER encoder object
+ * @property {Boolean} isModified flag whether internal data was changed
+ * @property {String} hTLV hexadecimal string of ASN.1 TLV
+ * @property {String} hT hexadecimal string of ASN.1 TLV tag(T)
+ * @property {String} hL hexadecimal string of ASN.1 TLV length(L)
+ * @property {String} hV hexadecimal string of ASN.1 TLV value(V)
+ * @description
+ */
+KJUR.asn1.ASN1Object = function() {
+    var hV = '';
+
+    /**
+     * get hexadecimal ASN.1 TLV length(L) bytes from TLV value(V)
+     * @name getLengthHexFromValue
+     * @memberOf KJUR.asn1.ASN1Object#
+     * @function
+     * @return {String} hexadecimal string of ASN.1 TLV length(L)
+     */
+    this.getLengthHexFromValue = function() {
+        if (typeof this.hV == "undefined" || this.hV == null) {
+            throw "this.hV is null or undefined.";
+        }
+        if (this.hV.length % 2 == 1) {
+            throw "value hex must be even length: n=" + hV.length + ",v=" + this.hV;
+        }
+        var n = this.hV.length / 2;
+        var hN = n.toString(16);
+        if (hN.length % 2 == 1) {
+            hN = "0" + hN;
+        }
+        if (n < 128) {
+            return hN;
+        } else {
+            var hNlen = hN.length / 2;
+            if (hNlen > 15) {
+                throw "ASN.1 length too long to represent by 8x: n = " + n.toString(16);
+            }
+            var head = 128 + hNlen;
+            return head.toString(16) + hN;
+        }
+    };
+
+    /**
+     * get hexadecimal string of ASN.1 TLV bytes
+     * @name getEncodedHex
+     * @memberOf KJUR.asn1.ASN1Object#
+     * @function
+     * @return {String} hexadecimal string of ASN.1 TLV
+     */
+    this.getEncodedHex = function() {
+        if (this.hTLV == null || this.isModified) {
+            this.hV = this.getFreshValueHex();
+            this.hL = this.getLengthHexFromValue();
+            this.hTLV = this.hT + this.hL + this.hV;
+            this.isModified = false;
+            //alert("first time: " + this.hTLV);
+        }
+        return this.hTLV;
+    };
+
+    /**
+     * get hexadecimal string of ASN.1 TLV value(V) bytes
+     * @name getValueHex
+     * @memberOf KJUR.asn1.ASN1Object#
+     * @function
+     * @return {String} hexadecimal string of ASN.1 TLV value(V) bytes
+     */
+    this.getValueHex = function() {
+        this.getEncodedHex();
+        return this.hV;
+    };
+
+    this.getFreshValueHex = function() {
+        return '';
+    };
+};
+
+// == BEGIN DERAbstractString ================================================
+/**
+ * base class for ASN.1 DER string classes
+ * @name KJUR.asn1.DERAbstractString
+ * @class base class for ASN.1 DER string classes
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @property {String} s internal string of value
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>str - specify initial ASN.1 value(V) by a string</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERAbstractString = function(params) {
+    KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
+
+    /**
+     * get string value of this string object
+     * @name getString
+     * @memberOf KJUR.asn1.DERAbstractString#
+     * @function
+     * @return {String} string value of this string object
+     */
+    this.getString = function() {
+        return this.s;
+    };
+
+    /**
+     * set value by a string
+     * @name setString
+     * @memberOf KJUR.asn1.DERAbstractString#
+     * @function
+     * @param {String} newS value by a string to set
+     */
+    this.setString = function(newS) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.s = newS;
+        this.hV = stohex(this.s);
+    };
+
+    /**
+     * set value by a hexadecimal string
+     * @name setStringHex
+     * @memberOf KJUR.asn1.DERAbstractString#
+     * @function
+     * @param {String} newHexString value by a hexadecimal string to set
+     */
+    this.setStringHex = function(newHexString) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.s = null;
+        this.hV = newHexString;
+    };
+
+    this.getFreshValueHex = function() {
+        return this.hV;
+    };
+
+    if (typeof params != "undefined") {
+        if (typeof params == "string") {
+            this.setString(params);
+        } else if (typeof params['str'] != "undefined") {
+            this.setString(params['str']);
+        } else if (typeof params['hex'] != "undefined") {
+            this.setStringHex(params['hex']);
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERAbstractString, KJUR.asn1.ASN1Object);
+// == END   DERAbstractString ================================================
+
+// == BEGIN DERAbstractTime ==================================================
+/**
+ * base class for ASN.1 DER Generalized/UTCTime class
+ * @name KJUR.asn1.DERAbstractTime
+ * @class base class for ASN.1 DER Generalized/UTCTime class
+ * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERAbstractTime = function(params) {
+    KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);
+
+    // --- PRIVATE METHODS --------------------
+    this.localDateToUTC = function(d) {
+        utc = d.getTime() + (d.getTimezoneOffset() * 60000);
+        var utcDate = new Date(utc);
+        return utcDate;
+    };
+
+    /*
+     * format date string by Data object
+     * @name formatDate
+     * @memberOf KJUR.asn1.AbstractTime;
+     * @param {Date} dateObject
+     * @param {string} type 'utc' or 'gen'
+     * @param {boolean} withMillis flag for with millisections or not
+     * @description
+     * 'withMillis' flag is supported from asn1 1.0.6.
+     */
+    this.formatDate = function(dateObject, type, withMillis) {
+        var pad = this.zeroPadding;
+        var d = this.localDateToUTC(dateObject);
+        var year = String(d.getFullYear());
+        if (type == 'utc') year = year.substr(2, 2);
+        var month = pad(String(d.getMonth() + 1), 2);
+        var day = pad(String(d.getDate()), 2);
+        var hour = pad(String(d.getHours()), 2);
+        var min = pad(String(d.getMinutes()), 2);
+        var sec = pad(String(d.getSeconds()), 2);
+        var s = year + month + day + hour + min + sec;
+        if (withMillis === true) {
+            var millis = d.getMilliseconds();
+            if (millis != 0) {
+                var sMillis = pad(String(millis), 3);
+                sMillis = sMillis.replace(/[0]+$/, "");
+                s = s + "." + sMillis;
+            }
+        }
+        return s + "Z";
+    };
+
+    this.zeroPadding = function(s, len) {
+        if (s.length >= len) return s;
+        return new Array(len - s.length + 1).join('0') + s;
+    };
+
+    // --- PUBLIC METHODS --------------------
+    /**
+     * get string value of this string object
+     * @name getString
+     * @memberOf KJUR.asn1.DERAbstractTime#
+     * @function
+     * @return {String} string value of this time object
+     */
+    this.getString = function() {
+        return this.s;
+    };
+
+    /**
+     * set value by a string
+     * @name setString
+     * @memberOf KJUR.asn1.DERAbstractTime#
+     * @function
+     * @param {String} newS value by a string to set such like "130430235959Z"
+     */
+    this.setString = function(newS) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.s = newS;
+        this.hV = stohex(newS);
+    };
+
+    /**
+     * set value by a Date object
+     * @name setByDateValue
+     * @memberOf KJUR.asn1.DERAbstractTime#
+     * @function
+     * @param {Integer} year year of date (ex. 2013)
+     * @param {Integer} month month of date between 1 and 12 (ex. 12)
+     * @param {Integer} day day of month
+     * @param {Integer} hour hours of date
+     * @param {Integer} min minutes of date
+     * @param {Integer} sec seconds of date
+     */
+    this.setByDateValue = function(year, month, day, hour, min, sec) {
+        var dateObject = new Date(Date.UTC(year, month - 1, day, hour, min, sec, 0));
+        this.setByDate(dateObject);
+    };
+
+    this.getFreshValueHex = function() {
+        return this.hV;
+    };
+};
+YAHOO.lang.extend(KJUR.asn1.DERAbstractTime, KJUR.asn1.ASN1Object);
+// == END   DERAbstractTime ==================================================
+
+// == BEGIN DERAbstractStructured ============================================
+/**
+ * base class for ASN.1 DER structured class
+ * @name KJUR.asn1.DERAbstractStructured
+ * @class base class for ASN.1 DER structured class
+ * @property {Array} asn1Array internal array of ASN1Object
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERAbstractStructured = function(params) {
+    KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
+
+    /**
+     * set value by array of ASN1Object
+     * @name setByASN1ObjectArray
+     * @memberOf KJUR.asn1.DERAbstractStructured#
+     * @function
+     * @param {array} asn1ObjectArray array of ASN1Object to set
+     */
+    this.setByASN1ObjectArray = function(asn1ObjectArray) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.asn1Array = asn1ObjectArray;
+    };
+
+    /**
+     * append an ASN1Object to internal array
+     * @name appendASN1Object
+     * @memberOf KJUR.asn1.DERAbstractStructured#
+     * @function
+     * @param {ASN1Object} asn1Object to add
+     */
+    this.appendASN1Object = function(asn1Object) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.asn1Array.push(asn1Object);
+    };
+
+    this.asn1Array = new Array();
+    if (typeof params != "undefined") {
+        if (typeof params['array'] != "undefined") {
+            this.asn1Array = params['array'];
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured, KJUR.asn1.ASN1Object);
+
+
+// ********************************************************************
+//  ASN.1 Object Classes
+// ********************************************************************
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Boolean
+ * @name KJUR.asn1.DERBoolean
+ * @class class for ASN.1 DER Boolean
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERBoolean = function() {
+    KJUR.asn1.DERBoolean.superclass.constructor.call(this);
+    this.hT = "01";
+    this.hTLV = "0101ff";
+};
+YAHOO.lang.extend(KJUR.asn1.DERBoolean, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Integer
+ * @name KJUR.asn1.DERInteger
+ * @class class for ASN.1 DER Integer
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>int - specify initial ASN.1 value(V) by integer value</li>
+ * <li>bigint - specify initial ASN.1 value(V) by BigInteger object</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERInteger = function(params) {
+    KJUR.asn1.DERInteger.superclass.constructor.call(this);
+    this.hT = "02";
+
+    /**
+     * set value by Tom Wu's BigInteger object
+     * @name setByBigInteger
+     * @memberOf KJUR.asn1.DERInteger#
+     * @function
+     * @param {BigInteger} bigIntegerValue to set
+     */
+    this.setByBigInteger = function(bigIntegerValue) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
+    };
+
+    /**
+     * set value by integer value
+     * @name setByInteger
+     * @memberOf KJUR.asn1.DERInteger
+     * @function
+     * @param {Integer} integer value to set
+     */
+    this.setByInteger = function(intValue) {
+        var bi = new BigInteger(String(intValue), 10);
+        this.setByBigInteger(bi);
+    };
+
+    /**
+     * set value by integer value
+     * @name setValueHex
+     * @memberOf KJUR.asn1.DERInteger#
+     * @function
+     * @param {String} hexadecimal string of integer value
+     * @description
+     * <br/>
+     * NOTE: Value shall be represented by minimum octet length of
+     * two's complement representation.
+     * @example
+     * new KJUR.asn1.DERInteger(123);
+     * new KJUR.asn1.DERInteger({'int': 123});
+     * new KJUR.asn1.DERInteger({'hex': '1fad'});
+     */
+    this.setValueHex = function(newHexString) {
+        this.hV = newHexString;
+    };
+
+    this.getFreshValueHex = function() {
+        return this.hV;
+    };
+
+    if (typeof params != "undefined") {
+        if (typeof params['bigint'] != "undefined") {
+            this.setByBigInteger(params['bigint']);
+        } else if (typeof params['int'] != "undefined") {
+            this.setByInteger(params['int']);
+        } else if (typeof params == "number") {
+            this.setByInteger(params);
+        } else if (typeof params['hex'] != "undefined") {
+            this.setValueHex(params['hex']);
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER encoded BitString primitive
+ * @name KJUR.asn1.DERBitString
+ * @class class for ASN.1 DER encoded BitString primitive
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>bin - specify binary string (ex. '10111')</li>
+ * <li>array - specify array of boolean (ex. [true,false,true,true])</li>
+ * <li>hex - specify hexadecimal string of ASN.1 value(V) including unused bits</li>
+ * <li>obj - specify {@link KJUR.asn1.ASN1Util.newObject}
+ * argument for "BitString encapsulates" structure.</li>
+ * </ul>
+ * NOTE1: 'params' can be omitted.<br/>
+ * NOTE2: 'obj' parameter have been supported since
+ * asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).<br/>
+ * @example
+ * // default constructor
+ * o = new KJUR.asn1.DERBitString();
+ * // initialize with binary string
+ * o = new KJUR.asn1.DERBitString({bin: "1011"});
+ * // initialize with boolean array
+ * o = new KJUR.asn1.DERBitString({array: [true,false,true,true]});
+ * // initialize with hexadecimal string (04 is unused bits)
+ * o = new KJUR.asn1.DEROctetString({hex: "04bac0"});
+ * // initialize with ASN1Util.newObject argument for encapsulated
+ * o = new KJUR.asn1.DERBitString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
+ * // above generates a ASN.1 data like this:
+ * // BIT STRING, encapsulates {
+ * //   SEQUENCE {
+ * //     INTEGER 3
+ * //     PrintableString 'aaa'
+ * //     }
+ * //   }
+ */
+KJUR.asn1.DERBitString = function(params) {
+    if (params !== undefined && typeof params.obj !== "undefined") {
+        var o = KJUR.asn1.ASN1Util.newObject(params.obj);
+        params.hex = "00" + o.getEncodedHex();
+    }
+    KJUR.asn1.DERBitString.superclass.constructor.call(this);
+    this.hT = "03";
+
+    /**
+     * set ASN.1 value(V) by a hexadecimal string including unused bits
+     * @name setHexValueIncludingUnusedBits
+     * @memberOf KJUR.asn1.DERBitString#
+     * @function
+     * @param {String} newHexStringIncludingUnusedBits
+     */
+    this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.hV = newHexStringIncludingUnusedBits;
+    };
+
+    /**
+     * set ASN.1 value(V) by unused bit and hexadecimal string of value
+     * @name setUnusedBitsAndHexValue
+     * @memberOf KJUR.asn1.DERBitString#
+     * @function
+     * @param {Integer} unusedBits
+     * @param {String} hValue
+     */
+    this.setUnusedBitsAndHexValue = function(unusedBits, hValue) {
+        if (unusedBits < 0 || 7 < unusedBits) {
+            throw "unused bits shall be from 0 to 7: u = " + unusedBits;
+        }
+        var hUnusedBits = "0" + unusedBits;
+        this.hTLV = null;
+        this.isModified = true;
+        this.hV = hUnusedBits + hValue;
+    };
+
+    /**
+     * set ASN.1 DER BitString by binary string<br/>
+     * @name setByBinaryString
+     * @memberOf KJUR.asn1.DERBitString#
+     * @function
+     * @param {String} binaryString binary value string (i.e. '10111')
+     * @description
+     * Its unused bits will be calculated automatically by length of
+     * 'binaryValue'. <br/>
+     * NOTE: Trailing zeros '0' will be ignored.
+     * @example
+     * o = new KJUR.asn1.DERBitString();
+     * o.setByBooleanArray("01011");
+     */
+    this.setByBinaryString = function(binaryString) {
+        binaryString = binaryString.replace(/0+$/, '');
+        var unusedBits = 8 - binaryString.length % 8;
+        if (unusedBits == 8) unusedBits = 0;
+        for (var i = 0; i <= unusedBits; i++) {
+            binaryString += '0';
+        }
+        var h = '';
+        for (var i = 0; i < binaryString.length - 1; i += 8) {
+            var b = binaryString.substr(i, 8);
+            var x = parseInt(b, 2).toString(16);
+            if (x.length == 1) x = '0' + x;
+            h += x;
+        }
+        this.hTLV = null;
+        this.isModified = true;
+        this.hV = '0' + unusedBits + h;
+    };
+
+    /**
+     * set ASN.1 TLV value(V) by an array of boolean<br/>
+     * @name setByBooleanArray
+     * @memberOf KJUR.asn1.DERBitString#
+     * @function
+     * @param {array} booleanArray array of boolean (ex. [true, false, true])
+     * @description
+     * NOTE: Trailing falses will be ignored in the ASN.1 DER Object.
+     * @example
+     * o = new KJUR.asn1.DERBitString();
+     * o.setByBooleanArray([false, true, false, true, true]);
+     */
+    this.setByBooleanArray = function(booleanArray) {
+        var s = '';
+        for (var i = 0; i < booleanArray.length; i++) {
+            if (booleanArray[i] == true) {
+                s += '1';
+            } else {
+                s += '0';
+            }
+        }
+        this.setByBinaryString(s);
+    };
+
+    /**
+     * generate an array of falses with specified length<br/>
+     * @name newFalseArray
+     * @memberOf KJUR.asn1.DERBitString
+     * @function
+     * @param {Integer} nLength length of array to generate
+     * @return {array} array of boolean falses
+     * @description
+     * This static method may be useful to initialize boolean array.
+     * @example
+     * o = new KJUR.asn1.DERBitString();
+     * o.newFalseArray(3) &rarr; [false, false, false]
+     */
+    this.newFalseArray = function(nLength) {
+        var a = new Array(nLength);
+        for (var i = 0; i < nLength; i++) {
+            a[i] = false;
+        }
+        return a;
+    };
+
+    this.getFreshValueHex = function() {
+        return this.hV;
+    };
+
+    if (typeof params != "undefined") {
+        if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
+            this.setHexValueIncludingUnusedBits(params);
+        } else if (typeof params['hex'] != "undefined") {
+            this.setHexValueIncludingUnusedBits(params['hex']);
+        } else if (typeof params['bin'] != "undefined") {
+            this.setByBinaryString(params['bin']);
+        } else if (typeof params['array'] != "undefined") {
+            this.setByBooleanArray(params['array']);
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER OctetString<br/>
+ * @name KJUR.asn1.DEROctetString
+ * @class class for ASN.1 DER OctetString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * This class provides ASN.1 OctetString simple type.<br/>
+ * Supported "params" attributes are:
+ * <ul>
+ * <li>str - to set a string as a value</li>
+ * <li>hex - to set a hexadecimal string as a value</li>
+ * <li>obj - to set a encapsulated ASN.1 value by JSON object
+ * which is defined in {@link KJUR.asn1.ASN1Util.newObject}</li>
+ * </ul>
+ * NOTE: A parameter 'obj' have been supported
+ * for "OCTET STRING, encapsulates" structure.
+ * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
+ * @see KJUR.asn1.DERAbstractString - superclass
+ * @example
+ * // default constructor
+ * o = new KJUR.asn1.DEROctetString();
+ * // initialize with string
+ * o = new KJUR.asn1.DEROctetString({str: "aaa"});
+ * // initialize with hexadecimal string
+ * o = new KJUR.asn1.DEROctetString({hex: "616161"});
+ * // initialize with ASN1Util.newObject argument
+ * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
+ * // above generates a ASN.1 data like this:
+ * // OCTET STRING, encapsulates {
+ * //   SEQUENCE {
+ * //     INTEGER 3
+ * //     PrintableString 'aaa'
+ * //     }
+ * //   }
+ */
+KJUR.asn1.DEROctetString = function(params) {
+    if (params !== undefined && typeof params.obj !== "undefined") {
+        var o = KJUR.asn1.ASN1Util.newObject(params.obj);
+        params.hex = o.getEncodedHex();
+    }
+    KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
+    this.hT = "04";
+};
+YAHOO.lang.extend(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Null
+ * @name KJUR.asn1.DERNull
+ * @class class for ASN.1 DER Null
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * @see KJUR.asn1.ASN1Object - superclass
+ */
+KJUR.asn1.DERNull = function() {
+    KJUR.asn1.DERNull.superclass.constructor.call(this);
+    this.hT = "05";
+    this.hTLV = "0500";
+};
+YAHOO.lang.extend(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER ObjectIdentifier
+ * @name KJUR.asn1.DERObjectIdentifier
+ * @class class for ASN.1 DER ObjectIdentifier
+ * @param {Array} params associative array of parameters (ex. {'oid': '2.5.4.5'})
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERObjectIdentifier = function(params) {
+    var itox = function(i) {
+        var h = i.toString(16);
+        if (h.length == 1) h = '0' + h;
+        return h;
+    };
+    var roidtox = function(roid) {
+        var h = '';
+        var bi = new BigInteger(roid, 10);
+        var b = bi.toString(2);
+        var padLen = 7 - b.length % 7;
+        if (padLen == 7) padLen = 0;
+        var bPad = '';
+        for (var i = 0; i < padLen; i++) bPad += '0';
+        b = bPad + b;
+        for (var i = 0; i < b.length - 1; i += 7) {
+            var b8 = b.substr(i, 7);
+            if (i != b.length - 7) b8 = '1' + b8;
+            h += itox(parseInt(b8, 2));
+        }
+        return h;
+    };
+
+    KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
+    this.hT = "06";
+
+    /**
+     * set value by a hexadecimal string
+     * @name setValueHex
+     * @memberOf KJUR.asn1.DERObjectIdentifier#
+     * @function
+     * @param {String} newHexString hexadecimal value of OID bytes
+     */
+    this.setValueHex = function(newHexString) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.s = null;
+        this.hV = newHexString;
+    };
+
+    /**
+     * set value by a OID string<br/>
+     * @name setValueOidString
+     * @memberOf KJUR.asn1.DERObjectIdentifier#
+     * @function
+     * @param {String} oidString OID string (ex. 2.5.4.13)
+     * @example
+     * o = new KJUR.asn1.DERObjectIdentifier();
+     * o.setValueOidString("2.5.4.13");
+     */
+    this.setValueOidString = function(oidString) {
+        if (! oidString.match(/^[0-9.]+$/)) {
+            throw "malformed oid string: " + oidString;
+        }
+        var h = '';
+        var a = oidString.split('.');
+        var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
+        h += itox(i0);
+        a.splice(0, 2);
+        for (var i = 0; i < a.length; i++) {
+            h += roidtox(a[i]);
+        }
+        this.hTLV = null;
+        this.isModified = true;
+        this.s = null;
+        this.hV = h;
+    };
+
+    /**
+     * set value by a OID name
+     * @name setValueName
+     * @memberOf KJUR.asn1.DERObjectIdentifier#
+     * @function
+     * @param {String} oidName OID name (ex. 'serverAuth')
+     * @since 1.0.1
+     * @description
+     * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'.
+     * Otherwise raise error.
+     * @example
+     * o = new KJUR.asn1.DERObjectIdentifier();
+     * o.setValueName("serverAuth");
+     */
+    this.setValueName = function(oidName) {
+        var oid = KJUR.asn1.x509.OID.name2oid(oidName);
+        if (oid !== '') {
+            this.setValueOidString(oid);
+        } else {
+            throw "DERObjectIdentifier oidName undefined: " + oidName;
+        }
+    };
+
+    this.getFreshValueHex = function() {
+        return this.hV;
+    };
+
+    if (params !== undefined) {
+        if (typeof params === "string") {
+            if (params.match(/^[0-2].[0-9.]+$/)) {
+                this.setValueOidString(params);
+            } else {
+                this.setValueName(params);
+            }
+        } else if (params.oid !== undefined) {
+            this.setValueOidString(params.oid);
+        } else if (params.hex !== undefined) {
+            this.setValueHex(params.hex);
+        } else if (params.name !== undefined) {
+            this.setValueName(params.name);
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Enumerated
+ * @name KJUR.asn1.DEREnumerated
+ * @class class for ASN.1 DER Enumerated
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>int - specify initial ASN.1 value(V) by integer value</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ * @example
+ * new KJUR.asn1.DEREnumerated(123);
+ * new KJUR.asn1.DEREnumerated({int: 123});
+ * new KJUR.asn1.DEREnumerated({hex: '1fad'});
+ */
+KJUR.asn1.DEREnumerated = function(params) {
+    KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
+    this.hT = "0a";
+
+    /**
+     * set value by Tom Wu's BigInteger object
+     * @name setByBigInteger
+     * @memberOf KJUR.asn1.DEREnumerated#
+     * @function
+     * @param {BigInteger} bigIntegerValue to set
+     */
+    this.setByBigInteger = function(bigIntegerValue) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
+    };
+
+    /**
+     * set value by integer value
+     * @name setByInteger
+     * @memberOf KJUR.asn1.DEREnumerated#
+     * @function
+     * @param {Integer} integer value to set
+     */
+    this.setByInteger = function(intValue) {
+        var bi = new BigInteger(String(intValue), 10);
+        this.setByBigInteger(bi);
+    };
+
+    /**
+     * set value by integer value
+     * @name setValueHex
+     * @memberOf KJUR.asn1.DEREnumerated#
+     * @function
+     * @param {String} hexadecimal string of integer value
+     * @description
+     * <br/>
+     * NOTE: Value shall be represented by minimum octet length of
+     * two's complement representation.
+     */
+    this.setValueHex = function(newHexString) {
+        this.hV = newHexString;
+    };
+
+    this.getFreshValueHex = function() {
+        return this.hV;
+    };
+
+    if (typeof params != "undefined") {
+        if (typeof params['int'] != "undefined") {
+            this.setByInteger(params['int']);
+        } else if (typeof params == "number") {
+            this.setByInteger(params);
+        } else if (typeof params['hex'] != "undefined") {
+            this.setValueHex(params['hex']);
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER UTF8String
+ * @name KJUR.asn1.DERUTF8String
+ * @class class for ASN.1 DER UTF8String
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERUTF8String = function(params) {
+    KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
+    this.hT = "0c";
+};
+YAHOO.lang.extend(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER NumericString
+ * @name KJUR.asn1.DERNumericString
+ * @class class for ASN.1 DER NumericString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERNumericString = function(params) {
+    KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
+    this.hT = "12";
+};
+YAHOO.lang.extend(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER PrintableString
+ * @name KJUR.asn1.DERPrintableString
+ * @class class for ASN.1 DER PrintableString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERPrintableString = function(params) {
+    KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
+    this.hT = "13";
+};
+YAHOO.lang.extend(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER TeletexString
+ * @name KJUR.asn1.DERTeletexString
+ * @class class for ASN.1 DER TeletexString
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERTeletexString = function(params) {
+    KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
+    this.hT = "14";
+};
+YAHOO.lang.extend(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER IA5String
+ * @name KJUR.asn1.DERIA5String
+ * @class class for ASN.1 DER IA5String
+ * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+ * @extends KJUR.asn1.DERAbstractString
+ * @description
+ * @see KJUR.asn1.DERAbstractString - superclass
+ */
+KJUR.asn1.DERIA5String = function(params) {
+    KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
+    this.hT = "16";
+};
+YAHOO.lang.extend(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER UTCTime
+ * @name KJUR.asn1.DERUTCTime
+ * @class class for ASN.1 DER UTCTime
+ * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
+ * @extends KJUR.asn1.DERAbstractTime
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * <li>date - specify Date object.</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ * <h4>EXAMPLES</h4>
+ * @example
+ * d1 = new KJUR.asn1.DERUTCTime();
+ * d1.setString('130430125959Z');
+ *
+ * d2 = new KJUR.asn1.DERUTCTime({'str': '130430125959Z'});
+ * d3 = new KJUR.asn1.DERUTCTime({'date': new Date(Date.UTC(2015, 0, 31, 0, 0, 0, 0))});
+ * d4 = new KJUR.asn1.DERUTCTime('130430125959Z');
+ */
+KJUR.asn1.DERUTCTime = function(params) {
+    KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
+    this.hT = "17";
+
+    /**
+     * set value by a Date object<br/>
+     * @name setByDate
+     * @memberOf KJUR.asn1.DERUTCTime#
+     * @function
+     * @param {Date} dateObject Date object to set ASN.1 value(V)
+     * @example
+     * o = new KJUR.asn1.DERUTCTime();
+     * o.setByDate(new Date("2016/12/31"));
+     */
+    this.setByDate = function(dateObject) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.date = dateObject;
+        this.s = this.formatDate(this.date, 'utc');
+        this.hV = stohex(this.s);
+    };
+
+    this.getFreshValueHex = function() {
+        if (typeof this.date == "undefined" && typeof this.s == "undefined") {
+            this.date = new Date();
+            this.s = this.formatDate(this.date, 'utc');
+            this.hV = stohex(this.s);
+        }
+        return this.hV;
+    };
+
+    if (params !== undefined) {
+        if (params.str !== undefined) {
+            this.setString(params.str);
+        } else if (typeof params == "string" && params.match(/^[0-9]{12}Z$/)) {
+            this.setString(params);
+        } else if (params.hex !== undefined) {
+            this.setStringHex(params.hex);
+        } else if (params.date !== undefined) {
+            this.setByDate(params.date);
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER GeneralizedTime
+ * @name KJUR.asn1.DERGeneralizedTime
+ * @class class for ASN.1 DER GeneralizedTime
+ * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'})
+ * @property {Boolean} withMillis flag to show milliseconds or not
+ * @extends KJUR.asn1.DERAbstractTime
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')</li>
+ * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+ * <li>date - specify Date object.</li>
+ * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
+ * </ul>
+ * NOTE1: 'params' can be omitted.
+ * NOTE2: 'withMillis' property is supported from asn1 1.0.6.
+ */
+KJUR.asn1.DERGeneralizedTime = function(params) {
+    KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
+    this.hT = "18";
+    this.withMillis = false;
+
+    /**
+     * set value by a Date object
+     * @name setByDate
+     * @memberOf KJUR.asn1.DERGeneralizedTime#
+     * @function
+     * @param {Date} dateObject Date object to set ASN.1 value(V)
+     * @example
+     * When you specify UTC time, use 'Date.UTC' method like this:<br/>
+     * o1 = new DERUTCTime();
+     * o1.setByDate(date);
+     *
+     * date = new Date(Date.UTC(2015, 0, 31, 23, 59, 59, 0)); #2015JAN31 23:59:59
+     */
+    this.setByDate = function(dateObject) {
+        this.hTLV = null;
+        this.isModified = true;
+        this.date = dateObject;
+        this.s = this.formatDate(this.date, 'gen', this.withMillis);
+        this.hV = stohex(this.s);
+    };
+
+    this.getFreshValueHex = function() {
+        if (this.date === undefined && this.s === undefined) {
+            this.date = new Date();
+            this.s = this.formatDate(this.date, 'gen', this.withMillis);
+            this.hV = stohex(this.s);
+        }
+        return this.hV;
+    };
+
+    if (params !== undefined) {
+        if (params.str !== undefined) {
+            this.setString(params.str);
+        } else if (typeof params == "string" && params.match(/^[0-9]{14}Z$/)) {
+            this.setString(params);
+        } else if (params.hex !== undefined) {
+            this.setStringHex(params.hex);
+        } else if (params.date !== undefined) {
+            this.setByDate(params.date);
+        }
+        if (params.millis === true) {
+            this.withMillis = true;
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Sequence
+ * @name KJUR.asn1.DERSequence
+ * @class class for ASN.1 DER Sequence
+ * @extends KJUR.asn1.DERAbstractStructured
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>array - specify array of ASN1Object to set elements of content</li>
+ * </ul>
+ * NOTE: 'params' can be omitted.
+ */
+KJUR.asn1.DERSequence = function(params) {
+    KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
+    this.hT = "30";
+    this.getFreshValueHex = function() {
+        var h = '';
+        for (var i = 0; i < this.asn1Array.length; i++) {
+            var asn1Obj = this.asn1Array[i];
+            h += asn1Obj.getEncodedHex();
+        }
+        this.hV = h;
+        return this.hV;
+    };
+};
+YAHOO.lang.extend(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER Set
+ * @name KJUR.asn1.DERSet
+ * @class class for ASN.1 DER Set
+ * @extends KJUR.asn1.DERAbstractStructured
+ * @description
+ * <br/>
+ * As for argument 'params' for constructor, you can specify one of
+ * following properties:
+ * <ul>
+ * <li>array - specify array of ASN1Object to set elements of content</li>
+ * <li>sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.</li>
+ * </ul>
+ * NOTE1: 'params' can be omitted.<br/>
+ * NOTE2: sortflag is supported since 1.0.5.
+ */
+KJUR.asn1.DERSet = function(params) {
+    KJUR.asn1.DERSet.superclass.constructor.call(this, params);
+    this.hT = "31";
+    this.sortFlag = true; // item shall be sorted only in ASN.1 DER
+    this.getFreshValueHex = function() {
+        var a = new Array();
+        for (var i = 0; i < this.asn1Array.length; i++) {
+            var asn1Obj = this.asn1Array[i];
+            a.push(asn1Obj.getEncodedHex());
+        }
+        if (this.sortFlag == true) a.sort();
+        this.hV = a.join('');
+        return this.hV;
+    };
+
+    if (typeof params != "undefined") {
+        if (typeof params.sortflag != "undefined" &&
+            params.sortflag == false)
+            this.sortFlag = false;
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
+
+// ********************************************************************
+/**
+ * class for ASN.1 DER TaggedObject
+ * @name KJUR.asn1.DERTaggedObject
+ * @class class for ASN.1 DER TaggedObject
+ * @extends KJUR.asn1.ASN1Object
+ * @description
+ * <br/>
+ * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object.
+ * For example, if you find '[1]' tag in a ASN.1 dump,
+ * 'tagNoHex' will be 'a1'.
+ * <br/>
+ * As for optional argument 'params' for constructor, you can specify *ANY* of
+ * following properties:
+ * <ul>
+ * <li>explicit - specify true if this is explicit tag otherwise false
+ *     (default is 'true').</li>
+ * <li>tag - specify tag (default is 'a0' which means [0])</li>
+ * <li>obj - specify ASN1Object which is tagged</li>
+ * </ul>
+ * @example
+ * d1 = new KJUR.asn1.DERUTF8String({'str':'a'});
+ * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1});
+ * hex = d2.getEncodedHex();
+ */
+KJUR.asn1.DERTaggedObject = function(params) {
+    KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
+    this.hT = "a0";
+    this.hV = '';
+    this.isExplicit = true;
+    this.asn1Object = null;
+
+    /**
+     * set value by an ASN1Object
+     * @name setString
+     * @memberOf KJUR.asn1.DERTaggedObject#
+     * @function
+     * @param {Boolean} isExplicitFlag flag for explicit/implicit tag
+     * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag
+     * @param {ASN1Object} asn1Object ASN.1 to encapsulate
+     */
+    this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
+        this.hT = tagNoHex;
+        this.isExplicit = isExplicitFlag;
+        this.asn1Object = asn1Object;
+        if (this.isExplicit) {
+            this.hV = this.asn1Object.getEncodedHex();
+            this.hTLV = null;
+            this.isModified = true;
+        } else {
+            this.hV = null;
+            this.hTLV = asn1Object.getEncodedHex();
+            this.hTLV = this.hTLV.replace(/^../, tagNoHex);
+            this.isModified = false;
+        }
+    };
+
+    this.getFreshValueHex = function() {
+        return this.hV;
+    };
+
+    if (typeof params != "undefined") {
+        if (typeof params['tag'] != "undefined") {
+            this.hT = params['tag'];
+        }
+        if (typeof params['explicit'] != "undefined") {
+            this.isExplicit = params['explicit'];
+        }
+        if (typeof params['obj'] != "undefined") {
+            this.asn1Object = params['obj'];
+            this.setASN1Object(this.isExplicit, this.hT, this.asn1Object);
+        }
+    }
+};
+YAHOO.lang.extend(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
+
+/**
+ * Create a new JSEncryptRSAKey that extends Tom Wu's RSA key object.
+ * This object is just a decorator for parsing the key parameter
+ * @param {string|Object} key - The key in string format, or an object containing
+ * the parameters needed to build a RSAKey object.
+ * @constructor
+ */
+var JSEncryptRSAKey = /** @class */ (function (_super) {
+    __extends(JSEncryptRSAKey, _super);
+    function JSEncryptRSAKey(key) {
+        var _this = _super.call(this) || this;
+        // Call the super constructor.
+        //  RSAKey.call(this);
+        // If a key key was provided.
+        if (key) {
+            // If this is a string...
+            if (typeof key === "string") {
+                _this.parseKey(key);
+            }
+            else if (JSEncryptRSAKey.hasPrivateKeyProperty(key) ||
+                JSEncryptRSAKey.hasPublicKeyProperty(key)) {
+                // Set the values for the key.
+                _this.parsePropertiesFrom(key);
+            }
+        }
+        return _this;
+    }
+    /**
+     * Method to parse a pem encoded string containing both a public or private key.
+     * The method will translate the pem encoded string in a der encoded string and
+     * will parse private key and public key parameters. This method accepts public key
+     * in the rsaencryption pkcs #1 format (oid: 1.2.840.113549.1.1.1).
+     *
+     * @todo Check how many rsa formats use the same format of pkcs #1.
+     *
+     * The format is defined as:
+     * PublicKeyInfo ::= SEQUENCE {
+     *   algorithm       AlgorithmIdentifier,
+     *   PublicKey       BIT STRING
+     * }
+     * Where AlgorithmIdentifier is:
+     * AlgorithmIdentifier ::= SEQUENCE {
+     *   algorithm       OBJECT IDENTIFIER,     the OID of the enc algorithm
+     *   parameters      ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
+     * }
+     * and PublicKey is a SEQUENCE encapsulated in a BIT STRING
+     * RSAPublicKey ::= SEQUENCE {
+     *   modulus           INTEGER,  -- n
+     *   publicExponent    INTEGER   -- e
+     * }
+     * it's possible to examine the structure of the keys obtained from openssl using
+     * an asn.1 dumper as the one used here to parse the components: http://lapo.it/asn1js/
+     * @argument {string} pem the pem encoded string, can include the BEGIN/END header/footer
+     * @private
+     */
+    JSEncryptRSAKey.prototype.parseKey = function (pem) {
+        try {
+            var modulus = 0;
+            var public_exponent = 0;
+            var reHex = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/;
+            var der = reHex.test(pem) ? Hex.decode(pem) : Base64.unarmor(pem);
+            var asn1 = ASN1.decode(der);
+            // Fixes a bug with OpenSSL 1.0+ private keys
+            if (asn1.sub.length === 3) {
+                asn1 = asn1.sub[2].sub[0];
+            }
+            if (asn1.sub.length === 9) {
+                // Parse the private key.
+                modulus = asn1.sub[1].getHexStringValue(); // bigint
+                this.n = parseBigInt(modulus, 16);
+                public_exponent = asn1.sub[2].getHexStringValue(); // int
+                this.e = parseInt(public_exponent, 16);
+                var private_exponent = asn1.sub[3].getHexStringValue(); // bigint
+                this.d = parseBigInt(private_exponent, 16);
+                var prime1 = asn1.sub[4].getHexStringValue(); // bigint
+                this.p = parseBigInt(prime1, 16);
+                var prime2 = asn1.sub[5].getHexStringValue(); // bigint
+                this.q = parseBigInt(prime2, 16);
+                var exponent1 = asn1.sub[6].getHexStringValue(); // bigint
+                this.dmp1 = parseBigInt(exponent1, 16);
+                var exponent2 = asn1.sub[7].getHexStringValue(); // bigint
+                this.dmq1 = parseBigInt(exponent2, 16);
+                var coefficient = asn1.sub[8].getHexStringValue(); // bigint
+                this.coeff = parseBigInt(coefficient, 16);
+            }
+            else if (asn1.sub.length === 2) {
+                // Parse the public key.
+                var bit_string = asn1.sub[1];
+                var sequence = bit_string.sub[0];
+                modulus = sequence.sub[0].getHexStringValue();
+                this.n = parseBigInt(modulus, 16);
+                public_exponent = sequence.sub[1].getHexStringValue();
+                this.e = parseInt(public_exponent, 16);
+            }
+            else {
+                return false;
+            }
+            return true;
+        }
+        catch (ex) {
+            return false;
+        }
+    };
+    /**
+     * Translate rsa parameters in a hex encoded string representing the rsa key.
+     *
+     * The translation follow the ASN.1 notation :
+     * RSAPrivateKey ::= SEQUENCE {
+     *   version           Version,
+     *   modulus           INTEGER,  -- n
+     *   publicExponent    INTEGER,  -- e
+     *   privateExponent   INTEGER,  -- d
+     *   prime1            INTEGER,  -- p
+     *   prime2            INTEGER,  -- q
+     *   exponent1         INTEGER,  -- d mod (p1)
+     *   exponent2         INTEGER,  -- d mod (q-1)
+     *   coefficient       INTEGER,  -- (inverse of q) mod p
+     * }
+     * @returns {string}  DER Encoded String representing the rsa private key
+     * @private
+     */
+    JSEncryptRSAKey.prototype.getPrivateBaseKey = function () {
+        var options = {
+            array: [
+                new KJUR.asn1.DERInteger({ int: 0 }),
+                new KJUR.asn1.DERInteger({ bigint: this.n }),
+                new KJUR.asn1.DERInteger({ int: this.e }),
+                new KJUR.asn1.DERInteger({ bigint: this.d }),
+                new KJUR.asn1.DERInteger({ bigint: this.p }),
+                new KJUR.asn1.DERInteger({ bigint: this.q }),
+                new KJUR.asn1.DERInteger({ bigint: this.dmp1 }),
+                new KJUR.asn1.DERInteger({ bigint: this.dmq1 }),
+                new KJUR.asn1.DERInteger({ bigint: this.coeff })
+            ]
+        };
+        var seq = new KJUR.asn1.DERSequence(options);
+        return seq.getEncodedHex();
+    };
+    /**
+     * base64 (pem) encoded version of the DER encoded representation
+     * @returns {string} pem encoded representation without header and footer
+     * @public
+     */
+    JSEncryptRSAKey.prototype.getPrivateBaseKeyB64 = function () {
+        return hex2b64(this.getPrivateBaseKey());
+    };
+    /**
+     * Translate rsa parameters in a hex encoded string representing the rsa public key.
+     * The representation follow the ASN.1 notation :
+     * PublicKeyInfo ::= SEQUENCE {
+     *   algorithm       AlgorithmIdentifier,
+     *   PublicKey       BIT STRING
+     * }
+     * Where AlgorithmIdentifier is:
+     * AlgorithmIdentifier ::= SEQUENCE {
+     *   algorithm       OBJECT IDENTIFIER,     the OID of the enc algorithm
+     *   parameters      ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
+     * }
+     * and PublicKey is a SEQUENCE encapsulated in a BIT STRING
+     * RSAPublicKey ::= SEQUENCE {
+     *   modulus           INTEGER,  -- n
+     *   publicExponent    INTEGER   -- e
+     * }
+     * @returns {string} DER Encoded String representing the rsa public key
+     * @private
+     */
+    JSEncryptRSAKey.prototype.getPublicBaseKey = function () {
+        var first_sequence = new KJUR.asn1.DERSequence({
+            array: [
+                new KJUR.asn1.DERObjectIdentifier({ oid: "1.2.840.113549.1.1.1" }),
+                new KJUR.asn1.DERNull()
+            ]
+        });
+        var second_sequence = new KJUR.asn1.DERSequence({
+            array: [
+                new KJUR.asn1.DERInteger({ bigint: this.n }),
+                new KJUR.asn1.DERInteger({ int: this.e })
+            ]
+        });
+        var bit_string = new KJUR.asn1.DERBitString({
+            hex: "00" + second_sequence.getEncodedHex()
+        });
+        var seq = new KJUR.asn1.DERSequence({
+            array: [
+                first_sequence,
+                bit_string
+            ]
+        });
+        return seq.getEncodedHex();
+    };
+    /**
+     * base64 (pem) encoded version of the DER encoded representation
+     * @returns {string} pem encoded representation without header and footer
+     * @public
+     */
+    JSEncryptRSAKey.prototype.getPublicBaseKeyB64 = function () {
+        return hex2b64(this.getPublicBaseKey());
+    };
+    /**
+     * wrap the string in block of width chars. The default value for rsa keys is 64
+     * characters.
+     * @param {string} str the pem encoded string without header and footer
+     * @param {Number} [width=64] - the length the string has to be wrapped at
+     * @returns {string}
+     * @private
+     */
+    JSEncryptRSAKey.wordwrap = function (str, width) {
+        width = width || 64;
+        if (!str) {
+            return str;
+        }
+        var regex = "(.{1," + width + "})( +|$\n?)|(.{1," + width + "})";
+        return str.match(RegExp(regex, "g")).join("\n");
+    };
+    /**
+     * Retrieve the pem encoded private key
+     * @returns {string} the pem encoded private key with header/footer
+     * @public
+     */
+    JSEncryptRSAKey.prototype.getPrivateKey = function () {
+        var key = "-----BEGIN RSA PRIVATE KEY-----\n";
+        key += JSEncryptRSAKey.wordwrap(this.getPrivateBaseKeyB64()) + "\n";
+        key += "-----END RSA PRIVATE KEY-----";
+        return key;
+    };
+    /**
+     * Retrieve the pem encoded public key
+     * @returns {string} the pem encoded public key with header/footer
+     * @public
+     */
+    JSEncryptRSAKey.prototype.getPublicKey = function () {
+        var key = "-----BEGIN PUBLIC KEY-----\n";
+        key += JSEncryptRSAKey.wordwrap(this.getPublicBaseKeyB64()) + "\n";
+        key += "-----END PUBLIC KEY-----";
+        return key;
+    };
+    /**
+     * Check if the object contains the necessary parameters to populate the rsa modulus
+     * and public exponent parameters.
+     * @param {Object} [obj={}] - An object that may contain the two public key
+     * parameters
+     * @returns {boolean} true if the object contains both the modulus and the public exponent
+     * properties (n and e)
+     * @todo check for types of n and e. N should be a parseable bigInt object, E should
+     * be a parseable integer number
+     * @private
+     */
+    JSEncryptRSAKey.hasPublicKeyProperty = function (obj) {
+        obj = obj || {};
+        return (obj.hasOwnProperty("n") &&
+            obj.hasOwnProperty("e"));
+    };
+    /**
+     * Check if the object contains ALL the parameters of an RSA key.
+     * @param {Object} [obj={}] - An object that may contain nine rsa key
+     * parameters
+     * @returns {boolean} true if the object contains all the parameters needed
+     * @todo check for types of the parameters all the parameters but the public exponent
+     * should be parseable bigint objects, the public exponent should be a parseable integer number
+     * @private
+     */
+    JSEncryptRSAKey.hasPrivateKeyProperty = function (obj) {
+        obj = obj || {};
+        return (obj.hasOwnProperty("n") &&
+            obj.hasOwnProperty("e") &&
+            obj.hasOwnProperty("d") &&
+            obj.hasOwnProperty("p") &&
+            obj.hasOwnProperty("q") &&
+            obj.hasOwnProperty("dmp1") &&
+            obj.hasOwnProperty("dmq1") &&
+            obj.hasOwnProperty("coeff"));
+    };
+    /**
+     * Parse the properties of obj in the current rsa object. Obj should AT LEAST
+     * include the modulus and public exponent (n, e) parameters.
+     * @param {Object} obj - the object containing rsa parameters
+     * @private
+     */
+    JSEncryptRSAKey.prototype.parsePropertiesFrom = function (obj) {
+        this.n = obj.n;
+        this.e = obj.e;
+        if (obj.hasOwnProperty("d")) {
+            this.d = obj.d;
+            this.p = obj.p;
+            this.q = obj.q;
+            this.dmp1 = obj.dmp1;
+            this.dmq1 = obj.dmq1;
+            this.coeff = obj.coeff;
+        }
+    };
+    return JSEncryptRSAKey;
+}(RSAKey));
+
+/**
+ *
+ * @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
+ * possible parameters are:
+ * - default_key_size        {number}  default: 1024 the key size in bit
+ * - default_public_exponent {string}  default: '010001' the hexadecimal representation of the public exponent
+ * - log                     {boolean} default: false whether log warn/error or not
+ * @constructor
+ */
+var JSEncrypt = /** @class */ (function () {
+    function JSEncrypt(options) {
+        options = options || {};
+        this.default_key_size = parseInt(options.default_key_size, 10) || 1024;
+        this.default_public_exponent = options.default_public_exponent || "010001"; // 65537 default openssl public exponent for rsa key type
+        this.log = options.log || false;
+        // The private and public key.
+        this.key = null;
+    }
+    /**
+     * Method to set the rsa key parameter (one method is enough to set both the public
+     * and the private key, since the private key contains the public key paramenters)
+     * Log a warning if logs are enabled
+     * @param {Object|string} key the pem encoded string or an object (with or without header/footer)
+     * @public
+     */
+    JSEncrypt.prototype.setKey = function (key) {
+        if (this.log && this.key) {
+            console.warn("A key was already set, overriding existing.");
+        }
+        this.key = new JSEncryptRSAKey(key);
+    };
+    /**
+     * Proxy method for setKey, for api compatibility
+     * @see setKey
+     * @public
+     */
+    JSEncrypt.prototype.setPrivateKey = function (privkey) {
+        // Create the key.
+        this.setKey(privkey);
+    };
+    /**
+     * Proxy method for setKey, for api compatibility
+     * @see setKey
+     * @public
+     */
+    JSEncrypt.prototype.setPublicKey = function (pubkey) {
+        // Sets the public key.
+        this.setKey(pubkey);
+    };
+    /**
+     * Proxy method for RSAKey object's decrypt, decrypt the string using the private
+     * components of the rsa key object. Note that if the object was not set will be created
+     * on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
+     * @param {string} str base64 encoded crypted string to decrypt
+     * @return {string} the decrypted string
+     * @public
+     */
+    JSEncrypt.prototype.decrypt = function (str) {
+        // Return the decrypted string.
+        try {
+            return this.getKey().decrypt(b64tohex(str));
+        }
+        catch (ex) {
+            return false;
+        }
+    };
+    /**
+     * Proxy method for RSAKey object's encrypt, encrypt the string using the public
+     * components of the rsa key object. Note that if the object was not set will be created
+     * on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
+     * @param {string} str the string to encrypt
+     * @return {string} the encrypted string encoded in base64
+     * @public
+     */
+    JSEncrypt.prototype.encrypt = function (str) {
+        // Return the encrypted string.
+        try {
+            return hex2b64(this.getKey().encrypt(str));
+        }
+        catch (ex) {
+            return false;
+        }
+    };
+    /**
+     * Proxy method for RSAKey object's sign.
+     * @param {string} str the string to sign
+     * @param {function} digestMethod hash method
+     * @param {string} digestName the name of the hash algorithm
+     * @return {string} the signature encoded in base64
+     * @public
+     */
+    JSEncrypt.prototype.sign = function (str, digestMethod, digestName) {
+        // return the RSA signature of 'str' in 'hex' format.
+        try {
+            return hex2b64(this.getKey().sign(str, digestMethod, digestName));
+        }
+        catch (ex) {
+            return false;
+        }
+    };
+    /**
+     * Proxy method for RSAKey object's verify.
+     * @param {string} str the string to verify
+     * @param {string} signature the signature encoded in base64 to compare the string to
+     * @param {function} digestMethod hash method
+     * @return {boolean} whether the data and signature match
+     * @public
+     */
+    JSEncrypt.prototype.verify = function (str, signature, digestMethod) {
+        // Return the decrypted 'digest' of the signature.
+        try {
+            return this.getKey().verify(str, b64tohex(signature), digestMethod);
+        }
+        catch (ex) {
+            return false;
+        }
+    };
+    /**
+     * Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object
+     * will be created and returned
+     * @param {callback} [cb] the callback to be called if we want the key to be generated
+     * in an async fashion
+     * @returns {JSEncryptRSAKey} the JSEncryptRSAKey object
+     * @public
+     */
+    JSEncrypt.prototype.getKey = function (cb) {
+        // Only create new if it does not exist.
+        if (!this.key) {
+            // Get a new private key.
+            this.key = new JSEncryptRSAKey();
+            if (cb && {}.toString.call(cb) === "[object Function]") {
+                this.key.generateAsync(this.default_key_size, this.default_public_exponent, cb);
+                return;
+            }
+            // Generate the key.
+            this.key.generate(this.default_key_size, this.default_public_exponent);
+        }
+        return this.key;
+    };
+    /**
+     * Returns the pem encoded representation of the private key
+     * If the key doesn't exists a new key will be created
+     * @returns {string} pem encoded representation of the private key WITH header and footer
+     * @public
+     */
+    JSEncrypt.prototype.getPrivateKey = function () {
+        // Return the private representation of this key.
+        return this.getKey().getPrivateKey();
+    };
+    /**
+     * Returns the pem encoded representation of the private key
+     * If the key doesn't exists a new key will be created
+     * @returns {string} pem encoded representation of the private key WITHOUT header and footer
+     * @public
+     */
+    JSEncrypt.prototype.getPrivateKeyB64 = function () {
+        // Return the private representation of this key.
+        return this.getKey().getPrivateBaseKeyB64();
+    };
+    /**
+     * Returns the pem encoded representation of the public key
+     * If the key doesn't exists a new key will be created
+     * @returns {string} pem encoded representation of the public key WITH header and footer
+     * @public
+     */
+    JSEncrypt.prototype.getPublicKey = function () {
+        // Return the private representation of this key.
+        return this.getKey().getPublicKey();
+    };
+    /**
+     * Returns the pem encoded representation of the public key
+     * If the key doesn't exists a new key will be created
+     * @returns {string} pem encoded representation of the public key WITHOUT header and footer
+     * @public
+     */
+    JSEncrypt.prototype.getPublicKeyB64 = function () {
+        // Return the private representation of this key.
+        return this.getKey().getPublicBaseKeyB64();
+    };
+    JSEncrypt.version = "3.0.0-rc.1";
+    return JSEncrypt;
+}());
+
+if(window){
+	window.JSEncrypt = JSEncrypt;
+}
+exports.JSEncrypt = JSEncrypt;
+exports.default = JSEncrypt;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+
+

+ 82 - 72
utils/request.js

@@ -1,76 +1,86 @@
-
 //  配置请求根路径
 const BASE_URL = process.env.UNI_BASE_URL;
+import { showToast } from '@/utils/index'
+
+const request = (requesUrl, data, method = "GET") => {
+  let url = `${BASE_URL}${requesUrl}`;
+  return new Promise((resolve, reject) => {
+    let header = {
+      "Content-Type": "application/json; charset=UTF-8",
+      "Authorization-Business":uni.getStorageSync("storage_key")
+    };
+    uni.request({
+      url: url,
+      data: data,
+      method: method,
+      header: header,
+      success: (res) => {
+        if (res.statusCode == 200) {
+          if (res.data.code === "200" || res.data.code === "") {
+            resolve(res.data);
+          } else if (res.data.code === "20004" || res.data.code === "20005") {
+            uni.removeStorageSync("storage_key");
+            uni.navigateTo({
+              url: "/pages/login/index",
+            });
+          } else {
+            uni.showToast({
+              title: res.data.message,
+              icon: "none",
+            });
+          }
+        } else {
+          reject(res);
+        }
+      },
+      fail: (res) => {
+        reject(res);
+      },
+    });
+  });
+};
+//不带token接口请求,
+const request1 = (requesUrl, data, method = "GET") => {
+  let url = `${BASE_URL}${requesUrl}`;
+  return new Promise((resolve, reject) => {
+    let header = {
+      "Content-Type": "application/json; charset=UTF-8",
+    };
+    uni.request({
+      url: url,
+      data: data,
+      method: method,
+      header: header,
+      success: (res) => {
+        const { data } = res;
+        if (data.code !== "") {
+          //  判断是不是 token 过期了
+          const tokenerr = [20003, "20003", 20004, "20004", 20005, "20005"];
+          if (tokenerr.includes(data.code)) {
+            //  清除本地缓存所有的数据
+            uni.clearStorageSync();
+            setTimeout(() => {
+              //  跳转回登陆页面
+              uni.redirectTo({
+                url: "pages/login/index",
+              });
+            }, 1000);
+
+            showToast("登陆超时,请重新登陆","none",1000)
+            return;
+          }
+          // showToast(data.message || "系统突然出差了,请稍后再试","none",2000)
+          return resolve(data);
+        }
+        return resolve(data);
+      },
 
-const request = (requesUrl, data, method = 'GET') => {
-	let url = `${BASE_URL}${requesUrl}`
-	return new Promise((resolve, reject) => {
-		let header = {
-			"Content-Type": "application/json"
-		}
-		const res = uni.getStorageSync('storage_key');
-		const token = res.token
-		if (token) {
-			header['Authorization'] = token
-		}
-		uni.request({
-			url: url,
-			data: data,
-			method: method,
-			header: header,
-			success: res => {
-				if (res.statusCode == 200) {
-					if (res.data.code === "200" || res.data.code === "") {
-						resolve(res.data)
-					} else if (res.data.code === "20004" || res.data.code === "20005") {
-						uni.removeStorageSync("storage_key")
-						uni.navigateTo({
-							url: '/pages/login/index'
-						})
-					} else {
-						uni.showToast({
-							title: res.data.message,
-							icon: "none"
-						})
-					}
-				} else {
-					reject(res)
-				}
-			},
-			fail: res => {
-				reject(res)
-			},
-		})
-	});
-}
-//不带token接口请求,首页
-const request1 = (requesUrl, data, method = 'GET') => {
-	let url = `${BASE_URL}${requesUrl}`
-	return new Promise((resolve, reject) => {
-		let header = {
-			'Content-Type': 'application/json',
-			'tenant': 'MDAwMA==',
-		}
-		uni.request({
-			url: url,
-			data: data,
-			method: method,
-			header: header,
-			success: res => {
-				if (res.data.code === "200" || res.data.code == "" || data.code === "") {
-					resolve(res.data)
-				} else {
-					reject(res)
-				}
-			},
-			fail: res => {
-				reject(res)
-			}
-		})
-	});
-}
+      fail: (res) => {
+        reject(res);
+        showToast("系统突然出差了,请稍后再试","none",2000)
+      },
+    });
+  });
+};
 
-export {
-	request,
-	request1,
-}
+export { request, request1 };

+ 61 - 0
utils/rsaEncrypt.js

@@ -0,0 +1,61 @@
+import JSEncrypt from './jsencrypt'
+// import JSEncrypt from '../node_modules/jsencrypt/bin/jsencrypt.js'
+
+
+// 密钥对生成 http://web.chacuo.net/netrsakeypair
+
+const publicKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu5EcZCw8a2QAwGwuDk/d
++AQDKwqye2OG73gKvoUCkH2H47XtUHw9MOGYtG44BXrh4KYM0YqZrZIPu4FZzFTs
+0wAyhzAHRXray0l/kAfCHtI+A9bwqOwbtBFOrL2lOCuVHptEE+RPmO4v7UCGcYIK
+umb0/cOtvXAa0yM5V9kxrGXpavsLPsoB5kWQwnelW/mYyIEm4Rtvh9uKsTyfkb80
+cxJtQNlq1sOrh0dR0aSIdDGnqCrtsaNw19UBQtOe5JsdXSeZYff9vuT9lwtjvkta
+k4hI3IwtmR1STTVp8ZJ+6Oumu+QCDQvNGHzX5oBumiGPmDqPd2wyTnFsDPypc685
+MwIDAQAB`
+
+const privateKey = `MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7kRxkLDxrZADA
+bC4OT934BAMrCrJ7Y4bveAq+hQKQfYfjte1QfD0w4Zi0bjgFeuHgpgzRipmtkg+7
+gVnMVOzTADKHMAdFetrLSX+QB8Ie0j4D1vCo7Bu0EU6svaU4K5Uem0QT5E+Y7i/t
+QIZxggq6ZvT9w629cBrTIzlX2TGsZelq+ws+ygHmRZDCd6Vb+ZjIgSbhG2+H24qx
+PJ+RvzRzEm1A2WrWw6uHR1HRpIh0MaeoKu2xo3DX1QFC057kmx1dJ5lh9/2+5P2X
+C2O+S1qTiEjcjC2ZHVJNNWnxkn7o66a75AINC80YfNfmgG6aIY+YOo93bDJOcWwM
+/KlzrzkzAgMBAAECggEAQaVK84BL8SYB4Va7U8T+IeR9m13WE7tEqaEw2XdB64IT
+wk2U7jtdSzNZt6RvtPNKBM7444mHuajKGsztucbrT/nctVXI5bdWxhlGLQmaFiFt
+FPjwJ57jH0WDbI+/OIaAXULoM7IPba3HVljj9OwXhx+rlPkcYJXQvZ6xXh6k9Pno
+ezxXUT9Dt7jW9/NL6iZgy16f4DcvWQ3zazpzVfXx9+qa43QvFWvVqeqALP3Ndnw8
+6xrSQrb3I2iMc1Uj9ts4bB8BHhDomeU2GDVheNIrmpRNMl4BCoCLXDrvQC+PMJ6Y
+sbUTdf0eoCo9TbJFNX0PGvhSO0+ToDIqnKX9gnr6yQKBgQDnBJ9YlZRvfnzRKGfB
+//XyxNRDDfgD2axQS/raycynoNbHWBWd2/anEx5750EngvEapIm8xryMRrp3BPMR
+DlYZrkbCZi6zTjR7bbmXXMcRkHnXT4r8/UsP3GUPJ45DEPf/DVBk8bGe/L6UHxh6
+Tm4cAQT7Dbo34Lo4H8L8LOCMzwKBgQDP2ZvVgp6CENslLjL61lMPRtC2yrjnpJ29
+NjFBWC2R/YUoGgo1oTOCCkjMuX34ZN9So2cBMsPfCbaHHjIU9py0C6eroibm4ALu
+vf1vlgiEHL0r7qCyy9F61B8IzI1dZxgUvnBgY+dLAx+gzn+BS56veBlLpbASBoX2
+bnxAILtOXQKBgC5isDgSOK62YAuDKGo8ob6wJMqd+GmVgFLTHrhlgpE560Y1eomq
+y/i6Dwnj4iIz2YN2/C0KXntwDCqvtLp8/W7EnnKUH9Zi4ojR/EzXFSWCs+Q2lXq8
+xSCXKTeEwrzWoGT24GiUWwzIRN/q6nhMXTGERuK92+EyX1G7luQZgrDjAoGBALpM
+vGcV2umOHj8nN76pmG1a9fzBnBbU8CYGiwOc+8udR1r4bCpBwR9QBIyrvoOENr+l
+gtAKJpKl7BsUL6OmoDKpN7KZdvD93OMNHDqGaj+wWscj7poUIkFMHD0Qy6zqmSUO
+xT9AjLIprJHARX0owKVaqqGpczXU7wJBadE5BWppAoGBAOXXoxO6sWbpWTI1yBhN
+sG6576FPksdV8cJKQAT9zaQFXl+K0aXx0aADZrpm0jA7zL1jrUEvtWIeiDJ47Sdq
+tsob57LKyjiUqJT+rG0F1UMhXX4Bhx0/itmTzoXMFg2x4gCLLDsse4OYSprsZFxY
+EZ1+TtYg/zZVCOPJk39N8mIX`
+
+// 加密
+function encrypt(txt) {
+  const encryptor = new JSEncrypt()
+  encryptor.setPublicKey(publicKey) // 设置公钥
+  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
+}
+
+// 解密
+function decrypt(txt) {
+  const encryptor = new JSEncrypt()
+  encryptor.setPrivateKey(privateKey)
+  return encryptor.decrypt(txt)
+}
+
+export default {
+  encrypt,
+  decrypt
+}
+
+