parent
5077d7cefc
commit
233d47483d
@ -0,0 +1,61 @@
|
|||||||
|
const COMPANY_BASE = 'https://api-dsb.dingtax.cn/dsb/tax-appoint/api/dx/third'
|
||||||
|
|
||||||
|
const isCompanyOk = (body) => {
|
||||||
|
if (!body || typeof body !== 'object') return false
|
||||||
|
if (body.respCode !== undefined && Number(body.respCode) !== 0) return false
|
||||||
|
const code = body.code
|
||||||
|
if (code === undefined || code === null || code === '') return true
|
||||||
|
return code === 0 || code === '0' || code === 200 || code === '200'
|
||||||
|
}
|
||||||
|
|
||||||
|
const companyPost = (path, payload) => {
|
||||||
|
const token = uni.getStorageSync('token') || ''
|
||||||
|
const header = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
if (token) {
|
||||||
|
header.token = token
|
||||||
|
header.Authorization = `Bearer ${token}`
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: `${COMPANY_BASE}${path}`,
|
||||||
|
method: 'POST',
|
||||||
|
data: payload,
|
||||||
|
header,
|
||||||
|
timeout: 20000,
|
||||||
|
success: (res) => {
|
||||||
|
let body = res.data
|
||||||
|
if (typeof body === 'string') {
|
||||||
|
try {
|
||||||
|
body = JSON.parse(body)
|
||||||
|
} catch (error) {
|
||||||
|
reject(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Number(res.statusCode) !== 200 || !isCompanyOk(body)) {
|
||||||
|
reject(body || res)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resolve(body)
|
||||||
|
},
|
||||||
|
fail: (err) => reject(err),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const searchCompanyPage = (params = {}) => {
|
||||||
|
return companyPost('/company/info/page', {
|
||||||
|
zjhm: params.zjhm,
|
||||||
|
pageNum: params.pageNum || 1,
|
||||||
|
pageSize: params.pageSize || 50,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getCompanyRisk = (params = {}) => {
|
||||||
|
return companyPost('/company/risk/info', {
|
||||||
|
zjhm: params.zjhm,
|
||||||
|
djxh: params.djxh,
|
||||||
|
})
|
||||||
|
}
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,67 @@
|
|||||||
|
// 验证将嵌入页面的纯 JS MD5 —— 采用已按 RFC 1321 向量验证通过的 Wikipedia 伪代码式实现(无符号运算)
|
||||||
|
var MD5 = (function(){
|
||||||
|
"use strict";
|
||||||
|
var K = []; for (var i = 0; i < 64; i++) K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296) >>> 0;
|
||||||
|
var S = [7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,
|
||||||
|
5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,
|
||||||
|
4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,
|
||||||
|
6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21];
|
||||||
|
function rotl(x,c){ return ((x << c) | (x >>> (32 - c))) >>> 0; }
|
||||||
|
|
||||||
|
function md5bytes(bytes){
|
||||||
|
var msg = bytes.slice();
|
||||||
|
msg.push(0x80);
|
||||||
|
while (msg.length % 64 !== 56) msg.push(0);
|
||||||
|
var bitLen = bytes.length * 8;
|
||||||
|
for (var i = 0; i < 8; i++) msg.push(Math.floor(bitLen / Math.pow(2, 8*i)) & 0xFF);
|
||||||
|
|
||||||
|
var a0 = 0x67452301, b0 = 0xefcdab89, c0 = 0x98badcfe, d0 = 0x10325476;
|
||||||
|
for (var off = 0; off < msg.length; off += 64) {
|
||||||
|
var M = [];
|
||||||
|
for (var j = 0; j < 16; j++) M[j] = (msg[off+4*j] | (msg[off+4*j+1] << 8) | (msg[off+4*j+2] << 16) | (msg[off+4*j+3] << 24)) >>> 0;
|
||||||
|
var A = a0, B = b0, C = c0, D = d0;
|
||||||
|
for (i = 0; i < 64; i++) {
|
||||||
|
var F, g;
|
||||||
|
if (i < 16) { F = (B & C) | (~B & D); g = i; }
|
||||||
|
else if (i < 32) { F = (D & B) | (~D & C); g = (5*i + 1) % 16; }
|
||||||
|
else if (i < 48) { F = B ^ C ^ D; g = (3*i + 5) % 16; }
|
||||||
|
else { F = C ^ (B | ~D); g = (7*i) % 16; }
|
||||||
|
F = (F + A + K[i] + M[g]) >>> 0;
|
||||||
|
var oB = B; A = D; D = C; C = B;
|
||||||
|
B = (oB + rotl(F, S[i])) >>> 0;
|
||||||
|
}
|
||||||
|
a0 = (a0 + A) >>> 0; b0 = (b0 + B) >>> 0; c0 = (c0 + C) >>> 0; d0 = (d0 + D) >>> 0;
|
||||||
|
}
|
||||||
|
function hex(n){
|
||||||
|
var s = "";
|
||||||
|
for (var q = 0; q < 4; q++) s += ((n >>> (8*q)) & 0xFF).toString(16).padStart(2, "0");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
return hex(a0) + hex(b0) + hex(c0) + hex(d0);
|
||||||
|
}
|
||||||
|
return function(text){ return md5bytes(Array.from(new TextEncoder().encode(text))); };
|
||||||
|
})();
|
||||||
|
|
||||||
|
// RFC 1321 全部标准向量 + Node crypto 交叉验证 + sign 黄金样本
|
||||||
|
var crypto = require("crypto");
|
||||||
|
var vectors = [
|
||||||
|
["", "d41d8cd98f00b204e9800998ecf8427e"],
|
||||||
|
["a", "0cc175b9c0f1b6a831c399e269772661"],
|
||||||
|
["abc", "900150983cd24fb0d6963f7d28e17f72"],
|
||||||
|
["message digest", "f96b697d7cb7938d525a2f31aaf161d0"],
|
||||||
|
["abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b"],
|
||||||
|
["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f"],
|
||||||
|
["12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a"]
|
||||||
|
];
|
||||||
|
var fail = 0;
|
||||||
|
vectors.forEach(function(v){
|
||||||
|
var got = MD5(v[0]);
|
||||||
|
if (got !== v[1]) { console.log("FAIL:", JSON.stringify(v[0]).slice(0,40), "got", got); fail++; }
|
||||||
|
});
|
||||||
|
["中文测试身份信息","J4jfHM+yZFENVRar0N+/NxgQzgEAdluPWGVyQ4Csq9A=","430703198610010059"].forEach(function(cn){
|
||||||
|
if (MD5(cn) !== crypto.createHash("md5").update(cn,"utf8").digest("hex")) { console.log("CN FAIL:", cn); fail++; }
|
||||||
|
});
|
||||||
|
var sign = MD5("D5flYECKtjoOaXB5UiHkO0DKYvmCk7dFFW7plSwDhPI=" + "1789254840029" + "CKtjoOaXB5UiHkO0DKYvmCk7dFFW7plSwDhPI=" + "1789254840029".slice(6)).toUpperCase();
|
||||||
|
if (sign !== "4CB87B6061991364D261753E3291F2A1") { console.log("SIGN FAIL:", sign); fail++; }
|
||||||
|
console.log(fail === 0 ? "MD5 + SIGN ALL VERIFIED" : "FAILED: " + fail);
|
||||||
|
process.exit(fail ? 1 : 0);
|
||||||
@ -0,0 +1,136 @@
|
|||||||
|
<template>
|
||||||
|
<view class="page-container bg-white">
|
||||||
|
<view class="top-bar">
|
||||||
|
<tn-button
|
||||||
|
width="90px"
|
||||||
|
height="32px"
|
||||||
|
:plain="true"
|
||||||
|
text-color="#0099ff"
|
||||||
|
@click="goBack"
|
||||||
|
>
|
||||||
|
<uni-icons
|
||||||
|
type="arrow-left"
|
||||||
|
size="18"
|
||||||
|
color="#0099ff"
|
||||||
|
style="margin-right: 5px"
|
||||||
|
></uni-icons
|
||||||
|
>返回
|
||||||
|
</tn-button>
|
||||||
|
<text class="title">运行日志</text>
|
||||||
|
<tn-button
|
||||||
|
width="90px"
|
||||||
|
height="32px"
|
||||||
|
:plain="true"
|
||||||
|
text-color="#fa541c"
|
||||||
|
@click="handleClear"
|
||||||
|
>
|
||||||
|
清空日志
|
||||||
|
</tn-button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view
|
||||||
|
class="log-scroll"
|
||||||
|
scroll-y
|
||||||
|
:scroll-into-view="scrollIntoView"
|
||||||
|
scroll-with-animation
|
||||||
|
>
|
||||||
|
<text v-if="!logText" class="log-empty">暂无日志</text>
|
||||||
|
<text v-else class="log-text" selectable>{{ logText }}</text>
|
||||||
|
<view id="log-bottom" class="log-bottom"></view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { clearLogs, getLogsText } from '@/utils/appLog.js'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { nextTick, ref } from 'vue'
|
||||||
|
|
||||||
|
const logText = ref('')
|
||||||
|
const scrollIntoView = ref('')
|
||||||
|
|
||||||
|
const refreshLogs = async () => {
|
||||||
|
logText.value = getLogsText()
|
||||||
|
scrollIntoView.value = ''
|
||||||
|
await nextTick()
|
||||||
|
scrollIntoView.value = 'log-bottom'
|
||||||
|
}
|
||||||
|
|
||||||
|
const goBack = () => {
|
||||||
|
uni.navigateBack({
|
||||||
|
fail: () => {
|
||||||
|
uni.navigateTo({ url: '/pages/index/index' })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClear = () => {
|
||||||
|
uni.showModal({
|
||||||
|
title: '清空日志',
|
||||||
|
content: '确认清空全部运行日志吗?',
|
||||||
|
success: (res) => {
|
||||||
|
if (!res.confirm) return
|
||||||
|
clearLogs()
|
||||||
|
refreshLogs()
|
||||||
|
uni.showToast({ title: '已清空', icon: 'none' })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
refreshLogs()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page-container {
|
||||||
|
min-height: var(--pad-h);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: calc(6 * var(--pad-vh)) 20px 10px;
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-scroll {
|
||||||
|
flex: 1;
|
||||||
|
height: 0;
|
||||||
|
margin: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
background: #111827;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-text {
|
||||||
|
display: block;
|
||||||
|
color: #d1fae5;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.6;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
font-family: Consolas, Monaco, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-empty {
|
||||||
|
color: #9ca3af;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-bottom {
|
||||||
|
height: 1px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,271 @@
|
|||||||
|
<template>
|
||||||
|
<view class="page-container">
|
||||||
|
<view class="page-toolbar">
|
||||||
|
<button class="btn btn-ghost back-btn" @click="goBack">
|
||||||
|
<uni-icons type="arrow-left" size="18" color="#1e3a8a"></uni-icons>
|
||||||
|
返回
|
||||||
|
</button>
|
||||||
|
<view class="toolbar-title-wrap">
|
||||||
|
<text class="toolbar-title">待办事项</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="add-bar">
|
||||||
|
<input
|
||||||
|
v-model="draft"
|
||||||
|
class="add-input"
|
||||||
|
confirm-type="done"
|
||||||
|
placeholder="请输入待办内容"
|
||||||
|
@confirm="addTodo"
|
||||||
|
/>
|
||||||
|
<button class="btn btn-primary add-btn" @click="addTodo">添加</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view class="todo-list" scroll-y>
|
||||||
|
<view v-if="todos.length === 0" class="empty-text">暂无待办事项</view>
|
||||||
|
<view v-for="item in todos" :key="item.id" class="todo-item">
|
||||||
|
<view class="todo-check" @click="toggleTodo(item.id)">
|
||||||
|
<uni-icons
|
||||||
|
:type="item.done ? 'checkbox-filled' : 'smallcircle'"
|
||||||
|
size="22"
|
||||||
|
:color="item.done ? '#2563eb' : '#94a3b8'"
|
||||||
|
></uni-icons>
|
||||||
|
</view>
|
||||||
|
<input
|
||||||
|
class="todo-input"
|
||||||
|
:class="{ 'todo-input-done': item.done }"
|
||||||
|
:value="item.text"
|
||||||
|
@blur="onTodoBlur(item.id, $event)"
|
||||||
|
/>
|
||||||
|
<button class="btn btn-ghost del-btn" @click="removeTodo(item.id)">
|
||||||
|
删除
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
createDutyTodo,
|
||||||
|
loadDutyTodos,
|
||||||
|
saveDutyTodos,
|
||||||
|
} from "@/utils/dutyTodos.js";
|
||||||
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
|
import { ref } from "vue";
|
||||||
|
|
||||||
|
const draft = ref("");
|
||||||
|
const todos = ref([]);
|
||||||
|
|
||||||
|
const persist = (next) => {
|
||||||
|
todos.value = saveDutyTodos(next);
|
||||||
|
};
|
||||||
|
|
||||||
|
const addTodo = () => {
|
||||||
|
const text = String(draft.value || "").trim();
|
||||||
|
if (!text) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "请输入待办内容",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
persist([createDutyTodo(text), ...todos.value]);
|
||||||
|
draft.value = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateTodo = (id, value) => {
|
||||||
|
const text = String(value || "").trim();
|
||||||
|
persist(
|
||||||
|
todos.value
|
||||||
|
.map((item) => (item.id === id ? { ...item, text } : item))
|
||||||
|
.filter((item) => item.text),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onTodoBlur = (id, event) => {
|
||||||
|
updateTodo(id, event?.detail?.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleTodo = (id) => {
|
||||||
|
persist(
|
||||||
|
todos.value.map((item) =>
|
||||||
|
item.id === id ? { ...item, done: !item.done } : item,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeTodo = (id) => {
|
||||||
|
persist(todos.value.filter((item) => item.id !== id));
|
||||||
|
};
|
||||||
|
|
||||||
|
const goBack = () => {
|
||||||
|
uni.navigateBack({
|
||||||
|
fail: () => {
|
||||||
|
uni.navigateTo({ url: "/pages/index/index" });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
todos.value = loadDutyTodos();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.page-container {
|
||||||
|
height: var(--pad-h);
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: #eef3f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-toolbar {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
gap: 12px;
|
||||||
|
padding: calc(env(safe-area-inset-top) + 10px) 20px 10px;
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 1px solid #d7e2ee;
|
||||||
|
box-shadow: 0 8px 24px rgba(30, 58, 138, 0.06);
|
||||||
|
z-index: 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-toolbar button {
|
||||||
|
width: auto;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-btn {
|
||||||
|
width: auto;
|
||||||
|
min-width: 84px;
|
||||||
|
height: 40px;
|
||||||
|
padding: 0 14px;
|
||||||
|
margin: 0;
|
||||||
|
gap: 4px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-title-wrap {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding-left: 10px;
|
||||||
|
border-left: 3px solid #1d4ed8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1e3a8a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-bar {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 14px 20px;
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 1px solid #d7e2ee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-input {
|
||||||
|
flex: 1;
|
||||||
|
height: 42px;
|
||||||
|
padding: 0 12px;
|
||||||
|
background: #f4f7fb;
|
||||||
|
border: 1px solid #d7e2ee;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #1e293b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-btn {
|
||||||
|
width: 88px;
|
||||||
|
height: 42px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todo-list {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 12px 20px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
padding: 48px 0;
|
||||||
|
text-align: center;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todo-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #d7e2ee;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todo-check {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todo-input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: 36px;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #1e293b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todo-input-done {
|
||||||
|
color: #94a3b8;
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
|
||||||
|
.del-btn {
|
||||||
|
width: auto;
|
||||||
|
min-width: 64px;
|
||||||
|
height: 32px;
|
||||||
|
padding: 0 12px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
width: auto;
|
||||||
|
min-width: 84px;
|
||||||
|
height: 32px;
|
||||||
|
margin: 0;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
border: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn::after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: #2563eb;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-ghost {
|
||||||
|
background: #fff;
|
||||||
|
color: #1e3a8a;
|
||||||
|
border: 1px solid #c7d7ea;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,119 @@
|
|||||||
|
const AES_KEY = 'Gi4swf3llyafmsuK'
|
||||||
|
|
||||||
|
const sbox = new Uint8Array([
|
||||||
|
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
||||||
|
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
||||||
|
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
||||||
|
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
||||||
|
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
||||||
|
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
||||||
|
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
||||||
|
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
||||||
|
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
||||||
|
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
||||||
|
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
||||||
|
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
||||||
|
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
||||||
|
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
||||||
|
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
||||||
|
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16,
|
||||||
|
])
|
||||||
|
|
||||||
|
const RCON = [1, 2, 4, 8, 16, 32, 64, 128, 27, 54]
|
||||||
|
|
||||||
|
const expandKey = (keyBytes) => {
|
||||||
|
const rk = new Uint8Array(176)
|
||||||
|
let i = 16
|
||||||
|
let rconIdx = 0
|
||||||
|
rk.set(keyBytes)
|
||||||
|
while (i < 176) {
|
||||||
|
let t = [rk[i - 4], rk[i - 3], rk[i - 2], rk[i - 1]]
|
||||||
|
if (i % 16 === 0) {
|
||||||
|
t = [sbox[t[1]] ^ RCON[rconIdx++], sbox[t[2]], sbox[t[3]], sbox[t[0]]]
|
||||||
|
}
|
||||||
|
for (let j = 0; j < 4; j++) {
|
||||||
|
rk[i] = rk[i - 16] ^ t[j]
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rk
|
||||||
|
}
|
||||||
|
|
||||||
|
const xtime = (a) => ((a << 1) ^ (a & 128 ? 27 : 0)) & 255
|
||||||
|
|
||||||
|
const mul = (a, b) => {
|
||||||
|
let r = 0
|
||||||
|
while (b) {
|
||||||
|
if (b & 1) r ^= a
|
||||||
|
a = xtime(a)
|
||||||
|
b >>= 1
|
||||||
|
}
|
||||||
|
return r & 255
|
||||||
|
}
|
||||||
|
|
||||||
|
const encryptBlock = (b, rk) => {
|
||||||
|
for (let i = 0; i < 16; i++) b[i] ^= rk[i]
|
||||||
|
for (let round = 1; round <= 10; round++) {
|
||||||
|
for (let i = 0; i < 16; i++) b[i] = sbox[b[i]]
|
||||||
|
for (let r = 1; r < 4; r++) {
|
||||||
|
const row = [b[r], b[r + 4], b[r + 8], b[r + 12]]
|
||||||
|
for (let c = 0; c < 4; c++) b[r + 4 * c] = row[(c + r) % 4]
|
||||||
|
}
|
||||||
|
if (round < 10) {
|
||||||
|
for (let c = 0; c < 4; c++) {
|
||||||
|
const o = 4 * c
|
||||||
|
const a0 = b[o]
|
||||||
|
const a1 = b[o + 1]
|
||||||
|
const a2 = b[o + 2]
|
||||||
|
const a3 = b[o + 3]
|
||||||
|
b[o] = mul(a0, 2) ^ mul(a1, 3) ^ a2 ^ a3
|
||||||
|
b[o + 1] = a0 ^ mul(a1, 2) ^ mul(a2, 3) ^ a3
|
||||||
|
b[o + 2] = a0 ^ a1 ^ mul(a2, 2) ^ mul(a3, 3)
|
||||||
|
b[o + 3] = mul(a0, 3) ^ a1 ^ a2 ^ mul(a3, 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < 16; i++) b[i] ^= rk[16 * round + i]
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
const pkcs7 = (bytes) => {
|
||||||
|
const pad = 16 - (bytes.length % 16)
|
||||||
|
const out = new Uint8Array(bytes.length + pad)
|
||||||
|
out.set(bytes)
|
||||||
|
out.fill(pad, bytes.length)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
const b2a = (bytes) => {
|
||||||
|
let s = ''
|
||||||
|
for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i])
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
const utf8Bytes = (text) => {
|
||||||
|
if (typeof TextEncoder !== 'undefined') {
|
||||||
|
return new TextEncoder().encode(text)
|
||||||
|
}
|
||||||
|
const escaped = unescape(encodeURIComponent(text))
|
||||||
|
const out = new Uint8Array(escaped.length)
|
||||||
|
for (let i = 0; i < escaped.length; i++) out[i] = escaped.charCodeAt(i) & 255
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
export const encryptAesEcb = (plainText, keyStr = AES_KEY) => {
|
||||||
|
const text = String(plainText ?? '')
|
||||||
|
if (!text) return ''
|
||||||
|
if (String(keyStr).length !== 16) {
|
||||||
|
throw new Error('密钥长度必须为 16 位')
|
||||||
|
}
|
||||||
|
const data = pkcs7(utf8Bytes(text))
|
||||||
|
const rk = expandKey(utf8Bytes(keyStr))
|
||||||
|
let out = ''
|
||||||
|
for (let off = 0; off < data.length; off += 16) {
|
||||||
|
const b = data.slice(off, off + 16)
|
||||||
|
encryptBlock(b, rk)
|
||||||
|
out += b2a(b)
|
||||||
|
}
|
||||||
|
return btoa(out)
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
const FALLBACK_VERSION = '1.2.1'
|
||||||
|
|
||||||
|
export const getAppVersion = () => {
|
||||||
|
try {
|
||||||
|
const info = uni.getSystemInfoSync() || {}
|
||||||
|
return info.appWgtVersion || info.appVersion || FALLBACK_VERSION
|
||||||
|
} catch (error) {
|
||||||
|
return FALLBACK_VERSION
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
const STORAGE_KEY = "dutyTodos";
|
||||||
|
|
||||||
|
export const loadDutyTodos = () => {
|
||||||
|
try {
|
||||||
|
const raw = uni.getStorageSync(STORAGE_KEY);
|
||||||
|
const list = typeof raw === "string" ? JSON.parse(raw) : raw;
|
||||||
|
if (!Array.isArray(list)) return [];
|
||||||
|
return list
|
||||||
|
.map((item) => ({
|
||||||
|
id: String(item?.id || ""),
|
||||||
|
text: String(item?.text || "").trim(),
|
||||||
|
done: Boolean(item?.done),
|
||||||
|
}))
|
||||||
|
.filter((item) => item.id && item.text);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("读取待办事项失败", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveDutyTodos = (list) => {
|
||||||
|
const next = Array.isArray(list) ? list : [];
|
||||||
|
uni.setStorageSync(STORAGE_KEY, JSON.stringify(next));
|
||||||
|
return next;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createDutyTodo = (text) => ({
|
||||||
|
id: `${Date.now()}-${Math.random().toString(16).slice(2, 8)}`,
|
||||||
|
text: String(text || "").trim(),
|
||||||
|
done: false,
|
||||||
|
});
|
||||||
@ -0,0 +1,143 @@
|
|||||||
|
import { getCompanyRisk, searchCompanyPage } from '@/api/company.js'
|
||||||
|
import { encryptAesEcb } from '@/utils/aesEcb.js'
|
||||||
|
|
||||||
|
const healthCache = new Map()
|
||||||
|
const healthInflight = new Map()
|
||||||
|
|
||||||
|
const listLen = (value) => (Array.isArray(value) ? value.length : 0)
|
||||||
|
|
||||||
|
const personIdCard = (row) => String(row?.idCard || '').trim()
|
||||||
|
|
||||||
|
const mapPool = async (items, limit, mapper) => {
|
||||||
|
const result = new Array(items.length)
|
||||||
|
let cursor = 0
|
||||||
|
const worker = async () => {
|
||||||
|
while (cursor < items.length) {
|
||||||
|
const index = cursor
|
||||||
|
cursor += 1
|
||||||
|
result[index] = await mapper(items[index], index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const size = Math.min(Math.max(limit, 1), items.length || 1)
|
||||||
|
await Promise.all(Array.from({ length: size }, () => worker()))
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchCompanyList = async (zjhm) => {
|
||||||
|
const pageSize = 50
|
||||||
|
let pageNum = 1
|
||||||
|
let all = []
|
||||||
|
let total = 0
|
||||||
|
while (pageNum <= 10) {
|
||||||
|
const res = await searchCompanyPage({ zjhm, pageNum, pageSize })
|
||||||
|
const list = Array.isArray(res?.data) ? res.data : []
|
||||||
|
total = Number(res?.count) || 0
|
||||||
|
all = all.concat(list)
|
||||||
|
if (list.length < pageSize || (total > 0 && all.length >= total)) break
|
||||||
|
pageNum += 1
|
||||||
|
}
|
||||||
|
return all
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildHealth = (companies, risks) => {
|
||||||
|
let violation = 0
|
||||||
|
let undeclare = 0
|
||||||
|
let owing = 0
|
||||||
|
let abnormal = 0
|
||||||
|
const details = companies.map((company, index) => {
|
||||||
|
const risk = risks[index] || null
|
||||||
|
const nsr = risk?.nsrxx || {}
|
||||||
|
const wfwz = listLen(risk?.wfwzxxList)
|
||||||
|
const wsb = listLen(risk?.sfzwsbList) + listLen(risk?.cwbbwsbList)
|
||||||
|
const qj = listLen(risk?.sfqjxxList)
|
||||||
|
violation += wfwz
|
||||||
|
undeclare += wsb
|
||||||
|
owing += qj
|
||||||
|
const ztDm = String(nsr.nsrztDm || company.nsrztDm || '')
|
||||||
|
if (ztDm && ztDm !== '03') abnormal += 1
|
||||||
|
return {
|
||||||
|
nsrmc: nsr.nsrmc || company.nsrmc || '',
|
||||||
|
nsrsbh: nsr.shxydm || nsr.nsrsbh || company.nsrsbh || '',
|
||||||
|
djxh: nsr.djxh || company.djxh || '',
|
||||||
|
nsrztDm: ztDm,
|
||||||
|
nsrztmc: nsr.nsrztmc || '',
|
||||||
|
fddbrxm: nsr.fddbrxm || company.fddbrxm || '',
|
||||||
|
violation: wfwz,
|
||||||
|
undeclare: wsb,
|
||||||
|
owing: qj,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
companyCount: companies.length,
|
||||||
|
abnormal,
|
||||||
|
violation,
|
||||||
|
undeclare,
|
||||||
|
owing,
|
||||||
|
details,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryPersonHealth = async (idCard) => {
|
||||||
|
const zjhm = encryptAesEcb(idCard)
|
||||||
|
const companies = await fetchCompanyList(zjhm)
|
||||||
|
const risks = await mapPool(companies, 3, async (company) => {
|
||||||
|
const djxh = String(company?.djxh || '').trim()
|
||||||
|
if (!djxh) return null
|
||||||
|
try {
|
||||||
|
const res = await getCompanyRisk({
|
||||||
|
zjhm,
|
||||||
|
djxh: encryptAesEcb(djxh),
|
||||||
|
})
|
||||||
|
return res?.data || null
|
||||||
|
} catch (error) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return buildHealth(companies, risks)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getHealthState = (row) => {
|
||||||
|
const idCard = personIdCard(row)
|
||||||
|
if (!idCard) {
|
||||||
|
return { unavailable: true, reason: '无身份证,暂无法体检' }
|
||||||
|
}
|
||||||
|
if (healthCache.has(idCard)) {
|
||||||
|
return healthCache.get(idCard)
|
||||||
|
}
|
||||||
|
return { loading: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const loadHealthForRecords = async (records, onUpdate) => {
|
||||||
|
const list = Array.isArray(records) ? records : []
|
||||||
|
const need = []
|
||||||
|
const seen = new Set()
|
||||||
|
list.forEach((row) => {
|
||||||
|
const idCard = personIdCard(row)
|
||||||
|
if (!idCard || seen.has(idCard)) return
|
||||||
|
seen.add(idCard)
|
||||||
|
if (healthCache.has(idCard) || healthInflight.has(idCard)) return
|
||||||
|
need.push(idCard)
|
||||||
|
})
|
||||||
|
if (!need.length) return
|
||||||
|
if (typeof onUpdate === 'function') onUpdate()
|
||||||
|
await Promise.all(
|
||||||
|
need.map(async (idCard) => {
|
||||||
|
const task = queryPersonHealth(idCard)
|
||||||
|
.then((health) => {
|
||||||
|
healthCache.set(idCard, health)
|
||||||
|
return health
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
const failed = { queryFail: true, reason: '体检查询失败' }
|
||||||
|
healthCache.set(idCard, failed)
|
||||||
|
return failed
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
healthInflight.delete(idCard)
|
||||||
|
})
|
||||||
|
healthInflight.set(idCard, task)
|
||||||
|
await task
|
||||||
|
if (typeof onUpdate === 'function') onUpdate()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue