20 Commits

Author SHA1 Message Date
f1daab1193 1 2025-11-03 13:40:27 +08:00
64426e6834 修改配置 2025-11-03 09:35:43 +08:00
wuzhimiao
18e21f366d Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	main.js
2025-11-03 09:33:53 +08:00
wuzhimiao
97922abde8 提交11月3日 2025-11-03 09:32:51 +08:00
a34e86ae60 Merge branch 'dev' of http://124.243.245.42:3000/sdz/ks-app-employment-service into dev 2025-11-03 08:48:44 +08:00
3f472bda8a 修改引用 2025-11-03 08:48:43 +08:00
wuzhimiao
228800c214 Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	packageRc/api/company/index.js
#	unpackage/dist/dev/mp-weixin/project.config.json
2025-10-31 18:43:51 +08:00
wuzhimiao
a8742d4521 提交10.31 2025-10-31 18:43:06 +08:00
46e3659d98 Merge branch 'main' of http://124.243.245.42:3000/sdz/ks-app-employment-service into dev 2025-10-31 18:25:20 +08:00
1d6bf629ec 添加功能 2025-10-31 17:48:31 +08:00
wuzhimiao
5859560694 Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	main.js
2025-10-31 11:05:02 +08:00
wuzhimiao
a6c7678a5e 提交1 2025-10-31 11:04:16 +08:00
b00396d056 Merge branch 'kashi' of http://124.243.245.42:3000/sdz/ks-app-employment-service into dev 2025-10-31 09:47:49 +08:00
wuzhimiao
e84b367360 提交 2025-10-31 09:30:04 +08:00
7369be7fce 优化 2025-10-30 17:17:15 +08:00
6579abe021 合并 智慧就业第一版 2025-10-30 11:29:57 +08:00
577b20661a Merge branch 'kashi' of http://124.243.245.42:3000/sdz/ks-app-employment-service into kashi 2025-10-23 15:06:55 +08:00
fc345ad26b 修改 2025-10-23 15:05:24 +08:00
95bc79b1d3 注释问题 2025-10-23 15:04:00 +08:00
5b1d11eb37 测试 2025-10-23 14:36:38 +08:00
587 changed files with 2835320 additions and 32607 deletions

8
.idea/.gitignore generated vendored
View File

@@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

92
.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="d1c3f1c8-c1f7-4e7b-8f95-b53233831e5a" name="更改" comment="">
<change beforePath="$PROJECT_DIR$/main.js" beforeDir="false" afterPath="$PROJECT_DIR$/main.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/manifest.json" beforeDir="false" afterPath="$PROJECT_DIR$/manifest.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/packageRc/pages/daiban/daiban.vue" beforeDir="false" afterPath="$PROJECT_DIR$/packageRc/pages/daiban/daiban.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/packageRc/pages/index/index.vue" beforeDir="false" afterPath="$PROJECT_DIR$/packageRc/pages/index/index.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages.json" beforeDir="false" afterPath="$PROJECT_DIR$/pages.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/login/login.vue" beforeDir="false" afterPath="$PROJECT_DIR$/pages/login/login.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unpackage/dist/cache/.vite/deps/_metadata.json" beforeDir="false" afterPath="$PROJECT_DIR$/unpackage/dist/cache/.vite/deps/_metadata.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unpackage/dist/cache/.vite/deps/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/unpackage/dist/cache/.vite/deps/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unpackage/dist/dev/mp-weixin/project.config.json" beforeDir="false" afterPath="$PROJECT_DIR$/unpackage/dist/dev/mp-weixin/project.config.json" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="kashi" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 5
}</component>
<component name="ProjectId" id="34d7ujHT03QwPL2xzGtFFa7cAse" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;dev&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;ts.external.directory.path&quot;: &quot;C:\\Program Files\\JetBrains\\WebStorm 2025.1\\plugins\\javascript-plugin\\jsLanguageServicesImpl\\external&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-d6986cc7102b-f27c65a3e318-JavaScript-WS-251.23774.424" />
</set>
</attachedChunks>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="d1c3f1c8-c1f7-4e7b-8f95-b53233831e5a" name="更改" comment="" />
<created>1761531820211</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1761531820211</updated>
<workItem from="1761531821927" duration="3212000" />
<workItem from="1761552146567" duration="49000" />
<workItem from="1761553662904" duration="1204000" />
<workItem from="1761795269754" duration="1248000" />
<workItem from="1761819899814" duration="2588000" />
<workItem from="1761873794088" duration="313000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>

View File

@@ -13,10 +13,10 @@ onLaunch((options) => {
// 先尝试从缓存恢复用户信息
const restored = useUserStore().restoreUserInfo();
// 用户信息恢复后再初始化自定义tabbar
tabbarManager.initTabBar();
if (restored) {
// 如果成功恢复用户信息验证token是否有效
let token = uni.getStorageSync('token') || '';
@@ -54,8 +54,9 @@ onHide(() => {
});
</script>
<style>
<style lang="scss">
/*每个页面公共css */
// @import 'uview-ui/index.scss';
@import '@/common/animation.css';
@import '@/common/common.css';
/* 引入阿里图标库 */

View File

@@ -1,4 +1,4 @@
import request from '@/packageCa/utilCa/request.js'
import request from '@/utilB/request.js'
const api = {}
// 获取职业大类 中类
@@ -9,4 +9,3 @@ api.queryJobListByParentCode = (name,code) => request.globalRequest(`/Job/QueryJ
api.queryJobDetailById = (id) => request.globalRequest(`/Job/QueryJobDetailById?id=${id}`,'GET', {}, 2,3)
export default api

View File

@@ -1,4 +1,4 @@
import request from '@/packageCa/utilCa/request.js'
import request from '@/utilB/request.js'
const api = {}
// 获取生涯罗盘
@@ -22,12 +22,4 @@ api.queryPlanList = (encodeId) => request.globalRequest(`/StudentProfile/QueryPl
api.savePlanList = (data) => request.globalRequest(`/StudentProfile/SavePlanList`,'POST', data, 1)
// 获取生涯档案(高校
api.getGXWechatStudentProfile = () => request.globalRequest(`/StudentProfile/GetGXWechatStudentProfile`,'GET', {}, 1)
//获取职业路径职业列表
api.queryCareerPath = () => request.globalRequest(`/StudentManage/QueryCareerPath`,'POST', {}, 1)
// 获取职业详情参数encodeId 加密id
api.queryPathInfo = (encodeId) => request.globalRequest(`/StudentManage/QueryPathInfo?encodeId=${encodeId}`,'POST', {}, 1)
export default api

10
apiB/tenpayOrder.js Normal file
View File

@@ -0,0 +1,10 @@
import request from '@/utilB/request.js'
const api = {}
// 获取openid
api.getOpenId = (params) => request.globalRequest(`/WishOrder/GetOpenId?code=${params}`,'GET', {}, "")
// 微信支付
api.createWeiXinOrder = (data) => request.globalRequest(`/TenpayOrder/CreateWeiXinOrder`, 'POST', data)
export default api

View File

@@ -1,4 +1,4 @@
import request from '@/packageCa/utilCa/request.js'
import request from '@/utilB/request.js'
const api = {}
@@ -123,4 +123,3 @@ api.getUserTestTypeProcessList = (testTypes) => request.globalRequest(`/TestReco
export default api

View File

@@ -1,23 +1,6 @@
import request from '@/packageCa/utilCa/request.js'
import request from '@/utilB/request.js'
const api = {}
//根据openId,获取token,并判断用户是否已绑定账号
api.queryKaShiToken = (userId,name) => request.globalRequest(`/KaShi/QueryKaShiToken?userId=${userId}&name=${name}&schoolId=2268`,'GET', {})
// 获取ai面试路径
api.queryAIUrl = (userId,name) => request.globalRequest(`/KaShi/QueryAIUrl?userId=${userId}&name=${name}&schoolId=2268`,'GET', {})
//根据openId,获取token,并判断用户是否已绑定账号
api.getAccessTokenAndUser = (params) => request.globalRequest(`/WeChartToken/GetAccessTokenAndUser?openId=${params}`,'GET', {})
//获取用户token 生涯平台token
api.queryWechartToken = (userId,schoolId,userType) => request.globalRequest(`/Auth/QueryWechartToken?userId=${userId}&schoolId=${schoolId}&userType=${userType}`,'GET', {},1,4)
// 获取openid
api.getOpenId = (params) => request.globalRequest(`/WishOrder/GetOpenId?code=${params}`,'GET', {}, "")
// 微信支付
api.createWeiXinOrder = (data) => request.globalRequest(`/TenpayOrder/CreateWeiXinOrder`, 'POST', data)
// 用户绑定登录
api.userBindLogin = (data) => request.globalRequest(`/user/UserBindLogin`, 'POST', data)
//用户解绑账号或切换账号有返回User, Token话,前端重新绑定到header上
@@ -78,4 +61,3 @@ api.saveUserBasisInfo = (mobileCode,data) => request.globalRequest(`/user/SaveUs
api.getUserBasisInfo = () => request.globalRequest(`/user/GetUserBasisInfo`,'GET', {}, 1)
export default api

26
apiB/weChartUser.js Normal file
View File

@@ -0,0 +1,26 @@
import request from '@/utilB/request.js'
const api = {}
// 获取个人信息
api.getMyWeChartUser = (params) => request.globalRequest(`/WeChartUser/GetMyWeChartUser?openId=${params}`,'GET', {})
// 保存个人信息
api.saveChartUser = (data) => request.globalRequest(`/WeChartUser/SaveChartUser`, 'POST', data)
// 保存反馈信息
api.saveWeChartUserFeedback = (data) => request.globalRequest(`/WeChartUser/SaveWeChartUserFeedback`, 'POST', data)
// 获取出行人列表
api.getResearchUserList = (params) => request.globalRequest(`/WeChartUser/GetResearchUserList?openId=${params}`,'GET', {})
// 删除出行人
api.deleteResearchUser = (params) => request.globalRequest(`/WeChartUser/DeleteResearchUser?id=${params}`,'GET', {})
// 保存出行人
api.saveResearchUser = (data) => request.globalRequest(`/WeChartUser/SaveResearchUser`, 'POST', data)
//根据openId,获取token,并判断用户是否已绑定账号
api.getAccessTokenAndUser = (params) => request.globalRequest(`/WeChartToken/GetAccessTokenAndUser?openId=${params}`,'GET', {})
//获取用户token 生涯平台token
api.queryWechartToken = (userId,schoolId,userType) => request.globalRequest(`/Auth/QueryWechartToken?userId=${userId}&schoolId=${schoolId}&userType=${userType}`,'GET', {},1,4)
api.sLLogin = (accessToken,openId,studentId) => request.globalRequest(`/WeChartUser/SLLogin?accessToken=${accessToken}&openId=${openId}&studentId=${studentId}`, 'POST', {})
export default api

View File

@@ -1,514 +0,0 @@
// 获取人员基本信息详情
// import { post, get } from '../../utils/request.js'
// export function getPersonInfo(id) {
// return get({
// url: `personnel/personBaseInfo/${id}`,
// method: 'get'
// })
// }
import request from '@/utilsRc/request'
// 根据 userId 获取企业详情
export function companyDetails(userId) {
return request({
method: 'get',
url: `/company/unitBaseInfo/user/${userId}`,
})
}
// 企业-推荐人员信息
export function recommendedPerson(params) {
return request({
url: '/company/unitBaseInfo/recommend/person',
method: 'get',
params
})
}
// 人员邀请
export function invitePerson(params) {
return request({
url: '/company/unitBaseInfo/invite',
method: 'get',
params
})
}
// 获取企业招聘岗位列表
export function jobList(params) {
return request({
url: '/company/unitPostInfo/list',
method: 'get',
params
})
}
// 查找已投递、已推荐、已邀请的人员信息
export function listMatch(query) {
return request({
url: '/company/unitBaseInfo/relevance',
method: 'get',
params: query
})
}
// 添加企业基本信息
export function addJobBase(data) {
return request({
url: '/company/unitBaseInfo',
method: 'post',
data: data
})
}
// 查询部门下拉树结构
export function deptTreeSelect() {
return request({
url: '/system/center/user/deptTree',
method: 'get'
})
}
// 企业发布招聘岗位
export function addJob(data) {
return request({
url: '/company/unitPostInfo',
method: 'post',
data: data
})
}
// 获取招聘工种列表
export function jobTypeList(params) {
return request({
url: '/basicdata/workType/list',
method: 'get',
params
})
}
// 企业基本信息列表
export function jobBaseList(query) {
return request({
url: '/company/unitBaseInfo/list',
method: 'get',
params: query
})
}
// 获取企业招聘岗位信息详细信息
export function getJob(id) {
return request({
url: `/company/unitPostInfo/${id}`,
method: 'get'
})
}
// 修改企业招聘岗位信息
export function updateJob(data) {
return request({
url: '/company/unitPostInfo',
method: 'put',
data: data
})
}
// 修改企业基本信息
export function updateJobBase(data) {
return request({
url: '/company/unitBaseInfo',
method: 'put',
data: data
})
}
// 查询角色详细
export function getJobService(id) {
return request({
url: '/personnel/personBaseInfo/' + id,
method: 'get'
})
}
// 查询推荐人员、已推荐、已邀请 详情
export function getUnitBaseInfo(id) {
return request({
url: '/manage/personDemand/' + id,
method: 'get'
})
}
// 查询工种列表
export function listJobType(query) {
return request({
url: '/basicdata/workType/list',
method: 'get',
params: query
})
}
// 人员基本信息 - 列表
export function personInfoList(query) {
return request({
url: '/personnel/personBaseInfo/list',
method: 'get',
params: query
})
}
// 获取人员基本信息详情
export function getPersonInfo(id) {
return request({
url: `/personnel/personBaseInfo/${id}`,
method: 'get'
})
}
// 删除人员基本信息
export function delPersonInfo(ids) {
return request({
url: '/personnel/personBaseInfo/' + ids,
method: 'delete'
})
}
// 删除录入人员 公用 type = 1 失业中 2 就业困难 3 离校生 4 其他人员
export function delPersonUser(ids) {
return request({
url: `/personnel/personInputInfo/${ids}`,
method: 'delete',
})
}
// 新增人员基本信息
export function addPersonInfo(data) {
return request({
url: '/personnel/personBaseInfo',
method: 'post',
data: data
})
}
// 修改人员基本信息
export function updatePersonInfo(data) {
return request({
url: '/personnel/personBaseInfo',
method: 'put',
data
})
}
//社区人员审核
export function personInfoAudit(data) {
return request({
url: '/personnel/personBaseInfo/audit',
method: 'post',
data: data
})
}
//记录查看身份证
export function recordLookIdCard(params) {
return request({
url: '/personnel/personBaseInfo/recordLookIdCard',
method: 'get',
params
})
}
/* 失业人员 --------------------------------------------- start */
// 新增失业人员
export function addPersonUnemployed(data) {
return request({
url: '/person/unemployment',
method: 'post',
data
})
}
// 失业人员修改
export function updatePersonUnemployed(data) {
return request({
url: '/person/unemployment',
method: 'put',
data,
})
}
// 失业人员列表
export function unemployment(params) {
return request({
url: '/person/unemployment/list',
method: 'get',
params
})
}
// 失业人员详情
export function unemploymentDetails(id) {
return request({
url: `/person/unemployment/${id}`,
method: 'get',
})
}
// 失业人员删除
export function unemploymentDelete(id) {
return request({
url: `/person/unemployment/${id}`,
method: 'delete',
})
}
/* 失业人员 --------------------------------------------- end */
/* 就业困难人员 --------------------------------------------- start */
// 新增就业困难
export function addPersonDifficult(data) {
return request({
url: '/person/findingEmployment',
method: 'post',
data
})
}
// 修改就业困难
export function updatePersonDifficult(data) {
return request({
url: '/person/findingEmployment',
method: 'put',
data
})
}
// 就业困难列表
export function findingEmployment(params) {
return request({
url: '/person/findingEmployment/list',
method: 'get',
params
})
}
// 就业困难详情
export function findingEmploymentDetails(id) {
return request({
url: `/person/findingEmployment/${id}`,
method: 'get',
})
}
// 就业困难删除
export function findingEmploymentDelete(id) {
return request({
url: `/person/findingEmployment/${id}`,
method: 'delete',
})
}
/* 就业困难人员 --------------------------------------------- end */
/* 离校未就业高校生 --------------------------------------------- start */
// 新增离校未就业高校生
export function addLeaveSchool(data) {
return request({
url: '/person/leavingSchoolInfo',
method: 'post',
data
})
}
// 修改离校未就业高校生
export function updateLeaveSchool(data) {
return request({
url: '/person/leavingSchoolInfo',
method: 'put',
data,
})
}
// 高校未就业列表
export function leavingSchoolInfo(params) {
return request({
url: '/person/leavingSchoolInfo/list',
method: 'get',
params
})
}
// 高校未就业详情
export function leavingSchoolInfoDetails(id) {
return request({
url: `/person/leavingSchoolInfo/${id}`,
method: 'get',
})
}
// 高校未就业删除
export function leavingSchoolInfoDelete(id) {
return request({
url: `/person/leavingSchoolInfo/${id}`,
method: 'delete',
})
}
/* 离校未就业高校生 --------------------------------------------- end */
/* 其他人员 --------------------------------------------- start */
// 新增其他人员
export function addOther(data) {
return request({
url: '/person/other',
method: 'post',
data
})
}
// 其他人员修改
export function updateOther(data) {
return request({
url: '/person/other',
method: 'post',
data,
})
}
// 其他人员列表
export function other(params) {
return request({
url: '/person/other/list',
method: 'get',
params
})
}
// 其他人员详情
export function otherDetails(id) {
return request({
url: `/person/other/${id}`,
method: 'get',
})
}
// 其他人员删除
export function otherDelete(id) {
return request({
url: `/person/other/${id}`,
method: 'delete',
})
}
/* 其他人员 --------------------------------------------- end */
// 需求预警列表
export function personAlertList(params) {
return request({
url: '/manage/personDemand/warningList',
method: 'get',
params
})
}
export function personDealList(params) {
return request({
url: '/manage/personDemand/dealingList',
method: 'get',
params
})
}
// 服务追踪 服务类型/服务id
export function serviceTraceability({
demandType,
id
}) {
return request({
// url: `/system/personRequirementsRecords/serviceTraceability/${demandType}/${id}`,
url: `/timelime/timelime/fwzs/${id}`,
method: 'get',
})
}
// 需求办结
export function requirementCompletion(url, data) {
return request({
url,
method: 'post',
data
})
}
//岗位审核
export function jobAudit(data) {
return request({
url: '/company/unitPostInfo/audit',
method: 'post',
data: data
})
}
//社群 首页未完成数
// export function getPeopleCount() {
// return request({
// url: '/pc/index/getPeopleCount',
// method: 'get',
// })
// }
//社群 首页未完成数
export function getDemandUnfinished() {
return request({
url: '/pc/index/todo',
method: 'get',
})
}
// 删除企业招聘岗位信息
export function delJob(ids) {
return request({
url: '/company/unitPostInfo/' + ids,
method: 'delete'
})
}
// 所在社区列表
export function deptList(params) {
return request({
'url': `/system/center/user/deptList`,
'method': 'get',
params
})
}
// 所在社区列表
export function returnPerson(params) {
return request({
'url': `/personnel/personBaseInfo/returnPerson`,
'method': 'get',
params
})
}
// 根据人的身份证查询人的详细信息
export function getIdNumberInfo(params) {
return request({
'url': `/personnel/personBaseInfo/getIdNumberInfo`,
'method': 'get',
params
})
}

View File

@@ -1,15 +0,0 @@
/*
* @Date: 2025-10-31 11:06:15
* @LastEditors: lip
* @LastEditTime: 2025-11-03 12:48:22
*/
// import { post, get } from '@/utilsRc/request'
import request from '@/utilsRc/request'
export function listJobType(query) {
return request({
url: '/basicdata/workType/list',
method: 'get',
params: query
})
}

View File

@@ -1,53 +1,177 @@
/*
* @Date: 2025-10-31 11:06:15
* @Descripttion:
* @Author: lip
* @Date: 2023-07-27 16:01:59
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-03 15:51:28
*/
import request from '@/utilsRc/request'
// 登录方法
// export function login(data) {
// return request({
// 'url': '/login',
// headers: {
// isToken: false
// },
// 'method': 'post',
// data
// })
// }
const userApi = {
Login: '/login',
Logout: '/logout',
Register: '/register',
// get my info
UserInfo: '/getInfo'
}
// 登录接口
export function login(data) {
return request({
method: 'get',
url: '/not/login/person/zkrLogin',
params: data,
})
}
export function smsLogin(data) {
return request({
method: 'post',
url: '/personnel/personBaseInfo/loginGrAndQy',
data,
'url': '/personnel/personBaseInfo/loginGrAndQy',
headers: {
isToken: false
}
},
'method': 'post',
data
})
}
export function loginphone(data) {
return request({
'url': '/not/login/person/xcxLogin',
'method': 'get',
headers: {
isToken: false
},
data
})
}
// 注册方法
export function register (data) {
return request({
'url': '/register',
headers: {
isToken: false
},
method: 'post',
data: data
})
}
// 短信登录
export function smsLogin(data) {
return request({
'url': '/smsLogin',
'method': 'post',
'data': data
})
}
export function wechatLogin(data) {
return request({
url: '/xcxLogin',
method: 'post',
url: '/personnel/personBaseInfo/loginGrAndQy',
data,
headers: {
isToken: false
}
})
}
export function register(data) {
return request({
method: 'post',
url: '/personnel/personBaseInfo/loginGrAndQy',
data,
headers: {
isToken: false
}
params: data
})
}
// 获取用户详细信息
export function getInfo() {
return request({
url: '/getInfo',
method: 'get'
'url': '/getInfo',
'method': 'get'
})
}
}
// 退出方法
export function logout() {
return request({
'url': '/logout',
'method': 'post'
})
}
// 获取验证码
export function getCodeImg() {
return request({
'url': '/captchaImage',
headers: {
isToken: false
},
method: 'get',
timeout: 20000
})
}
export function registerReq(data) {
// const data = {
// username,
// password,
// code,
// uuid,
// userType
// }
return request({
'url': '/registerBody',
headers: {
isToken: false
},
'method': 'post',
'data': data
})
}
// 发送邮箱验证码
export function sendMailCode(query) {
return request({
url: '/manage/mail/sendMailCode',
method: 'get',
params: query
})
}
// 发送短信(人才集团)
export function sendSmsForRcjt(data) {
return request({
'url': '/sendSmsForRcjt',
'method': 'post',
'data': data
})
}
// 发送登录短信
export function sendSmsCode(data) {
return request({
'url': '/onlySendSms',
'method': 'post',
'data': data
})
}
// 修改密码
export function updateUserPwd({oldPassword, newPassword}) {
return request({
url: '/system/center/user/profile/updatePwd',
method: 'put',
params: {
oldPassword,
newPassword
}
})
}
// 找回密码 发送验证码
export function sendSms(data) {
return request({
'url': '/sendSms',
'method': 'post',
data
})
}
// 找回密码
export function retrieve(data) {
return request({
'url': '/retrieve',
'method': 'post',
data
})
}

View File

@@ -1,58 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:56:51
*/
import request from '@/utilsRc/request'
// 查询援助需求列表
export function listAssistService(query) {
return request({
url: '/demand/personAssistDemandInfo/list',
method: 'get',
params: query
})
}
// 查询援助需求详细
export function getAssistService(ids) {
return request({
url: '/demand/personAssistDemandInfo/' + ids,
method: 'get'
})
}
// 新增援助需求
export function addAssistService(data) {
return request({
url: '/demand/personAssistDemandInfo',
method: 'post',
data: data
})
}
// 修改援助需求
export function updateAssistService(data) {
return request({
url: '/demand/personAssistDemandInfo',
method: 'put',
data: data
})
}
// 删除援助需求
export function delAssistService(ids) {
return request({
url: '/manage/personDemand/' + ids,
method: 'delete'
})
}
// 个人援助需求办结
export function finishAssistService(data) {
return request({
url: '/demand/personAssistDemandInfo/assistDone',
method: 'post',
data: data
})
}

View File

@@ -1,58 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:56:35
*/
import request from '@/utilsRc/request'
// 查询创业需求列表
export function listEntrepreneurshipService(query) {
return request({
url: '/demand/personEntrepreneurshipDemandInfo/list',
method: 'get',
params: query
})
}
// 查询创业需求详细
export function getEntrepreneurshipService(ids) {
return request({
url: '/demand/personEntrepreneurshipDemandInfo/' + ids,
method: 'get'
})
}
// 新增创业需求
export function addEntrepreneurshipService(data) {
return request({
url: '/demand/personEntrepreneurshipDemandInfo',
method: 'post',
data: data
})
}
// 修改创业需求
export function updateEntrepreneurshipService(data) {
return request({
url: '/demand/personEntrepreneurshipDemandInfo',
method: 'put',
data: data
})
}
// 删除创业需求
export function delEntrepreneurshipService(ids) {
return request({
url: '/manage/personDemand/' + ids,
method: 'delete'
})
}
// 个人援助需求办结
export function finishEntrepreneurshipService(data) {
return request({
url: '/demand/personEntrepreneurshipDemandInfo/entrepreneurshipDone',
method: 'post',
data: data
})
}

View File

@@ -1,57 +0,0 @@
/*
* @Date: 2025-04-07 14:23:47
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:56:39
*/
import request from '@/utilsRc/request'
// 查询求职需求列表
export function listJobService(query) {
return request({
url: '/manage/personDemand/list',
method: 'get',
params: query
})
}
// 查询求职需求详细
export function getJobService(ids) {
return request({
url: '/manage/personDemand/' + ids,
method: 'get'
})
}
// 新增求职需求
export function addJobService(data) {
return request({
url: '/manage/personDemand',
method: 'post',
data: data
})
}
// 修改求职需求
export function updateJobService(data) {
return request({
url: '/manage/personDemand',
method: 'put',
data: data
})
}
// 删除求职需求
export function delJobService(ids) {
return request({
url: '/manage/personDemand/' + ids,
method: 'delete'
})
}
//查询服务次数
export function serviceTraceability(userId) {
return request({
url: '/timelime/timelime/getFwcs/' + userId,
method: 'get'
})
}

View File

@@ -1,58 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:56:42
*/
import request from '@/utilsRc/request'
// 查询其他需求列表
export function listOtherService(query) {
return request({
url: '/demand/personOtherDemandInfo/list',
method: 'get',
params: query
})
}
// 查询其他需求详细
export function getOtherService(ids) {
return request({
url: '/demand/personOtherDemandInfo/' + ids,
method: 'get'
})
}
// 新增其他需求
export function addOtherService(data) {
return request({
url: '/demand/personOtherDemandInfo',
method: 'post',
data: data
})
}
// 修改其他需求
export function updateOtherService(data) {
return request({
url: '/demand/personOtherDemandInfo',
method: 'put',
data: data
})
}
// 删除其他需求
export function delOtherService(ids) {
return request({
url: '/manage/personDemand/' + ids,
method: 'delete'
})
}
// 个人援助需求办结
export function finishOtherService(data) {
return request({
url: '/demand/personOtherDemandInfo/otherDemandDone',
method: 'post',
data: data
})
}

View File

@@ -1,34 +0,0 @@
/*
* @Date: 2025-10-31 11:06:15
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-05 15:33:21
*/
// 人员接口
// import { post, get } from '@/utilsRc/request'
import request from '@/utilsRc/request'
export function getPersonBase(params) {
return request({
url: '/personnel/personBaseInfo/list',
method: 'get',
params
})
}
export function getPersonList(params) {
return request({
url: '/personnel/personBaseInfo/list',
method: 'get',
params
})
}
// 新增角色
export function addInvestigate(data) {
return request({
// url: '//process/processInterview',
url: '/timelime/timelime',
method: 'post',
data: data
})
}

View File

@@ -1,52 +0,0 @@
/*
* @Date: 2025-11-03 08:48:44
* @LastEditors: lip
* @LastEditTime: 2025-11-03 12:48:41
*/
// 查询个人需求信息列表
// import { post, get } from '@/utilsRc/request'
import request from '@/utilsRc/request'
export function listPersonDemand(query) {
return request({
method: 'get',
url: '/manage/personDemand/list',
params: query
})
}
export function delPersonDemand(id) {
return request({
url: '/manage/personDemand/' + id,
method: 'delete'
})
}
// 查询个人需求信息详细
export function getPersonDemand(id) {
return request({
method: 'get',
url: '/manage/personDemand/' + id,
})
}
// 新增个人需求信息
export function addPersonDemand(data) {
// 确保传递数据前进行日志输出
console.log('addPersonDemand函数接收到的数据:', data);
return request({
url: '/manage/personDemand',
method: 'post', // 修改为大写POST确保请求参数正确传递
data: data
})
}
// 修改个人需求信息
export function updatePersonDemand(data) {
return request({
url: '/manage/personDemand',
method: 'put',
data: data
})
}

View File

@@ -1,49 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:56:47
*/
import request from '@/utilsRc/request'
// 查询培训需求列表
export function listTrainService(query) {
return request({
url: '/demand/personTrainDemandInfo/list',
method: 'get',
params: query
})
}
// 查询培训需求详细
export function getTrainService(ids) {
return request({
url: '/demand/personTrainDemandInfo/' + ids,
method: 'get'
})
}
// 新增培训需求
export function addTrainService(data) {
return request({
url: '/demand/personTrainDemandInfo',
method: 'post',
data: data
})
}
// 修改培训需求
export function updateTrainService(data) {
return request({
url: '/demand/personTrainDemandInfo',
method: 'put',
data: data
})
}
// 删除培训需求
export function delTrainService(ids) {
return request({
url: '/manage/personDemand/' + ids,
method: 'delete'
})
}

View File

@@ -1,56 +0,0 @@
/*
* @Descripttion:
* @Author: lip
* @Date: 2025-11-03 12:35:56
* @LastEditors: shirlwang
*/
// import { post, get } from '../../utils/request.js'
import request from '@/utilsRc/request'
// 登录方法
export function personInfoList(data) {
return request({
method: 'get',
url: '/personnel/personBaseInfo/list',
params: data,
})
}
// 需求预警列表
export function personAlertList(params) {
return request({
method: 'get',
url: '/manage/personDemand/warningList',
params
})
}
//经办人数据获取
export function getJbrInfo() {
return request({
method: 'get',
url: `/system/center/user/selectHxjbr`,
method: 'get'
})
}
export function getPersonBase() {
return request({
method: 'get',
url: `/system/center/user/selectHxjbr`,
method: 'get'
})
}
export function returnPerson(params) {
return request({
method: 'get',
'url': `/personnel/personBaseInfo/returnPerson`,
params
})
}
export function getStatistic(params) {
return request({
method: 'get',
'url': `/pc/index/fwqkfx`,
params
})
}

View File

@@ -1,50 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:56:56
*/
import request from '@/utilsRc/request'
// 查询角色列表
export function listInvestigate(query) {
return request({
url: '/process/processInterview/list',
method: 'get',
params: query
})
}
// 查询角色详细
export function getInvestigate(ids) {
return request({
url: '/process/processInterview/' + ids,
method: 'get'
})
}
// 新增角色
export function addInvestigate(data) {
return request({
// url: '/process/processInterview',
url: '/timelime/timelime',
method: 'post',
data: data
})
}
// 修改角色
export function updateInvestigate(data) {
return request({
url: '/process/processInterview',
method: 'put',
data: data
})
}
// 删除角色
export function delInvestigate(ids) {
return request({
url: '/process/processInterview/' + ids,
method: 'delete'
})
}

View File

@@ -1,86 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:56:59
*/
import request from '@/utilsRc/request'
// 查询角色列表
export function listJobRecommend(query) {
return request({
url: '/process/processJobRecommend/list',
method: 'get',
params: query
})
}
// 查询角色列表
export function getWorkListReq(query) {
return request({
// url: '/personnel/personBaseInfo/postRecommend',
url: '/company/unitPostInfo/postElectedList',
method: 'get',
params: query
})
}
// 查询角色详细
export function getJobRecommend(ids) {
return request({
url: '/process/processJobRecommend/' + ids,
method: 'get'
})
}
// 新增角色
export function addJobRecommend(data) {
return request({
url: '/process/processJobRecommend',
method: 'post',
data: data
})
}
//岗位推荐保存和办结
export function saveJobRecommend(data) {
return request({
url: '/process/processJobRecommend/create',
method: 'post',
data: data
})
}
// 修改角色
export function updateJobRecommend(data) {
return request({
url: '/process/processJobRecommend',
method: 'put',
data: data
})
}
// 删除角色
export function delJobRecommend(ids) {
return request({
url: '/process/processJobRecommend/' + ids,
method: 'delete'
})
}
// 获取绑定的职位
export function getAddedJobs(params) {
return request({
// url: '/company/postDeliverInfo/list',
url: '/company/unitPostInfo/no/permission/list',
method: 'get',
params,
})
}
// // 获取推荐岗位
// export function getAddedJobs(params) {
// return request({
// url: '/personnel/personBaseInfo/postRecommend',
// method: 'get',
// params,
// })
// }

View File

@@ -1,49 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:57:02
*/
import request from '@/utilsRc/request'
// 查询角色列表
export function listJobTrack(query) {
return request({
url: '/process/processEmploymentTracking/list',
method: 'get',
params: query
})
}
// 查询角色详细
export function getJobTrack(ids) {
return request({
url: '/process/processEmploymentTracking/' + ids,
method: 'get'
})
}
// 新增角色
export function addJobTrack(data) {
return request({
url: '/process/processEmploymentTracking',
method: 'post',
data: data
})
}
// 修改角色
export function updateJobTrack(data) {
return request({
url: '/process/processEmploymentTracking',
method: 'put',
data: data
})
}
// 删除角色
export function delJobTrack(ids) {
return request({
url: '/process/processEmploymentTracking/' + ids,
method: 'delete'
})
}

View File

@@ -1,49 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:57:05
*/
import request from '@/utilsRc/request'
// 查询角色列表
export function listPolicyConsultation(query) {
return request({
url: '/process/processPolicyConsult/list',
method: 'get',
params: query
})
}
// 查询角色详细
export function getPolicyConsultation(ids) {
return request({
url: '/process/processPolicyConsult/' + ids,
method: 'get'
})
}
// 新增角色
export function addPolicyConsultation(data) {
return request({
url: '/process/processPolicyConsult',
method: 'post',
data: data
})
}
// 修改角色
export function updatePolicyConsultation(data) {
return request({
url: '/process/processPolicyConsult',
method: 'put',
data: data
})
}
// 删除角色
export function delPolicyConsultation(ids) {
return request({
url: '/process/processPolicyConsult/' + ids,
method: 'delete'
})
}

View File

@@ -1,49 +0,0 @@
/*
* @Date: 2024-09-25 11:14:29
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 08:57:09
*/
import request from '@/utilsRc/request'
// 查询角色列表
export function listSkillTrain(query) {
return request({
url: '/process/processSkillTraining/list',
method: 'get',
params: query
})
}
// 查询角色详细
export function getSkillTrain(ids) {
return request({
url: '/process/processSkillTraining/' + ids,
method: 'get'
})
}
// 新增角色
export function addSkillTrain(data) {
return request({
url: '/process/processSkillTraining',
method: 'post',
data: data
})
}
// 修改角色
export function updateSkillTrain(data) {
return request({
url: '/process/processSkillTraining',
method: 'put',
data: data
})
}
// 删除角色
export function delSkillTrain(ids) {
return request({
url: '/process/processSkillTraining/' + ids,
method: 'delete'
})
}

View File

@@ -1,8 +1,3 @@
/*
* @Date: 2025-10-31 15:06:34
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-03 12:20:28
*/
import request from '@/utilsRc/request'
// 查询字典数据列表
export function listData (query) {
@@ -28,13 +23,6 @@ export function getDicts (dictType) {
method: 'get'
})
}
// 根据字典类型查询字典数据信息
export function getDict (dictType) {
return request({
url: '/system/dict/data/type/' + dictType,
method: 'get'
})
}
// 新增字典数据
export function addData (data) {

View File

@@ -1,26 +0,0 @@
import request from '@/utilsRc/request'
// 查询时间轴列表
export function timelineList(params) {
return request({
url: '/timelime/timelime/timeline',
method: 'get',
params
})
}
// 查询时间轴详情列表
export function timeList(params) {
return request({
url: '/timelime/timelime/list',
method: 'get',
params
})
}
//获取时间轴详细信息
export function timeDetails(id) {
return request({
url: '/timelime/timelime/' + id,
method: 'get'
})
}

View File

@@ -50,7 +50,7 @@ const prePage = () => {
return prePage.$vm;
}
export const urls ='http://10.110.145.145/images/train/'
/**
* 页面跳转封装,支持 query 参数传递和返回回调
@@ -894,7 +894,6 @@ export const $api = {
export default {
$api,
urls,
navTo,
navBack,
cloneDeep,

158
components/ImageUpload.vue Normal file
View File

@@ -0,0 +1,158 @@
<template>
<view class="upload-container">
<u-upload :disabled="disabled" :width="width" :height="height" :fileList="internalFileList" :name="name" :multiple="multiple"
:maxCount="maxCount" @afterRead="handleAfterRead" @delete="handleRemove">
</u-upload>
</view>
</template>
<script>
// import {
// uploadImg
// } from '@/api/company'
import config from '@/config'
//import {
// getToken
//} from '@/utils/auth'
export default {
props: {
maxSize: {
type: Number,
default: 5, // 最大文件大小MB
},
allowedFormats: {
type: Array,
default: () => [], // 允许的文件格式
},
maxImageSize: {
type: Object,
default: () => ({
width: 2048,
height: 2048
}), // 图片最大宽度和高度
},
width: {
type: String,
default: '100rpx', // 默认宽度
},
height: {
type: String,
default: '100rpx', // 默认高度
},
name: {
type: String,
default: 'file', // 默认name字段
},
multiple: {
type: Boolean,
default: false, // 是否允许多选,默认不允许
},
maxCount: {
type: Number,
default: 1, // 默认最大上传数量为1
},
fileList: {
type: Array,
default: () => [], // 默认的文件列表为空
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
internalFileList: [...this.fileList], // 内部的文件列表,确保与父组件的同步
};
},
watch: {
// 监听 fileList 的变化,确保内外部数据同步
fileList(newVal) {
this.internalFileList = [...newVal];
},
},
methods: {
// 新增图片
async handleAfterRead(event) {
let lists = [].concat(event.file);
let fileListLen = this.internalFileList.length;
lists.map((item) => {
this.internalFileList.push({
...item,
status: "uploading",
message: "上传中",
});
});
for (let i = 0; i < lists.length; i++) {
if (this.allowedFormats.length > 0) {
let fileType = lists[i].name.split('.').pop().toLowerCase();
if (!this.allowedFormats.includes(fileType)) {
// this.$emit('error', '不支持的文件格式');
uni.showToast({
title: '不支持的文件格式',
icon: 'none',
});
this.internalFileList.splice(fileListLen, 1);
this.$emit('update', this.internalFileList); // 通知父组件文件列表更新
return;
}
}
const result = await this.uploadFilePromise(lists[i].url);
let item = this.internalFileList[fileListLen];
this.internalFileList.splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
data: result,
})
);
fileListLen++;
this.$emit('update', this.internalFileList); // 通知父组件文件列表更新
}
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: config.baseUrl + '/system/oss/upload',
filePath: url,
name: "file",
header: {
Authorization: "Bearer " + getToken(),
},
success: (uploadFileRes) => {
let res = JSON.parse(uploadFileRes.data);
resolve(res.data);
},
fail: (err) => {
console.log(err);
},
});
});
},
handleRemove({file, index}) {
this.internalFileList.splice(index, 1); // 从文件列表中移除指定文件
this.$emit('update', this.internalFileList); // 通知父组件文件列表更新
},
},
};
</script>
<style scoped>
.upload-container {
display: flex;
align-items: center;
justify-content: center;
}
.upload-slot {
display: flex;
align-items: center;
justify-content: center;
border: 1px dashed #ccc;
border-radius: 4px;
padding: 20px;
}
</style>

View File

@@ -70,7 +70,6 @@ const openPicker = () => {
| cancel | Function | 否 | - | 取消选择的回调函数 |
| change | Function | 否 | - | 选择变化的回调函数 |
| defaultValue | Object | 否 | null | 默认选中的地址(暂未实现) |
| forceRefresh | Boolean | 否 | false | 是否强制刷新数据(忽略缓存) |
#### success 回调参数
@@ -108,14 +107,6 @@ const openPicker = () => {
areaPicker.value?.close()
```
### clearCache()
清除地址数据缓存
```javascript
areaPicker.value?.clearCache()
```
## 数据格式
组件使用树形结构的地址数据,格式如下:
@@ -218,73 +209,12 @@ const selectLocation = () => {
</script>
```
## 性能优化
### 懒加载方案(已实现)⭐
组件已实现**懒加载**机制大幅优化90M+地址数据的加载性能:
#### 核心优化
1. **首次加载**:只加载省份列表(< 1MB3-5秒完成
2. **按需加载**用户选择省份后再加载该省份的详细数据2-5MB5-10秒
3. **智能缓存**已加载的数据会缓存切换省份时秒开
4. **自动降级**如果服务器不支持分片接口自动从完整数据中提取
#### 性能对比
| 场景 | 优化前 | 优化后懒加载 |
|------|--------|------------------|
| 首次打开选择器 | 加载90M+3-5分钟 | 加载省份列表< 1MB3-5秒 |
| 选择省份 | 无需加载 | 加载该省份数据2-5MB5-10秒 |
| 切换省份 | 无需加载 | 从缓存读取< 1秒 |
#### 使用方式
组件已自动使用懒加载模式无需修改调用代码
```javascript
// 正常使用,自动懒加载
areaPicker.value?.open({
success: (addressData) => {
console.log('选择的地址:', addressData)
}
})
// 强制刷新数据(忽略缓存)
areaPicker.value?.open({
forceRefresh: true, // 强制从服务器重新加载
success: (addressData) => {
console.log('选择的地址:', addressData)
}
})
// 清除缓存
areaPicker.value?.clearCache()
```
### 服务器分片接口(最佳方案)🚀
如果服务器可以提供分片接口性能会进一步提升详见[地址数据懒加载优化方案.md](../../docs/地址数据懒加载优化方案.md)
需要的接口
- 省份列表接口`/address_provinces.json`轻量级< 1MB
- 省份详情接口`/address_province_{code}.json`按需加载每个2-5MB
### 缓存机制
1. **自动缓存**已加载的数据会自动缓存到 IndexedDBH5 uni.storage小程序
2. **缓存有效期**默认7天过期后自动重新加载
3. **离线支持**网络失败时自动使用缓存数据
4. **存储方案**优先使用 IndexedDB自动降级到 uni.storage
## 注意事项
1. **数据来源**当前从远程JSON文件加载生产环境建议接入后端API
1. **数据来源**:当前使用本地模拟数据,生产环境建议接入后端API
2. **数据更新**如需接入后端API修改 `loadAreaData` 方法即可
3. **性能优化**已集成缓存机制首次加载后速度大幅提升
3. **性能优化**:地址数据量大时,建议使用懒加载
4. **兼容性**:支持 H5、微信小程序等多端
5. **存储限制**小程序环境有存储限制如遇问题会自动清理旧缓存
## 接入后端API
@@ -312,21 +242,6 @@ async loadAreaData() {
## 更新日志
### v1.2.0 (2025-01-XX)
- 🚀 **懒加载优化**实现按需加载首次加载从几分钟减少到几秒
- 首次只加载省份列表< 1MB3-5秒
- 按需加载省份详情选择省份时才加载
- 智能缓存已加载的数据切换省份秒开
- 支持服务器分片接口最佳性能
- 自动降级方案兼容完整数据
### v1.1.0 (2025-01-XX)
- 🚀 **性能优化**集成智能缓存系统优化90M+地址数据加载
- 支持 IndexedDB uni.storage 双缓存方案
- 支持缓存过期管理和自动清理
- 支持强制刷新数据
- 优化首次加载体验后续加载秒开
### v1.0.0 (2025-10-21)
- ✨ 初始版本
- ✅ 实现五级联动选择功能

View File

@@ -85,35 +85,33 @@
</template>
<script>
import { createRequest } from '@/utils/request';
import addressJson from '@/static/json/xinjiang.json';
export default {
name: 'AreaCascadePicker',
data() {
return {
maskClick: false,
title: '选择地址',
confirmCallback: null,
cancelCallback: null,
changeCallback: null,
selectedIndex: [0, 0, 0, 0, 0],
// 原始数据(懒加载模式下,只存储省份列表)
areaData: [],
// 各级列表
provinceList: [],
cityList: [],
districtList: [],
streetList: [],
communityList: [],
// 当前选中的项
selectedProvince: null,
selectedCity: null,
selectedDistrict: null,
selectedStreet: null,
selectedCommunity: null,
// 加载状态
isLoading: false,
};
},
return {
maskClick: false,
title: '选择地址',
confirmCallback: null,
cancelCallback: null,
changeCallback: null,
selectedIndex: [0, 0, 0, 0, 0],
// 原始数据
areaData: [],
// 各级列表
provinceList: [],
cityList: [],
districtList: [],
streetList: [],
communityList: [],
// 当前选中的项
selectedProvince: null,
selectedCity: null,
selectedDistrict: null,
selectedStreet: null,
selectedCommunity: null,
};
},
methods: {
async open(newConfig = {}) {
const {
@@ -123,7 +121,6 @@ export default {
change,
maskClick = false,
defaultValue = null,
forceRefresh = false, // 是否强制刷新数据
} = newConfig;
this.reset();
@@ -134,103 +131,50 @@ export default {
this.maskClick = maskClick;
// 加载地区数据
this.isLoading = true;
await this.loadAreaData();
// 初始化列表
this.initLists();
this.$nextTick(() => {
this.$refs.popup.open();
});
},
async loadAreaData() {
try {
// 先显示弹窗,避免长时间等待
this.$nextTick(() => {
this.$refs.popup.open();
});
// 尝试调用后端API获取地区数据
// 如果后端API不存在将使用模拟数据
console.log('正在加载地区数据...');
// const resp = await uni.request({
// url: '/app/common/area/cascade',
// method: 'GET'
// });
// if (resp.statusCode === 200 && resp.data && resp.data.data) {
// this.areaData = resp.data.data;
// }
// 加载省份数据
await this.loadAreaData(forceRefresh);
// 只有当provinceList有数据时才初始化后续列表
if (this.areaData && this.areaData.length > 0) {
await this.initLists();
console.log('地址选择器初始化完成');
} else {
console.warn('没有加载到省份数据');
// 即使没有数据,也保持弹窗打开,让用户可以关闭它
}
// 暂时使用模拟数据
this.areaData = this.getMockData();
} catch (error) {
console.error('打开地址选择器失败:', error);
// 注意由于loadAreaData已经处理了错误这里不应该会被触发
// 但保留作为额外的安全措施
} finally {
this.isLoading = false;
console.error('加载地区数据失败:', error);
// 如果后端API不存在使用模拟数据
this.areaData = this.getMockData();
}
},
async loadAreaData(forceRefresh = false) {
try {
console.log('正在加载省份列表...');
const resp = await createRequest('/cms/dict/sysarea/list', { parentCode: '' }, 'GET', false);
console.log('省份列表接口响应:', resp);
// 处理正确的数据格式
if (resp && resp.code === 200 && resp.data) {
// 数据在data字段中
this.areaData = resp.data.map(item => ({
code: item.code,
name: item.name
}));
console.log('省份列表加载成功:', this.areaData);
if (this.areaData.length === 0) {
console.warn('省份列表为空');
}
} else {
console.error('获取省份列表失败:', resp);
throw new Error(`获取省份列表失败: ${resp?.msg || '未知错误'}`);
}
} catch (error) {
console.error('加载省份列表失败:', error);
// 不抛出错误,避免阻止页面打开
// 而是使用默认空数据,让用户可以继续操作
this.areaData = [];
// 显示更友好的错误提示
uni.showToast({
title: error.message || '加载地址数据失败,请检查网络连接',
icon: 'none',
duration: 3000
});
}
},
async initLists() {
initLists() {
// 初始化省列表
this.provinceList = this.areaData || [];
this.provinceList = this.areaData;
if (this.provinceList.length > 0) {
this.selectedProvince = this.provinceList[0];
// 懒加载:首次选择第一个省份时,加载其详情
await this.updateCityList();
// 如果有城市数据,初始化第一个城市的区县数据
if (this.cityList.length > 0) {
this.selectedCity = this.cityList[0];
await this.updateDistrictList();
// 如果有区县数据,初始化第一个区县的街道数据
if (this.districtList.length > 0) {
this.selectedDistrict = this.districtList[0];
await this.updateStreetList();
// 如果有街道数据,初始化第一个街道的社区数据
if (this.streetList.length > 0) {
this.selectedStreet = this.streetList[0];
await this.updateCommunityList();
}
}
}
// 更新选中索引
this.selectedIndex = [0, 0, 0, 0, 0];
this.updateCityList();
}
},
async updateCityList() {
if (!this.selectedProvince) {
updateCityList() {
if (!this.selectedProvince || !this.selectedProvince.children) {
this.cityList = [];
this.districtList = [];
this.streetList = [];
@@ -238,168 +182,55 @@ export default {
return;
}
try {
console.log(`正在加载城市列表,父级编码: ${this.selectedProvince.code}`);
// 使用createRequest工具调用接口
const resp = await createRequest('/cms/dict/sysarea/list', { parentCode: this.selectedProvince.code }, 'GET', false);
console.log('城市列表接口响应:', resp);
// 处理正确的数据格式
let cityData = [];
if (resp && resp.code === 200 && resp.data) {
cityData = resp.data;
this.cityList = cityData.map(item => ({
code: item.code,
name: item.name
}));
console.log('城市列表加载成功:', this.cityList);
} else {
console.error('获取城市列表失败:', resp);
this.cityList = [];
}
} catch (error) {
console.error('加载城市列表失败:', error);
this.cityList = [];
}
this.cityList = this.selectedProvince.children;
this.selectedIndex[1] = 0;
if (this.cityList.length > 0) {
this.selectedCity = this.cityList[0];
await this.updateDistrictList();
} else {
this.districtList = [];
this.streetList = [];
this.communityList = [];
this.updateDistrictList();
}
},
async updateDistrictList() {
if (!this.selectedCity) {
updateDistrictList() {
if (!this.selectedCity || !this.selectedCity.children) {
this.districtList = [];
this.streetList = [];
this.communityList = [];
return;
}
try {
console.log(`正在加载区县列表,父级编码: ${this.selectedCity.code}`);
// 使用createRequest工具调用接口
const resp = await createRequest('/cms/dict/sysarea/list', { parentCode: this.selectedCity.code }, 'GET', false);
console.log('区县列表接口响应:', resp);
// 处理正确的数据格式
let districtData = [];
if (resp && resp.code === 200 && resp.data) {
districtData = resp.data;
this.districtList = districtData.map(item => ({
code: item.code,
name: item.name
}));
console.log('区县列表加载成功:', this.districtList);
} else {
console.error('获取区县列表失败:', resp);
this.districtList = [];
}
} catch (error) {
console.error('加载区县列表失败:', error);
this.districtList = [];
}
this.districtList = this.selectedCity.children;
this.selectedIndex[2] = 0;
if (this.districtList.length > 0) {
this.selectedDistrict = this.districtList[0];
await this.updateStreetList();
} else {
this.streetList = [];
this.communityList = [];
this.updateStreetList();
}
},
async updateStreetList() {
if (!this.selectedDistrict) {
updateStreetList() {
if (!this.selectedDistrict || !this.selectedDistrict.children) {
this.streetList = [];
this.communityList = [];
return;
}
try {
console.log(`正在加载街道列表,父级编码: ${this.selectedDistrict.code}`);
// 使用createRequest工具调用接口
const resp = await createRequest('/cms/dict/sysarea/list', { parentCode: this.selectedDistrict.code }, 'GET', false);
console.log('街道列表接口响应:', resp);
// 处理正确的数据格式
let streetData = [];
if (resp && resp.code === 200 && resp.data) {
streetData = resp.data;
this.streetList = streetData.map(item => ({
code: item.code,
name: item.name
}));
console.log('街道列表加载成功:', this.streetList);
} else {
console.error('获取街道列表失败:', resp);
this.streetList = [];
}
} catch (error) {
console.error('加载街道列表失败:', error);
this.streetList = [];
}
this.streetList = this.selectedDistrict.children;
this.selectedIndex[3] = 0;
if (this.streetList.length > 0) {
this.selectedStreet = this.streetList[0];
await this.updateCommunityList();
} else {
this.communityList = [];
this.updateCommunityList();
}
},
async updateCommunityList() {
if (!this.selectedStreet) {
updateCommunityList() {
if (!this.selectedStreet || !this.selectedStreet.children) {
this.communityList = [];
return;
}
try {
console.log(`正在加载社区列表,父级编码: ${this.selectedStreet.code}`);
// 使用createRequest工具调用接口
const resp = await createRequest('/cms/dict/sysarea/list', { parentCode: this.selectedStreet.code }, 'GET', false);
console.log('社区列表接口响应:', resp);
// 处理正确的数据格式
let communityData = [];
if (resp && resp.code === 200 && resp.data) {
communityData = resp.data;
this.communityList = communityData.map(item => ({
code: item.code,
name: item.name
}));
console.log('社区列表加载成功:', this.communityList);
} else {
console.error('获取社区列表失败:', resp);
this.communityList = [];
}
} catch (error) {
console.error('加载社区列表失败:', error);
this.communityList = [];
}
this.communityList = this.selectedStreet.children;
this.selectedIndex[4] = 0;
if (this.communityList.length > 0) {
@@ -407,7 +238,7 @@ export default {
}
},
async bindChange(e) {
bindChange(e) {
const newIndex = e.detail.value;
// 检查哪一列发生了变化
@@ -417,21 +248,21 @@ export default {
// 根据变化的列更新后续列
if (i === 0) {
// 省变化 - 需要加载新省份的城市
// 省变化
this.selectedProvince = this.provinceList[newIndex[0]];
await this.updateCityList();
this.updateCityList();
} else if (i === 1) {
// 市变化
this.selectedCity = this.cityList[newIndex[1]];
await this.updateDistrictList();
this.updateDistrictList();
} else if (i === 2) {
// 区县变化
this.selectedDistrict = this.districtList[newIndex[2]];
await this.updateStreetList();
this.updateStreetList();
} else if (i === 3) {
// 街道变化
this.selectedStreet = this.streetList[newIndex[3]];
await this.updateCommunityList();
this.updateCommunityList();
} else if (i === 4) {
// 社区变化
this.selectedCommunity = this.communityList[newIndex[4]];
@@ -492,48 +323,22 @@ export default {
}
},
/**
* 重置所有状态(内部使用)
*/
reset() {
this.maskClick = false;
this.confirmCallback = null;
this.cancelCallback = null;
this.changeCallback = null;
this.selectedIndex = [0, 0, 0, 0, 0];
this.selectedProvince = null;
this.selectedCity = null;
this.selectedDistrict = null;
this.selectedStreet = null;
this.selectedCommunity = null;
this.provinceList = [];
this.cityList = [];
this.districtList = [];
this.streetList = [];
this.communityList = [];
this.areaData = [];
},
/**
* 清除地址数据缓存(供外部调用)
*/
async clearCache() {
try {
// 清除内存缓存
this.reset();
uni.showToast({
title: '缓存已清除',
icon: 'success',
duration: 2000
});
} catch (error) {
console.error('清除缓存失败:', error);
uni.showToast({
title: '清除缓存失败',
icon: 'none',
duration: 2000
});
}
// 模拟数据(用于演示)
getMockData() {
return addressJson
}
},
};

View File

@@ -1,37 +0,0 @@
<template>
<uni-data-pickerview
ref="pickerView"
v-bind="$attrs"
@change="handleChange"
@datachange="handleDatachange"
@nodeclick="handleNodeclick"
@update:modelValue="handleUpdateModelValue"
/>
</template>
<script>
export default {
name: 'DataPickerView',
inheritAttrs: false,
methods: {
updateData(data) {
if (this.$refs.pickerView && this.$refs.pickerView.updateData) {
this.$refs.pickerView.updateData(data)
}
},
handleChange(event) {
this.$emit('change', event)
},
handleDatachange(event) {
this.$emit('datachange', event)
},
handleNodeclick(event) {
this.$emit('nodeclick', event)
},
handleUpdateModelValue(value) {
this.$emit('update:modelValue', value)
}
}
}
</script>

View File

@@ -1,639 +0,0 @@
<template>
<view class="job-dialog">
<view class="header-title">
<image :src="`${imgBaseUrl}/jobfair/xb.png`" mode=""></image>
<text>招聘会报名</text>
</view>
<view class="dialog-content">
<view class="detail-item" v-if="type == 2">
<view class="gw-label">选择展区展位</view>
<!-- 展位状态说明 -->
<view class="status-description">
<view class="status-title">
<text>展位状态说明</text>
</view>
<view class="status-item">
<view class="status-color available"></view>
<text class="status-text">未被占用</text>
</view>
<view class="status-item">
<view class="status-color occupied"></view>
<text class="status-text">已被占用</text>
</view>
<view class="status-item">
<view class="status-color pending"></view>
<text class="status-text">待审核占用</text>
</view>
<view class="status-item">
<view class="status-color selected"></view>
<text class="status-text">当前选中</text>
</view>
</view>
<view class="gw-value">
<view class="cd-detail" v-for="(item, index) in areaAndBoothList" :key="index">
<view class="cd-name">{{ item.jobFairAreaName }}</view>
<view class="cd-con">
<view class="cd-con-item" :class="getBoothStatusClass(booth)"
v-for="(booth, boothIndex) in item.boothList" :key="boothIndex"
@click="selectBooth(booth, item.jobFairAreaId)">
<text>{{ booth.jobFairBoothName }}</text>
</view>
</view>
</view>
</view>
</view>
<view class="detail-item">
<view class="gw-label">请选择招聘岗位</view>
<view class="gw-value">
<view class="checkbox-group">
<view class="checkbox-item job-item" v-for="(item, index) in jobList" :key="index"
:class="{ 'checked': checkList.includes(item) }" @click="toggleJobSelection(item)">
<view class="item-checkbox">
<view class="checkbox-icon" :class="{ 'checked': checkList.includes(item) }">
<text v-if="checkList.includes(item)"></text>
</view>
<view class="job-info">
<view class="job-name">{{ item.jobTitle }}</view>
<view class="salary">{{ item.salaryRange }}/</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="detail-item">
<view class="gw-label">请上传招聘海报</view>
<view class="gw-value">
<view v-if="imageUrl">
<image v-if="imageUrl" :src="publicUrl + '/file/file/minio' + imageUrl" class="avatar"
mode="aspectFit" />
<button type="warn" class="del-icon" @click="imageUrl = ''" size="mini">删除</button>
</view>
<view v-else>
<button @click="chooseImage" class="avatar-uploader transparent-btn" type="default">
<view class="avatar-uploader-icon">+</view>
</button>
</view>
</view>
</view>
</view>
<view class="btn-box">
<button style="background: #409EFF;color: #fff;" @click="submitForm">提交</button>
<button type="default" @click="closeDialog">取消</button>
</view>
</view>
</template>
<script setup>
import config from "@/config.js"
import {
ref,
reactive,
onMounted,
nextTick,
watch,
inject
} from 'vue';
const emit = defineEmits(['closePopup']);
import {
createRequest
} from '@/utils/request.js';
const {
$api
} = inject('globalFunction');
// 定义props
const props = defineProps({
// 招聘会类型1线上 2线下
signType: {
type: Number,
default: 1
},
// 报名角色 ent企业 person个人
signRole: {
type: String,
default: 'ent'
},
// 招聘会id
jobFairId: {
type: String,
default: ''
}
});
// 监听props变化
watch(() => props.signType, (newVal) => {
type.value = newVal;
});
// 响应式数据
const checkList = ref([]);
const imageUrl = ref('');
const type = ref('');
const id = ref('');
const jobList = ref([]);
const userId = ref('');
const areaAndBoothList = ref([]);
const jobFairAreaId = ref(null);
const jobFairBoothId = ref(null);
const avatarUploader = ref(null);
// 配置
const publicUrl = config.LCBaseUrl;
const imgBaseUrl = config.imgBaseUrl
const uploadUrl = config.LCBaseUrl + "/file/file/upload";
// 方法
const selectBooth = (booth, jobFairAreaIdVal) => {
if (booth.status == 0) {
jobFairBoothId.value = booth.jobFairBoothId;
jobFairAreaId.value = jobFairAreaIdVal;
}
};
const submitForm = async () => {
if (type.value == "2") {
if (!jobFairBoothId.value || !jobFairAreaId.value) {
uni.showToast({
title: '请选择展区展位',
icon: 'none'
});
return;
}
}
if (checkList.value.length === 0) {
uni.showToast({
title: '请选择招聘岗位',
icon: 'none'
});
return;
}
if (!imageUrl.value) {
uni.showToast({
title: '请上传招聘海报',
icon: 'none'
});
return;
}
$api.myRequest("/system/user/login/user/info", {}, "GET", 10100, {
Authorization: `Bearer ${uni.getStorageSync("Padmin-Token")}`
}).then((userInfo) => {
let data = {}
if (type.value == "2") {
data = {
jobFairId: id.value,
enterpriseId: userInfo.info.userId,
jobInfoList: checkList.value,
poster: imageUrl.value,
jobFairAreaId: jobFairAreaId.value,
jobFairBoothId: jobFairBoothId.value,
code: userInfo.info.entCreditCode
};
} else {
data = {
jobFairId: id.value,
enterpriseId: userInfo.info.userId,
jobInfoList: checkList.value,
poster: imageUrl.value,
code: userInfo.info.entCreditCode
};
}
$api.myRequest("/jobfair/public/job-fair-sign-up-enterprise/sign-up", data, "post", 9100, {
Authorization: `Bearer ${uni.getStorageSync("Padmin-Token")}`
}).then((res) => {
if (res.code === 200) {
uni.showToast({
title: '报名成功',
icon: 'success'
});
closeDialog();
} else {
uni.showToast({
title: res.msg || '报名失败',
icon: 'none'
});
}
});
})
};
const closeDialog = () => {
checkList.value = [];
imageUrl.value = '';
jobFairBoothId.value = null;
jobFairAreaId.value = null;
emit('closePopup')
};
const handleAvatarSuccess = (response) => {
imageUrl.value = response.data.url;
uni.showToast({
title: '海报上传成功',
icon: 'success'
});
};
const showDialog = (dialogType, dialogId) => {
type.value = dialogType;
id.value = dialogId;
nextTick(() => {
getJobList();
if (type.value === "2") {
getAreaAndBoothInfo();
}
});
};
// 展区展位列表
const getAreaAndBoothInfo = () => {
const data = {
jobFairId: props.jobFairId,
}
$api.myRequest("/jobfair/public/jobfair/area-and-booth-info-by-job-fair-id", data, "GET", 9100, {
Authorization: `Bearer ${uni.getStorageSync("Padmin-Token")}`
}).then((resData) => {
areaAndBoothList.value = resData.data || [];
});
};
// 岗位列表
const getJobList = () => {
$api.myRequest("/system/user/login/user/info", {}, "GET", 10100, {
Authorization: `Bearer ${uni.getStorageSync("Padmin-Token")}`
}).then((userInfo) => {
const data = {
jobFairId: id.value,
enterpriseId: userInfo.info.userId,
pageNum: 1,
pageSize: 1000,
code: userInfo.info.entCreditCode
}
$api.myRequest("/jobfair/public/job-info/list", data, "GET", 9100, {
Authorization: `Bearer ${uni.getStorageSync("Padmin-Token")}`
}).then((resData) => {
jobList.value = resData.data.list || [];
});
});
};
const getBoothStatusClass = (booth) => {
const s = booth.status || 0;
if (s == 1) return "cd-con-item-checked";
if (s == 2) return "cd-con-item-review";
if (jobFairBoothId.value && jobFairBoothId.value == booth.jobFairBoothId)
return "cd-con-item-mychecked";
return "";
};
// 选择图片
const chooseImage = () => {
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
const tempFilePath = res.tempFilePaths[0];
uploadImage(tempFilePath);
}
});
};
// 上传图片
const uploadImage = (tempFilePath) => {
uni.uploadFile({
url: uploadUrl,
filePath: tempFilePath,
name: 'file',
success: (uploadFileRes) => {
try {
const response = JSON.parse(uploadFileRes.data);
handleAvatarSuccess(response);
} catch (e) {
uni.showToast({
title: '上传失败,请重试',
icon: 'none'
});
}
},
fail: (err) => {
console.error('上传失败:', err);
uni.showToast({
title: '上传失败,请重试',
icon: 'none'
});
}
});
};
// 切换岗位选择
const toggleJobSelection = (item) => {
const index = checkList.value.indexOf(item);
if (index > -1) {
checkList.value.splice(index, 1);
} else {
checkList.value.push(item);
}
};
// 暴露方法给父组件
defineExpose({
showDialog
});
onMounted(() => {
setTimeout(() => {
type.value = props.signType;
if (props.jobFairId) {
id.value = props.jobFairId;
getJobList();
if (props.signType == 2) {
getAreaAndBoothInfo();
}
}
}, 100);
});
// 监听jobFairId变化
watch(() => props.jobFairId, (newVal) => {
if (newVal) {
id.value = newVal;
getJobList();
if (type.value === 2) {
getAreaAndBoothInfo();
}
}
});
</script>
<style lang="scss" scoped>
.del-icon {
margin-left: 30rpx;
}
.btn-box {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
margin-top: 30rpx;
}
.btn-box button {
padding: 0 80rpx;
height: 80rpx;
line-height: 80rpx;
}
.avatar-uploader {
border: 2rpx solid #0983ff;
border-radius: 12rpx;
cursor: pointer;
position: relative;
overflow: hidden;
width: 400rpx;
height: 200rpx;
}
.avatar-uploader-icon {
font-size: 56rpx;
color: #007AFF;
line-height: 200rpx;
text-align: center;
}
.job-dialog {
width: 100%;
height: 100%;
}
.dialog-content {
padding: 0 20rpx;
height: calc(100% - 17vh);
overflow-y: auto;
box-sizing: border-box;
}
.checkbox-group {
width: 100%;
}
.checkbox-item {
display: flex;
align-items: center;
border-bottom: 2rpx solid #b5d3ff;
padding: 30rpx 0;
}
.job-item {
width: 97%;
}
.checkbox-icon {
width: 40rpx;
height: 40rpx;
border: 2rpx solid #ddd;
border-radius: 8rpx;
margin-right: 20rpx;
display: flex;
align-items: center;
justify-content: center;
}
.checkbox-icon.checked {
background-color: #409eff;
border-color: #409eff;
color: white;
}
.job-info {
flex: 1;
display: flex;
justify-content: space-between;
align-items: center;
}
.detail-item {
margin-bottom: 40rpx;
}
.detail-item .gw-label {
font-size: 32rpx;
color: #333333;
margin-bottom: 20rpx;
}
.detail-item .gw-value {
display: flex;
flex-wrap: wrap;
overflow-y: auto;
}
.detail-item .gw-value .cd-detail {
width: 100%;
background: #fff;
border-radius: 20rpx;
margin-bottom: 28rpx;
margin-top: 28rpx;
}
.detail-item .gw-value .cd-detail .cd-name {
background: #d3e8ff;
color: #0076d9;
font-size: 40rpx;
height: 80rpx;
line-height: 80rpx;
padding: 0 40rpx;
border-radius: 16rpx;
overflow: hidden;
position: relative;
}
.detail-item .gw-value .cd-detail .cd-name::after {
content: "";
position: absolute;
left: 0;
top: 0;
width: 10rpx;
height: 100%;
background: #349cfc;
}
.detail-item .gw-value .cd-detail .cd-con {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 30rpx 40rpx;
gap: 20rpx;
}
.detail-item .gw-value .cd-detail .cd-con .cd-con-item {
width: 80rpx;
height: 80rpx;
background: #67CFA7;
line-height: 80rpx;
text-align: center;
color: #fff;
border: 2rpx solid #ddd;
border-radius: 20rpx;
cursor: pointer;
font-weight: 600;
font-size: 32rpx;
}
.detail-item .gw-value .cd-detail .cd-con .cd-con-item-review {
background-color: #F8BB92;
}
.detail-item .gw-value .cd-detail .cd-con .cd-con-item-checked {
background: #F6A1A1;
}
.detail-item .gw-value .cd-detail .cd-con .cd-con-item-mychecked {
background: #79BEFE;
}
.item-checkbox {
width: 100%;
padding: 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.job-name {
font-size: 32rpx;
color: #409eff;
}
.salary {
font-size: 32rpx;
color: #ff6e27;
font-weight: 600;
}
.header-title {
font-size: 38rpx;
font-weight: 600;
color: #303133;
padding: 20rpx;
padding-bottom: 40rpx;
background: #fff;
display: flex;
align-items: center;
position: sticky;
top: 0;
}
.header-title image {
width: 14rpx;
height: 33rpx;
margin-right: 14rpx;
}
.avatar {
width: 400rpx;
height: 200rpx;
border-radius: 12rpx;
}
/* 展位状态说明样式 */
.status-description {
margin-top: 30rpx;
padding: 20rpx;
background-color: #f5f7fa;
border-radius: 8rpx;
display: flex;
align-items: center;
flex-wrap: wrap;
}
.status-title {
font-weight: bold;
margin-bottom: 16rpx;
width: 100%;
}
.status-item {
width: 43%;
display: flex;
align-items: center;
margin-right: 30rpx;
margin-bottom: 10rpx;
}
.status-color {
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
}
.status-color.available {
background-color: #67CFA7;
border: 2rpx solid #ddd;
}
.status-color.occupied {
background-color: #F6A1A1;
}
.status-color.pending {
background-color: #F8BB92;
}
.status-color.selected {
background-color: #79BEFE;
}
.status-text {
margin-right: 16rpx;
}
/* 透明按钮样式 */
.transparent-btn {
background: transparent !important;
border: 2rpx dashed #0983ff !important;
}
</style>

203
components/placePicker.vue Normal file
View File

@@ -0,0 +1,203 @@
<template>
<view>
<u-popup :show="visible">
<view style="position: relative;height: 100vh;width: 100%;">
<view class="button-area" style="padding: 8vh 32rpx 24rpx 32rpx; margin: 0;border: 0;position: relative;z-index: 2;display: block; top: 10rpx; border-radius: 0;">
<u-input style="margin-bottom: 16px;" v-model="placeInput" @change="getLocations" placeholder="请输入并选择相应地点"></u-input>
<view v-if="checkedMarker&&checkedMarker.name" class="selected">您已选择:{{ checkedMarker.name }}<text v-if="checkedMarker.address">{{ checkedMarker.address }}</text></view>
<view v-for="(item, index) in placeList" :key="index" :label="item.name" :value="item.name" @click="addIcon(item.name)" class="place-list">
<view style="display: flex;justify-content: space-between;">{{ item.name }}
<view style="color: #8492a6; font-size: 13px;width: 50%">{{ item.address }}</view>
</view>
</view>
</view>
<view class="map" id="map"></view>
<view class="button-area">
<view class="btn" @click="cancel"> </view>
<view class="btn save" @click="submitForm"> </view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
//import { jsonp } from "vue-jsonp";
export default {
data() {
return {
map: '',
placeList: [],
placeInput: '',
markerList: [],
checkedMarker: '',
visible: false,
}
},
mounted() {
// this.openDialog();
},
methods: {
submitForm() {
if(this.checkedMarker&&this.checkedMarker.name){
this.$emit('selected', this.checkedMarker)
this.visible = false;
}else{
this.$message.warning('您尚未选择地点!')
}
},
cancel() {
this.visible = false;
if (this.map) {
this.map.removeEventListener('click', this.handleMapClick);
}
},
openDialog() {
this.visible = true;
this.$nextTick(() => {
this.map = new BMapGL.Map("map");
var point = new BMapGL.Point(117.123237,36.657017);
this.map.centerAndZoom(point, 15);
this.map.enableScrollWheelZoom();
var locationCtrl = new BMapGL.LocationControl();
this.map.addControl(locationCtrl)
this.map.addEventListener('click', this.handleMapClick);
})
},
handleMapClick(e) {
const lng = e.latlng.lng;
const lat = e.latlng.lat;
// 逆地理编码
jsonp("https://api.map.baidu.com/reverse_geocoding/v3/", {
ak: "qr93Dm5Ph6Vb4n1aTfvHG9KZkvG8S4YU",
output: "json",
location: `${lat},${lng}`,
}).then(res => {
if (res.status === 0) {
// 清除原有标记
this.removeOverlay();
// 新建标记
const point = new BMapGL.Point(lng, lat);
const marker = new BMapGL.Marker(point);
this.map.addOverlay(marker);
this.markerList = [marker];
// 保存选中信息
this.checkedMarker = {
name: res.result.formatted_address,
address: res.result.sematic_description,
location: { lng, lat }
};
this.$forceUpdate();
}
});
},
getLocations(place) {
jsonp("https://api.map.baidu.com/place/v2/suggestion", {
q: place,
ak: "qr93Dm5Ph6Vb4n1aTfvHG9KZkvG8S4YU",
region: '济南市',
output: "json",
})
.then((json) => {
console.log(json,23423434)
this.placeList = json.result
})
.catch((err) => {
console.log(err);
});
},
addIcon(e) {
let arr = this.placeList.filter(ele => ele.name == e)
if(arr.length){
this.addMaker(arr)
this.clickMaker(arr[0]);
}else{
this.addMaker(JSON.parse(JSON.stringify(this.placeList)))
}
this.placeList = []
},
removeOverlay() {
this.markerList.forEach(ele => {
this.map.removeOverlay(ele)
})
},
addMaker(list) {
this.removeOverlay()
list.forEach((ele, index) => {
let point = new BMapGL.Point(ele.location.lng, ele.location.lat);
if(index == 0){
this.map.centerAndZoom(point, 15)
}
let marker = new BMapGL.Marker(point); // 创建标注
this.map.addOverlay(marker);
let that = this;
this.markerList.push(marker)
marker.addEventListener("click", function(){
that.clickMaker(ele)
});
})
},
clickMaker(e){
this.checkedMarker = e;
this.$forceUpdate();
}
}
}
</script>
<style lang="scss" scoped>
.selected {
margin-bottom: 16px;
position: relative;z-index: 2;
background: #DCE2E9;
border-radius: 8rpx;
padding: 12rpx 24rpx;
}
.map{
width: 100%;
margin-top: 16px;
height: 100%;
position: absolute;
z-index: 1;
left: 0;
top: 0;
}
.button-area{
position: absolute;
z-index: 2;
bottom: 0;
padding: 24rpx 32rpx 68rpx;
width: 100%;
background: #fff;
display: flex;
box-sizing: border-box;
margin-top: 40rpx;
border-radius: 16px 16px 0px 0px;
.btn{
line-height: 72rpx;
width: 176rpx;
margin-right: 16rpx;
font-size: 28rpx;
border: 1px solid #B8C5D4;
color: #282828;
text-align: center;
border-radius: 8rpx;
}
.reset{
background: #DCE2E9;
}
.save{
background: linear-gradient(103deg, #1D64CF 0%, #1590D4 99%);
color: #fff;
border: 0;
flex-grow: 1;
}
}
.place-list{
line-height: 32rpx;
padding: 16rpx 0;
border-bottom: 1px solid #DCE2E9;
}
</style>

View File

@@ -1,12 +1,9 @@
export default {
// baseUrl: 'http://39.98.44.136:8080', // 测试
baseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 测试
// baseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 测试
LCBaseUrl:'http://10.110.145.145:9100',//招聘、培训、帮扶
LCBaseUrlInner:'http://10.110.145.145:10100',//内网端口
imgBaseUrl:'http://10.110.145.145/images', //图片基础url
trainVideoImgUrl:'http://10.110.145.145:9100/file/file/minio',
// sseAI+
// StreamBaseURl: 'http://39.98.44.136:8000',
StreamBaseURl: 'https://qd.zhaopinzao8dian.com/ai',

View File

@@ -1,222 +0,0 @@
# 微信小程序主包体积优化方案
## 当前主包体积分析
根据代码依赖分析图,主包体积为 **2.74MB**,主要组成部分:
### 1. 静态资源 (848KB)
- **images (507KB)**: 包含多个大图片文件
- `video-bj2.png`: 156KB
- `video-jt.png`: 126KB
- `spxx-k.png`: 54KB
- `bj.jpg`: 52KB
- `imgs/avatar.jpg`: 48KB
- **icon (187KB)**: 图标文件
### 2. JavaScript 库文件
- **uni_modules/lime-echart/static/echarts.min.js**: 568KB ⚠️
- **lib/lunar-javascript@1.7.2.js**: 301KB ⚠️
- **lib/highlight/highlight-uni.min.js**: 166KB
- **common/vendor.js**: 293KB (未找到,可能已删除)
### 3. 其他
- **uni_modules**: 751KB
- **pages**: 363KB
- **common**: 316KB
---
## 优化方案
### 方案一:删除主包中未使用的大文件(立即执行)
#### 1.1 删除主包中的 echarts.min.js
**问题**: `uni_modules/lime-echart/static/echarts.min.js` (568KB) 在主包中,但只在 `packageCa` 分包中使用。
**解决方案**:
- ✅ 确认 `packageCa` 分包中已有 `packageCa/utilCa/echarts.min.js`
- ✅ 删除主包中的 `uni_modules/lime-echart/static/echarts.min.js`(如果不需要在主包使用)
- ⚠️ 注意:如果主包页面也需要使用 echarts需要保留或按需加载
**操作步骤**:
```bash
# 检查主包中是否有页面使用 echarts
# 如果没有,可以删除或移动到分包
```
#### 1.2 删除主包中的 lunar-javascript@1.7.2.js
**问题**: `lib/lunar-javascript@1.7.2.js` (301KB) 在主包中,但只在 `packageA/pages/selectDate/selectDate.vue` 中使用。
**解决方案**:
- ✅ 确认 `packageA/lib/lunar-javascript@1.7.2.js` 已存在
- ✅ 删除主包中的 `lib/lunar-javascript@1.7.2.js`
- ✅ 更新 `packageA/pages/selectDate/selectDate.vue` 中的引用路径
**操作步骤**:
1. 确认 `packageA/lib/lunar-javascript@1.7.2.js` 存在
2. 删除 `lib/lunar-javascript@1.7.2.js`
3. 确保 `packageA/pages/selectDate/selectDate.vue` 使用分包内的文件
---
### 方案二:优化图片资源(预计减少 300-400KB
#### 2.1 压缩大图片文件
**目标图片**:
- `static/images/train/video-bj2.png` (156KB) → 目标: <80KB
- `static/images/train/video-jt.png` (126KB) 目标: <60KB
- `static/images/train/spxx-k.png` (54KB) 目标: <30KB
- `static/images/train/bj.jpg` (52KB) 目标: <30KB
- `static/imgs/avatar.jpg` (48KB) 目标: <25KB
**工具推荐**:
- [TinyPNG](https://tinypng.com/) - PNG压缩
- [Squoosh](https://squoosh.app/) - 在线图片压缩
- [ImageOptim](https://imageoptim.com/) - 批量压缩
#### 2.2 将非首屏必需图片移到分包
**策略**:
- `static/images/train/` 目录下的图片移到 `packageB` 分包培训相关
- 只在需要时加载这些图片
**操作步骤**:
1. 创建 `packageB/static/images/train/` 目录
2. 移动图片文件到分包
3. 更新相关页面的图片路径
---
### 方案三:优化 markdown 相关库(预计减少 166KB
#### 3.1 将 highlight-uni.min.js 移到分包
**问题**: `lib/highlight/highlight-uni.min.js` (166KB) `utils/markdownParser.js` 中使用主要用于 chat 页面
**解决方案**:
- 方案A: markdown 相关库移到独立分包按需加载
- 方案B: 使用更轻量的代码高亮库
- 方案C: 如果只在 chat 页面使用可以移到 chat 页面所在的分包
**推荐方案**: 方案C - markdown 相关库移到 chat 页面附近
**操作步骤**:
1. 创建 `pages/chat/lib/` 目录
2. 移动 `lib/highlight/` `lib/markdown-it.min.js` 到该目录
3. 更新 `utils/markdownParser.js` 中的引用路径
---
### 方案四:清理未使用的 uni_modules预计减少 100-200KB
#### 4.1 检查 uni_modules 使用情况
**需要检查的模块**:
- `custom-waterfalls-flow` - 检查是否在主包使用
- `uni-data-select` - 检查是否在主包使用
- `uni-dateformat` - 检查是否在主包使用
- `uni-load-more` - 检查是否在主包使用
- `uni-popup` - 检查是否在主包使用
- `uni-steps` - 检查是否在主包使用
- `uni-swipe-action` - 检查是否在主包使用
- `uni-transition` - 检查是否在主包使用
**操作步骤**:
1. 搜索每个模块在主包中的使用情况
2. 如果只在分包中使用可以考虑移除主包的引用
3. 使用 `easycom` 配置确保组件能正确加载
---
### 方案五:代码分割和按需加载
#### 5.1 使用分包预加载
`pages.json` 中配置分包预加载优化用户体验
```json
{
"preloadRule": {
"pages/index/index": {
"network": "all",
"packages": ["packageA"]
}
}
}
```
#### 5.2 动态导入大型库
对于只在特定场景使用的大型库使用动态导入
```javascript
// 示例:按需加载 echarts
const loadEcharts = async () => {
if (typeof require !== 'undefined') {
return require('../../utilCa/echarts.min.js');
} else {
return await import('../../utilCa/echarts.min.js');
}
};
```
---
## 优化效果预估
| 优化项 | 预计减少体积 | 优先级 |
|--------|------------|--------|
| 删除主包 echarts.min.js | 568KB | 🔴 |
| 删除主包 lunar-javascript | 301KB | 🔴 |
| 压缩图片资源 | 300-400KB | 🟡 |
| 优化 markdown | 166KB | 🟡 |
| 清理未使用模块 | 100-200KB | 🟢 |
**总计预计减少**: 1.4MB - 1.6MB
**优化后主包体积**: 1.1MB - 1.3MB
---
## 实施步骤
### 第一阶段:立即执行(预计减少 869KB✅ 已完成
1. 删除主包中未使用的 `echarts.min.js` (567KB) - **已完成**
2. 删除主包中未使用的 `lunar-javascript@1.7.2.js` (301KB) - **已完成**
3. 验证分包中的文件引用正确 - **已验证**
**第一阶段优化结果**: 已减少 **868KB** 主包体积
### 第二阶段:图片优化(预计减少 300-400KB
1. 压缩大图片文件
2. 将非首屏图片移到分包
3. 更新图片路径引用
### 第三阶段:代码优化(预计减少 166-366KB
1. 优化 markdown 相关库的位置
2. 清理未使用的 uni_modules
3. 配置分包预加载
---
## 注意事项
1. **备份**: 在执行删除操作前请先备份项目
2. **测试**: 每个优化步骤后都要进行完整测试
3. **引用路径**: 确保所有文件引用路径正确更新
4. **分包限制**: 注意微信小程序分包大小限制单个分包不超过 2MB
5. **主包限制**: 主包大小建议控制在 1.5MB 以内
---
## 验证方法
1. 使用微信开发者工具上传代码查看主包体积
2. 使用代码依赖分析工具验证优化效果
3. 测试各个功能模块确保正常工作
4. 检查分包加载是否正常
---
## 后续维护建议
1. **定期检查**: 每月检查主包体积防止体积反弹
2. **图片规范**: 建立图片压缩和优化规范
3. **依赖管理**: 新增依赖时评估对主包体积的影响
4. **代码审查**: 在代码审查时关注主包体积变化

View File

@@ -1,118 +0,0 @@
# 主包体积优化执行记录
## 优化时间
2024年具体日期待补充
## 已完成的优化
### 1. 删除主包中未使用的 echarts.min.js ✅
- **文件路径**: `uni_modules/lime-echart/static/echarts.min.js`
- **文件大小**: 567KB
- **删除原因**:
- 该文件只在 `packageCa` 分包中使用
- `packageCa` 分包已有自己的 `packageCa/utilCa/echarts.min.js`
- `l-echart` 组件通过 `init()` 方法接收 echarts 实例,不直接引用主包文件
- `lime-echart` 组件未被使用
- **影响范围**: 无影响,分包功能正常
### 2. 删除主包中未使用的 lunar-javascript@1.7.2.js ✅
- **文件路径**: `lib/lunar-javascript@1.7.2.js`
- **文件大小**: 301KB
- **删除原因**:
- 该文件只在 `packageA/pages/selectDate/selectDate.vue` 中使用
- `packageA` 分包已有自己的 `packageA/lib/lunar-javascript@1.7.2.js`
- 主包中没有任何页面使用该文件
- **影响范围**: 无影响,分包功能正常
### 3. 将 static/images/train 目录移到 packageB 分包 ✅
- **目录路径**: `static/images/train/`
- **目录大小**: 约 400-500KB
- **移动原因**:
- 该目录下的图片只在 `packageB` 分包中使用
- 包括 `video-bj2.png` (156KB)、`video-jt.png` (126KB) 等大图片
- **操作**:
- 移动到 `packageB/static/images/train/`
- 更新所有引用路径为 `/packageB/static/images/train/`
- **影响范围**: 无影响,分包功能正常
### 4. 删除未使用的 demo 页面 ✅
- **目录路径**: `pages/demo/`
- **删除原因**:
- 该目录不在 `pages.json` 中配置
- 仅包含演示文件,未实际使用
- **影响范围**: 无影响
## 优化效果
### 已减少体积
- **echarts.min.js**: 567KB
- **lunar-javascript@1.7.2.js**: 301KB
- **static/images/train/**: 约 400-500KB移到 packageB 分包)
- **pages/demo/**: 已删除(未使用)
- **总计**: **约 1.27MB - 1.37MB**
### 优化前主包体积
- **2.74MB**
### 优化后主包体积(预估)
- **约 1.37MB - 1.47MB** (减少 50-50.5%)
### 当前状态
- **当前主包体积**: 2.19MB
- **目标**: < 1.5MB
- **还需减少**: 690KB
## 待执行的优化
### 1. 图片资源优化(预计减少 300-400KB
- [ ] 压缩 `static/images/train/video-bj2.png` (156KB <80KB)
- [ ] 压缩 `static/images/train/video-jt.png` (126KB <60KB)
- [ ] 压缩 `static/images/train/spxx-k.png` (54KB <30KB)
- [ ] 压缩 `static/images/train/bj.jpg` (52KB <30KB)
- [ ] 压缩 `static/imgs/avatar.jpg` (48KB <25KB)
- [ ] 将非首屏必需图片移到分包
### 2. Markdown 相关库优化(预计减少 166KB
- **说明**: `lib/highlight/highlight-uni.min.js` (166KB) `utils/markdownParser.js` 中使用
- **使用范围**:
- 主包: `pages/chat/chat.vue`
- 分包: `packageA/pages/moreJobs/moreJobs.vue`
- 组件: `components/md-render/md-render.vue`
- Store: `stores/userChatGroupStore.js`
- **建议**: 由于被主包和分包共同使用暂时保留在主包如需进一步优化可考虑
- 使用更轻量的代码高亮库
- 按需加载 highlight
- chat 相关功能移到独立分包
### 3. uni_modules 清理(预计减少 100-200KB
- [ ] 检查 `custom-waterfalls-flow` 是否在主包使用
- [ ] 检查 `uni-data-select` 是否在主包使用
- [ ] 检查 `uni-dateformat` 是否在主包使用
- [ ] 检查 `uni-load-more` 是否在主包使用
- [ ] 检查 `uni-popup` 是否在主包使用
- [ ] 检查 `uni-steps` 是否在主包使用
- [ ] 检查 `uni-swipe-action` 是否在主包使用
- [ ] 检查 `uni-transition` 是否在主包使用
## 验证方法
1. 使用微信开发者工具上传代码查看主包体积
2. 使用代码依赖分析工具验证优化效果
3. 测试各个功能模块确保正常工作
4. 检查分包加载是否正常
## 注意事项
1. **备份**: 已删除的文件可以从版本控制中恢复
2. **测试**: 建议在测试环境完整测试后再发布
3. **引用路径**: 所有文件引用路径已验证正确
4. **分包限制**: 注意微信小程序分包大小限制单个分包不超过 2MB
5. **主包限制**: 主包大小建议控制在 1.5MB 以内
## 后续建议
1. **定期检查**: 每月检查主包体积防止体积反弹
2. **图片规范**: 建立图片压缩和优化规范
3. **依赖管理**: 新增依赖时评估对主包体积的影响
4. **代码审查**: 在代码审查时关注主包体积变化

View File

@@ -1,246 +0,0 @@
# 地址数据懒加载优化方案
## 问题背景
地址JSON文件大小90M+,首次加载需要好几分钟,严重影响用户体验。
## 优化方案
### 方案1懒加载 + 分段加载(已实现)⭐ 推荐
**核心思想**:分段加载 + 后台预加载,大幅减少首次等待时间
1. **首次加载(优化策略)**
- **H5环境**使用Range请求只加载前2MB数据从中提取省份列表几秒完成
- **小程序环境**:如果完整数据已缓存,提取很快(< 1秒
- **降级方案**如果分段加载失败加载完整数据但只加载一次
- **后台预加载**提取省份列表后在后台加载完整数据不阻塞用户
2. **按需加载**用户选择省份后从缓存的完整数据中提取该省份的详细数据< 1秒
3. **智能缓存**完整数据会缓存后续使用会很快
#### 性能对比
| 场景 | 优化前 | 优化后懒加载+分段加载 |
|------|--------|--------------------------|
| 首次打开选择器H5无缓存 | 加载90M+3-5分钟 | 分段加载前2MB提取省份列表5-10秒 |
| 首次打开选择器小程序无缓存 | 加载90M+3-5分钟 | 加载完整数据并提取省份列表3-5分钟但只加载一次 |
| 首次打开选择器有缓存 | 加载90M+3-5分钟 | 从缓存提取省份列表< 1秒 |
| 选择省份有缓存 | 无需加载 | 从缓存提取省份数据< 1秒 |
| 切换省份有缓存 | 无需加载 | 从缓存读取< 1秒 |
**关键优化点**
- **H5环境**首次只需加载2MB数据几秒内显示省份列表
- **后台预加载**显示省份列表后在后台加载完整数据不阻塞用户
- 完整数据只加载一次之后永久缓存
- 后续所有操作都从缓存读取秒开
- 用户体验大幅提升首次打开几秒内可用而不是等待几分钟
#### 使用方式
组件已自动使用懒加载模式无需修改调用代码
```javascript
// 正常使用,自动懒加载
areaPicker.value?.open({
success: (addressData) => {
console.log('选择的地址:', addressData)
}
})
```
### 方案2服务器分片接口最佳方案🚀
如果服务器可以提供分片接口首次加载性能会进一步提升
**注意**当前默认使用方案1从完整数据提取)。如果服务器提供了分片接口可以在 `addressDataLoaderLazy.js` 中设置 `useSplitApi = true` 来启用
#### 需要的接口
1. **省份列表接口**轻量级
- URL: `http://124.243.245.42/ks_cms/address_provinces.json`
- 返回只包含省份基本信息不包含children
- 数据量< 1MB
2. **省份详情接口**按需加载
- URL: `http://124.243.245.42/ks_cms/address_province_{code}.json`
- 返回指定省份的完整数据包含所有下级
- 数据量每个省份 2-5MB
#### 数据格式示例
**省份列表接口返回格式:**
```json
[
{
"code": "110000",
"name": "北京市",
"_hasChildren": true
},
{
"code": "120000",
"name": "天津市",
"_hasChildren": true
}
]
```
**省份详情接口返回格式:**
```json
{
"code": "110000",
"name": "北京市",
"children": [
{
"code": "110100",
"name": "北京市",
"children": [...]
}
]
}
```
#### 配置分片接口
`utils/addressDataLoaderLazy.js` 中配置
```javascript
this.provinceListUrl = `${this.baseUrl}/address_provinces.json`;
this.provinceDetailUrl = `${this.baseUrl}/address_province_{code}.json`;
```
### 方案3数据压缩
确保服务器启用 gzip 压缩可以减少 70-80% 的传输大小
- 原始大小90MB
- 压缩后18-27MB
- 加载时间 3-5分钟 减少到 1-2分钟
**服务器配置示例Nginx**
```nginx
location /ks_cms/ {
gzip on;
gzip_types application/json;
gzip_min_length 1000;
}
```
## 数据分片工具
如果服务器无法提供分片接口可以使用提供的工具脚本将完整数据分片
### 使用 Node.js 脚本分片数据
创建 `scripts/splitAddressData.js`
```javascript
const fs = require('fs');
const path = require('path');
// 读取完整地址数据
const fullDataPath = path.join(__dirname, '../data/address.json');
const fullData = JSON.parse(fs.readFileSync(fullDataPath, 'utf8'));
// 输出目录
const outputDir = path.join(__dirname, '../data/split');
// 创建输出目录
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
// 1. 生成省份列表(轻量级)
const provinceList = fullData.map(province => ({
code: province.code,
name: province.name,
_hasChildren: !!province.children && province.children.length > 0
}));
fs.writeFileSync(
path.join(outputDir, 'address_provinces.json'),
JSON.stringify(provinceList, null, 2),
'utf8'
);
console.log('✅ 省份列表已生成');
// 2. 为每个省份生成详情文件
fullData.forEach(province => {
const fileName = `address_province_${province.code}.json`;
fs.writeFileSync(
path.join(outputDir, fileName),
JSON.stringify(province, null, 2),
'utf8'
);
console.log(`✅ ${province.name} 详情已生成`);
});
console.log('✅ 数据分片完成!');
```
运行脚本
```bash
node scripts/splitAddressData.js
```
然后将生成的文件上传到服务器
## 降级方案
如果服务器不提供分片接口懒加载器会自动降级
1. **首次加载省份列表**
- 尝试从完整数据缓存中提取如果已缓存很快
- 如果未缓存需要加载完整数据仍然很慢但只加载一次
2. **加载省份详情**
- 尝试从完整数据缓存中提取如果已缓存很快
- 如果未缓存需要加载完整数据仍然很慢
**建议**即使使用降级方案首次完整加载后后续使用会很快因为数据已缓存)。
## 最佳实践
1. **优先使用服务器分片接口**性能最佳
2. **启用 gzip 压缩**减少传输大小
3. **使用 CDN 加速**提升加载速度
4. **合理设置缓存时间**默认7天可根据数据更新频率调整
## 配置说明
`utils/addressDataLoaderLazy.js` 中可以配置
```javascript
// 数据源基础URL
this.baseUrl = 'http://124.243.245.42/ks_cms';
// 省份列表URL轻量级
this.provinceListUrl = `${this.baseUrl}/address_provinces.json`;
// 省份详情URL按需加载
this.provinceDetailUrl = `${this.baseUrl}/address_province_{code}.json`;
// 缓存有效期(天)
this.cacheExpireDays = 7;
```
## 性能监控
组件会在控制台输出加载日志可以监控性能
```
📥 开始加载: http://124.243.245.42/ks_cms/address_provinces.json
✅ 数据加载完成,耗时 2.34 秒
✅ 从缓存加载省份列表
📥 懒加载省份详情: 北京市 (110000)
✅ 数据加载完成,耗时 3.56 秒
```
## 总结
- **懒加载方案已实现**首次加载从几分钟减少到几秒
- 🚀 **服务器分片接口**可以进一步提升性能
- 💾 **智能缓存**已加载的数据会缓存切换时秒开
- 🔄 **自动降级**即使服务器不支持分片也能正常工作

View File

@@ -1,161 +0,0 @@
# 主包体积进一步优化方案
## 当前状态
- **优化前主包体积**: 2.74MB
- **第一次优化后**: 2.19MB (已减少 550KB)
- **目标**: < 1.5MB
- **还需减少**: 690KB
## 已完成的优化 ✅
### 1. 删除未使用的大文件 (868KB)
- `uni_modules/lime-echart/static/echarts.min.js` (567KB)
- `lib/lunar-javascript@1.7.2.js` (301KB)
### 2. 移动 train 图片到分包 (预计 400-500KB)
- `static/images/train/` 目录移到 `packageB/static/images/train/`
- 更新所有引用路径
**已减少总计**: 1.27MB - 1.37MB
## 进一步优化建议
### 方案一:优化图片资源(预计减少 200-300KB
#### 1.1 压缩主包中的大图片
需要压缩的图片文件
- `static/icon/background2.png` - 检查大小
- `static/imgs/avatar.jpg` (48KB) 目标: <25KB
- `static/imgs/fristEntry.png` - 检查大小
- 其他 `static/icon/` 目录下的图片
**工具推荐**:
- [TinyPNG](https://tinypng.com/) - PNG压缩
- [Squoosh](https://squoosh.app/) - 在线图片压缩
- [ImageOptim](https://imageoptim.com/) - 批量压缩
#### 1.2 将非首屏必需图片移到分包
- `static/imgs/` 目录移到分包如果只在特定页面使用
- 检查 `static/icon/` 中哪些图标可以移到分包
### 方案二:优化 Markdown 相关库(预计减少 296KB
#### 2.1 当前情况
- `lib/highlight/highlight-uni.min.js`: 203KB
- `lib/markdown-it.min.js`: 93KB
- 总计: 296KB
#### 2.2 使用范围
- 主包: `pages/chat/chat.vue` (主包页面)
- 分包: `packageA/pages/moreJobs/moreJobs.vue`
- 组件: `components/md-render/md-render.vue`
- Store: `stores/userChatGroupStore.js`
#### 2.3 优化方案
**方案A**: chat 页面移到独立分包推荐
- 创建新分包 `packageChat`
- `pages/chat/` 移到分包
- markdown 相关库移到分包
- **预计减少**: 296KB + chat页面代码体积
**方案B**: 使用更轻量的代码高亮库
- 替换 `highlight-uni.min.js` 为更轻量的库
- 或移除代码高亮功能如果非必需
**方案C**: 按需加载
- 使用动态 import 按需加载 markdown
- 只在需要时加载
### 方案三:检查并优化 components 目录
#### 3.1 检查组件使用情况
需要检查的组件
- `components/md-render/` - 如果只在 chat 使用可移到分包
- `components/area-cascade-picker/` - 检查使用范围
- 其他大型组件
#### 3.2 优化策略
- 将只在分包使用的组件移到对应分包
- 将大型组件按需加载
### 方案四:检查 pages 目录
#### 4.1 可以移到分包的页面
检查以下页面是否可以移到分包
- `pages/complete-info/` - 补全信息相关可能可以移到 packageA
- `pages/job/` - 发布岗位相关可能可以移到 packageA
- `pages/demo/` - 演示页面可以删除或移到测试分包
#### 4.2 优化策略
- 将非核心功能页面移到分包
- 删除测试/演示页面
### 方案五:清理未使用的 uni_modules
#### 5.1 检查列表
检查以下模块是否在主包使用
- `custom-waterfalls-flow`
- `uni-data-select`
- `uni-dateformat`
- `uni-load-more`
- `uni-popup`
- `uni-steps`
- `uni-swipe-action`
- `uni-transition`
#### 5.2 优化策略
- 如果只在分包使用可以考虑移除主包引用
- 使用 `easycom` 配置确保组件能正确加载
### 方案六:优化 common 目录
#### 6.1 检查文件
- `common/vendor.js` - 如果存在检查是否可以优化
- `common/globalFunction.js` - 检查是否可以拆分
- 其他 common 文件
## 推荐执行顺序
### 优先级1立即执行预计减少 300-400KB
1. 压缩主包中的大图片
2. `pages/demo/` 删除或移到测试分包
3. 检查并清理未使用的 uni_modules
### 优先级2中期执行预计减少 296KB
1. chat 页面移到独立分包推荐方案A
2. 或使用更轻量的代码高亮库方案B
### 优先级3长期优化
1. 优化 components 目录
2. 优化 pages 目录结构
3. 优化 common 目录
## 预期效果
| 优化项 | 预计减少 | 优先级 |
|--------|---------|--------|
| 压缩图片 | 200-300KB | 🔴 |
| 移动 chat 页面到分包 | 296KB+ | 🔴 |
| 删除 demo 页面 | 50-100KB | 🟡 |
| 清理 uni_modules | 100-200KB | 🟡 |
| 优化 components | 50-150KB | 🟢 |
**总计预计减少**: 696KB - 1046KB
**优化后主包体积**: 1.14MB - 1.49MB
## 注意事项
1. **备份**: 在执行优化前请先备份项目
2. **测试**: 每个优化步骤后都要进行完整测试
3. **引用路径**: 确保所有文件引用路径正确更新
4. **分包限制**: 注意微信小程序分包大小限制单个分包不超过 2MB
5. **主包限制**: 主包大小必须控制在 1.5MB 以内
## 验证方法
1. 使用微信开发者工具上传代码查看主包体积
2. 使用代码依赖分析工具验证优化效果
3. 测试各个功能模块确保正常工作
4. 检查分包加载是否正常

View File

@@ -1,174 +1,173 @@
import {
ref,
reactive,
watch,
isRef,
nextTick
} from 'vue'
export function usePagination(
requestFn,
transformFn,
options = {}
) {
const list = ref([])
const loading = ref(false)
const error = ref(false)
const finished = ref(false)
const firstLoading = ref(true)
const empty = ref(false)
const {
pageSize = 10,
search = {},
autoWatchSearch = false,
debounceTime = 300,
autoFetch = false,
// 字段映射
dataKey = 'rows',
totalKey = 'total',
// 分页字段名映射
pageField = 'current',
sizeField = 'pageSize',
onBeforeRequest,
onAfterRequest
} = options
const pageState = reactive({
page: 1,
pageSize: isRef(pageSize) ? pageSize.value : pageSize,
total: 0,
maxPage: 1,
search: isRef(search) ? search.value : search
})
let debounceTimer = null
const fetchData = async (type = 'refresh') => {
if (loading.value) return Promise.resolve()
console.log(type)
loading.value = true
error.value = false
if (typeof onBeforeRequest === 'function') {
try {
onBeforeRequest(type, pageState)
} catch (err) {
console.warn('onBeforeRequest 执行异常:', err)
}
}
if (type === 'refresh') {
pageState.page = 1
finished.value = false
if (list.value.length === 0) {
firstLoading.value = true
}
} else if (type === 'loadMore') {
if (pageState.page >= pageState.maxPage) {
loading.value = false
finished.value = true
return Promise.resolve('no more')
}
pageState.page += 1
}
const params = {
...pageState.search,
[pageField]: pageState.page,
[sizeField]: pageState.pageSize,
}
try {
const res = await requestFn(params)
const rawData = res[dataKey]
const total = res[totalKey] || 99999999
console.log(total, rawData)
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
if (type === 'refresh') {
list.value = data
} else {
list.value.push(...data)
}
pageState.total = total
pageState.maxPage = Math.ceil(total / pageState.pageSize)
finished.value = list.value.length >= total
empty.value = list.value.length === 0
} catch (err) {
console.error('分页请求失败:', err)
error.value = true
} finally {
loading.value = false
firstLoading.value = false
if (typeof onAfterRequest === 'function') {
try {
onAfterRequest(type, pageState, {
error: error.value
})
} catch (err) {
console.warn('onAfterRequest 执行异常:', err)
}
}
}
}
const refresh = () => fetchData('refresh')
const loadMore = () => fetchData('loadMore')
const resetPagination = () => {
list.value = []
pageState.page = 1
pageState.total = 0
pageState.maxPage = 1
finished.value = false
error.value = false
firstLoading.value = true
empty.value = false
}
if (autoWatchSearch && isRef(search)) {
watch(search, (newVal) => {
pageState.search = newVal
clearTimeout(debounceTimer)
debounceTimer = setTimeout(() => {
refresh()
}, debounceTime)
}, {
deep: true
})
}
watch(pageSize, (newVal) => {
pageState.pageSize = newVal
}, {
deep: true
})
if (autoFetch) {
nextTick(() => {
refresh()
})
}
return {
list,
loading,
error,
finished,
firstLoading,
empty,
pageState,
refresh,
loadMore,
resetPagination
}
}
import {
ref,
reactive,
watch,
isRef,
nextTick
} from 'vue'
export function usePagination(
requestFn,
transformFn,
options = {}
) {
const list = ref([])
const loading = ref(false)
const error = ref(false)
const finished = ref(false)
const firstLoading = ref(true)
const empty = ref(false)
const {
pageSize = 10,
search = {},
autoWatchSearch = false,
debounceTime = 300,
autoFetch = false,
// 字段映射
dataKey = 'rows',
totalKey = 'total',
// 分页字段名映射
pageField = 'current',
sizeField = 'pageSize',
onBeforeRequest,
onAfterRequest
} = options
const pageState = reactive({
page: 1,
pageSize: isRef(pageSize) ? pageSize.value : pageSize,
total: 0,
maxPage: 1,
search: isRef(search) ? search.value : search
})
let debounceTimer = null
const fetchData = async (type = 'refresh') => {
if (loading.value) return Promise.resolve()
console.log(type)
loading.value = true
error.value = false
if (typeof onBeforeRequest === 'function') {
try {
onBeforeRequest(type, pageState)
} catch (err) {
console.warn('onBeforeRequest 执行异常:', err)
}
}
if (type === 'refresh') {
pageState.page = 1
finished.value = false
if (list.value.length === 0) {
firstLoading.value = true
}
} else if (type === 'loadMore') {
if (pageState.page >= pageState.maxPage) {
loading.value = false
finished.value = true
return Promise.resolve('no more')
}
pageState.page += 1
}
const params = {
...pageState.search,
[pageField]: pageState.page,
[sizeField]: pageState.pageSize,
}
try {
const res = await requestFn(params)
const rawData = res[dataKey]
const total = res[totalKey] || 99999999
console.log(total, rawData)
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
if (type === 'refresh') {
list.value = data
} else {
list.value.push(...data)
}
pageState.total = total
pageState.maxPage = Math.ceil(total / pageState.pageSize)
finished.value = list.value.length >= total
empty.value = list.value.length === 0
} catch (err) {
console.error('分页请求失败:', err)
error.value = true
} finally {
loading.value = false
firstLoading.value = false
if (typeof onAfterRequest === 'function') {
try {
onAfterRequest(type, pageState, {
error: error.value
})
} catch (err) {
console.warn('onAfterRequest 执行异常:', err)
}
}
}
}
const refresh = () => fetchData('refresh')
const loadMore = () => fetchData('loadMore')
const resetPagination = () => {
list.value = []
pageState.page = 1
pageState.total = 0
pageState.maxPage = 1
finished.value = false
error.value = false
firstLoading.value = true
empty.value = false
}
if (autoWatchSearch && isRef(search)) {
watch(search, (newVal) => {
pageState.search = newVal
clearTimeout(debounceTimer)
debounceTimer = setTimeout(() => {
refresh()
}, debounceTime)
}, {
deep: true
})
}
watch(pageSize, (newVal) => {
pageState.pageSize = newVal
}, {
deep: true
})
if (autoFetch) {
nextTick(() => {
refresh()
})
}
return {
list,
loading,
error,
finished,
firstLoading,
empty,
pageState,
refresh,
loadMore,
resetPagination
}
}

153
main.js
View File

@@ -1,14 +1,20 @@
/*
* @Date: 2025-11-03 10:52:09
* @Date: 2025-10-23 14:48:48
* @LastEditors: shirlwang
* @LastEditTime: 2025-11-04 11:14:21
* @LastEditTime: 2025-11-03 09:39:18
*/
import App from '@/App'
import App from './App'
import * as Pinia from 'pinia'
import globalFunction from '@/common/globalFunction'
import '@/lib/string-similarity.min.js'
import similarityJobs from '@/utils/similarity_Job.js';
import config from '@/config.js';
import globalFunction from './common/globalFunction'
import './lib/string-similarity.min.js'
import similarityJobs from './utils/similarity_Job.js';
import config from './config.js';
// 导入主包中的request.js用于字典服务
// 在uni-app小程序环境中主包不能直接引用分包中的模块
import { request, get, post, packageRcRequest, packageRcGet, packageRcPost } from './utils/request.js';
// 将request, get, post函数挂载到全局方便使用
// 挂载分包专用的请求函数使用固定baseURL和token
// 组件
import AppLayout from './components/AppLayout/AppLayout.vue';
import Empty from './components/empty/empty.vue';
@@ -18,13 +24,6 @@ import SelectPopup from '@/components/selectPopup/selectPopup.vue'
import SelectPopupPlugin from '@/components/selectPopup/selectPopupPlugin';
import RenderJobs from '@/components/renderJobs/renderJobs.vue';
import RenderCompanys from '@/components/renderCompanys/renderCompanys.vue';
import uniIcons from './uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
import uniPopup from './uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
import uniDataSelect from './uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue'
import uniSwipeAction from './uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.vue'
import uniSwipeActionItem from './uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item.vue'
import storeRc from './utilsRc/store/index.js'
import {processFileUrl,} from '@/utilsRc/common.js'
// iconfont.css 已在 App.vue 中通过 @import 引入,无需在此处重复引入
// import Tabbar from '@/components/tabbar/midell-box.vue'
// 自动导入 directives 目录下所有指令
@@ -32,18 +31,90 @@ const directives = import.meta.glob('./directives/*.js', {
eager: true
});
import {
createSSRApp,
} from 'vue'
import { createSSRApp } from 'vue'
// import { createStore } from 'vuex'
// 导入已安装的uni-ui组件
import uniIcons from './uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
import uniPopup from './uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
// // 创建Vuex store实例避免从分包导入
// const storeRc = createStore({
// state() {
// return {
// userInfo: null,
// token: '',
// roles: []
// }
// },
// mutations: {
// setUserInfo(state, userInfo) {
// state.userInfo = userInfo
// },
// setToken(state, token) {
// state.token = token
// },
// setRoles(state, roles) {
// state.roles = roles
// },
// logout(state) {
// state.userInfo = null
// state.token = ''
// state.roles = []
// }
// },
// actions: {
// async login({ commit }, userData) {
// // 登录逻辑
// commit('setUserInfo', userData)
// commit('setToken', 'mock-token')
// commit('setRoles', ['user'])
// }
// },
// getters: {
// roles: state => state.roles
// }
// })
import storeRc from './utilsRc/store/index.js'
// const foldFeature = window.visualViewport && 'segments' in window.visualViewport
// console.log('是否支持多段屏幕:', foldFeature)
import { getDict } from '@/apiRc/system/dict.js';
// 全局组件
// 字典缓存,避免重复请求
const dictCache = new Map();
// 获取字典数据的方法
async function getDict(dictType, forceRefresh = false) {
// 检查缓存
if (dictCache.has(dictType) && !forceRefresh) {
return dictCache.get(dictType);
}
try {
// 使用packageRc/utils/request.js中的请求方法
// 注意这里使用的baseURL是 http://10.160.0.5:8907/
const response = await request({
url: `system/dict/data/type/${dictType}`,
method: 'GET',
load: true
});
// 处理响应数据
if (response.code === 200 && response.data) {
// 缓存数据
dictCache.set(dictType, response.data);
return response.data;
}
return [];
} catch (error) {
console.error(`获取字典[${dictType}]失败:`, error);
return [];
}
}
export function createApp() {
const app = createSSRApp(App)
app.component('AppLayout', AppLayout)
app.component('Empty', Empty)
app.component('NoBouncePage', NoBouncePage)
@@ -51,30 +122,17 @@ export function createApp() {
app.component('SelectPopup', SelectPopup)
app.component('RenderJobs', RenderJobs)
app.component('RenderCompanys', RenderCompanys)
// app.component('tabbar-custom', Tabbar)
// 注册已安装的uni-ui组件
app.component('uni-icons', uniIcons)
app.component('uni-popup', uniPopup)
app.component('uni-data-select', uniDataSelect)
app.component('uni-swipe-action', uniSwipeAction)
app.component('uni-swipe-action-item', uniSwipeActionItem)
app.config.globalProperties.$processFileUrl = processFileUrl;
app.config.globalProperties.$getDict = getDict;
app.config.globalProperties.$store = storeRc;
app.config.globalProperties.$getDictSelectOption = async (dictType, isDigital = false, forceRefresh = false) => {
const dictData = await getDict(dictType, forceRefresh);
return dictData.map(item => ({
value: isDigital ? Number(item.dictValue || item.dictvalue) : (item.dictValue || item.dictvalue),
label: item.dictLabel || item.dictlabel,
...item
}));
};
// app.component('tabbar-custom', Tabbar)
// 注意项目缺少表单相关组件需要将模板中的uni-ui组件改为原生元素
for (const path in directives) {
const directiveModule = directives[path];
// 文件名作为指令名,./directives/fade.js => v-fade
const name = path.match(/\.\/directives\/(.*)\.js$/)[1];
const name = path.match(/\/directives\/(.*)\.js$/)[1];
app.directive(name, directiveModule.default);
}
@@ -85,13 +143,30 @@ export function createApp() {
});
app.provide('deviceInfo', globalFunction.getdeviceInfo());
app.use(SelectPopupPlugin);
// 先注册Pinia
app.use(Pinia.createPinia());
// 注册vuex
app.use(storeRc);
// 注册其他插件
app.use(SelectPopupPlugin);
// Vue 3 中挂载全局属性 - 字典获取方法
app.config.globalProperties.$getDict = getDict;
app.config.globalProperties.$store = storeRc;
app.config.globalProperties.$getDictSelectOption = async (dictType, isDigital = false, forceRefresh = false) => {
const dictData = await getDict(dictType, forceRefresh);
return dictData.map(item => ({
value: isDigital ? Number(item.dictValue || item.dictvalue) : (item.dictValue || item.dictvalue),
label: item.dictLabel || item.dictlabel,
...item
}));
};
return {
app,
Pinia
}
}
}

View File

@@ -50,7 +50,7 @@
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "wx4aa34488b965a331",
"appid" : "wx9d1cbc11c8c40ba7",
"setting" : {
"urlCheck" : false,
"es6" : true,
@@ -63,11 +63,7 @@
"desc" : "用于用户选择地图查看位置"
}
},
"lazyCodeLoading" : "requiredComponents",
"libVersion" : "3.5.7",
"optimization" : {
"subPackages" : true
}
"libVersion" : "3.5.7"
},
"mp-alipay" : {
"usingComponents" : true

25
node_modules/.package-lock.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "ks-app-employment-service",
"lockfileVersion": 2,
"requires": true,
"packages": {
"node_modules/dayjs": {
"version": "1.11.19",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz",
"integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw=="
},
"node_modules/jsbn": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz",
"integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A=="
},
"node_modules/sm-crypto": {
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/sm-crypto/-/sm-crypto-0.3.13.tgz",
"integrity": "sha512-ztNF+pZq6viCPMA1A6KKu3bgpkmYti5avykRHbcFIdSipFdkVmfUw2CnpM2kBJyppIalqvczLNM3wR8OQ0pT5w==",
"dependencies": {
"jsbn": "^1.1.0"
}
}
}
}

2
node_modules/jsbn/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
.DS_Store

16
node_modules/jsbn/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,16 @@
# v1.1.0
- Allow for es6 "default import", e.g. `import BigInteger from 'jsbn'`.
- Updated license file to read MIT
# v1.0.0
- breaking change: `require('jsbn')` no longer returns `BigInteger`. Use `require('jsbn').BigInteger` instead.
# v0.1.1
- fixed backwards-incompatible change in v0.1.0 where `require('jsbn') != BigInteger`. This patch version allows for `var BigInteger = require('jsbn')` or `var BigInteger = require('jsbn').BigInteger`.

40
node_modules/jsbn/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,40 @@
Licensing
---------
This software is covered under the following copyright:
/*
* Copyright (c) 2003-2005 Tom Wu
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
* THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* In addition, the following condition applies:
*
* All redistributions must retain an intact copy of this copyright notice
* and disclaimer.
*/
Address all questions regarding this license to:
Tom Wu
tjw@cs.Stanford.EDU

173
node_modules/jsbn/README.md generated vendored Normal file
View File

@@ -0,0 +1,173 @@
# jsbn: javascript big number
[Tom Wu's Original Website](http://www-cs-students.stanford.edu/~tjw/jsbn/)
I felt compelled to put this on github and publish to npm. I haven't tested every other big integer library out there, but the few that I have tested in comparison to this one have not even come close in performance. I am aware of the `bi` module on npm, however it has been modified and I wanted to publish the original without modifications. This is jsbn and jsbn2 from Tom Wu's original website above, with the module pattern applied to prevent global leaks and to allow for use with node.js on the server side.
## usage
var BigInteger = require('jsbn').BigInteger;
var bi = new BigInteger('91823918239182398123');
console.log(bi.bitLength()); // 67
## API
### bi.toString()
returns the base-10 number as a string
### bi.negate()
returns a new BigInteger equal to the negation of `bi`
### bi.abs
returns new BI of absolute value
### bi.compareTo
### bi.bitLength
### bi.mod
### bi.modPowInt
### bi.clone
### bi.intValue
### bi.byteValue
### bi.shortValue
### bi.signum
### bi.toByteArray
### bi.equals
### bi.min
### bi.max
### bi.and
### bi.or
### bi.xor
### bi.andNot
### bi.not
### bi.shiftLeft
### bi.shiftRight
### bi.getLowestSetBit
### bi.bitCount
### bi.testBit
### bi.setBit
### bi.clearBit
### bi.flipBit
### bi.add
### bi.subtract
### bi.multiply
### bi.divide
### bi.remainder
### bi.divideAndRemainder
### bi.modPow
### bi.modInverse
### bi.pow
### bi.gcd
### bi.isProbablePrime

11
node_modules/jsbn/example.html generated vendored Normal file
View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="index.js"></script>
<script src="example.js"></script>
</body>
</html>

5
node_modules/jsbn/example.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
(function () {
var BigInteger = jsbn.BigInteger;
var a = new BigInteger('91823918239182398123');
console.log(a.bitLength());
}());

1361
node_modules/jsbn/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

21
node_modules/jsbn/package.json generated vendored Normal file
View File

@@ -0,0 +1,21 @@
{
"name": "jsbn",
"version": "1.1.0",
"description": "The jsbn library is a fast, portable implementation of large-number math in pure JavaScript, enabling public-key crypto and other applications on desktop and mobile browsers.",
"main": "index.js",
"scripts": {
"test": "mocha test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/andyperlitch/jsbn.git"
},
"keywords": [
"biginteger",
"bignumber",
"big",
"integer"
],
"author": "Tom Wu",
"license": "MIT"
}

3
node_modules/jsbn/test/es6-import.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import {BigInteger} from '../';
console.log(typeof BigInteger)

3
node_modules/sm-crypto/.babelrc generated vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}

97
node_modules/sm-crypto/.eslintrc.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
module.exports = {
'extends': [
'airbnb-base',
'plugin:promise/recommended'
],
'parserOptions': {
'ecmaVersion': 9,
'ecmaFeatures': {
'jsx': false
},
'sourceType': 'module'
},
'env': {
'es6': true,
'node': true,
'jest': true
},
'plugins': [
'import',
'node',
'promise'
],
'rules': {
'arrow-parens': 'off',
'comma-dangle': [
'error',
'only-multiline'
],
'complexity': ['error', 20],
'func-names': 'off',
'global-require': 'off',
'handle-callback-err': [
'error',
'^(err|error)$'
],
'import/no-unresolved': [
'error',
{
'caseSensitive': true,
'commonjs': true,
'ignore': ['^[^.]']
}
],
'import/prefer-default-export': 'off',
'linebreak-style': 'off',
'no-catch-shadow': 'error',
'no-continue': 'off',
'no-div-regex': 'warn',
'no-else-return': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-shadow': 'off',
'no-multi-assign': 'off',
'no-underscore-dangle': 'off',
'node/no-deprecated-api': 'error',
'node/process-exit-as-throw': 'error',
'object-curly-spacing': [
'error',
'never'
],
'operator-linebreak': [
'error',
'after',
{
'overrides': {
':': 'before',
'?': 'before'
}
}
],
'prefer-arrow-callback': 'off',
'prefer-destructuring': 'off',
'prefer-template': 'off',
'quote-props': [
1,
'as-needed',
{
'unnecessary': true
}
],
'semi': [
'error',
'never'
],
'max-len': 'off',
'no-bitwise': 'off',
'no-mixed-operators': 'off',
},
'globals': {
'window': true,
'document': true,
'App': true,
'Page': true,
'Component': true,
'Behavior': true
}
}

82
node_modules/sm-crypto/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,82 @@
## 0.3.13
* 支持根据私钥获取公钥
## 0.3.12
* 优化 sm3 运行性能
## 0.3.11
* sm2 支持压缩公钥
## 0.3.10
* 支持 sm3 hmac 模式
## 0.3.9
* 补充 sm4 解密时的 padding 判断
## 0.3.8
* sm2 解密时兼容密文可能是大写的情况
## 0.3.7
* 默认填充改为 pkcs#7,如传入 pkcs#5 也转到 pkcs#7 逻辑
## 0.3.6
* sm2 加解密支持二进制数据
## 0.3.5
* sm2.generateKeyPairHex 支持完整的 BigInteger 入参
## 0.3.4
* sm2 支持验证公钥接口
* sm2 生成密钥时支持自定义随机数
## 0.3.3
* dist 输出改成 umd 模式
## 0.3.2
* 修复 sm2 在 userId 长度大于 31 时新旧版本验签不通过的问题
## 0.3.0
* sm2、sm3 重构
* sm4 支持 cbc 模式
## 0.2.7
* 优化 sm3 性能
## 0.2.5
* sm3 支持字节数组输入
## 0.2.4
* 修复 sm4 四字节字符输出编码
## 0.2.3
* sm3/sm4 支持输入四字节字符
## 0.2.2
* sm3 支持中文输入
## 0.2.1
* 修复 sm2 点 16 进制串可能不满 64 位的问题
## 0.2.0
* sm4 默认支持 pkcs#5 填充方式
* sm4 支持输入输出为字符串

7
node_modules/sm-crypto/LICENCE_MIT generated vendored Normal file
View File

@@ -0,0 +1,7 @@
Copyright © 2018 june01
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

171
node_modules/sm-crypto/README.md generated vendored Normal file
View File

@@ -0,0 +1,171 @@
# sm-crypto
国密算法sm2、sm3和sm4的js实现。
## 安装
```bash
npm install --save sm-crypto
```
## sm2
### 获取密钥对
```js
const sm2 = require('sm-crypto').sm2
let keypair = sm2.generateKeyPairHex()
publicKey = keypair.publicKey // 公钥
privateKey = keypair.privateKey // 私钥
// 默认生成公钥 130 位太长,可以压缩公钥到 66 位
const compressedPublicKey = sm2.compressPublicKeyHex(publicKey) // compressedPublicKey 和 publicKey 等价
sm2.comparePublicKeyHex(publicKey, compressedPublicKey) // 判断公钥是否等价
// 自定义随机数,参数会直接透传给 jsbn 库的 BigInteger 构造器
// 注意:开发者使用自定义随机数,需要自行确保传入的随机数符合密码学安全
let keypair2 = sm2.generateKeyPairHex('123123123123123')
let keypair3 = sm2.generateKeyPairHex(256, SecureRandom)
let verifyResult = sm2.verifyPublicKey(publicKey) // 验证公钥
verifyResult = sm2.verifyPublicKey(compressedPublicKey) // 验证公钥
```
### 加密解密
```js
const sm2 = require('sm-crypto').sm2
const cipherMode = 1 // 1 - C1C3C20 - C1C2C3默认为1
let encryptData = sm2.doEncrypt(msgString, publicKey, cipherMode) // 加密结果
let decryptData = sm2.doDecrypt(encryptData, privateKey, cipherMode) // 解密结果
encryptData = sm2.doEncrypt(msgArray, publicKey, cipherMode) // 加密结果,输入数组
decryptData = sm2.doDecrypt(encryptData, privateKey, cipherMode, {output: 'array'}) // 解密结果,输出数组
```
> ps密文会在解密时自动补充 `04`,如遇到其他工具补充的 `04` 需手动去除再传入。
### 签名验签
> ps理论上来说只做纯签名是最快的。
```js
const sm2 = require('sm-crypto').sm2
// 纯签名 + 生成椭圆曲线点
let sigValueHex = sm2.doSignature(msg, privateKey) // 签名
let verifyResult = sm2.doVerifySignature(msg, sigValueHex, publicKey) // 验签结果
// 纯签名
let sigValueHex2 = sm2.doSignature(msg, privateKey, {
pointPool: [sm2.getPoint(), sm2.getPoint(), sm2.getPoint(), sm2.getPoint()], // 传入事先已生成好的椭圆曲线点,可加快签名速度
}) // 签名
let verifyResult2 = sm2.doVerifySignature(msg, sigValueHex2, publicKey) // 验签结果
// 纯签名 + 生成椭圆曲线点 + der编解码
let sigValueHex3 = sm2.doSignature(msg, privateKey, {
der: true,
}) // 签名
let verifyResult3 = sm2.doVerifySignature(msg, sigValueHex3, publicKey, {
der: true,
}) // 验签结果
// 纯签名 + 生成椭圆曲线点 + sm3杂凑
let sigValueHex4 = sm2.doSignature(msg, privateKey, {
hash: true,
}) // 签名
let verifyResult4 = sm2.doVerifySignature(msg, sigValueHex4, publicKey, {
hash: true,
}) // 验签结果
// 纯签名 + 生成椭圆曲线点 + sm3杂凑不做公钥推导
let sigValueHex5 = sm2.doSignature(msg, privateKey, {
hash: true,
publicKey, // 传入公钥的话可以去掉sm3杂凑中推导公钥的过程速度会比纯签名 + 生成椭圆曲线点 + sm3杂凑快
})
let verifyResult5 = sm2.doVerifySignature(msg, sigValueHex5, publicKey, {
hash: true,
publicKey,
})
// 纯签名 + 生成椭圆曲线点 + sm3杂凑 + 不做公钥推 + 添加 userId长度小于 8192
// 默认 userId 值为 1234567812345678
let sigValueHex6 = sm2.doSignature(msgString, privateKey, {
hash: true,
publicKey,
userId: 'testUserId',
})
let verifyResult6 = sm2.doVerifySignature(msgString, sigValueHex6, publicKey, {
hash: true,
userId: 'testUserId',
})
```
### 获取椭圆曲线点
```js
const sm2 = require('sm-crypto').sm2
let point = sm2.getPoint() // 获取一个椭圆曲线点可在sm2签名时传入
```
### 根据私钥获取公钥
```js
const sm2 = require('sm-crypto).sm2
let publicKey = sm2.getPublicKeyFromPrivateKey(privateKey)
```
## sm3
```js
const sm3 = require('sm-crypto').sm3
let hashData = sm3('abc') // 杂凑
// hmac
hashData = sm3('abc', {
key: 'daac25c1512fe50f79b0e4526b93f5c0e1460cef40b6dd44af13caec62e8c60e0d885f3c6d6fb51e530889e6fd4ac743a6d332e68a0f2a3923f42585dceb93e9', // 要求为 16 进制串或字节数组
})
```
## sm4
### 加密
```js
const sm4 = require('sm-crypto').sm4
const msg = 'hello world! 我是 juneandgreen.' // 可以为 utf8 串或字节数组
const key = '0123456789abcdeffedcba9876543210' // 可以为 16 进制串或字节数组,要求为 128 比特
let encryptData = sm4.encrypt(msg, key) // 加密,默认输出 16 进制字符串,默认使用 pkcs#7 填充(传 pkcs#5 也会走 pkcs#7 填充)
let encryptData = sm4.encrypt(msg, key, {padding: 'none'}) // 加密,不使用 padding
let encryptData = sm4.encrypt(msg, key, {padding: 'none', output: 'array'}) // 加密,不使用 padding输出为字节数组
let encryptData = sm4.encrypt(msg, key, {mode: 'cbc', iv: 'fedcba98765432100123456789abcdef'}) // 加密cbc 模式
```
### 解密
```js
const sm4 = require('sm-crypto').sm4
const encryptData = '0e395deb10f6e8a17e17823e1fd9bd98a1bff1df508b5b8a1efb79ec633d1bb129432ac1b74972dbe97bab04f024e89c' // 可以为 16 进制串或字节数组
const key = '0123456789abcdeffedcba9876543210' // 可以为 16 进制串或字节数组,要求为 128 比特
let decryptData = sm4.decrypt(encryptData, key) // 解密,默认输出 utf8 字符串,默认使用 pkcs#7 填充(传 pkcs#5 也会走 pkcs#7 填充)
let decryptData = sm4.decrypt(encryptData, key, {padding: 'none'}) // 解密,不使用 padding
let decryptData = sm4.decrypt(encryptData, key, {padding: 'none', output: 'array'}) // 解密,不使用 padding输出为字节数组
let decryptData = sm4.decrypt(encryptData, key, {mode: 'cbc', iv: 'fedcba98765432100123456789abcdef'}) // 解密cbc 模式
```
## 其他实现
* 小程序移植版:[https://github.com/wechat-miniprogram/sm-crypto](https://github.com/wechat-miniprogram/sm-crypto)
* java 实现(感谢 @antherd 提供):[https://github.com/antherd/sm-crypto](https://github.com/antherd/sm-crypto)
* dart 实现(感谢 @luckykellan 提供):[https://github.com/luckykellan/dart_sm](https://github.com/luckykellan/dart_sm)
## 协议
MIT

1
node_modules/sm-crypto/dist/sm2.js generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/sm-crypto/dist/sm3.js generated vendored Normal file
View File

@@ -0,0 +1 @@
!function(r,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sm3=n():r.sm3=n()}("undefined"!=typeof self?self:this,function(){return function(r){function n(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return r[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=r,n.c=t,n.d=function(r,t,e){n.o(r,t)||Object.defineProperty(r,t,{configurable:!1,enumerable:!0,get:e})},n.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(t,"a",t),t},n.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},n.p="",n(n.s=6)}({1:function(r,n,t){"use strict";function e(r){if(Array.isArray(r)){for(var n=0,t=Array(r.length);n<r.length;n++)t[n]=r[n];return t}return Array.from(r)}function o(r,n){var t=31&n;return r<<t|r>>>32-t}function u(r,n){for(var t=[],e=r.length-1;e>=0;e--)t[e]=255&(r[e]^n[e]);return t}function i(r){return r^o(r,9)^o(r,17)}function f(r){return r^o(r,15)^o(r,23)}function a(r){var n=8*r.length,t=n%512;t=t>=448?512-t%448-1:448-t-1;for(var u=new Array((t-7)/8),a=new Array(8),s=0,p=u.length;s<p;s++)u[s]=0;for(var h=0,v=a.length;h<v;h++)a[h]=0;n=n.toString(2);for(var y=7;y>=0;y--)if(n.length>8){var g=n.length-8;a[y]=parseInt(n.substr(g),2),n=n.substr(0,g)}else n.length>0&&(a[y]=parseInt(n,2),n="");for(var d=new Uint8Array([].concat(e(r),[128],u,a)),w=new DataView(d.buffer,0),m=d.length/64,A=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]),b=0;b<m;b++){c.fill(0),l.fill(0);for(var x=16*b,j=0;j<16;j++)c[j]=w.getUint32(4*(x+j),!1);for(var U=16;U<68;U++)c[U]=f(c[U-16]^c[U-9]^o(c[U-3],15))^o(c[U-13],7)^c[U-6];for(var E=0;E<64;E++)l[E]=c[E]^c[E+4];for(var I=A[0],O=A[1],P=A[2],k=A[3],S=A[4],_=A[5],D=A[6],M=A[7],V=void 0,q=void 0,z=void 0,B=void 0,C=void 0,F=0;F<64;F++)C=F>=0&&F<=15?2043430169:2055708042,V=o(o(I,12)+S+o(C,F),7),q=V^o(I,12),z=(F>=0&&F<=15?I^O^P:I&O|I&P|O&P)+k+q+l[F],B=(F>=0&&F<=15?S^_^D:S&_|~S&D)+M+V+c[F],k=P,P=o(O,9),O=I,I=z,M=D,D=o(_,19),_=S,S=i(B);A[0]^=I,A[1]^=O,A[2]^=P,A[3]^=k,A[4]^=S,A[5]^=_,A[6]^=D,A[7]^=M}for(var G=[],H=0,J=A.length;H<J;H++){var K=A[H];G.push((4278190080&K)>>>24,(16711680&K)>>>16,(65280&K)>>>8,255&K)}return G}function s(r,n){for(n.length>p&&(n=a(n));n.length<p;)n.push(0);var t=u(n,h),o=u(n,v),i=a([].concat(e(t),e(r)));return a([].concat(e(o),e(i)))}for(var c=new Uint32Array(68),l=new Uint32Array(64),p=64,h=new Uint8Array(p),v=new Uint8Array(p),y=0;y<p;y++)h[y]=54,v[y]=92;r.exports={sm3:a,hmac:s}},6:function(r,n,t){"use strict";function e(r,n){return r.length>=n?r:new Array(n-r.length+1).join("0")+r}function o(r){return r.map(function(r){return r=r.toString(16),1===r.length?"0"+r:r}).join("")}function u(r){var n=[],t=r.length;t%2!=0&&(r=e(r,t+1)),t=r.length;for(var o=0;o<t;o+=2)n.push(parseInt(r.substr(o,2),16));return n}function i(r){for(var n=[],t=0,e=r.length;t<e;t++){var o=r.codePointAt(t);if(o<=127)n.push(o);else if(o<=2047)n.push(192|o>>>6),n.push(128|63&o);else if(o<=55295||o>=57344&&o<=65535)n.push(224|o>>>12),n.push(128|o>>>6&63),n.push(128|63&o);else{if(!(o>=65536&&o<=1114111))throw n.push(o),new Error("input is not supported");t++,n.push(240|o>>>18&28),n.push(128|o>>>12&63),n.push(128|o>>>6&63),n.push(128|63&o)}}return n}var f=t(1),a=f.sm3,s=f.hmac;r.exports=function(r,n){if(r="string"==typeof r?i(r):Array.prototype.slice.call(r),n){if("hmac"!==(n.mode||"hmac"))throw new Error("invalid mode");var t=n.key;if(!t)throw new Error("invalid key");return t="string"==typeof t?u(t):Array.prototype.slice.call(t),o(s(r,t))}return o(a(r))}}})});

1
node_modules/sm-crypto/dist/sm4.js generated vendored Normal file

File diff suppressed because one or more lines are too long

42
node_modules/sm-crypto/package.json generated vendored Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "sm-crypto",
"version": "0.3.13",
"description": "sm-crypto",
"main": "src/index.js",
"scripts": {
"prepublish": "npm run build",
"test": "jest ./test/*",
"lint": "eslint \"src/**/*.js\" --fix",
"build": "npm run lint && webpack"
},
"repository": {
"type": "git",
"url": "git+https://github.com/JuneAndGreen/sm-crypto.git"
},
"keywords": [
"sm",
"js",
"crypto"
],
"jest": {
"testEnvironment": "jsdom",
"testURL": "https://jest.test"
},
"author": "june_01",
"license": "MIT",
"dependencies": {
"jsbn": "^1.1.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"jest": "^22.1.4",
"webpack": "^3.10.0",
"eslint": "^5.3.0",
"eslint-config-airbnb-base": "13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0"
}
}

5
node_modules/sm-crypto/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
module.exports = {
sm2: require('./sm2/index'),
sm3: require('./sm3/index'),
sm4: require('./sm4/index'),
}

161
node_modules/sm-crypto/src/sm2/asn1.js generated vendored Executable file
View File

@@ -0,0 +1,161 @@
/* eslint-disable class-methods-use-this */
const {BigInteger} = require('jsbn')
function bigintToValue(bigint) {
let h = bigint.toString(16)
if (h[0] !== '-') {
// 正数
if (h.length % 2 === 1) h = '0' + h // 补齐到整字节
else if (!h.match(/^[0-7]/)) h = '00' + h // 非0开头则补一个全0字节
} else {
// 负数
h = h.substr(1)
let len = h.length
if (len % 2 === 1) len += 1 // 补齐到整字节
else if (!h.match(/^[0-7]/)) len += 2 // 非0开头则补一个全0字节
let mask = ''
for (let i = 0; i < len; i++) mask += 'f'
mask = new BigInteger(mask, 16)
// 对绝对值取反加1
h = mask.xor(bigint).add(BigInteger.ONE)
h = h.toString(16).replace(/^-/, '')
}
return h
}
class ASN1Object {
constructor() {
this.tlv = null
this.t = '00'
this.l = '00'
this.v = ''
}
/**
* 获取 der 编码比特流16进制串
*/
getEncodedHex() {
if (!this.tlv) {
this.v = this.getValue()
this.l = this.getLength()
this.tlv = this.t + this.l + this.v
}
return this.tlv
}
getLength() {
const n = this.v.length / 2 // 字节数
let nHex = n.toString(16)
if (nHex.length % 2 === 1) nHex = '0' + nHex // 补齐到整字节
if (n < 128) {
// 短格式,以 0 开头
return nHex
} else {
// 长格式,以 1 开头
const head = 128 + nHex.length / 2 // 1(1位) + 真正的长度占用字节数(7位) + 真正的长度
return head.toString(16) + nHex
}
}
getValue() {
return ''
}
}
class DERInteger extends ASN1Object {
constructor(bigint) {
super()
this.t = '02' // 整型标签说明
if (bigint) this.v = bigintToValue(bigint)
}
getValue() {
return this.v
}
}
class DERSequence extends ASN1Object {
constructor(asn1Array) {
super()
this.t = '30' // 序列标签说明
this.asn1Array = asn1Array
}
getValue() {
this.v = this.asn1Array.map(asn1Object => asn1Object.getEncodedHex()).join('')
return this.v
}
}
/**
* 获取 l 占用字节数
*/
function getLenOfL(str, start) {
if (+str[start + 2] < 8) return 1 // l 以0开头则表示短格式只占一个字节
return +str.substr(start + 2, 2) & 0x7f + 1 // 长格式取第一个字节后7位作为长度真正占用字节数再加上本身
}
/**
* 获取 l
*/
function getL(str, start) {
// 获取 l
const len = getLenOfL(str, start)
const l = str.substr(start + 2, len * 2)
if (!l) return -1
const bigint = +l[0] < 8 ? new BigInteger(l, 16) : new BigInteger(l.substr(2), 16)
return bigint.intValue()
}
/**
* 获取 v 的位置
*/
function getStartOfV(str, start) {
const len = getLenOfL(str, start)
return start + (len + 1) * 2
}
module.exports = {
/**
* ASN.1 der 编码,针对 sm2 签名
*/
encodeDer(r, s) {
const derR = new DERInteger(r)
const derS = new DERInteger(s)
const derSeq = new DERSequence([derR, derS])
return derSeq.getEncodedHex()
},
/**
* 解析 ASN.1 der针对 sm2 验签
*/
decodeDer(input) {
// 结构:
// input = | tSeq | lSeq | vSeq |
// vSeq = | tR | lR | vR | tS | lS | vS |
const start = getStartOfV(input, 0)
const vIndexR = getStartOfV(input, start)
const lR = getL(input, start)
const vR = input.substr(vIndexR, lR * 2)
const nextStart = vIndexR + vR.length
const vIndexS = getStartOfV(input, nextStart)
const lS = getL(input, nextStart)
const vS = input.substr(vIndexS, lS * 2)
const r = new BigInteger(vR, 16)
const s = new BigInteger(vS, 16)
return {r, s}
}
}

332
node_modules/sm-crypto/src/sm2/ec.js generated vendored Executable file
View File

@@ -0,0 +1,332 @@
/* eslint-disable no-case-declarations, max-len */
const {BigInteger} = require('jsbn')
/**
* thanks for Tom Wu : http://www-cs-students.stanford.edu/~tjw/jsbn/
*
* Basic Javascript Elliptic Curve implementation
* Ported loosely from BouncyCastle's Java EC code
* Only Fp curves implemented for now
*/
const TWO = new BigInteger('2')
const THREE = new BigInteger('3')
/**
* 椭圆曲线域元素
*/
class ECFieldElementFp {
constructor(q, x) {
this.x = x
this.q = q
// TODO if (x.compareTo(q) >= 0) error
}
/**
* 判断相等
*/
equals(other) {
if (other === this) return true
return (this.q.equals(other.q) && this.x.equals(other.x))
}
/**
* 返回具体数值
*/
toBigInteger() {
return this.x
}
/**
* 取反
*/
negate() {
return new ECFieldElementFp(this.q, this.x.negate().mod(this.q))
}
/**
* 相加
*/
add(b) {
return new ECFieldElementFp(this.q, this.x.add(b.toBigInteger()).mod(this.q))
}
/**
* 相减
*/
subtract(b) {
return new ECFieldElementFp(this.q, this.x.subtract(b.toBigInteger()).mod(this.q))
}
/**
* 相乘
*/
multiply(b) {
return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger()).mod(this.q))
}
/**
* 相除
*/
divide(b) {
return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q))
}
/**
* 平方
*/
square() {
return new ECFieldElementFp(this.q, this.x.square().mod(this.q))
}
}
class ECPointFp {
constructor(curve, x, y, z) {
this.curve = curve
this.x = x
this.y = y
// 标准射影坐标系zinv == null 或 z * zinv == 1
this.z = z == null ? BigInteger.ONE : z
this.zinv = null
// TODO: compression flag
}
getX() {
if (this.zinv === null) this.zinv = this.z.modInverse(this.curve.q)
return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))
}
getY() {
if (this.zinv === null) this.zinv = this.z.modInverse(this.curve.q)
return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))
}
/**
* 判断相等
*/
equals(other) {
if (other === this) return true
if (this.isInfinity()) return other.isInfinity()
if (other.isInfinity()) return this.isInfinity()
// u = y2 * z1 - y1 * z2
const u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q)
if (!u.equals(BigInteger.ZERO)) return false
// v = x2 * z1 - x1 * z2
const v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q)
return v.equals(BigInteger.ZERO)
}
/**
* 是否是无穷远点
*/
isInfinity() {
if ((this.x === null) && (this.y === null)) return true
return this.z.equals(BigInteger.ZERO) && !this.y.toBigInteger().equals(BigInteger.ZERO)
}
/**
* 取反x 轴对称点
*/
negate() {
return new ECPointFp(this.curve, this.x, this.y.negate(), this.z)
}
/**
* 相加
*
* 标准射影坐标系:
*
* λ1 = x1 * z2
* λ2 = x2 * z1
* λ3 = λ1 λ2
* λ4 = y1 * z2
* λ5 = y2 * z1
* λ6 = λ4 λ5
* λ7 = λ1 + λ2
* λ8 = z1 * z2
* λ9 = λ3^2
* λ10 = λ3 * λ9
* λ11 = λ8 * λ6^2 λ7 * λ9
* x3 = λ3 * λ11
* y3 = λ6 * (λ9 * λ1 λ11) λ4 * λ10
* z3 = λ10 * λ8
*/
add(b) {
if (this.isInfinity()) return b
if (b.isInfinity()) return this
const x1 = this.x.toBigInteger()
const y1 = this.y.toBigInteger()
const z1 = this.z
const x2 = b.x.toBigInteger()
const y2 = b.y.toBigInteger()
const z2 = b.z
const q = this.curve.q
const w1 = x1.multiply(z2).mod(q)
const w2 = x2.multiply(z1).mod(q)
const w3 = w1.subtract(w2)
const w4 = y1.multiply(z2).mod(q)
const w5 = y2.multiply(z1).mod(q)
const w6 = w4.subtract(w5)
if (BigInteger.ZERO.equals(w3)) {
if (BigInteger.ZERO.equals(w6)) {
return this.twice() // this == b计算自加
}
return this.curve.infinity // this == -b则返回无穷远点
}
const w7 = w1.add(w2)
const w8 = z1.multiply(z2).mod(q)
const w9 = w3.square().mod(q)
const w10 = w3.multiply(w9).mod(q)
const w11 = w8.multiply(w6.square()).subtract(w7.multiply(w9)).mod(q)
const x3 = w3.multiply(w11).mod(q)
const y3 = w6.multiply(w9.multiply(w1).subtract(w11)).subtract(w4.multiply(w10)).mod(q)
const z3 = w10.multiply(w8).mod(q)
return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3)
}
/**
* 自加
*
* 标准射影坐标系:
*
* λ1 = 3 * x1^2 + a * z1^2
* λ2 = 2 * y1 * z1
* λ3 = y1^2
* λ4 = λ3 * x1 * z1
* λ5 = λ2^2
* λ6 = λ1^2 8 * λ4
* x3 = λ2 * λ6
* y3 = λ1 * (4 * λ4 λ6) 2 * λ5 * λ3
* z3 = λ2 * λ5
*/
twice() {
if (this.isInfinity()) return this
if (!this.y.toBigInteger().signum()) return this.curve.infinity
const x1 = this.x.toBigInteger()
const y1 = this.y.toBigInteger()
const z1 = this.z
const q = this.curve.q
const a = this.curve.a.toBigInteger()
const w1 = x1.square().multiply(THREE).add(a.multiply(z1.square())).mod(q)
const w2 = y1.shiftLeft(1).multiply(z1).mod(q)
const w3 = y1.square().mod(q)
const w4 = w3.multiply(x1).multiply(z1).mod(q)
const w5 = w2.square().mod(q)
const w6 = w1.square().subtract(w4.shiftLeft(3)).mod(q)
const x3 = w2.multiply(w6).mod(q)
const y3 = w1.multiply(w4.shiftLeft(2).subtract(w6)).subtract(w5.shiftLeft(1).multiply(w3)).mod(q)
const z3 = w2.multiply(w5).mod(q)
return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3)
}
/**
* 倍点计算
*/
multiply(k) {
if (this.isInfinity()) return this
if (!k.signum()) return this.curve.infinity
// 使用加减法
const k3 = k.multiply(THREE)
const neg = this.negate()
let Q = this
for (let i = k3.bitLength() - 2; i > 0; i--) {
Q = Q.twice()
const k3Bit = k3.testBit(i)
const kBit = k.testBit(i)
if (k3Bit !== kBit) {
Q = Q.add(k3Bit ? this : neg)
}
}
return Q
}
}
/**
* 椭圆曲线 y^2 = x^3 + ax + b
*/
class ECCurveFp {
constructor(q, a, b) {
this.q = q
this.a = this.fromBigInteger(a)
this.b = this.fromBigInteger(b)
this.infinity = new ECPointFp(this, null, null) // 无穷远点
}
/**
* 判断两个椭圆曲线是否相等
*/
equals(other) {
if (other === this) return true
return (this.q.equals(other.q) && this.a.equals(other.a) && this.b.equals(other.b))
}
/**
* 生成椭圆曲线域元素
*/
fromBigInteger(x) {
return new ECFieldElementFp(this.q, x)
}
/**
* 解析 16 进制串为椭圆曲线点
*/
decodePointHex(s) {
switch (parseInt(s.substr(0, 2), 16)) {
// 第一个字节
case 0:
return this.infinity
case 2:
case 3:
// 压缩
const x = this.fromBigInteger(new BigInteger(s.substr(2), 16))
// 对 p ≡ 3 (mod4),即存在正整数 u使得 p = 4u + 3
// 计算 y = (√ (x^3 + ax + b) % p)^(u + 1) modp
let y = this.fromBigInteger(x.multiply(x.square()).add(
x.multiply(this.a)
).add(this.b).toBigInteger()
.modPow(
this.q.divide(new BigInteger('4')).add(BigInteger.ONE), this.q
))
// 算出结果 2 进制最后 1 位不等于第 1 个字节减 2 则取反
if (!y.toBigInteger().mod(TWO).equals(new BigInteger(s.substr(0, 2), 16).subtract(TWO))) {
y = y.negate()
}
return new ECPointFp(this, x, y)
case 4:
case 6:
case 7:
const len = (s.length - 2) / 2
const xHex = s.substr(2, len)
const yHex = s.substr(len + 2, len)
return new ECPointFp(this, this.fromBigInteger(new BigInteger(xHex, 16)), this.fromBigInteger(new BigInteger(yHex, 16)))
default:
// 不支持
return null
}
}
}
module.exports = {
ECPointFp,
ECCurveFp,
}

261
node_modules/sm-crypto/src/sm2/index.js generated vendored Normal file
View File

@@ -0,0 +1,261 @@
/* eslint-disable no-use-before-define */
const {BigInteger} = require('jsbn')
const {encodeDer, decodeDer} = require('./asn1')
const _ = require('./utils')
const sm3 = require('./sm3').sm3
const {G, curve, n} = _.generateEcparam()
const C1C2C3 = 0
/**
* 加密
*/
function doEncrypt(msg, publicKey, cipherMode = 1) {
msg = typeof msg === 'string' ? _.hexToArray(_.utf8ToHex(msg)) : Array.prototype.slice.call(msg)
publicKey = _.getGlobalCurve().decodePointHex(publicKey) // 先将公钥转成点
const keypair = _.generateKeyPairHex()
const k = new BigInteger(keypair.privateKey, 16) // 随机数 k
// c1 = k * G
let c1 = keypair.publicKey
if (c1.length > 128) c1 = c1.substr(c1.length - 128)
// (x2, y2) = k * publicKey
const p = publicKey.multiply(k)
const x2 = _.hexToArray(_.leftPad(p.getX().toBigInteger().toRadix(16), 64))
const y2 = _.hexToArray(_.leftPad(p.getY().toBigInteger().toRadix(16), 64))
// c3 = hash(x2 || msg || y2)
const c3 = _.arrayToHex(sm3([].concat(x2, msg, y2)))
let ct = 1
let offset = 0
let t = [] // 256 位
const z = [].concat(x2, y2)
const nextT = () => {
// (1) Hai = hash(z || ct)
// (2) ct++
t = sm3([...z, ct >> 24 & 0x00ff, ct >> 16 & 0x00ff, ct >> 8 & 0x00ff, ct & 0x00ff])
ct++
offset = 0
}
nextT() // 先生成 Ha1
for (let i = 0, len = msg.length; i < len; i++) {
// t = Ha1 || Ha2 || Ha3 || Ha4
if (offset === t.length) nextT()
// c2 = msg ^ t
msg[i] ^= t[offset++] & 0xff
}
const c2 = _.arrayToHex(msg)
return cipherMode === C1C2C3 ? c1 + c2 + c3 : c1 + c3 + c2
}
/**
* 解密
*/
function doDecrypt(encryptData, privateKey, cipherMode = 1, {
output = 'string',
} = {}) {
privateKey = new BigInteger(privateKey, 16)
let c3 = encryptData.substr(128, 64)
let c2 = encryptData.substr(128 + 64)
if (cipherMode === C1C2C3) {
c3 = encryptData.substr(encryptData.length - 64)
c2 = encryptData.substr(128, encryptData.length - 128 - 64)
}
const msg = _.hexToArray(c2)
const c1 = _.getGlobalCurve().decodePointHex('04' + encryptData.substr(0, 128))
const p = c1.multiply(privateKey)
const x2 = _.hexToArray(_.leftPad(p.getX().toBigInteger().toRadix(16), 64))
const y2 = _.hexToArray(_.leftPad(p.getY().toBigInteger().toRadix(16), 64))
let ct = 1
let offset = 0
let t = [] // 256 位
const z = [].concat(x2, y2)
const nextT = () => {
// (1) Hai = hash(z || ct)
// (2) ct++
t = sm3([...z, ct >> 24 & 0x00ff, ct >> 16 & 0x00ff, ct >> 8 & 0x00ff, ct & 0x00ff])
ct++
offset = 0
}
nextT() // 先生成 Ha1
for (let i = 0, len = msg.length; i < len; i++) {
// t = Ha1 || Ha2 || Ha3 || Ha4
if (offset === t.length) nextT()
// c2 = msg ^ t
msg[i] ^= t[offset++] & 0xff
}
// c3 = hash(x2 || msg || y2)
const checkC3 = _.arrayToHex(sm3([].concat(x2, msg, y2)))
if (checkC3 === c3.toLowerCase()) {
return output === 'array' ? msg : _.arrayToUtf8(msg)
} else {
return output === 'array' ? [] : ''
}
}
/**
* 签名
*/
function doSignature(msg, privateKey, {
pointPool, der, hash, publicKey, userId
} = {}) {
let hashHex = typeof msg === 'string' ? _.utf8ToHex(msg) : _.arrayToHex(msg)
if (hash) {
// sm3杂凑
publicKey = publicKey || getPublicKeyFromPrivateKey(privateKey)
hashHex = getHash(hashHex, publicKey, userId)
}
const dA = new BigInteger(privateKey, 16)
const e = new BigInteger(hashHex, 16)
// k
let k = null
let r = null
let s = null
do {
do {
let point
if (pointPool && pointPool.length) {
point = pointPool.pop()
} else {
point = getPoint()
}
k = point.k
// r = (e + x1) mod n
r = e.add(point.x1).mod(n)
} while (r.equals(BigInteger.ZERO) || r.add(k).equals(n))
// s = ((1 + dA)^-1 * (k - r * dA)) mod n
s = dA.add(BigInteger.ONE).modInverse(n).multiply(k.subtract(r.multiply(dA))).mod(n)
} while (s.equals(BigInteger.ZERO))
if (der) return encodeDer(r, s) // asn.1 der 编码
return _.leftPad(r.toString(16), 64) + _.leftPad(s.toString(16), 64)
}
/**
* 验签
*/
function doVerifySignature(msg, signHex, publicKey, {der, hash, userId} = {}) {
let hashHex = typeof msg === 'string' ? _.utf8ToHex(msg) : _.arrayToHex(msg)
if (hash) {
// sm3杂凑
hashHex = getHash(hashHex, publicKey, userId)
}
let r; let
s
if (der) {
const decodeDerObj = decodeDer(signHex) // asn.1 der 解码
r = decodeDerObj.r
s = decodeDerObj.s
} else {
r = new BigInteger(signHex.substring(0, 64), 16)
s = new BigInteger(signHex.substring(64), 16)
}
const PA = curve.decodePointHex(publicKey)
const e = new BigInteger(hashHex, 16)
// t = (r + s) mod n
const t = r.add(s).mod(n)
if (t.equals(BigInteger.ZERO)) return false
// x1y1 = s * G + t * PA
const x1y1 = G.multiply(s).add(PA.multiply(t))
// R = (e + x1) mod n
const R = e.add(x1y1.getX().toBigInteger()).mod(n)
return r.equals(R)
}
/**
* sm3杂凑算法
*/
function getHash(hashHex, publicKey, userId = '1234567812345678') {
// z = hash(entl || userId || a || b || gx || gy || px || py)
userId = _.utf8ToHex(userId)
const a = _.leftPad(G.curve.a.toBigInteger().toRadix(16), 64)
const b = _.leftPad(G.curve.b.toBigInteger().toRadix(16), 64)
const gx = _.leftPad(G.getX().toBigInteger().toRadix(16), 64)
const gy = _.leftPad(G.getY().toBigInteger().toRadix(16), 64)
let px
let py
if (publicKey.length === 128) {
px = publicKey.substr(0, 64)
py = publicKey.substr(64, 64)
} else {
const point = G.curve.decodePointHex(publicKey)
px = _.leftPad(point.getX().toBigInteger().toRadix(16), 64)
py = _.leftPad(point.getY().toBigInteger().toRadix(16), 64)
}
const data = _.hexToArray(userId + a + b + gx + gy + px + py)
const entl = userId.length * 4
data.unshift(entl & 0x00ff)
data.unshift(entl >> 8 & 0x00ff)
const z = sm3(data)
// e = hash(z || msg)
return _.arrayToHex(sm3(z.concat(_.hexToArray(hashHex))))
}
/**
* 计算公钥
*/
function getPublicKeyFromPrivateKey(privateKey) {
const PA = G.multiply(new BigInteger(privateKey, 16))
const x = _.leftPad(PA.getX().toBigInteger().toString(16), 64)
const y = _.leftPad(PA.getY().toBigInteger().toString(16), 64)
return '04' + x + y
}
/**
* 获取椭圆曲线点
*/
function getPoint() {
const keypair = _.generateKeyPairHex()
const PA = curve.decodePointHex(keypair.publicKey)
keypair.k = new BigInteger(keypair.privateKey, 16)
keypair.x1 = PA.getX().toBigInteger()
return keypair
}
module.exports = {
generateKeyPairHex: _.generateKeyPairHex,
compressPublicKeyHex: _.compressPublicKeyHex,
comparePublicKeyHex: _.comparePublicKeyHex,
doEncrypt,
doDecrypt,
doSignature,
doVerifySignature,
getPublicKeyFromPrivateKey,
getPoint,
verifyPublicKey: _.verifyPublicKey,
}

170
node_modules/sm-crypto/src/sm2/sm3.js generated vendored Executable file
View File

@@ -0,0 +1,170 @@
// 消息扩展
const W = new Uint32Array(68)
const M = new Uint32Array(64) // W'
/**
* 循环左移
*/
function rotl(x, n) {
const s = n & 31
return (x << s) | (x >>> (32 - s))
}
/**
* 二进制异或运算
*/
function xor(x, y) {
const result = []
for (let i = x.length - 1; i >= 0; i--) result[i] = (x[i] ^ y[i]) & 0xff
return result
}
/**
* 压缩函数中的置换函数 P0(X) = X xor (X <<< 9) xor (X <<< 17)
*/
function P0(X) {
return (X ^ rotl(X, 9)) ^ rotl(X, 17)
}
/**
* 消息扩展中的置换函数 P1(X) = X xor (X <<< 15) xor (X <<< 23)
*/
function P1(X) {
return (X ^ rotl(X, 15)) ^ rotl(X, 23)
}
/**
* sm3 本体
*/
function sm3(array) {
let len = array.length * 8
// k 是满足 len + 1 + k = 448mod512 的最小的非负整数
let k = len % 512
// 如果 448 <= (512 % len) < 512需要多补充 (len % 448) 比特'0'以满足总比特长度为512的倍数
k = k >= 448 ? 512 - (k % 448) - 1 : 448 - k - 1
// 填充
const kArr = new Array((k - 7) / 8)
const lenArr = new Array(8)
for (let i = 0, len = kArr.length; i < len; i++) kArr[i] = 0
for (let i = 0, len = lenArr.length; i < len; i++) lenArr[i] = 0
len = len.toString(2)
for (let i = 7; i >= 0; i--) {
if (len.length > 8) {
const start = len.length - 8
lenArr[i] = parseInt(len.substr(start), 2)
len = len.substr(0, start)
} else if (len.length > 0) {
lenArr[i] = parseInt(len, 2)
len = ''
}
}
const m = new Uint8Array([...array, 0x80, ...kArr, ...lenArr])
const dataView = new DataView(m.buffer, 0)
// 迭代压缩
const n = m.length / 64
const V = new Uint32Array([0x7380166f, 0x4914b2b9, 0x172442d7, 0xda8a0600, 0xa96f30bc, 0x163138aa, 0xe38dee4d, 0xb0fb0e4e])
for (let i = 0; i < n; i++) {
W.fill(0)
M.fill(0)
// 将消息分组B划分为 16 个字 W0 W1……W15
const start = 16 * i
for (let j = 0; j < 16; j++) {
W[j] = dataView.getUint32((start + j) * 4, false)
}
// W16 W67W[j] <- P1(W[j16] xor W[j9] xor (W[j3] <<< 15)) xor (W[j13] <<< 7) xor W[j6]
for (let j = 16; j < 68; j++) {
W[j] = (P1((W[j - 16] ^ W[j - 9]) ^ rotl(W[j - 3], 15)) ^ rotl(W[j - 13], 7)) ^ W[j - 6]
}
// W0 W63W[j] = W[j] xor W[j+4]
for (let j = 0; j < 64; j++) {
M[j] = W[j] ^ W[j + 4]
}
// 压缩
const T1 = 0x79cc4519
const T2 = 0x7a879d8a
// 字寄存器
let A = V[0]
let B = V[1]
let C = V[2]
let D = V[3]
let E = V[4]
let F = V[5]
let G = V[6]
let H = V[7]
// 中间变量
let SS1
let SS2
let TT1
let TT2
let T
for (let j = 0; j < 64; j++) {
T = j >= 0 && j <= 15 ? T1 : T2
SS1 = rotl(rotl(A, 12) + E + rotl(T, j), 7)
SS2 = SS1 ^ rotl(A, 12)
TT1 = (j >= 0 && j <= 15 ? ((A ^ B) ^ C) : (((A & B) | (A & C)) | (B & C))) + D + SS2 + M[j]
TT2 = (j >= 0 && j <= 15 ? ((E ^ F) ^ G) : ((E & F) | ((~E) & G))) + H + SS1 + W[j]
D = C
C = rotl(B, 9)
B = A
A = TT1
H = G
G = rotl(F, 19)
F = E
E = P0(TT2)
}
V[0] ^= A
V[1] ^= B
V[2] ^= C
V[3] ^= D
V[4] ^= E
V[5] ^= F
V[6] ^= G
V[7] ^= H
}
// 转回 uint8
const result = []
for (let i = 0, len = V.length; i < len; i++) {
const word = V[i]
result.push((word & 0xff000000) >>> 24, (word & 0xff0000) >>> 16, (word & 0xff00) >>> 8, word & 0xff)
}
return result
}
/**
* hmac 实现
*/
const blockLen = 64
const iPad = new Uint8Array(blockLen)
const oPad = new Uint8Array(blockLen)
for (let i = 0; i < blockLen; i++) {
iPad[i] = 0x36
oPad[i] = 0x5c
}
function hmac(input, key) {
// 密钥填充
if (key.length > blockLen) key = sm3(key)
while (key.length < blockLen) key.push(0)
const iPadKey = xor(key, iPad)
const oPadKey = xor(key, oPad)
const hash = sm3([...iPadKey, ...input])
return sm3([...oPadKey, ...hash])
}
module.exports = {
sm3,
hmac,
}

194
node_modules/sm-crypto/src/sm2/utils.js generated vendored Normal file
View File

@@ -0,0 +1,194 @@
/* eslint-disable no-bitwise, no-mixed-operators, no-use-before-define, max-len */
const {BigInteger, SecureRandom} = require('jsbn')
const {ECCurveFp} = require('./ec')
const rng = new SecureRandom()
const {curve, G, n} = generateEcparam()
/**
* 获取公共椭圆曲线
*/
function getGlobalCurve() {
return curve
}
/**
* 生成ecparam
*/
function generateEcparam() {
// 椭圆曲线
const p = new BigInteger('FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF', 16)
const a = new BigInteger('FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC', 16)
const b = new BigInteger('28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93', 16)
const curve = new ECCurveFp(p, a, b)
// 基点
const gxHex = '32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7'
const gyHex = 'BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0'
const G = curve.decodePointHex('04' + gxHex + gyHex)
const n = new BigInteger('FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123', 16)
return {curve, G, n}
}
/**
* 生成密钥对publicKey = privateKey * G
*/
function generateKeyPairHex(a, b, c) {
const random = a ? new BigInteger(a, b, c) : new BigInteger(n.bitLength(), rng)
const d = random.mod(n.subtract(BigInteger.ONE)).add(BigInteger.ONE) // 随机数
const privateKey = leftPad(d.toString(16), 64)
const P = G.multiply(d) // P = dGp 为公钥d 为私钥
const Px = leftPad(P.getX().toBigInteger().toString(16), 64)
const Py = leftPad(P.getY().toBigInteger().toString(16), 64)
const publicKey = '04' + Px + Py
return {privateKey, publicKey}
}
/**
* 生成压缩公钥
*/
function compressPublicKeyHex(s) {
if (s.length !== 130) throw new Error('Invalid public key to compress')
const len = (s.length - 2) / 2
const xHex = s.substr(2, len)
const y = new BigInteger(s.substr(len + 2, len), 16)
let prefix = '03'
if (y.mod(new BigInteger('2')).equals(BigInteger.ZERO)) prefix = '02'
return prefix + xHex
}
/**
* utf8串转16进制串
*/
function utf8ToHex(input) {
input = unescape(encodeURIComponent(input))
const length = input.length
// 转换到字数组
const words = []
for (let i = 0; i < length; i++) {
words[i >>> 2] |= (input.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8)
}
// 转换到16进制
const hexChars = []
for (let i = 0; i < length; i++) {
const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff
hexChars.push((bite >>> 4).toString(16))
hexChars.push((bite & 0x0f).toString(16))
}
return hexChars.join('')
}
/**
* 补全16进制字符串
*/
function leftPad(input, num) {
if (input.length >= num) return input
return (new Array(num - input.length + 1)).join('0') + input
}
/**
* 转成16进制串
*/
function arrayToHex(arr) {
return arr.map(item => {
item = item.toString(16)
return item.length === 1 ? '0' + item : item
}).join('')
}
/**
* 转成utf8串
*/
function arrayToUtf8(arr) {
const words = []
let j = 0
for (let i = 0; i < arr.length * 2; i += 2) {
words[i >>> 3] |= parseInt(arr[j], 10) << (24 - (i % 8) * 4)
j++
}
try {
const latin1Chars = []
for (let i = 0; i < arr.length; i++) {
const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff
latin1Chars.push(String.fromCharCode(bite))
}
return decodeURIComponent(escape(latin1Chars.join('')))
} catch (e) {
throw new Error('Malformed UTF-8 data')
}
}
/**
* 转成字节数组
*/
function hexToArray(hexStr) {
const words = []
let hexStrLength = hexStr.length
if (hexStrLength % 2 !== 0) {
hexStr = leftPad(hexStr, hexStrLength + 1)
}
hexStrLength = hexStr.length
for (let i = 0; i < hexStrLength; i += 2) {
words.push(parseInt(hexStr.substr(i, 2), 16))
}
return words
}
/**
* 验证公钥是否为椭圆曲线上的点
*/
function verifyPublicKey(publicKey) {
const point = curve.decodePointHex(publicKey)
if (!point) return false
const x = point.getX()
const y = point.getY()
// 验证 y^2 是否等于 x^3 + ax + b
return y.square().equals(x.multiply(x.square()).add(x.multiply(curve.a)).add(curve.b))
}
/**
* 验证公钥是否等价等价返回true
*/
function comparePublicKeyHex(publicKey1, publicKey2) {
const point1 = curve.decodePointHex(publicKey1)
if (!point1) return false
const point2 = curve.decodePointHex(publicKey2)
if (!point2) return false
return point1.equals(point2)
}
module.exports = {
getGlobalCurve,
generateEcparam,
generateKeyPairHex,
compressPublicKeyHex,
utf8ToHex,
leftPad,
arrayToHex,
arrayToUtf8,
hexToArray,
verifyPublicKey,
comparePublicKeyHex,
}

94
node_modules/sm-crypto/src/sm3/index.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
const {sm3, hmac} = require('../sm2/sm3')
/**
* 补全16进制字符串
*/
function leftPad(input, num) {
if (input.length >= num) return input
return (new Array(num - input.length + 1)).join('0') + input
}
/**
* 字节数组转 16 进制串
*/
function ArrayToHex(arr) {
return arr.map(item => {
item = item.toString(16)
return item.length === 1 ? '0' + item : item
}).join('')
}
/**
* 转成字节数组
*/
function hexToArray(hexStr) {
const words = []
let hexStrLength = hexStr.length
if (hexStrLength % 2 !== 0) {
hexStr = leftPad(hexStr, hexStrLength + 1)
}
hexStrLength = hexStr.length
for (let i = 0; i < hexStrLength; i += 2) {
words.push(parseInt(hexStr.substr(i, 2), 16))
}
return words
}
/**
* utf8 串转字节数组
*/
function utf8ToArray(str) {
const arr = []
for (let i = 0, len = str.length; i < len; i++) {
const point = str.codePointAt(i)
if (point <= 0x007f) {
// 单字节标量值00000000 00000000 0zzzzzzz
arr.push(point)
} else if (point <= 0x07ff) {
// 双字节标量值00000000 00000yyy yyzzzzzz
arr.push(0xc0 | (point >>> 6)) // 110yyyyy0xc0-0xdf
arr.push(0x80 | (point & 0x3f)) // 10zzzzzz0x80-0xbf
} else if (point <= 0xD7FF || (point >= 0xE000 && point <= 0xFFFF)) {
// 三字节标量值00000000 xxxxyyyy yyzzzzzz
arr.push(0xe0 | (point >>> 12)) // 1110xxxx0xe0-0xef
arr.push(0x80 | ((point >>> 6) & 0x3f)) // 10yyyyyy0x80-0xbf
arr.push(0x80 | (point & 0x3f)) // 10zzzzzz0x80-0xbf
} else if (point >= 0x010000 && point <= 0x10FFFF) {
// 四字节标量值000wwwxx xxxxyyyy yyzzzzzz
i++
arr.push((0xf0 | (point >>> 18) & 0x1c)) // 11110www0xf0-0xf7
arr.push((0x80 | ((point >>> 12) & 0x3f))) // 10xxxxxx0x80-0xbf
arr.push((0x80 | ((point >>> 6) & 0x3f))) // 10yyyyyy0x80-0xbf
arr.push((0x80 | (point & 0x3f))) // 10zzzzzz0x80-0xbf
} else {
// 五、六字节,暂时不支持
arr.push(point)
throw new Error('input is not supported')
}
}
return arr
}
module.exports = function (input, options) {
input = typeof input === 'string' ? utf8ToArray(input) : Array.prototype.slice.call(input)
if (options) {
const mode = options.mode || 'hmac'
if (mode !== 'hmac') throw new Error('invalid mode')
let key = options.key
if (!key) throw new Error('invalid key')
key = typeof key === 'string' ? hexToArray(key) : Array.prototype.slice.call(key)
return ArrayToHex(hmac(input, key))
}
return ArrayToHex(sm3(input))
}

359
node_modules/sm-crypto/src/sm4/index.js generated vendored Executable file
View File

@@ -0,0 +1,359 @@
/* eslint-disable no-bitwise, no-mixed-operators, complexity */
const DECRYPT = 0
const ROUND = 32
const BLOCK = 16
const Sbox = [
0xd6, 0x90, 0xe9, 0xfe, 0xcc, 0xe1, 0x3d, 0xb7, 0x16, 0xb6, 0x14, 0xc2, 0x28, 0xfb, 0x2c, 0x05,
0x2b, 0x67, 0x9a, 0x76, 0x2a, 0xbe, 0x04, 0xc3, 0xaa, 0x44, 0x13, 0x26, 0x49, 0x86, 0x06, 0x99,
0x9c, 0x42, 0x50, 0xf4, 0x91, 0xef, 0x98, 0x7a, 0x33, 0x54, 0x0b, 0x43, 0xed, 0xcf, 0xac, 0x62,
0xe4, 0xb3, 0x1c, 0xa9, 0xc9, 0x08, 0xe8, 0x95, 0x80, 0xdf, 0x94, 0xfa, 0x75, 0x8f, 0x3f, 0xa6,
0x47, 0x07, 0xa7, 0xfc, 0xf3, 0x73, 0x17, 0xba, 0x83, 0x59, 0x3c, 0x19, 0xe6, 0x85, 0x4f, 0xa8,
0x68, 0x6b, 0x81, 0xb2, 0x71, 0x64, 0xda, 0x8b, 0xf8, 0xeb, 0x0f, 0x4b, 0x70, 0x56, 0x9d, 0x35,
0x1e, 0x24, 0x0e, 0x5e, 0x63, 0x58, 0xd1, 0xa2, 0x25, 0x22, 0x7c, 0x3b, 0x01, 0x21, 0x78, 0x87,
0xd4, 0x00, 0x46, 0x57, 0x9f, 0xd3, 0x27, 0x52, 0x4c, 0x36, 0x02, 0xe7, 0xa0, 0xc4, 0xc8, 0x9e,
0xea, 0xbf, 0x8a, 0xd2, 0x40, 0xc7, 0x38, 0xb5, 0xa3, 0xf7, 0xf2, 0xce, 0xf9, 0x61, 0x15, 0xa1,
0xe0, 0xae, 0x5d, 0xa4, 0x9b, 0x34, 0x1a, 0x55, 0xad, 0x93, 0x32, 0x30, 0xf5, 0x8c, 0xb1, 0xe3,
0x1d, 0xf6, 0xe2, 0x2e, 0x82, 0x66, 0xca, 0x60, 0xc0, 0x29, 0x23, 0xab, 0x0d, 0x53, 0x4e, 0x6f,
0xd5, 0xdb, 0x37, 0x45, 0xde, 0xfd, 0x8e, 0x2f, 0x03, 0xff, 0x6a, 0x72, 0x6d, 0x6c, 0x5b, 0x51,
0x8d, 0x1b, 0xaf, 0x92, 0xbb, 0xdd, 0xbc, 0x7f, 0x11, 0xd9, 0x5c, 0x41, 0x1f, 0x10, 0x5a, 0xd8,
0x0a, 0xc1, 0x31, 0x88, 0xa5, 0xcd, 0x7b, 0xbd, 0x2d, 0x74, 0xd0, 0x12, 0xb8, 0xe5, 0xb4, 0xb0,
0x89, 0x69, 0x97, 0x4a, 0x0c, 0x96, 0x77, 0x7e, 0x65, 0xb9, 0xf1, 0x09, 0xc5, 0x6e, 0xc6, 0x84,
0x18, 0xf0, 0x7d, 0xec, 0x3a, 0xdc, 0x4d, 0x20, 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48
]
const CK = [
0x00070e15, 0x1c232a31, 0x383f464d, 0x545b6269,
0x70777e85, 0x8c939aa1, 0xa8afb6bd, 0xc4cbd2d9,
0xe0e7eef5, 0xfc030a11, 0x181f262d, 0x343b4249,
0x50575e65, 0x6c737a81, 0x888f969d, 0xa4abb2b9,
0xc0c7ced5, 0xdce3eaf1, 0xf8ff060d, 0x141b2229,
0x30373e45, 0x4c535a61, 0x686f767d, 0x848b9299,
0xa0a7aeb5, 0xbcc3cad1, 0xd8dfe6ed, 0xf4fb0209,
0x10171e25, 0x2c333a41, 0x484f565d, 0x646b7279
]
/**
* 16 进制串转字节数组
*/
function hexToArray(str) {
const arr = []
for (let i = 0, len = str.length; i < len; i += 2) {
arr.push(parseInt(str.substr(i, 2), 16))
}
return arr
}
/**
* 字节数组转 16 进制串
*/
function ArrayToHex(arr) {
return arr.map(item => {
item = item.toString(16)
return item.length === 1 ? '0' + item : item
}).join('')
}
/**
* utf8 串转字节数组
*/
function utf8ToArray(str) {
const arr = []
for (let i = 0, len = str.length; i < len; i++) {
const point = str.codePointAt(i)
if (point <= 0x007f) {
// 单字节标量值00000000 00000000 0zzzzzzz
arr.push(point)
} else if (point <= 0x07ff) {
// 双字节标量值00000000 00000yyy yyzzzzzz
arr.push(0xc0 | (point >>> 6)) // 110yyyyy0xc0-0xdf
arr.push(0x80 | (point & 0x3f)) // 10zzzzzz0x80-0xbf
} else if (point <= 0xD7FF || (point >= 0xE000 && point <= 0xFFFF)) {
// 三字节标量值00000000 xxxxyyyy yyzzzzzz
arr.push(0xe0 | (point >>> 12)) // 1110xxxx0xe0-0xef
arr.push(0x80 | ((point >>> 6) & 0x3f)) // 10yyyyyy0x80-0xbf
arr.push(0x80 | (point & 0x3f)) // 10zzzzzz0x80-0xbf
} else if (point >= 0x010000 && point <= 0x10FFFF) {
// 四字节标量值000wwwxx xxxxyyyy yyzzzzzz
i++
arr.push((0xf0 | (point >>> 18) & 0x1c)) // 11110www0xf0-0xf7
arr.push((0x80 | ((point >>> 12) & 0x3f))) // 10xxxxxx0x80-0xbf
arr.push((0x80 | ((point >>> 6) & 0x3f))) // 10yyyyyy0x80-0xbf
arr.push((0x80 | (point & 0x3f))) // 10zzzzzz0x80-0xbf
} else {
// 五、六字节,暂时不支持
arr.push(point)
throw new Error('input is not supported')
}
}
return arr
}
/**
* 字节数组转 utf8 串
*/
function arrayToUtf8(arr) {
const str = []
for (let i = 0, len = arr.length; i < len; i++) {
if (arr[i] >= 0xf0 && arr[i] <= 0xf7) {
// 四字节
str.push(String.fromCodePoint(((arr[i] & 0x07) << 18) + ((arr[i + 1] & 0x3f) << 12) + ((arr[i + 2] & 0x3f) << 6) + (arr[i + 3] & 0x3f)))
i += 3
} else if (arr[i] >= 0xe0 && arr[i] <= 0xef) {
// 三字节
str.push(String.fromCodePoint(((arr[i] & 0x0f) << 12) + ((arr[i + 1] & 0x3f) << 6) + (arr[i + 2] & 0x3f)))
i += 2
} else if (arr[i] >= 0xc0 && arr[i] <= 0xdf) {
// 双字节
str.push(String.fromCodePoint(((arr[i] & 0x1f) << 6) + (arr[i + 1] & 0x3f)))
i++
} else {
// 单字节
str.push(String.fromCodePoint(arr[i]))
}
}
return str.join('')
}
/**
* 32 比特循环左移
*/
function rotl(x, n) {
const s = n & 31
return (x << s) | (x >>> (32 - s))
}
/**
* 非线性变换
*/
function byteSub(a) {
return (Sbox[a >>> 24 & 0xFF] & 0xFF) << 24 |
(Sbox[a >>> 16 & 0xFF] & 0xFF) << 16 |
(Sbox[a >>> 8 & 0xFF] & 0xFF) << 8 |
(Sbox[a & 0xFF] & 0xFF)
}
/**
* 线性变换,加密/解密用
*/
function l1(b) {
return b ^ rotl(b, 2) ^ rotl(b, 10) ^ rotl(b, 18) ^ rotl(b, 24)
}
/**
* 线性变换,生成轮密钥用
*/
function l2(b) {
return b ^ rotl(b, 13) ^ rotl(b, 23)
}
/**
* 以一组 128 比特进行加密/解密操作
*/
function sms4Crypt(input, output, roundKey) {
const x = new Array(4)
// 字节数组转成字数组(此处 1 字 = 32 比特)
const tmp = new Array(4)
for (let i = 0; i < 4; i++) {
tmp[0] = input[4 * i] & 0xff
tmp[1] = input[4 * i + 1] & 0xff
tmp[2] = input[4 * i + 2] & 0xff
tmp[3] = input[4 * i + 3] & 0xff
x[i] = tmp[0] << 24 | tmp[1] << 16 | tmp[2] << 8 | tmp[3]
}
// x[i + 4] = x[i] ^ l1(byteSub(x[i + 1] ^ x[i + 2] ^ x[i + 3] ^ roundKey[i]))
for (let r = 0, mid; r < 32; r += 4) {
mid = x[1] ^ x[2] ^ x[3] ^ roundKey[r + 0]
x[0] ^= l1(byteSub(mid)) // x[4]
mid = x[2] ^ x[3] ^ x[0] ^ roundKey[r + 1]
x[1] ^= l1(byteSub(mid)) // x[5]
mid = x[3] ^ x[0] ^ x[1] ^ roundKey[r + 2]
x[2] ^= l1(byteSub(mid)) // x[6]
mid = x[0] ^ x[1] ^ x[2] ^ roundKey[r + 3]
x[3] ^= l1(byteSub(mid)) // x[7]
}
// 反序变换
for (let j = 0; j < 16; j += 4) {
output[j] = x[3 - j / 4] >>> 24 & 0xff
output[j + 1] = x[3 - j / 4] >>> 16 & 0xff
output[j + 2] = x[3 - j / 4] >>> 8 & 0xff
output[j + 3] = x[3 - j / 4] & 0xff
}
}
/**
* 密钥扩展算法
*/
function sms4KeyExt(key, roundKey, cryptFlag) {
const x = new Array(4)
// 字节数组转成字数组(此处 1 字 = 32 比特)
const tmp = new Array(4)
for (let i = 0; i < 4; i++) {
tmp[0] = key[0 + 4 * i] & 0xff
tmp[1] = key[1 + 4 * i] & 0xff
tmp[2] = key[2 + 4 * i] & 0xff
tmp[3] = key[3 + 4 * i] & 0xff
x[i] = tmp[0] << 24 | tmp[1] << 16 | tmp[2] << 8 | tmp[3]
}
// 与系统参数做异或
x[0] ^= 0xa3b1bac6
x[1] ^= 0x56aa3350
x[2] ^= 0x677d9197
x[3] ^= 0xb27022dc
// roundKey[i] = x[i + 4] = x[i] ^ l2(byteSub(x[i + 1] ^ x[i + 2] ^ x[i + 3] ^ CK[i]))
for (let r = 0, mid; r < 32; r += 4) {
mid = x[1] ^ x[2] ^ x[3] ^ CK[r + 0]
roundKey[r + 0] = x[0] ^= l2(byteSub(mid)) // x[4]
mid = x[2] ^ x[3] ^ x[0] ^ CK[r + 1]
roundKey[r + 1] = x[1] ^= l2(byteSub(mid)) // x[5]
mid = x[3] ^ x[0] ^ x[1] ^ CK[r + 2]
roundKey[r + 2] = x[2] ^= l2(byteSub(mid)) // x[6]
mid = x[0] ^ x[1] ^ x[2] ^ CK[r + 3]
roundKey[r + 3] = x[3] ^= l2(byteSub(mid)) // x[7]
}
// 解密时使用反序的轮密钥
if (cryptFlag === DECRYPT) {
for (let r = 0, mid; r < 16; r++) {
mid = roundKey[r]
roundKey[r] = roundKey[31 - r]
roundKey[31 - r] = mid
}
}
}
function sm4(inArray, key, cryptFlag, {
padding = 'pkcs#7', mode, iv = [], output = 'string'
} = {}) {
if (mode === 'cbc') {
// CBC 模式,默认走 ECB 模式
if (typeof iv === 'string') iv = hexToArray(iv)
if (iv.length !== (128 / 8)) {
// iv 不是 128 比特
throw new Error('iv is invalid')
}
}
// 检查 key
if (typeof key === 'string') key = hexToArray(key)
if (key.length !== (128 / 8)) {
// key 不是 128 比特
throw new Error('key is invalid')
}
// 检查输入
if (typeof inArray === 'string') {
if (cryptFlag !== DECRYPT) {
// 加密,输入为 utf8 串
inArray = utf8ToArray(inArray)
} else {
// 解密,输入为 16 进制串
inArray = hexToArray(inArray)
}
} else {
inArray = [...inArray]
}
// 新增填充sm4 是 16 个字节一个分组,所以统一走到 pkcs#7
if ((padding === 'pkcs#5' || padding === 'pkcs#7') && cryptFlag !== DECRYPT) {
const paddingCount = BLOCK - inArray.length % BLOCK
for (let i = 0; i < paddingCount; i++) inArray.push(paddingCount)
}
// 生成轮密钥
const roundKey = new Array(ROUND)
sms4KeyExt(key, roundKey, cryptFlag)
const outArray = []
let lastVector = iv
let restLen = inArray.length
let point = 0
while (restLen >= BLOCK) {
const input = inArray.slice(point, point + 16)
const output = new Array(16)
if (mode === 'cbc') {
for (let i = 0; i < BLOCK; i++) {
if (cryptFlag !== DECRYPT) {
// 加密过程在组加密前进行异或
input[i] ^= lastVector[i]
}
}
}
sms4Crypt(input, output, roundKey)
for (let i = 0; i < BLOCK; i++) {
if (mode === 'cbc') {
if (cryptFlag === DECRYPT) {
// 解密过程在组解密后进行异或
output[i] ^= lastVector[i]
}
}
outArray[point + i] = output[i]
}
if (mode === 'cbc') {
if (cryptFlag !== DECRYPT) {
// 使用上一次输出作为加密向量
lastVector = output
} else {
// 使用上一次输入作为解密向量
lastVector = input
}
}
restLen -= BLOCK
point += BLOCK
}
// 去除填充sm4 是 16 个字节一个分组,所以统一走到 pkcs#7
if ((padding === 'pkcs#5' || padding === 'pkcs#7') && cryptFlag === DECRYPT) {
const len = outArray.length
const paddingCount = outArray[len - 1]
for (let i = 1; i <= paddingCount; i++) {
if (outArray[len - i] !== paddingCount) throw new Error('padding is invalid')
}
outArray.splice(len - paddingCount, paddingCount)
}
// 调整输出
if (output !== 'array') {
if (cryptFlag !== DECRYPT) {
// 加密,输出转 16 进制串
return ArrayToHex(outArray)
} else {
// 解密,输出转 utf8 串
return arrayToUtf8(outArray)
}
} else {
return outArray
}
}
module.exports = {
encrypt(inArray, key, options) {
return sm4(inArray, key, 1, options)
},
decrypt(inArray, key, options) {
return sm4(inArray, key, 0, options)
}
}

26
node_modules/sm-crypto/webpack.config.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
sm2: './src/sm2/index.js',
sm3: './src/sm3/index.js',
sm4: './src/sm4/index.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
library: '[name]',
libraryTarget: 'umd',
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
]
};

18
package-lock.json generated
View File

@@ -1,18 +1,14 @@
{
"name": "ks-app-employment-service",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"@dcloudio/uni-ui": "^1.5.11",
"dayjs": "^1.11.19",
"sm-crypto": "^0.3.13"
}
},
"node_modules/@dcloudio/uni-ui": {
"version": "1.5.11",
"resolved": "https://registry.npmjs.org/@dcloudio/uni-ui/-/uni-ui-1.5.11.tgz",
"integrity": "sha512-DBtk046ofmeFd82zRI7d89SoEwrAxYzUN3WVPm1DIBkpLPG5F5QDNkHMnZGu2wNrMEmGBjBpUh3vqEY1L3jaMw=="
},
"node_modules/dayjs": {
"version": "1.11.19",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz",
@@ -25,20 +21,14 @@
},
"node_modules/sm-crypto": {
"version": "0.3.13",
"resolved": "https://registry.npmmirror.com/sm-crypto/-/sm-crypto-0.3.13.tgz",
"resolved": "https://registry.npmjs.org/sm-crypto/-/sm-crypto-0.3.13.tgz",
"integrity": "sha512-ztNF+pZq6viCPMA1A6KKu3bgpkmYti5avykRHbcFIdSipFdkVmfUw2CnpM2kBJyppIalqvczLNM3wR8OQ0pT5w==",
"license": "MIT",
"dependencies": {
"jsbn": "^1.1.0"
}
}
},
"dependencies": {
"@dcloudio/uni-ui": {
"version": "1.5.11",
"resolved": "https://registry.npmjs.org/@dcloudio/uni-ui/-/uni-ui-1.5.11.tgz",
"integrity": "sha512-DBtk046ofmeFd82zRI7d89SoEwrAxYzUN3WVPm1DIBkpLPG5F5QDNkHMnZGu2wNrMEmGBjBpUh3vqEY1L3jaMw=="
},
"dayjs": {
"version": "1.11.19",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz",
@@ -51,7 +41,7 @@
},
"sm-crypto": {
"version": "0.3.13",
"resolved": "https://registry.npmmirror.com/sm-crypto/-/sm-crypto-0.3.13.tgz",
"resolved": "https://registry.npmjs.org/sm-crypto/-/sm-crypto-0.3.13.tgz",
"integrity": "sha512-ztNF+pZq6viCPMA1A6KKu3bgpkmYti5avykRHbcFIdSipFdkVmfUw2CnpM2kBJyppIalqvczLNM3wR8OQ0pT5w==",
"requires": {
"jsbn": "^1.1.0"

View File

@@ -1,6 +1,5 @@
{
"dependencies": {
"@dcloudio/uni-ui": "^1.5.11",
"dayjs": "^1.11.19",
"sm-crypto": "^0.3.13"
}

View File

@@ -1,423 +1,329 @@
<template>
<AppLayout title="" :use-scroll-view="false">
<template #headerleft>
<view class="btnback">
<image src="@/static/icon/back.png" @click="navBack"></image>
</view>
</template>
<template #headerright>
<view class="btn mar_ri10">
<image src="@/static/icon/collect3.png" v-if="!companyInfo.isCollection"></image>
<image src="@/static/icon/collect2.png" v-else></image>
</view>
</template>
<view class="content">
<view class="content-top">
<view class="companyinfo-left">
<image src="@/static/icon/companyIcon.png" mode=""></image>
</view>
<view class="companyinfo-right">
<view class="row1">{{ companyInfo?.companyName }}</view>
<view class="row2">
{{ companyInfo?.scale }}
</view>
</view>
</view>
<view class="conetent-info" :class="{ expanded: isExpanded }">
<view class="info-title">公司介绍</view>
<view class="info-desirption">{{
<AppLayout title="" :use-scroll-view="false">
<template #headerleft>
<view class="btnback">
<image src="@/static/icon/back.png" @click="navBack"></image>
</view>
</template>
<template #headerright>
<view class="btn mar_ri10">
<image
src="@/static/icon/collect3.png"
v-if="!companyInfo.isCollection"
></image>
<image src="@/static/icon/collect2.png" v-else></image>
</view>
</template>
<view class="content">
<view class="content-top">
<view class="companyinfo-left">
<image src="@/static/icon/companyIcon.png" mode=""></image>
</view>
<view class="companyinfo-right">
<view class="row1">{{ companyInfo?.companyName }}</view>
<view class="row2">
{{ companyInfo?.scale }}
</view>
</view>
</view>
<view class="conetent-info" :class="{ expanded: isExpanded }">
<view class="info-title">公司介绍</view>
<view class="info-desirption">{{
companyInfo.companyIntroduction
}}</view>
<!-- <view class="info-title title2">公司地址</view>
<!-- <view class="info-title title2">公司地址</view>
<view class="locationCompany"></view> -->
</view>
<view class="expand" @click="expand">
<text>{{ isExpanded ? "收起" : "展开" }}</text>
<image class="expand-img" :class="{ 'expand-img-active': !isExpanded }" src="@/static/icon/downs.png">
</image>
</view>
<scroll-view scroll-y class="Detailscroll-view">
<view class="views">
<view class="Detail-title"><text class="title">在招职位</text></view>
<template v-if="companyInfo.jobInfoList.length != 0">
<view v-for="job in companyInfo.jobInfoList" :key="job.id">
<!-- @click="navTo(`/packageA/pages/post/post?jobId=${JSON.stringify(job)}`)" -->
<!-- :style="getItemBackgroundStyle('bj2.png')" -->
<view class="cards">
<view class="card-company">
<text class="company">{{ job.jobTitle }}</text>
<view class="salary"> {{ job.salaryRange }}/ </view>
</view>
<view class="card-tags">
<view class="tag jy">
<image :src="`${baseUrl}/jobfair/jy.png`" mode=""></image>
{{ job.experienceRequirement }}
</view>
<view class="tag xl">
<image :src="`${baseUrl}/jobfair/xx.png`" mode=""></image>
{{ job.educationRequirement }}
</view>
<view class="tag yd" v-if="job.jobRequirement">
<image :src="`${baseUrl}/jobfair/lx-1.png`" mode=""></image>
{{ job.jobRequirement }}
</view>
</view>
<view class="card-companyName">
{{ job.jobDescription }}
</view>
<view class="deliver-box">
<view class="deliver-btn" @click="deliverResume(job)">
简历投递
</view>
</view>
</view>
</view>
</template>
<empty v-else pdTop="200"></empty>
</view>
</scroll-view>
</view>
</AppLayout>
</view>
<view class="expand" @click="expand">
<text>{{ isExpanded ? "收起" : "展开" }}</text>
<image
class="expand-img"
:class="{ 'expand-img-active': !isExpanded }"
src="@/static/icon/downs.png"
></image>
</view>
<scroll-view scroll-y class="Detailscroll-view">
<view class="views">
<view class="Detail-title"><text class="title">在招职位</text></view>
<template v-if="companyInfo.jobInfoList.length != 0">
<view v-for="job in companyInfo.jobInfoList" :key="job.id">
<view class="cards" @click="navTo(`/packageA/pages/post/post?jobId=${JSON.stringify(job)}`)">
<view class="card-company">
<text class="company">{{ job.jobTitle }}</text>
<view class="salary"> {{ job.salaryRange }} </view>
</view>
<view class="card-companyName">{{ job.companyName }}</view>
<view class="card-companyName">{{ job.jobDescription }}</view>
<view class="card-tags">
<view class="tag">
{{ job.educationRequirement }}
</view>
<view class="tag">
{{ job.experienceRequirement }}
</view>
<!-- <view class="tag">
{{ vacanciesTo(job.vacancies) }}
</view> -->
<view class="tag" v-if="job.jobRequirement">
{{ job.jobRequirement }}
</view>
</view>
<view class="card-bottom">
<view>{{ job.postingDate }}</view>
<view>
<convert-distance
:alat="job.latitude"
:along="job.longitude"
:blat="latitude"
:blong="longitude"
></convert-distance>
<dict-Label
class="mar_le10"
dictType="area"
:value="job.jobLocationAreaCode"
></dict-Label>
</view>
</view>
</view>
</view>
</template>
<empty v-else pdTop="200"></empty>
</view>
</scroll-view>
</view>
</AppLayout>
</template>
<script setup>
import {
reactive,
inject,
watch,
ref,
onMounted,
computed
} from "vue";
import {
onLoad,
onShow
} from "@dcloudio/uni-app";
import dictLabel from "@/components/dict-Label/dict-Label.vue";
import config from "@/config.js";
import {
storeToRefs
} from "pinia";
import useLocationStore from "@/stores/useLocationStore";
const {
longitudeVal,
latitudeVal
} = storeToRefs(useLocationStore());
const {
$api,
navTo,
vacanciesTo,
navBack
} = inject("globalFunction");
const isExpanded = ref(false);
const pageState = reactive({
page: 0,
list: [],
total: 0,
maxPage: 1,
pageSize: 10,
});
const companyInfo = ref({
jobInfoList: [],
});
import point from "@/static/icon/point.png";
import { reactive, inject, watch, ref, onMounted, computed } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import dictLabel from "@/components/dict-Label/dict-Label.vue";
import { storeToRefs } from "pinia";
import useLocationStore from "@/stores/useLocationStore";
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
const { $api, navTo, vacanciesTo, navBack } = inject("globalFunction");
const baseUrl = config.imgBaseUrl;
const getItemBackgroundStyle = (imageName) => ({
backgroundImage: `url(${baseUrl}/jobfair/${imageName})`,
backgroundSize: "100% 100%", // 覆盖整个容器
backgroundPosition: "center", // 居中
backgroundRepeat: "no-repeat",
});
const isExpanded = ref(false);
const pageState = reactive({
page: 0,
list: [],
total: 0,
maxPage: 1,
pageSize: 10,
});
const companyInfo = ref({});
onLoad((options) => {
companyInfo.value = JSON.parse(options.job);
});
onLoad((options) => {
companyInfo.value = JSON.parse(options.job);
console.log(companyInfo.value, "companyInfo.value");
});
function expand() {
isExpanded.value = !isExpanded.value;
}
function deliverResume(job) {
const raw = uni.getStorageSync("Padmin-Token");
const token = typeof raw === "string" ? raw.trim() : "";
const headers = token ? {
Authorization: raw.startsWith("Bearer ") ? raw : `Bearer ${token}`
} : {};
$api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, headers).then((resData1) => {
if (resData1.code == 200) {
$api.myRequest("/system/user/login/user/info", {}, "GET", 10100, headers).then((resData) => {
$api.myRequest("/jobfair/public/job-fair-person-job/insert", {
jobFairId: companyInfo.value.jobFairId, // 招聘会id
personId: resData.info.userId, // 当前登录用户id
enterpriseId: companyInfo.value.companyId, // 企业id
jobId: job.jobId, // 岗位id
idCard:resData.info.personCardNo
}, "post", 9100, {
"Content-Type": "application/json"
}).then((data) => {
if (data && data.code === 200) {
$api.msg("简历投递成功");
} else {
$api.msg((data && data.msg) || "简历投递失败");
}
});
});
} else {
$api.msg('请先登录')
}
});
}
function expand() {
isExpanded.value = !isExpanded.value;
}
</script>
<style lang="stylus" scoped>
.btnback {
width: 64rpx;
height: 64rpx;
}
.btnback {
width: 64rpx;
height: 64rpx;
}
.btn {
display: flex;
justify-content: space-between;
align-items: center;
width: 52rpx;
height: 52rpx;
}
.btn {
display: flex;
justify-content: space-between;
align-items: center;
width: 52rpx;
height: 52rpx;
}
image {
height: 100%;
width: 100%;
}
image {
height: 100%;
width: 100%;
}
.content {
height: 100%;
display: flex;
flex-direction: column;
.content {
height: 100%;
display: flex;
flex-direction: column;
.content-top {
padding: 28rpx;
padding-top: 50rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.content-top {
padding: 28rpx;
padding-top: 50rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.companyinfo-left {
width: 96rpx;
height: 96rpx;
margin-right: 24rpx;
}
.companyinfo-left {
width: 96rpx;
height: 96rpx;
margin-right: 24rpx;
}
.companyinfo-right {
.row1 {
font-weight: 500;
font-size: 32rpx;
color: #333333;
}
.companyinfo-right {
.row1 {
font-weight: 500;
font-size: 32rpx;
color: #333333;
}
.row2 {
font-weight: 400;
font-size: 28rpx;
color: #6C7282;
line-height: 45rpx;
}
}
}
.row2 {
font-weight: 400;
font-size: 28rpx;
color: #6C7282;
line-height: 45rpx;
}
}
}
.conetent-info {
padding: 0 28rpx;
overflow: hidden;
max-height: 0rpx;
transition: max-height 0.3s ease;
.conetent-info {
padding: 0 28rpx;
overflow: hidden;
max-height: 0rpx;
transition: max-height 0.3s ease;
.info-title {
font-weight: 600;
font-size: 28rpx;
color: #000000;
}
.info-title {
font-weight: 600;
font-size: 28rpx;
color: #000000;
}
.info-desirption {
margin-top: 12rpx;
font-weight: 400;
font-size: 28rpx;
color: #495265;
text-align: justified;
}
.info-desirption {
margin-top: 12rpx;
font-weight: 400;
font-size: 28rpx;
color: #495265;
text-align: justified;
}
.title2 {
margin-top: 48rpx;
}
}
.title2 {
margin-top: 48rpx;
}
}
.expanded {
max-height: 1000rpx; // 足够显示完整内容
}
.expanded {
max-height: 1000rpx; // 足够显示完整内容
}
.expand {
display: flex;
flex-wrap: nowrap;
white-space: nowrap;
justify-content: center;
margin-top: 20rpx;
margin-bottom: 28rpx;
font-weight: 400;
font-size: 28rpx;
color: #256BFA;
.expand {
display: flex;
flex-wrap: nowrap;
white-space: nowrap;
justify-content: center;
margin-top: 20rpx;
margin-bottom: 28rpx;
font-weight: 400;
font-size: 28rpx;
color: #256BFA;
.expand-img {
width: 40rpx;
height: 40rpx;
}
.expand-img {
width: 40rpx;
height: 40rpx;
}
.expand-img-active {
transform: rotate(180deg);
}
}
}
.expand-img-active {
transform: rotate(180deg);
}
}
}
.Detailscroll-view {
flex: 1;
overflow: hidden;
background: #F4F4F4;
.Detailscroll-view {
flex: 1;
overflow: hidden;
background: #F4F4F4;
.views {
padding: 28rpx;
.views {
padding: 28rpx;
.Detail-title {
font-weight: 600;
font-size: 32rpx;
color: #000000;
position: relative;
display: flex;
justify-content: space-between;
.Detail-title {
font-weight: 600;
font-size: 32rpx;
color: #000000;
position: relative;
display: flex;
justify-content: space-between;
.title {
position: relative;
z-index: 2;
}
}
.title {
position: relative;
z-index: 2;
}
}
.Detail-title::before {
position: absolute;
content: '';
left: -14rpx;
bottom: 0;
height: 16rpx;
width: 108rpx;
background: linear-gradient(to right, #CBDEFF, #FFFFFF);
border-radius: 8rpx;
z-index: 1;
}
.Detail-title::before {
position: absolute;
content: '';
left: -14rpx;
bottom: 0;
height: 16rpx;
width: 108rpx;
background: linear-gradient(to right, #CBDEFF, #FFFFFF);
border-radius: 8rpx;
z-index: 1;
}
.cards {
padding: 32rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.04);
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin-top: 22rpx;
padding-bottom: 18rpx;
background: #f2f8fc;
.cards {
padding: 32rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.04);
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin-top: 22rpx;
.card-company {
display: flex;
justify-content: space-between;
align-items: flex-start;
border-bottom: 1rpx solid #c2d7ea;
.card-company {
display: flex;
justify-content: space-between;
align-items: flex-start;
.company {
font-weight: 600;
font-size: 32rpx;
color: #207AC7;
}
.company {
font-weight: 500;
font-size: 32rpx;
color: #333333;
}
.salary {
font-weight: 600;
font-size: 28rpx;
color: #F83A3C;
white-space: nowrap;
line-height: 48rpx;
}
}
.salary {
font-weight: 500;
font-size: 28rpx;
color: #4C6EFB;
white-space: nowrap;
line-height: 48rpx;
}
}
.deliver-box {
width: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
margin-top: 5rpx;
.card-companyName {
font-weight: 400;
font-size: 28rpx;
color: #6C7282;
}
.deliver-btn {
padding: 10rpx 25rpx;
background: #53ACFF;
width: max-content;
color: #fff;
}
}
.card-tags {
display: flex;
flex-wrap: wrap;
.card-companyName {
font-weight: 400;
font-size: 28rpx;
margin-top: 23rpx;
display: flex;
align-items: center;
.tag {
width: fit-content;
height: 30rpx;
background: #F4F4F4;
border-radius: 4rpx;
padding: 6rpx 20rpx;
line-height: 30rpx;
font-weight: 400;
font-size: 24rpx;
color: #6C7282;
text-align: center;
margin-top: 14rpx;
white-space: nowrap;
margin-right: 20rpx;
}
}
image {
width: 24rpx;
height: 24rpx;
margin-right: 8rpx;
}
}
.card-tags {
display: flex;
flex-wrap: wrap;
margin: 25rpx 0 35rpx;
image {
width: 24rpx;
height: 24rpx;
margin-right: 8rpx;
}
.jy {
background: #D9EDFF;
color: #0086FF;
}
.xl {
background: #FFF1D5;
color: #FF7F01;
}
.yd {
background: #FFD8D8;
color: #F83A3C;
}
.tag {
width: fit-content;
height: 30rpx;
border-radius: 4rpx;
padding: 6rpx 20rpx;
line-height: 30rpx;
font-weight: 400;
font-size: 24rpx;
text-align: center;
white-space: nowrap;
margin-right: 20rpx;
display: flex;
align-items: center;
}
}
.card-bottom {
margin-top: 32rpx;
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #6C7282;
}
}
}
}
.card-bottom {
margin-top: 32rpx;
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #6C7282;
}
}
}
}
</style>

View File

@@ -1,5 +1,10 @@
<template>
<AppLayout title="我的浏览" :show-bg-image="false" :use-scroll-view="false">
<template #headerleft>
<view class="btnback">
<image src="@/static/icon/back.png" @click="navBack"></image>
</view>
</template>
<view class="collection-content">
<view class="collection-search">
<view class="search-content">

View File

@@ -1,5 +1,10 @@
<template>
<AppLayout title="我的收藏" :show-bg-image="false" :use-scroll-view="false">
<template #headerleft>
<view class="btn">
<image src="@/static/icon/back.png" @click="navBack"></image>
</view>
</template>
<view class="collection-content">
<view class="header">
<view class="button-click" :class="{ active: type === 0 }" @click="changeType(0)">工作职位</view>

View File

@@ -68,61 +68,48 @@
<text class="title">参会单位{{ companyList.length }}</text>
</view>
<view v-for="job in companyList" :key="job.id">
<view class="cards" :style="getItemBackgroundStyle('bj.png')"
@click="navTo('/packageA/pages/UnitDetails/UnitDetails?job='+JSON.stringify(job))">
<view class="card-company">
<view class="company line_1">
<image :src="`${baseUrl}/jobfair/mc.png`" mode=""></image>
{{ job.companyName }}
</view>
<view class="ris">
<text class="fs_14">
在招职位
{{ job.jobInfoList.length || '-' }}
</text>
</view>
</view>
<view class="card-bottom">
<view class="fl_box fs_14">
{{ job.scale }}
</view>
</view>
<view class="card-tags">
<view class="tag" v-if="job.industry">
<image :src="`${baseUrl}/jobfair/hy.png`" mode=""></image>
{{ job.industry }}
</view>
<view class="tag">
<image :src="`${baseUrl}/jobfair/lx.png`" mode=""></image>
{{ job.companyType }}
</view>
</view>
</view>
<view class="cards" @click="navTo('/packageA/pages/UnitDetails/UnitDetails?job='+JSON.stringify(job))">
<view class="card-company">
<text class="company line_1">{{ job.companyName }}</text>
</view>
<view class="card-bottom">
<view class="fl_box fs_14">
{{ job.scale }}
</view>
<view class="ris">
<text class="fs_14">
在招职位·
<text class="color_256BFA">{{ job.jobInfoList.length || '-' }}</text>
</text>
</view>
</view>
<view class="card-tags">
<view class="tag" v-if="job.industry">
{{ job.industry }}
</view>
<view class="tag">
{{ job.companyType }}
</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
<template #footer>
<view class="footer" v-if="hasnext">
<view class="btn-wq button-click" :class="{ 'btn-desbel': fairInfo.isSignUp==1 }"
<view class="btn-wq button-click" :class="{ 'btn-desbel': fairInfo.isCollection }"
@click="applyExhibitors">
{{ fairInfo.isSignUp==1 ? '报名' : '报名招聘会' }}
{{ fairInfo.isCollection ? '预约招聘会' : '预约招聘会' }}
</view>
</view>
</template>
<uni-popup ref="CompanySignPopup" background-color="#fff" :mask-click="false">
<view class="popup-content">
<signDialog v-if="signDialogisshow" :signType="signType" :signRole="signRole"
:jobFairId="fairInfo.jobFairId" @closePopup="closePopup"></signDialog>
</view>
</uni-popup>
</AppLayout>
</template>
<script setup>
import signDialog from '@/components/jobfair/signDialog.vue';
import config from "@/config.js"
import point from '@/static/icon/point.png';
import {
reactive,
inject,
@@ -135,6 +122,7 @@
onLoad,
onShow
} from '@dcloudio/uni-app';
import dictLabel from '@/components/dict-Label/dict-Label.vue';
import useLocationStore from '@/stores/useLocationStore';
const {
$api,
@@ -154,77 +142,29 @@
const fairInfo = ref({});
const companyList = ref([]);
const hasnext = ref(true);
const userInfo = ref({});
const signDialogisshow = ref(false)
// 弹窗
const signType = ref(1);
// person个人 ent企业
const signRole = ref('ent');
const CompanySignPopup = ref(null)
const jobFairId = ref(null)
const baseUrl = config.imgBaseUrl
const getItemBackgroundStyle = (imageName) => ({
backgroundImage: `url(${baseUrl}/jobfair/${imageName})`,
backgroundSize: '100% 100%', // 覆盖整个容器
backgroundPosition: 'center', // 居中
backgroundRepeat: 'no-repeat'
});
onLoad((options) => {
jobFairId.value=options.jobFairId
const raw = uni.getStorageSync("Padmin-Token");
const token = typeof raw === "string" ? raw.trim() : "";
const headers = token ? {
Authorization: raw.startsWith("Bearer ") ? raw : `Bearer ${token}`
} : {};
$api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, headers).then((resData) => {
if (resData.code == 200) {
$api.myRequest("/system/user/login/user/info", {}, "GET", 10100, {
Authorization: `Bearer ${uni.getStorageSync("Padmin-Token")}`
}).then((userinfo) => {
userInfo.value = userinfo
getCompanyInfo(userInfo.value.info.userId, options.jobFairId);
});
} else {
getCompanyInfo('', options.jobFairId);
}
});
getCompanyInfo(options.jobFairId);
});
function closePopup() {
CompanySignPopup.value.close()
getCompanyInfo(userInfo.value.info.userId, jobFairId.value)
}
function getCompanyInfo(userId, id) {
let data={}
if (userInfo.value&&userInfo.value.userType == 'ent') {
data={
jobFairId: id,
enterpriseId: userId,
code:userInfo.value.info.entCreditCode
}
}else if(userInfo.value&&userInfo.value.userType == 'ent'){
data={
jobFairId: id,
personId: userId,
idCard:userInfo.value.info.personCardNo
}
}else{
data={
jobFairId: id,
personId: userId
}
}
$api.myRequest('/jobfair/public/jobfair/detail', data).then((resData) => {
function getCompanyInfo(id) {
// $api.createRequest(`/app/fair/${id}`).then((resData) => {
// fairInfo.value = resData.data;
// companyList.value = resData.data.companyList;
// hasAppointment();
// });
$api.myRequest('/jobfair/public/jobfair/detail', {
jobFairId: id
}).then((resData) => {
console.log(resData, 'resData');
fairInfo.value = resData.data;
console.log(fairInfo.value, 'fairInfo.value');
// hasAppointment()
});
$api.myRequest('/jobfair/public/jobfair/enterprises-with-jobs-by-job-fair-id', {
jobFairId: id
}).then((resData) => {
companyList.value = resData.data;
// hasAppointment()
});
};
@@ -251,56 +191,21 @@
isExpanded.value = !isExpanded.value;
}
// 报名招聘会
// 取消/收藏岗位
function applyExhibitors() {
if (fairInfo.value.isSignUp == 1) {
$api.msg('请勿重复报名');
return
const fairId = fairInfo.value.jobFairId;
if (fairInfo.value.isCollection) {
// $api.createRequest(`/app/fair/collection/${fairId}`, {}, 'DELETE').then((resData) => {
// getCompanyInfo(fairId);
// $api.msg('取消预约成功');
// });
$api.msg('已预约成功');
} else {
$api.createRequest(`/app/fair/collection/${fairId}`, {}, 'POST').then((resData) => {
getCompanyInfo(fairId);
$api.msg('预约成功');
});
}
const raw = uni.getStorageSync("Padmin-Token");
const token = typeof raw === "string" ? raw.trim() : "";
const headers = token ? {
Authorization: raw.startsWith("Bearer ") ? raw : `Bearer ${token}`
} : {};
$api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, headers).then((resData) => {
if (resData.code == 200) {
if (userInfo.value.userType == 'ent') {
// 企业
signType.value = fairInfo.value.jobFairType;
signRole.value = userInfo.userType;
signDialogisshow.value = true
CompanySignPopup.value.open()
}else{
$api.myRequest("/jobfair/public/job-fair-sign-up-person/sign-up", {
personId: userInfo.value.info.userId,
jobFairId: jobFairId.value,
idCard:userInfo.value.info.personCardNo
}, "POST", 9100, { "Content-Type": "application/json",...headers }).then((res) => {
if (res.code === 200) {
uni.showToast({
title: '报名成功',
icon: 'success'
});
getCompanyInfo(userInfo.value.info.userId, jobFairId.value)
} else {
uni.showToast({
title: res.msg || '报名失败',
icon: 'none'
});
}
})
}
} else {
$api.msg('请先登录');
setTimeout(() => {
uni.redirectTo({
url: '/packageB/login'
})
}, 1000)
}
});
}
function parseDateTime(datetimeStr) {
@@ -336,24 +241,19 @@
// 判断状态0 开始中1 过期2 待开始
let status = 0;
let statusText = '开始中';
let color = '#13C57C'; // 进行中 - 绿色
if (now < startTime) {
status = 2; // 待开始
statusText = '待开始';
color = '#015EEA'; // 未开始 - 蓝色
} else if (now > endTime) {
status = 1; // 已过期
statusText = '已过期';
color = '#999999'; // 已过期 - 灰色
} else {
status = 0; // 进行中
statusText = '进行中';
color = '#13C57C'; // 进行中 - 绿色
}
return {
status, // 0: 进行中1: 已过期2: 待开始
statusText,
color
};
}
@@ -369,12 +269,6 @@
</script>
<style lang="stylus" scoped>
.popup-content {
width: 90vw;
height: 80vh;
position: relative;
}
.btnback {
width: 64rpx;
height: 64rpx;
@@ -397,30 +291,25 @@
height: 100%;
display: flex;
flex-direction: column;
.content-top {
padding: 28rpx;
padding-top: 50rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.companyinfo-left {
width: 96rpx;
height: 96rpx;
margin-right: 24rpx;
}
.companyinfo-right {
flex: 1;
.row1 {
font-weight: 500;
font-size: 32rpx;
color: #333333;
font-family: 'PingFangSC-Medium', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif;
}
.row2 {
font-weight: 400;
font-size: 28rpx;
@@ -459,7 +348,6 @@
align-items: center;
justify-content: space-between;
white-space: nowrap;
.info-title {
font-weight: 600;
font-size: 28rpx;
@@ -608,20 +496,10 @@
display: flex;
justify-content: space-between;
align-items: flex-start;
.company {
font-weight: 600;
font-weight: 500;
font-size: 32rpx;
color: #333333;
display: flex;
align-items: center;
image {
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
}
.salary {
@@ -630,13 +508,6 @@
white-space: nowrap;
line-height: 48rpx;
}
.ris {
background: #53ACFF;
color: #fff;
padding: 7rpx 20rpx;
border-radius: 8rpx;
}
}
.card-companyName {
@@ -648,34 +519,25 @@
.card-tags {
display: flex;
flex-wrap: wrap;
.tag {
width: fit-content;
height: 30rpx;
background: #E0F0FF;
background: #F4F4F4;
border-radius: 4rpx;
padding: 6rpx 26rpx;
padding: 6rpx 20rpx;
line-height: 30rpx;
font-weight: 400;
font-size: 24rpx;
color: #595959;
color: #6C7282;
text-align: center;
margin-top: 14rpx;
white-space: nowrap;
display: flex;
align-items: center;
margin-right: 20rpx;
image {
width: 22rpx;
height: 22rpx;
margin-right: 8rpx;
}
}
}
.card-bottom {
margin-top: 15rpx;
margin-top: 32rpx;
display: flex;
justify-content: space-between;
font-size: 28rpx;
@@ -690,17 +552,14 @@
justify-content: space-between;
align-items: center;
padding: 24rpx 30rpx 10rpx 30rpx;
.time-left,
.time-right {
text-align: center;
.left-date {
font-weight: 500;
font-size: 48rpx;
color: #333333;
}
.left-dateDay {
font-weight: 400;
font-size: 24rpx;
@@ -708,27 +567,23 @@
margin-top: 12rpx;
}
}
.line {
width: 40rpx;
height: 0rpx;
border: 2rpx solid #D4D4D4;
margin-top: 64rpx;
}
.time-center {
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.center-date {
font-weight: 400;
font-size: 28rpx;
color: #FF881A;
}
.center-dateDay {
font-weight: 400;
font-size: 24rpx;
@@ -766,4 +621,4 @@
box-shadow: 0rpx -4rpx 24rpx 0rpx rgba(11, 44, 112, 0.12);
}
}
</style>
</style>

View File

@@ -13,7 +13,7 @@ import useUserStore from '@/stores/useUserStore';
const { $api, navTo, navBack, vacanciesTo } = inject('globalFunction');
import { storeToRefs } from 'pinia';
import useLocationStore from '@/stores/useLocationStore';
import { usePagination } from '@/packageA/hook/usePagination';
import { usePagination } from '@/hook/usePagination';
import { jobMoreMap } from '@/utils/markdownParser';
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
const loadmoreRef = ref(null);

View File

@@ -122,7 +122,7 @@
</view>
<!-- 4. 新增简历上传区域固定在页面底部 -->
<view class="resume-upload-section">
<!-- <view class="resume-upload-section">
<button class="upload-btn" @click="handleResumeUpload" :loading="isUploading" :disabled="isUploading">
<uni-icons type="cloud-upload" size="20"></uni-icons>
<text class="upload-text">
@@ -138,7 +138,7 @@
<text class="file-name">{{ uploadedResumeName }}</text>
<button class="delete-file-btn" size="mini" @click.stop="handleDeleteResume">删除</button>
</view>
</view>
</view> -->
</view>
</template>
@@ -267,202 +267,12 @@ const handleDeleteItem = async (item, index) => {
};
// 简历上传核心逻辑
const handleResumeUpload = () => {
// 从缓存获取用户ID参考首页实现方式
// 优先从store获取如果为空则从缓存获取
const storeUserId = userInfo.value?.userId;
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const cachedUserId = cachedUserInfo.userId;
// 获取用户ID优先使用store中的userId如果store中没有使用缓存中的userId
const userId = storeUserId || cachedUserId;
if (!userId) {
$api.msg('请先登录');
return;
}
// 检查是否正在上传
if (isUploading.value) {
return;
}
// 选择文件(微信小程序使用 wx.chooseMessageFileuni-app 中对应 uni.chooseMessageFile
uni.chooseMessageFile({
count: 1, // 只能选择一个文件
type: 'file', // 选择任意文件类型
success: (res) => {
// 注意:文件路径在 res.tempFiles[0].path
const file = res.tempFiles[0];
const tempFilePath = file.path; // 获取临时文件路径
const fileName = file.name; // 获取文件名
// 检查文件大小20MB = 20 * 1024 * 1024 字节)
const maxSize = 20 * 1024 * 1024;
if (file.size > maxSize) {
$api.msg('文件大小不能超过 20MB');
return;
}
// 检查文件类型
const allowedTypes = ['pdf', 'doc', 'docx'];
const fileExtension = fileName.split('.').pop()?.toLowerCase();
if (!fileExtension || !allowedTypes.includes(fileExtension)) {
$api.msg('仅支持 PDF、Word 格式');
return;
}
// 开始上传
uploadResumeFile(tempFilePath, fileName, userId);
},
fail: (err) => {
console.error('选择文件失败:', err);
// 用户取消选择不提示错误
if (err.errMsg && !err.errMsg.includes('cancel')) {
$api.msg('选择文件失败,请重试');
}
}
});
};
// 上传简历文件到服务器(使用 wx.uploadFileuni-app 中对应 uni.uploadFile
const uploadResumeFile = (filePath, fileName, userId) => {
// 确保 userId 存在且有效
if (!userId) {
// 如果传入的userId为空尝试从缓存再次获取
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const cachedUserId = cachedUserInfo.userId;
if (!cachedUserId) {
$api.msg('用户ID不存在无法上传');
return;
}
// 使用缓存中的userId
userId = cachedUserId;
}
isUploading.value = true;
// 获取token从缓存获取参考首页实现方式
let Authorization = '';
const tokenValue = uni.getStorageSync('token') || '';
if (tokenValue) {
Authorization = tokenValue;
} else {
// 如果缓存中没有token尝试从store获取
const userStore = useUserStore();
if (userStore.token) {
Authorization = userStore.token;
}
}
// 根据接口文档bussinessId 应该作为 Query 参数传递,而不是 formData
// 将 bussinessId 拼接到 URL 上作为查询参数
const uploadUrl = `${config.baseUrl}/app/file/upload?bussinessId=${encodeURIComponent(String(userId))}`;
// 打印调试信息
console.log('上传文件参数:', {
url: uploadUrl,
fileName: fileName,
bussinessId: userId,
userId: userId,
token: Authorization ? '已获取' : '未获取'
});
// 上传文件(参考微信小程序 wx.uploadFile API
uni.uploadFile({
url: uploadUrl, // 开发者服务器的上传接口(必须是 HTTPSbussinessId 作为 Query 参数
filePath: filePath, // 本地文件路径(临时路径)
name: 'file', // 服务器端接收文件的字段名(需与后端一致)
// 注意根据接口文档bussinessId 通过 Query 参数传递,不需要 formData
header: {
'Authorization': encodeURIComponent(Authorization)
},
success: (uploadRes) => {
try {
// 注意res.data 是字符串,需转为 JSON如果后端返回 JSON
// 参考方案const result = JSON.parse(data);
let resData;
if (typeof uploadRes.data === 'string') {
resData = JSON.parse(uploadRes.data);
} else {
resData = uploadRes.data;
}
// 判断上传是否成功
if (uploadRes.statusCode === 200 && resData.code === 200) {
// 上传成功,处理返回结果
uploadedResumeName.value = fileName;
uploadedResumeUrl.value = resData.data || resData.msg || resData.url || '';
$api.msg('简历上传成功');
console.log('上传成功', resData);
// 可以在这里保存简历信息到后端(如果需要)
// saveResumeInfo(userId, uploadedResumeUrl.value, fileName);
} else {
// 上传失败
const errorMsg = resData.msg || resData.message || '上传失败,请重试';
$api.msg(errorMsg);
console.error('上传失败:', resData);
}
} catch (error) {
// 解析响应数据失败
console.error('解析上传响应失败:', error);
console.error('原始响应数据:', uploadRes.data);
$api.msg('上传失败,请重试');
}
},
fail: (err) => {
// 上传失败
console.error('上传文件失败:', err);
$api.msg('上传失败,请检查网络连接');
},
// 上传进度监听(可选)
progress: (res) => {
const progress = res.progress; // 上传进度0-100
console.log('上传进度:', progress + '%');
// 可以在这里更新进度条 UI如果需要
},
complete: () => {
// 上传完成(无论成功或失败)
isUploading.value = false;
}
});
};
const handleResumeUpload = () => {};
// 删除已上传的简历
const handleDeleteResume = () => {
if (!uploadedResumeName.value) {
return;
}
uni.showModal({
title: '确认删除',
content: '确定要删除已上传的简历吗?',
success: (res) => {
if (res.confirm) {
// 清除本地数据
uploadedResumeName.value = '';
uploadedResumeUrl.value = '';
$api.msg('已删除');
// 如果需要,可以调用后端接口删除服务器上的文件
// deleteResumeFile(userId);
}
}
});
};
const handleDeleteResume = () => {};
</script>
<style lang="stylus">
/* 修复页面滚动问题:覆盖全局的 overflow: hidden */
page {
overflow-y: auto !important;
overflow-x: hidden;
}
</style>
<style lang="stylus" scoped>
image{
width: 100%;

View File

@@ -52,81 +52,32 @@
</view>
<view class="content-input">
<view class="input-titile">身份证</view>
<input class="input-con" v-model="fromValue.idCard" placeholder="请输入身份证号码" />
<input class="input-con" v-model="fromValue.idcard" placeholder="" />
</view>
<view class="content-input">
<view class="input-titile">手机号码</view>
<input class="input-con" v-model="fromValue.phone" placeholder="请输入您的手机号码" />
</view>
<view class="content-input" @click="changeSkillLevel">
<view class="input-titile">技能等级</view>
<input
class="input-con triangle"
disabled
v-model="state.skillLevelText"
placeholder="请选择您的技能等级"
/>
</view>
<view class="content-input" @click="changeSkills">
<view class="input-titile">技能名称</view>
<input
class="input-con triangle"
disabled
v-if="!state.skillsText.length"
placeholder="请选择您的技能名称"
/>
<view class="input-nx" @click="changeSkills" v-else>
<view class="nx-item" v-for="(item, index) in state.skillsText" :key="index">{{ item }}</view>
</view>
</view>
</view>
<SelectPopup ref="selectPopupRef"></SelectPopup>
</AppLayout>
</template>
<script setup>
import { reactive, inject, watch, ref, onMounted, onUnmounted } from 'vue';
import { reactive, inject, watch, ref, onMounted } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
const { $api, navTo, navBack, checkingPhoneRegExp } = inject('globalFunction');
import { storeToRefs } from 'pinia';
import useUserStore from '@/stores/useUserStore';
import useDictStore from '@/stores/useDictStore';
import SelectPopup from '@/components/selectPopup/selectPopup.vue';
const { userInfo } = storeToRefs(useUserStore());
const { getUserResume } = useUserStore();
const dictStore = useDictStore();
const { dictLabel, oneDictData, complete: dictComplete, getDictSelectOption } = dictStore;
// #ifdef H5
const injectedOpenSelectPopup = inject('openSelectPopup', null);
// #endif
// #ifdef MP-WEIXIN
const selectPopupRef = ref();
// #endif
// 创建本地的 openSelectPopup 函数,兼容 H5 和微信小程序
const openSelectPopup = (config) => {
// #ifdef MP-WEIXIN
if (selectPopupRef.value) {
selectPopupRef.value.open(config);
}
// #endif
// #ifdef H5
if (injectedOpenSelectPopup) {
injectedOpenSelectPopup(config);
}
// #endif
};
const { dictLabel, oneDictData } = useDictStore();
const openSelectPopup = inject('openSelectPopup');
const percent = ref('0%');
const state = reactive({
educationText: '',
politicalAffiliationText: '',
skillsText: [],
skillLevelText: ''
});
const fromValue = reactive({
name: '',
@@ -134,308 +85,34 @@ const fromValue = reactive({
birthDate: '',
education: '',
politicalAffiliation: '',
idCard: '',
skills: '',
skillLevel: ''
idcard: '',
});
// 移除重复的onLoad定义已在上方实现
// 在onLoad中初始化数据确保页面加载时就能获取技能信息
onLoad(() => {
// 初始化页面数据
initLoad();
// initLoad执行完毕后尝试从appSkillsList获取和设置技能信息
// 使用setTimeout确保initLoad完全执行
setTimeout(() => {
try {
// 方式1直接从缓存获取appSkillsList
let appSkillsList = uni.getStorageSync('appSkillsList');
// 方式2如果缓存中没有尝试从用户信息中获取
if (!appSkillsList || !Array.isArray(appSkillsList) || appSkillsList.length === 0) {
const userInfo = uni.getStorageSync('userInfo');
if (userInfo && userInfo.appSkillsList) {
appSkillsList = userInfo.appSkillsList;
}
}
// 打印调试信息
console.log('获取到的appSkillsList:', appSkillsList);
// 处理技能信息回显
if (appSkillsList && Array.isArray(appSkillsList) && appSkillsList.length > 0) {
// 过滤掉name为空的技能项
const validSkills = appSkillsList.filter(item => item.name && item.name.trim() !== '');
console.log('过滤后的有效技能:', validSkills);
if (validSkills.length > 0) {
// 提取有效的技能名称数组
const skillNames = validSkills.map(item => item.name);
console.log('提取的技能名称数组:', skillNames);
// 确保fromValue.skills和state.skillsText的格式正确
fromValue.skills = skillNames.join(','); // 转换为逗号分隔的字符串
state.skillsText = skillNames; // 转换为数组格式
console.log('设置的fromValue.skills:', fromValue.skills);
console.log('设置的state.skillsText:', state.skillsText);
// 提取最后一个技能的等级
const lastSkill = validSkills[validSkills.length - 1];
const lastSkillLevel = lastSkill.levels;
console.log('最后一个技能等级:', lastSkillLevel);
if (lastSkillLevel) {
// 定义等级映射,用于兼容不同格式的等级值
const levelMap = {
'1': { value: '1', label: '初级' },
'2': { value: '2', label: '中级' },
'3': { value: '3', label: '高级' },
'初级': { value: '1', label: '初级' },
'中级': { value: '2', label: '中级' },
'高级': { value: '3', label: '高级' }
};
// 获取对应的等级信息
const levelInfo = levelMap[lastSkillLevel] || { value: '1', label: '初级' };
fromValue.skillLevel = levelInfo.value;
state.skillLevelText = levelInfo.label;
console.log('设置的技能等级:', levelInfo);
}
}
// 更新完成度百分比
const result = getFormCompletionPercent(fromValue);
percent.value = result;
console.log('更新完成度:', percent.value);
}
} catch (error) {
console.error('获取技能信息失败:', error);
}
}, 100); // 短暂延迟确保初始化完成
// setTimeout(() => {
// const { age, birthDate } = useUserStore().userInfo;
// const newAge = calculateAge(birthDate);
// // 计算年龄是否对等
// if (age != newAge) {
// completeResume();
// }
// }, 1000);
});
// 监听页面显示,接收从技能查询页面返回的数据
onShow(() => {
// 通过事件总线接收技能选择结果
uni.$on('skillSelected', handleSkillSelected);
// 在页面显示时也再次尝试获取技能信息,确保数据最新
try {
// 优先尝试从用户信息中获取
const userInfo = uni.getStorageSync('userInfo');
let appSkillsList = userInfo && userInfo.appSkillsList ? userInfo.appSkillsList : uni.getStorageSync('appSkillsList');
// 只有在之前未设置或数据有更新时才重新设置
if (appSkillsList && Array.isArray(appSkillsList) && appSkillsList.length > 0) {
const validSkills = appSkillsList.filter(item => item.name && item.name.trim() !== '');
if (validSkills.length > 0) {
// 检查是否需要更新
const currentSkillsText = state.skillsText || '';
const newSkillNames = validSkills.map(item => item.name);
const newSkillsText = newSkillNames.join(', ');
// 如果技能名称或等级有变化,才更新
if (currentSkillsText !== newSkillsText || !fromValue.skillLevel) {
fromValue.skills = newSkillNames;
state.skillsText = newSkillsText;
const lastSkill = validSkills[validSkills.length - 1];
if (lastSkill.levels) {
const levelMap = {
'1': { value: '1', label: '初级' },
'2': { value: '2', label: '中级' },
'3': { value: '3', label: '高级' },
'初级': { value: '1', label: '初级' },
'中级': { value: '2', label: '中级' },
'高级': { value: '3', label: '高级' }
};
const levelInfo = levelMap[lastSkill.levels] || { value: '1', label: '初级' };
fromValue.skillLevel = levelInfo.value;
state.skillLevelText = levelInfo.label;
}
// 更新完成度
const result = getFormCompletionPercent(fromValue);
percent.value = result;
}
}
}
} catch (error) {
console.error('页面显示时获取技能信息失败:', error);
}
});
// 页面卸载时移除事件监听
onUnmounted(() => {
uni.$off('skillSelected', handleSkillSelected);
});
// 监听 userInfo 变化,确保数据及时更新
watch(() => userInfo.value, (newVal) => {
if (newVal && Object.keys(newVal).length > 0) {
initLoad();
}
}, { deep: true, immediate: false });
// 监听字典数据加载完成,自动更新学历显示
watch(() => dictComplete.value, (newVal) => {
if (newVal) {
console.log('字典数据加载完成,更新学历显示');
// 确保有学历值(如果没有则使用默认值"4"本科)
if (!fromValue.education) {
fromValue.education = '4';
}
// 直接遍历字典数据查找对应标签
const eduValue = String(fromValue.education);
const eduItem = dictStore.state.education.find(item => String(item.value) === eduValue);
if (eduItem && eduItem.label) {
console.log('从字典数据中找到学历标签:', eduItem.label);
state.educationText = eduItem.label;
}
}
});
// 监听学历字典数据变化
watch(() => dictStore.state.education, (newVal) => {
if (newVal && newVal.length > 0) {
console.log('学历字典数据变化,更新显示');
// 确保有学历值(如果没有则使用默认值"4"本科)
if (!fromValue.education) {
fromValue.education = '4';
}
// 直接遍历字典数据查找对应标签
const eduValue = String(fromValue.education);
const eduItem = newVal.find(item => String(item.value) === eduValue);
if (eduItem && eduItem.label) {
console.log('从字典数据中找到学历标签:', eduItem.label);
state.educationText = eduItem.label;
}
}
}, { deep: true });
function initLoad() {
// 优先从 store 获取,如果没有则从本地缓存获取
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const currentUserInfo = userInfo.value && Object.keys(userInfo.value).length > 0 ? userInfo.value : cachedUserInfo;
fromValue.name = currentUserInfo.name || '';
fromValue.sex = currentUserInfo.sex !== undefined ? Number(currentUserInfo.sex) : 0;
fromValue.phone = currentUserInfo.phone || '';
fromValue.birthDate = currentUserInfo.birthDate || '';
// 将学历转换为字符串类型,确保类型一致
// 如果没有学历值,默认设置为本科(值为"4"
fromValue.education = currentUserInfo.education ? String(currentUserInfo.education) : '4';
fromValue.politicalAffiliation = currentUserInfo.politicalAffiliation || '';
fromValue.idCard = currentUserInfo.idCard || '';
// 初始化技能数据
if (currentUserInfo.skills) {
fromValue.skills = currentUserInfo.skills;
// 将技能字符串分割成数组用于显示
state.skillsText = currentUserInfo.skills.split(',');
} else {
fromValue.skills = '';
state.skillsText = [];
}
// 初始化技能等级数据
if (currentUserInfo.skillLevel) {
fromValue.skillLevel = currentUserInfo.skillLevel;
// 根据skillLevel值设置对应的文本
switch(currentUserInfo.skillLevel) {
case '1':
state.skillLevelText = '初级';
break;
case '2':
state.skillLevelText = '中级';
break;
case '3':
state.skillLevelText = '高级';
break;
default:
state.skillLevelText = '';
}
} else {
fromValue.skillLevel = '';
state.skillLevelText = '';
}
// 初始化学历显示文本(需要等待字典数据加载完成)
initEducationText();
// 回显政治面貌
if (currentUserInfo.politicalAffiliation) {
state.politicalAffiliationText = dictLabel('affiliation', currentUserInfo.politicalAffiliation);
}
fromValue.name = userInfo.value.name;
fromValue.sex = Number(userInfo.value.sex);
fromValue.phone = userInfo.value.phone;
fromValue.birthDate = userInfo.value.birthDate;
fromValue.education = userInfo.value.education;
fromValue.politicalAffiliation = userInfo.value.politicalAffiliation;
fromValue.idcard = userInfo.value.idcard;
// 回显
state.educationText = dictLabel('education', userInfo.value.education);
state.politicalAffiliationText = dictLabel('affiliation', userInfo.value.politicalAffiliation);
const result = getFormCompletionPercent(fromValue);
percent.value = result;
}
// 初始化学历显示文本
function initEducationText() {
// 确保有学历值(如果没有则使用默认值"4"本科)
if (!fromValue.education) {
fromValue.education = '4';
}
console.log('初始化学历显示,当前学历值:', fromValue.education);
// 直接遍历字典数据查找对应标签不依赖dictLabel函数确保准确性
const findLabelFromDict = () => {
if (dictStore.state.education && dictStore.state.education.length > 0) {
const eduValue = String(fromValue.education);
const eduItem = dictStore.state.education.find(item => String(item.value) === eduValue);
if (eduItem && eduItem.label) {
console.log('从字典数据中找到学历标签:', eduItem.label);
state.educationText = eduItem.label;
return true;
} else {
console.log('字典数据中未找到匹配的学历标签');
}
}
return false;
};
// 立即尝试查找
if (!findLabelFromDict() && dictComplete.value) {
// 如果字典数据已加载完成但未找到标签,尝试重新获取字典数据
loadEducationDictAndUpdate();
}
// 等待字典数据加载完成
const checkDictData = () => {
if (dictComplete.value && dictStore.state.education && dictStore.state.education.length > 0) {
findLabelFromDict();
} else {
// 如果字典数据未加载,等待一段时间后重试
setTimeout(() => {
if (dictComplete.value && dictStore.state.education && dictStore.state.education.length > 0) {
findLabelFromDict();
} else {
// 尝试主动加载字典数据
loadEducationDictAndUpdate();
}
}, 500);
}
};
// 主动加载学历字典数据并更新显示
function loadEducationDictAndUpdate() {
getDictSelectOption('education').then((data) => {
console.log('主动加载学历字典数据:', data);
dictStore.state.education = data;
findLabelFromDict();
}).catch((error) => {
console.error('加载学历字典数据失败:', error);
});
}
checkDictData();
}
const confirm = () => {
if (!fromValue.name) {
return $api.msg('请输入姓名');
@@ -452,57 +129,19 @@ const confirm = () => {
if (!checkingPhoneRegExp(fromValue.phone)) {
return $api.msg('请输入正确手机号');
}
// 构建appSkillsList数据结构
let appSkillsList = [];
if (state.skillsText && state.skillsText.length > 0) {
// 获取当前技能等级文本
const currentLevelText = state.skillLevelText || '';
// 为每个技能名称创建一个包含等级信息的对象
appSkillsList = state.skillsText.map(skillName => ({
name: skillName,
levels: currentLevelText
}));
}
const params = {
...fromValue,
age: calculateAge(fromValue.birthDate),
appSkillsList: appSkillsList
};
$api.createRequest('/app/user/resume', params, 'post').then((resData) => {
$api.msg('完成');
state.disbleDate = true;
getUserResume().then(() => {
navBack();
});
});
};
// 技能选择回调函数
const handleSkillSelected = (skills) => {
if (Array.isArray(skills) && skills.length > 0) {
// 更新技能显示和值技能字段值传name
state.skillsText = skills;
fromValue.skills = skills.join(',');
// 更新完成度
const result = getFormCompletionPercent(fromValue);
percent.value = result;
} else {
// 如果返回空数组,清空选择
state.skillsText = [];
fromValue.skills = '';
}
};
// 技能名称选择 - 跳转到模糊查询页面
function changeSkills() {
// 将当前已选中的技能名称传递给查询页面
const selectedSkills = state.skillsText || [];
uni.navigateTo({
url: `/pages/complete-info/skill-search?selected=${encodeURIComponent(JSON.stringify(selectedSkills))}`
});
}
const changeDateBirt = () => {
const datearray = generateDatePickerArrays();
const defaultIndex = getDatePickerIndexes(fromValue.birthDate);
@@ -522,97 +161,17 @@ const changeDateBirt = () => {
},
});
};
async function changeEducation() {
// 确保字典数据已加载
if (!dictComplete.value || !dictStore.state.education || dictStore.state.education.length === 0) {
// 如果字典数据未加载,先加载数据
try {
await getDictSelectOption('education').then((data) => {
dictStore.state.education = data;
});
} catch (error) {
console.error('加载学历字典数据失败:', error);
}
}
// 等待数据加载完成后再获取数据
let educationData = oneDictData('education');
// 如果数据还是为空,等待一下再试
if (!educationData || educationData.length === 0) {
await new Promise(resolve => setTimeout(resolve, 100));
educationData = oneDictData('education');
if (!educationData || educationData.length === 0) {
$api.msg('学历数据加载中,请稍后再试');
return;
}
}
// 确保有默认值
if (!fromValue.education) {
fromValue.education = '4'; // 默认设置为本科
}
// 将当前学历值转换为字符串,用于查找默认索引
const currentEducation = String(fromValue.education);
// 查找当前学历在数据中的索引
let defaultIndex = [0];
if (currentEducation && educationData && educationData.length > 0) {
// 同时支持字符串和数字类型的匹配
const index = educationData.findIndex(item => {
const itemValue = String(item.value);
return itemValue === currentEducation;
});
if (index >= 0) {
defaultIndex = [index];
console.log('找到学历默认索引:', index, '当前值:', currentEducation);
} else {
// 如果字符串匹配失败,尝试数字匹配
const currentNum = Number(currentEducation);
if (!isNaN(currentNum)) {
const numIndex = educationData.findIndex(item => {
const itemValue = Number(item.value);
return !isNaN(itemValue) && itemValue === currentNum;
});
if (numIndex >= 0) {
defaultIndex = [numIndex];
console.log('通过数字匹配找到学历默认索引:', numIndex, '当前值:', currentNum);
} else {
console.warn('未找到匹配的学历值:', currentEducation, '可用值:', educationData.map(item => item.value));
}
}
}
}
const changeEducation = () => {
openSelectPopup({
title: '学历',
maskClick: true,
data: [educationData],
defaultIndex: defaultIndex,
data: [oneDictData('education')],
success: (_, [value]) => {
console.log('切换学历选择,新值:', value.value);
fromValue.education = String(value.value); // 确保存储为字符串
// 使用相同的字典数据查找逻辑
const eduValue = String(value.value);
const eduItem = dictStore.state.education.find(item => String(item.value) === eduValue);
if (eduItem && eduItem.label) {
console.log('从字典数据中找到学历标签:', eduItem.label);
state.educationText = eduItem.label;
} else {
// 如果没找到,尝试重新加载字典数据
console.log('字典中未找到对应标签,尝试重新加载字典数据');
getDictSelectOption('education').then((data) => {
dictStore.state.education = data;
const newEduItem = data.find(item => String(item.value) === eduValue);
if (newEduItem && newEduItem.label) {
state.educationText = newEduItem.label;
}
});
}
fromValue.education = value.value;
state.educationText = value.label;
},
});
}
};
const changeSex = (sex) => {
fromValue.sex = sex;
};
@@ -629,37 +188,6 @@ const changePoliticalAffiliation = () => {
});
};
// 技能等级选择
function changeSkillLevel() {
const skillLevels = [
{ label: '初级', value: '1' },
{ label: '中级', value: '2' },
{ label: '高级', value: '3' }
];
// 查找当前技能等级在数据中的索引
let defaultIndex = [0];
if (fromValue.skillLevel) {
const index = skillLevels.findIndex(item => item.value === fromValue.skillLevel);
if (index >= 0) {
defaultIndex = [index];
}
}
openSelectPopup({
title: '技能等级',
maskClick: true,
data: [skillLevels],
defaultIndex: defaultIndex,
success: (_, [value]) => {
fromValue.skillLevel = value.value;
state.skillLevelText = value.label;
const result = getFormCompletionPercent(fromValue);
percent.value = result;
},
});
}
function generateDatePickerArrays(startYear = 1975, endYear = new Date().getFullYear()) {
const years = [];
const months = [];
@@ -679,39 +207,14 @@ function generateDatePickerArrays(startYear = 1975, endYear = new Date().getFull
}
function isValidDate(dateString) {
// 添加空值检查
if (!dateString || typeof dateString !== 'string' || dateString.trim() === '') {
return false;
}
const dateParts = dateString.split('-');
if (dateParts.length !== 3) {
return false;
}
const [year, month, day] = dateParts.map(Number);
// 检查是否为有效数字
if (isNaN(year) || isNaN(month) || isNaN(day)) {
return false;
}
const [year, month, day] = dateString.split('-').map(Number);
const date = new Date(year, month - 1, day); // 月份从0开始
return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
}
const calculateAge = (birthDate) => {
// 添加空值检查
if (!birthDate) {
return '';
}
const birth = new Date(birthDate);
// 检查日期是否有效
if (isNaN(birth.getTime())) {
return '';
}
const today = new Date();
let age = today.getFullYear() - birth.getFullYear();
const monthDiff = today.getMonth() - birth.getMonth();
@@ -746,33 +249,13 @@ function getFormCompletionPercent(form) {
}
// 主函数
function getDatePickerIndexes(dateStr) {
// 添加空值检查如果dateStr为空或null返回默认值当前日期
if (!dateStr || typeof dateStr !== 'string' || dateStr.trim() === '') {
const today = new Date();
const year = today.getFullYear().toString();
const month = (today.getMonth() + 1).toString().padStart(2, '0');
const day = today.getDate().toString().padStart(2, '0');
dateStr = `${year}-${month}-${day}`;
}
const dateParts = dateStr.split('-');
if (dateParts.length !== 3) {
// 如果分割后不是3部分使用当前日期作为默认值
const today = new Date();
const year = today.getFullYear().toString();
const month = (today.getMonth() + 1).toString().padStart(2, '0');
const day = today.getDate().toString().padStart(2, '0');
dateStr = `${year}-${month}-${day}`;
dateParts = dateStr.split('-');
}
const [year, month, day] = dateParts;
const [year, month, day] = dateStr.split('-');
const [years, months, days] = generateDatePickerArrays();
const yearIndex = years.indexOf(year) >= 0 ? years.indexOf(year) : 0;
const monthIndex = months.indexOf(month) >= 0 ? months.indexOf(month) : 0;
const dayIndex = days.indexOf(day) >= 0 ? days.indexOf(day) : 0;
const yearIndex = years.indexOf(year);
const monthIndex = months.indexOf(month);
const dayIndex = days.indexOf(day);
return [yearIndex, monthIndex, dayIndex];
}
@@ -824,28 +307,6 @@ function getDatePickerIndexes(dateStr) {
border-radius: 2rpx
background: #697279;
transform: rotate(45deg)
.input-nx
position: relative
border-bottom: 2rpx solid #EBEBEB
padding-bottom: 30rpx
display: flex
flex-wrap: wrap
.nx-item
padding: 16rpx 24rpx
width: fit-content
border-radius: 20rpx
border: 2rpx solid #E8EAEE
background-color: #f8f9fa
margin-right: 16rpx
margin-top: 16rpx
font-size: 28rpx
color: #333333
transition: all 0.2s ease
&:hover
background-color: #e9ecef
border-color: #256bfa
color: #256bfa
.content-sex
height: 110rpx;
display: flex

View File

@@ -16,52 +16,25 @@ const props = defineProps({
},
});
// 获取雷达图数据
function getRadarData() {
if (!props.value || !props.value.radarChart) {
// 如果没有数据使用默认值0
const defaultRadarChart = {
skill: 0,
experience: 0,
education: 0,
salary: 0,
age: 0,
location: 0
};
const labels = ['学历', '年龄', '工作地', '技能', '工作经验', '期望薪资'];
const data = [defaultRadarChart.education, defaultRadarChart.age, defaultRadarChart.location,
defaultRadarChart.skill, defaultRadarChart.experience, defaultRadarChart.salary].map((item) => item * 0.05);
return { labels, data };
}
const { skill, experience, education, salary, age, location } = props.value.radarChart;
const labels = ['学历', '年龄', '工作地', '技能', '工作经验', '期望薪资'];
const data = [education, age, location, skill, experience, salary].map((item) => item * 0.05);
return { labels, data };
}
// 监听页面初始化
onMounted(() => {
// 延迟执行,确保 canvas 已经渲染
setTimeout(() => {
const { labels, data } = getRadarData();
rawRadarChart(labels, data);
}, 100);
if (Object.keys(props.value).length > 0) {
rawRadarChart();
}
});
// 监听 props.value 变化
watch(
() => props.value,
(newVal) => {
if (newVal) {
// 延迟执行,确保数据更新完成
setTimeout(() => {
const { labels, data } = getRadarData();
rawRadarChart(labels, data);
}, 50);
if (newVal && Object.keys(newVal).length > 0) {
const { skill, experience, education, salary, age, location } = newVal.radarChart;
const labels = ['学历', '年龄', '工作地', '技能', '工作经验', '期望薪资'];
const data = [education, age, location, skill, experience, salary].map((item) => item * 0.05);
rawRadarChart(labels, data);
}
},
{ deep: true, immediate: true } // deep 递归监听对象内部变化immediate 立即执行一次
{ deep: true, immediate: false } // deep 递归监听对象内部变化
);
function rawRadarChart(labels, data) {

View File

@@ -208,20 +208,7 @@ const jobInfo = ref({});
const state = reactive({});
const mapCovers = ref([]);
const jobIdRef = ref();
// 竞争力分析数据,初始化为包含默认值的完整结构,确保雷达图能正常渲染
const raderData = ref({
matchScore: 0,
rank: 0,
percentile: 0,
radarChart: {
skill: 0,
experience: 0,
education: 0,
salary: 0,
age: 0,
location: 0
}
});
const raderData = ref({});
const videoPalyerRef = ref(null);
const explainUrlRef = ref('');
@@ -253,24 +240,16 @@ const applicants = ref([
]);
onLoad((option) => {
console.log(option, 'option');
if (option.jobId) {
initLoad(option);
}
});
onShow(() => {
// 仅在 H5 环境中从 URL 获取参数(小程序环境中 onShow 不会传递 URL 参数)
// #ifdef H5
try {
const option = parseQueryParams(); // 兼容微信内置浏览器
if (option.jobId) {
initLoad(option);
}
} catch (e) {
console.warn('onShow 中解析 URL 参数失败:', e);
const option = parseQueryParams(); // 兼容微信内置浏览器
if (option.jobId) {
initLoad(option);
}
// #endif
});
function initLoad(option) {
@@ -338,59 +317,8 @@ function getTextWidth(text, size = 12) {
function getCompetivetuveness(jobId) {
$api.createRequest(`/app/job/competitiveness/${jobId}`, {}, 'GET').then((resData) => {
// 如果接口返回的数据为 null 或空使用默认值0
if (resData && resData.data) {
// 确保 radarChart 字段存在,如果不存在则使用默认值
const radarChart = resData.data.radarChart || {
skill: 0,
experience: 0,
education: 0,
salary: 0,
age: 0,
location: 0
};
raderData.value = {
matchScore: resData.data.matchScore || 0,
rank: resData.data.rank || 0,
percentile: resData.data.percentile || 0,
radarChart: radarChart
};
currentStep.value = (resData.data.matchScore || 0) * 0.04;
} else {
// 接口返回 null 或空数据时使用默认值0
raderData.value = {
matchScore: 0,
rank: 0,
percentile: 0,
radarChart: {
skill: 0,
experience: 0,
education: 0,
salary: 0,
age: 0,
location: 0
}
};
currentStep.value = 0;
}
}).catch((error) => {
// 接口请求失败时使用默认值0
console.error('获取竞争力分析失败:', error);
raderData.value = {
matchScore: 0,
rank: 0,
percentile: 0,
radarChart: {
skill: 0,
experience: 0,
education: 0,
salary: 0,
age: 0,
location: 0
}
};
currentStep.value = 0;
raderData.value = resData.data;
currentStep.value = resData.data.matchScore * 0.04;
});
}

View File

@@ -50,7 +50,7 @@ const { $api, navTo, navBack } = inject('globalFunction');
const weekMap = ['日', '一', '二', '三', '四', '五', '六'];
const calendarData = ref([]);
const current = ref({});
import { Solar, Lunar } from '@/packageA/lib/lunar-javascript@1.7.2.js';
import { Solar, Lunar } from '@/lib/lunar-javascript@1.7.2.js';
const isRecord = ref(false);
const recordNum = ref(4);

559
packageB/jobFair/detail.vue Normal file
View File

@@ -0,0 +1,559 @@
<template>
<AppLayout title="" :use-scroll-view="false">
<template #headerleft>
<view class="btnback">
<image src="@/static/icon/back.png" @click="navBack"></image>
</view>
</template>
<view class="content">
<view class="content-top">
<view class="companyinfo-left">
<image src="@/static/icon/companyIcon.png" mode=""></image>
</view>
<view class="companyinfo-right">
<view class="row1 line_2">{{ fairInfo?.name }}</view>
<view class="row2">
<text>{{ fairInfo.location }}</text>
<convert-distance
:alat="fairInfo.latitude"
:along="fairInfo.longitude"
:blat="latitudeVal"
:blong="longitudeVal"
></convert-distance>
</view>
</view>
</view>
<view class="locations">
<image class="location-img" src="/static/icon/mapLine.png"></image>
<view class="location-info">
<view class="info">
<text class="info-title">{{ fairInfo.address }}</text>
<text class="info-text">位置</text>
</view>
</view>
</view>
<view class="conetent-info" :class="{ expanded: isExpanded }">
<view class="info-title">内容描述</view>
<view class="info-desirption">{{ fairInfo.description }}</view>
<!-- <view class="info-title title2">公司地址</view>
<view class="locationCompany"></view> -->
<view class="company-times">
<view class="info-title">内容描述</view>
<view class="card-times">
<view class="time-left">
<view class="left-date">{{ parseDateTime(fairInfo.startTime).time }}</view>
<view class="left-dateDay">{{ parseDateTime(fairInfo.startTime).date }}</view>
</view>
<view class="line"></view>
<view class="time-center">
<view class="center-date">
{{ getTimeStatus(fairInfo.startTime, fairInfo.endTime).statusText }}
</view>
<view class="center-dateDay">
{{ getHoursBetween(fairInfo.startTime, fairInfo.endTime) }}小时
</view>
</view>
<view class="line"></view>
<view class="time-right">
<view class="left-date">{{ parseDateTime(fairInfo.endTime).time }}</view>
<view class="left-dateDay">{{ parseDateTime(fairInfo.endTime).date }}</view>
</view>
</view>
</view>
</view>
<view class="expand" @click="expand">
<text>{{ isExpanded ? '收起' : '展开' }}</text>
<image
class="expand-img"
:class="{ 'expand-img-active': !isExpanded }"
src="@/static/icon/downs.png"
></image>
</view>
<scroll-view scroll-y class="Detailscroll-view">
<view class="views">
<view class="Detail-title">
<text class="title">参会单位{{ companyList.length }}</text>
</view>
<renderCompanys
v-if="companyList.length"
:list="companyList"
:longitude="longitudeVal"
:latitude="latitudeVal"
></renderCompanys>
<empty v-else pdTop="200"></empty>
</view>
</scroll-view>
</view>
<template #footer>
<view class="footer" v-if="hasnext">
<view
class="btn-wq button-click"
:class="{ 'btn-desbel': fairInfo.isCollection }"
@click="applyExhibitors"
>
{{ fairInfo.isCollection ? '已预约招聘会' : '预约招聘会' }}
</view>
</view>
</template>
</AppLayout>
</template>
<script setup>
import point from '@/static/icon/point.png';
import { reactive, inject, watch, ref, onMounted, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import dictLabel from '@/components/dict-Label/dict-Label.vue';
import useLocationStore from '@/stores/useLocationStore';
const { $api, navTo, vacanciesTo, navBack } = inject('globalFunction');
import { storeToRefs } from 'pinia';
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
const isExpanded = ref(false);
const fairInfo = ref({});
const companyList = ref([]);
const hasnext = ref(true);
onLoad((options) => {
getCompanyInfo(options.jobFairId);
});
function getCompanyInfo(id) {
$api.createRequest(`/app/fair/${id}`).then((resData) => {
fairInfo.value = resData.data;
companyList.value = resData.data.companyList;
hasAppointment();
});
}
const hasAppointment = () => {
const isTimePassed = (timeStr) => {
const targetTime = new Date(timeStr.replace(/-/g, '/')).getTime(); // 兼容格式
const now = Date.now();
return now < targetTime;
};
hasnext.value = isTimePassed(fairInfo.value.startTime);
};
function openMap(lat, lng, name = '位置') {
const isConfirmed = window.confirm('是否打开地图查看位置?');
if (!isConfirmed) return;
// 使用高德地图或百度地图的 H5 链接打开
const url = `https://uri.amap.com/marker?position=${lng},${lat}&name=${encodeURIComponent(name)}`;
window.location.href = url;
}
function expand() {
isExpanded.value = !isExpanded.value;
}
// 取消/收藏岗位
function applyExhibitors() {
const fairId = fairInfo.value.jobFairId;
if (fairInfo.value.isCollection) {
// $api.createRequest(`/app/fair/collection/${fairId}`, {}, 'DELETE').then((resData) => {
// getCompanyInfo(fairId);
// $api.msg('取消预约成功');
// });
$api.msg('已预约成功');
} else {
$api.createRequest(`/app/fair/collection/${fairId}`, {}, 'POST').then((resData) => {
getCompanyInfo(fairId);
$api.msg('预约成功');
});
}
}
function toIOSDate(input) {
if (!input) return null;
if (input instanceof Date) return isNaN(input.getTime()) ? null : input;
if (typeof input === 'number') {
const d = new Date(input);
return isNaN(d.getTime()) ? null : d;
}
if (typeof input !== 'string') return null;
let s = input.trim();
if (/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}(:\d{2})?$/.test(s)) {
s = s.replace(' ', 'T');
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(s)) {
s = s + ':00';
}
}
const d = new Date(s);
return isNaN(d.getTime()) ? null : d;
}
function parseDateTime(datetimeStr) {
if (!datetimeStr) return { time: '', date: '' };
const dateObj = toIOSDate(datetimeStr);
if (isNaN(dateObj.getTime())) return { time: '', date: '' }; // 无效时间
const year = dateObj.getFullYear();
const month = String(dateObj.getMonth() + 1).padStart(2, '0');
const day = String(dateObj.getDate()).padStart(2, '0');
const hours = String(dateObj.getHours()).padStart(2, '0');
const minutes = String(dateObj.getMinutes()).padStart(2, '0');
return {
time: `${hours}:${minutes}`,
date: `${year}${month}${day}`,
};
}
function getTimeStatus(startTimeStr, endTimeStr) {
const now = new Date();
const startTime = toIOSDate(startTimeStr);
const endTime = toIOSDate(endTimeStr);
if (!startTime || !endTime) {
return { status: 1, statusText: '时间异常' };
}
let status = 0;
let statusText = '开始中';
if (now < startTime) {
status = 2;
statusText = '待开始';
} else if (now > endTime) {
status = 1;
statusText = '已过期';
} else {
status = 0;
statusText = '进行中';
}
return { status, statusText };
}
function getHoursBetween(startTimeStr, endTimeStr) {
const start = toIOSDate(startTimeStr);
const end = toIOSDate(endTimeStr);
if (!start || !end) return 0;
const diffMs = end - start;
const diffHours = diffMs / (1000 * 60 * 60);
return +diffHours.toFixed(2);
}
</script>
<style lang="stylus" scoped>
.btnback{
width: 64rpx;
height: 64rpx;
}
.btn {
display: flex;
justify-content: space-between;
align-items: center;
width: 52rpx;
height: 52rpx;
}
image {
height: 100%;
width: 100%;
}
.content{
height: 100%
display: flex;
flex-direction: column
.content-top{
padding: 28rpx
padding-top: 50rpx
display: flex
flex-direction: row
flex-wrap: nowrap
.companyinfo-left{
width: 96rpx;
height: 96rpx;
margin-right: 24rpx
}
.companyinfo-right{
flex: 1
.row1{
font-weight: 500;
font-size: 32rpx;
color: #333333;
font-family: 'PingFangSC-Medium', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif;
}
.row2{
font-weight: 400;
font-size: 28rpx;
color: #6C7282;
line-height: 45rpx;
display: flex
justify-content: space-between
}
}
}
.locations{
padding: 0 28rpx
height: 86rpx;
position: relative
margin-bottom: 36rpx
.location-img{
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #EFEFEF;
}
.location-info{
position: absolute
top: 0
left: 0
width: 100%
height: 100%
.info{
padding: 0 60rpx
height: 100%
display: flex
align-items: center
justify-content: space-between
white-space: nowrap
padding-top: rpx
.info-title{
font-weight: 600;
font-size: 28rpx;
color: #333333;
}
.info-text{
font-weight: 400;
font-size: 28rpx;
color: #9B9B9B;
position: relative;
padding-right: 20rpx
}
.info-text::before{
position: absolute;
right: 0;
top: 50%;
content: '';
width: 4rpx;
height: 16rpx;
border-radius: 2rpx
background: #9B9B9B;
transform: translate(0, -75%) rotate(-45deg)
}
.info-text::after {
position: absolute;
right: 0;
top: 50%;
content: '';
width: 4rpx;
height: 16rpx;
border-radius: 2rpx
background: #9B9B9B;
transform: translate(0, -25%) rotate(45deg)
}
}
}
}
.conetent-info{
padding: 0 28rpx
overflow: hidden;
max-height: 0rpx;
transition: max-height 0.3s ease;
.info-title{
font-weight: 600;
font-size: 28rpx;
color: #000000;
}
.info-desirption{
margin-top: 12rpx
font-weight: 400;
font-size: 28rpx;
color: #495265;
text-align: justified;
}
.title2{
margin-top: 48rpx
}
}
.company-times{
padding-top: 40rpx
.info-title{
font-weight: 600;
font-size: 28rpx;
color: #000000;
}
}
.expanded {
max-height: 1000rpx; // 足够显示完整内容
}
.expand{
display: flex
flex-wrap: nowrap
white-space: nowrap
justify-content: center
margin-bottom: 46rpx
font-weight: 400;
font-size: 28rpx;
color: #256BFA;
.expand-img{
width: 40rpx;
height: 40rpx;
}
.expand-img-active{
transform: rotate(180deg)
}
}
}
.Detailscroll-view{
flex: 1;
overflow: hidden;
background: #F4F4F4;
.views{
padding: 28rpx
.Detail-title{
font-weight: 600;
font-size: 32rpx;
color: #000000;
position: relative;
display: flex
justify-content: space-between
.title{
position: relative;
z-index: 2;
}
}
.Detail-title::before{
position: absolute
content: '';
left: -14rpx
bottom: 0
height: 16rpx;
width: 108rpx;
background: linear-gradient(to right, #CBDEFF, #FFFFFF);
border-radius: 8rpx;
z-index: 1;
}
.cards{
padding: 32rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.04);
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin-top: 22rpx;
.card-company{
display: flex
justify-content: space-between
align-items: flex-start
.company{
font-weight: 500;
font-size: 32rpx;
color: #333333;
}
.salary{
font-weight: 500;
font-size: 28rpx;
color: #4C6EFB;
white-space: nowrap
line-height: 48rpx
}
}
.card-companyName{
font-weight: 400;
font-size: 28rpx;
color: #6C7282;
}
.card-tags{
display: flex
flex-wrap: wrap
.tag{
width: fit-content;
height: 30rpx;
background: #F4F4F4;
border-radius: 4rpx;
padding: 6rpx 20rpx;
line-height: 30rpx;
font-weight: 400;
font-size: 24rpx;
color: #6C7282;
text-align: center;
margin-top: 14rpx;
white-space: nowrap
margin-right: 20rpx
}
}
.card-bottom{
margin-top: 32rpx
display: flex
justify-content: space-between
font-size: 28rpx;
color: #6C7282;
}
}
}
}
.card-times{
display: flex;
justify-content: space-between
align-items: center
padding: 24rpx 30rpx 10rpx 30rpx
.time-left,
.time-right{
text-align: center
.left-date{
font-weight: 500;
font-size: 48rpx;
color: #333333;
}
.left-dateDay{
font-weight: 400;
font-size: 24rpx;
color: #333333;
margin-top: 12rpx
}
}
.line{
width: 40rpx;
height: 0rpx;
border: 2rpx solid #D4D4D4;
margin-top: 64rpx
}
.time-center{
text-align: center;
display: flex
flex-direction: column
justify-content: center
align-items: center
.center-date{
font-weight: 400;
font-size: 28rpx;
color: #FF881A;
padding-top: 10rpx
}
.center-dateDay{
font-weight: 400;
font-size: 24rpx;
color: #333333;
margin-top: 6rpx
line-height: 48rpx;
width: 104rpx;
height: 48rpx;
background: #F9F9F9;
border-radius: 8rpx 8rpx 8rpx 8rpx;
}
}
}
.footer{
background: #FFFFFF;
box-shadow: 0rpx -4rpx 24rpx 0rpx rgba(11,44,112,0.12);
border-radius: 0rpx 0rpx 0rpx 0rpx;
padding: 40rpx 28rpx 20rpx 28rpx
.btn-wq{
height: 90rpx;
background: #256BFA;
border-radius: 12rpx 12rpx 12rpx 12rpx;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
text-align: center;
line-height: 90rpx
}
.btn-desbel{
background: #6697FB;
box-shadow: 0rpx -4rpx 24rpx 0rpx rgba(11,44,112,0.12);
}
}
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,6 @@
const placeholderStyle = 'font-size:30rpx'
const checked = ref(true)
const codeUrl = ref('')
const flag=ref('hlw')
const form = reactive({
username: 'langchaojituan',
@@ -50,10 +49,8 @@
uuid: ''
})
onLoad((option) => {
if(option.flag){
flag.value=option.flag
}
onLoad(() => {
})
onMounted(() => {
@@ -86,51 +83,27 @@
title: '登录中...',
mask: true
})
if(flag.value=='hlw'){
$api.myRequest('/auth/login',form,'post',10100).then((res) => {
uni.setStorageSync('Padmin-Token', res.data.access_token)
uni.reLaunch({
url: '/pages/index/index'
})
codeUrl.value = 'data:image/gif;base64,' + res.img
}).catch(() => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '登录失败,请重试'
})
$api.myRequest('/auth/login',form,'post',10100).then((res) => {
console.log(res, 'res')
uni.setStorageSync('Padmin-Token', res.data.access_token)
uni.reLaunch({
url: '/pages/index/index'
})
}else if(flag.value=='nw'){
$api.myRequest('/auth/login',form,'post',9100).then((res) => {
uni.setStorageSync('Padmin-Token', res.data.access_token)
uni.reLaunch({
url: '/packageB/priority/helpFilter'
})
codeUrl.value = 'data:image/gif;base64,' + res.img
}).catch(() => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '登录失败,请重试'
})
codeUrl.value = 'data:image/gif;base64,' + res.img
}).catch(() => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '登录失败,请重试'
})
}
})
}
function getCodeImg() {
if(flag.value=='hlw'){
$api.myRequest('/code',{},'get',10100).then((resData) => {
codeUrl.value = 'data:image/gif;base64,' + resData.img
form.uuid = resData.uuid
});
}else if(flag.value=='nw'){
$api.myRequest('/code',{},'get',9100).then((resData) => {
codeUrl.value = 'data:image/gif;base64,' + resData.img
form.uuid = resData.uuid
});
}
$api.myRequest('/code',{},'get',10100).then((resData) => {
codeUrl.value = 'data:image/gif;base64,' + resData.img
form.uuid = resData.uuid
});
}
</script>

View File

@@ -126,14 +126,14 @@
</template>
<script>
import api from "@/packageCa/apiCa/job.js"
import api1 from "@/packageCa/apiCa/user.js"
import api from "@/apiB/job.js"
import api1 from "@/apiB/user.js"
export default {
data() {
return {
showLogin: false,
isVisitor: false, //
user: uni.getStorageSync("CAuserInfo").user,
user: uni.getStorageSync("userInfo").user,
id: 0,
jobDetailData: {
Name: "",

View File

@@ -10,12 +10,11 @@
<text class="icon icon-search"></text>
<input type="search" v-model="kw" placeholder="请输入职业名称" @input="inputKeywrok"/>
<view class="list-wrap" v-show="kw != ''">
<navigator class="link" :url="'/packageCa/job/details?id='+item.Id" v-for="(item, index) in jobDataList" :key="index">{{item.Name}}</navigator>
<navigator class="link" :url="'/packageB/pages/job/details?id='+item.Id" v-for="(item, index) in jobDataList" :key="index">{{item.Name}}</navigator>
</view>
</view>
</view>
<!-- :style="{height: winHeight - barHeight - loginHeight + 'px'}" -->
<view class="u-menu-wrap" >
<view class="u-menu-wrap" :style="{height: winHeight - barHeight - loginHeight + 'px'}">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop" :scroll-into-view="itemId">
<view v-for="(item,index) in jobList" :key="index" class="u-tab-item"
:class="[current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
@@ -30,7 +29,7 @@
</view>
<view class="item-container">
<view class="thumb-box" v-for="(item1, index1) in item.SubList" :key="index1" >
<navigator class="item-menu-name" :url="`/packageCa/job/midList?code=${item1.Code}&name=${item1.Name}`" >{{item1.Name}}</navigator>
<navigator class="item-menu-name" :url="`/packageB/pages/job/midList?code=${item1.Code}&name=${item1.Name}`" >{{item1.Name}}</navigator>
</view>
</view>
</view>
@@ -52,13 +51,13 @@
</template>
<script>
import api from "@/packageCa/apiCa/job.js"
import jobList from "@/packageCa/job/jobList.json";
import api from "@/apiB/job.js"
import jobList from "@/dataB/jobList.json";
export default {
data() {
return {
kw: "", //
user: uni.getStorageSync("CAuserInfo").user,
user: uni.getStorageSync("userInfo").user,
isVisitor: false, //
barHeight: wx.getWindowInfo().statusBarHeight,
winHeight: wx.getWindowInfo().windowHeight,
@@ -248,7 +247,7 @@
})
}
uni.navigateTo({
url: "/packageCa/job/smallList?name=" + this.kw.trim()
url: "/packageB/pages/job/smallList?name=" + this.kw.trim()
})
},
}
@@ -276,10 +275,9 @@
.jobIndex {
position: relative;
padding-top: 0;
height: 100vh;
.u-menu-wrap {
display: flex;
height: calc(100vh - 100rpx);
// height: calc(100vh - 100rpx);
overflow: auto;
padding-top: 100rpx;
.u-tab-view {
@@ -303,7 +301,7 @@
.u-tab-item-active {
position: relative;
color: #fff;
font-size: 26rpx;
font-size: 28rpx;
font-weight: 500;
background: #1677ff;
border-radius:5px;
@@ -444,7 +442,6 @@
overflow: auto;
box-shadow: 0 0 4rpx 2rpx #f2f2f2;
border-radius: 8rpx;
z-index: 90;
.link {
display: flex;
align-items: center;

View File

@@ -38,13 +38,13 @@
</template>
<script>
import api from "@/packageCa/apiCa/job.js"
import api from "@/apiB/job.js"
export default {
data() {
return {
showLogin: false,
isVisitor: false, //
user: uni.getStorageSync("CAuserInfo").user,
user: uni.getStorageSync("userInfo").user,
name: "",
code: "",
jobList: [],
@@ -80,7 +80,7 @@
//this.showLogin = true;
}else {
uni.navigateTo({
url: `/packageCa/job/smallList?code=${item.Code}&name=${item.Name}`
url: `/packageB/pages/job/smallList?code=${item.Code}&name=${item.Name}`
})
}
}

View File

@@ -35,13 +35,13 @@
</template>
<script>
import api from "@/packageCa/apiCa/job.js"
import api from "@/apiB/job.js"
export default {
data() {
return {
showLogin: false,
isVisitor: false, //
user: uni.getStorageSync("CAuserInfo").user,
user: uni.getStorageSync("userInfo").user,
name: "",
code: "",
jobList: [],
@@ -75,7 +75,7 @@
//this.showLogin = true;
}else {
uni.navigateTo({
url: `/packageCa/job/details?id=${item.Id}&name=${item.Name}`
url: `/packageB/pages/job/details?id=${item.Id}&name=${item.Name}`
})
}
},

View File

@@ -56,7 +56,7 @@
</template>
<script>
import api from "@/packageCa/apiCa/testManage.js"
import api from "@/apiB/testManage.js"
export default {
data() {
return {
@@ -329,11 +329,11 @@
setTimeout(() => {
if (this.testType == -27) {
uni.redirectTo({
url: `/packageCa/testReport/multipleAbilityTestReport?id=${res.Data.TestId}`
url: `/packageB/pages/testReport/multipleAbilityTestReport?id=${res.Data.TestId}`
})
} else if (this.testType == -28) {
uni.redirectTo({
url: `/packageCa/testReport/generalCareerTestReport?id=${res.Data.TestId}`
url: `/packageB/pages/testReport/generalCareerTestReport?id=${res.Data.TestId}`
})
}
}, 1000)

View File

@@ -64,7 +64,7 @@
</view>
</template>
<script>
import api from "@/packageCa/apiCa/testManage.js"
import api from "@/apiB/testManage.js"
export default {
data() {
return {
@@ -333,7 +333,7 @@
beforePage.data.refreshIfNeeded = true;
setTimeout(()=>{
uni.redirectTo({
url: `/packageCa/testReport/interestTestReport`
url: `/packageB/pages/testReport/interestTestReport`
})
},1000)
} else {

View File

@@ -48,7 +48,7 @@
<script>
import api from "@/packageCa/apiCa/testManage.js"
import api from "@/apiB/testManage.js"
export default {
data() {
return {
@@ -263,7 +263,7 @@
beforePage.data.refreshIfNeeded = true;
setTimeout(()=>{
uni.redirectTo({
url: `/packageCa/testReport/personalTestReport?year=${res.Data.Year}`
url: `/packageB/pages/testReport/personalTestReport?year=${res.Data.Year}`
})
},1000)
@@ -375,7 +375,7 @@
width: 630rpx;
height: 96rpx;
padding-left: 40rpx;
background: #f5f5f5;
background: #EDF6FF;
margin-bottom: 24rpx;
border-radius: 12rpx 12rpx 12rpx 12rpx;
font-size: 28rpx;

View File

@@ -76,7 +76,7 @@
</template>
<script>
import api from "@/packageCa/apiCa/testManage.js"
import api from "@/apiB/testManage.js"
export default {
data() {
return {
@@ -231,7 +231,7 @@
uni.showLoading({
title: "加载中"
})
let eduLevel = uni.getStorageSync("CAuserInfo").user.GradeLevel;
let eduLevel = uni.getStorageSync("userInfo").user.GradeLevel;
new Promise((resolve,reject)=>{
return api.getTestTypeTagLIst().then((res)=>{
resolve(res)
@@ -423,21 +423,21 @@
case 11: {
//
uni.navigateTo({
url: "/packageCa/pagesTest/interestTestTitle"
url: "/packageB/pages/pagesTest/interestTestTitle"
})
break;
}
case 15: {
//
uni.navigateTo({
url: "/packageCa/pagesTest/personalTestTitle"
url: "/packageB/pages/pagesTest/personalTestTitle"
})
break;
}
case 17: {
//
uni.navigateTo({
url: "/packageCa/pagesTest/workValuesTestTitle"
url: "/packageB/pages/pagesTest/workValuesTestTitle"
})
break;
}
@@ -445,14 +445,14 @@
case -27: {
//
uni.navigateTo({
url: "/packageCa/pagesTest/customTestTitle?testType=-27"
url: "/packageB/pages/pagesTest/customTestTitle?testType=-27"
})
break;
}
case -28: {
//
uni.navigateTo({
url: "/packageCa/pagesTest/customTestTitle?testType=-28"
url: "/packageB/pages/pagesTest/customTestTitle?testType=-28"
})
break;
}
@@ -478,35 +478,35 @@
case 11: {
//
uni.navigateTo({
url: `/packageCa/testReport/interestTestReport`
url: `/packageB/pages/testReport/interestTestReport`
})
break;
}
case 15: {
//
uni.navigateTo({
url: `/packageCa/testReport/personalTestReport`
url: `/packageB/pages/testReport/personalTestReport`
})
break;
}
case 17: {
//
uni.navigateTo({
url: `/packageCa/testReport/workValuesTestReport`
url: `/packageB/pages/testReport/workValuesTestReport`
})
break;
}
case -27: {
//
uni.navigateTo({
url: `/packageCa/testReport/multipleAbilityTestReport?id=${item.RecordId}`
url: `/packageB/pages/testReport/multipleAbilityTestReport?id=${item.RecordId}`
})
break;
}
case -28: {
//
uni.navigateTo({
url: `/packageCa/testReport/generalCareerTestReport?id=${item.RecordId}`
url: `/packageB/pages/testReport/generalCareerTestReport?id=${item.RecordId}`
})
break;
}

View File

@@ -47,7 +47,7 @@
</template>
<script>
import api from "@/packageCa/apiCa/testManage.js"
import api from "@/apiB/testManage.js"
export default {
data() {
return {
@@ -231,7 +231,7 @@
beforePage.data.refreshIfNeeded = true;
setTimeout(()=>{
uni.redirectTo({
url: `/packageCa/testReport/workValuesTestReport?year=${res.Data.Year}`
url: `/packageB/pages/testReport/workValuesTestReport?year=${res.Data.Year}`
})
},1000)
} else {

Some files were not shown because too many files have changed in this diff Show More