From 2801f5c8ceb1b7ddb77e79d757160c5cb89ff067 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期一, 04 八月 2025 17:11:39 +0800 Subject: [PATCH] 个人资料更改 --- src/utils/auth.ts | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 156 insertions(+), 1 deletions(-) diff --git a/src/utils/auth.ts b/src/utils/auth.ts index 7e5a326..d4646a5 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1,6 +1,7 @@ import Cookies from "js-cookie"; import { useUserStoreHook } from "@/store/modules/user"; import { storageLocal, isString, isIncludeAllChildren } from "@pureadmin/utils"; +import type { nowRoleType } from "@/store/types"; export interface DataInfo<T> { /** token */ @@ -19,6 +20,130 @@ exRoles?: Array<string>; /** 褰撳墠鐧诲綍鐢ㄦ埛鐨勬寜閽骇鍒潈闄� */ permissions?: Array<string>; +} +/** + * AdminResult_CusExtendDto锛屽叏灞�杩斿洖缁撴灉 + */ +export interface ResponseEnterprise { + /** + * 鐘舵�佺爜 + */ + code?: number; + /** + * 闄勫姞鏁版嵁 + */ + extras?: null; + /** + * 閿欒淇℃伅 + */ + message?: null | string; + result?: CusExtendDto; + /** + * 鏃堕棿 + */ + time?: Date; + /** + * 绫诲瀷success銆亀arning銆乪rror + */ + type?: null | string; +} + +/** + * CusExtendDto锛岀敤鎴疯鑹茶祫鏂� + */ +export interface CusExtendDto { + /** + * 浼佷笟閾惰璐﹀彿 + */ + bankAccount?: null | string; + /** + * 浼佷笟寮�鎴疯 + */ + bankName?: null | string; + /** + * 钀ヤ笟鎵х収鏂囦欢璺緞 + */ + businessLicense?: null | string; + /** + * 浼佷笟閭 + */ + enterpriseEmail?: null | string; + /** + * 浼佷笟鍚嶇О + */ + enterpriseName?: null | string; + /** + * 浼佷笟鑱旂郴鐢佃瘽 + */ + enterprisePhone?: null | string; + /** + * 浼佷笟绫诲瀷 浠庝紒涓氱被鍨嬩腑閫夋嫨 鏉ユ簮浼佷笟绫诲瀷 + */ + enterpriseType?: null | string; + /** + * 浼佷笟鎴愮珛鏃堕棿 + */ + establishmentTime?: Date; + /** + * 涓婚敭 + */ + id?: number | null; + /** + * 娉曞畾浠h〃浜鸿韩浠借瘉鏂囦欢璺緞 + */ + legalRepresentativeIdCard?: null | string; + /** + * 娉曞畾浠h〃浜鸿韩浠借瘉鍙风爜 + */ + legalRepresentativeIdNumber?: null | string; + /** + * 娉曞畾浠h〃浜哄鍚� + */ + legalRepresentativeName?: null | string; + /** + * 娉曞畾浠h〃浜鸿仈绯荤數璇� + */ + legalRepresentativePhone?: null | string; + /** + * 浼佷笟涓昏惀涓氬姟 + */ + mainBusiness?: null | string; + /** + * 涓氬姟缁忓姙浜鸿韩浠借瘉鏂囦欢璺緞鎴栨爣璇嗭紙涓婁紶鍚庡瓨鍌ㄤ俊鎭級 + */ + operatorIdCard?: null | string; + /** + * 涓氬姟缁忓姙浜鸿韩浠借瘉鍙风爜 + */ + operatorIdNumber?: null | string; + /** + * 涓氬姟缁忓姙浜哄鍚� + */ + operatorName?: null | string; + /** + * 涓氬姟缁忓姙浜鸿仈绯荤數璇� + */ + operatorPhone?: null | string; + /** + * 娉ㄥ唽璧勯噾锛堝崟浣嶏細涓囧厓 锛� + */ + registeredCapital?: null | string; + /** + * 浼佷笟浣忔墍锛堜笅鎷夐�夋嫨锛岄渶缁撳悎瀹為檯鍙�夊�硷紝鍏堝瓧绗︿覆鎺ユ敹 锛� + */ + residence?: null | string; + /** + * 浜ゆ槗涓讳綋 浠g爜 鍚岃鑹蹭唬鐮� + */ + transactionCode: string; + /** + * 浜ゆ槗涓讳綋鍚嶇О + */ + transactionName?: null | string; + /** + * 缁熶竴绀句細淇$敤浠g爜 + */ + unifiedSocialCreditCode?: null | string; } export const userKey = "user-info"; @@ -43,7 +168,7 @@ * @description 璁剧疆`token`浠ュ強涓�浜涘繀瑕佷俊鎭苟閲囩敤鏃犳劅鍒锋柊`token`鏂规 * 鏃犳劅鍒锋柊锛氬悗绔繑鍥瀈accessToken`锛堣闂帴鍙d娇鐢ㄧ殑`token`锛夈�乣refreshToken`锛堢敤浜庤皟鐢ㄥ埛鏂癭accessToken`鐨勬帴鍙f椂鎵�闇�鐨刞token`锛宍refreshToken`鐨勮繃鏈熸椂闂达紙姣斿30澶╋級搴斿ぇ浜巂accessToken`鐨勮繃鏈熸椂闂达紙姣斿2灏忔椂锛夛級銆乣expires`锛坄accessToken`鐨勮繃鏈熸椂闂达級 * 灏哷accessToken`銆乣expires`銆乣refreshToken`杩欎笁鏉′俊鎭斁鍦╧ey鍊间负authorized-token鐨刢ookie閲岋紙杩囨湡鑷姩閿�姣侊級 - * 灏哷avatar`銆乣username`銆乣nickname`銆乣roles`銆乣permissions`銆乣refreshToken`銆乣expires`杩欎竷鏉′俊鎭斁鍦╧ey鍊间负`user-info`鐨刲ocalStorage閲岋紙鍒╃敤`multipleTabsKey`褰撴祻瑙堝櫒瀹屽叏鍏抽棴鍚庤嚜鍔ㄩ攢姣侊級 + * 灏哷avatar`銆乣username`銆乣nickname`銆乣exRoles`銆乣permissions`銆乣refreshToken`銆乣expires`杩欎竷鏉′俊鎭斁鍦╧ey鍊间负`user-info`鐨刲ocalStorage閲岋紙鍒╃敤`multipleTabsKey`褰撴祻瑙堝櫒瀹屽叏鍏抽棴鍚庤嚜鍔ㄩ攢姣侊級 */ export function setToken(data: DataInfo<Date>) { let expires = 0; @@ -115,6 +240,36 @@ } } +export function setEnterpriseInfo(data: CusExtendDto) { + useUserStoreHook().SET_ENTERPRISEINFO(data); + useUserStoreHook().SET_USERNAME(data.enterpriseName); + storageLocal().setItem("enterpriseInfo", data); + const obj = storageLocal().getItem(userKey); + obj.username = data.enterpriseName; + storageLocal().setItem(userKey, obj); +} + +export function setRoleListInfo(data: DataInfo<string>) { + useUserStoreHook().SET_ROLES_LIST(data); + storageLocal().setItem("rolesList", data); +} + +export function setNowRole(data: nowRoleType) { + const list = storageLocal().getItem<DataInfo<number>>(userKey)?.exRoles ?? []; + if (list.length > 0) { + const obj = list.find(item => { + return item.code == data.code; + }); + data = { ...obj, ...data }; + } + useUserStoreHook().SET_NOW_ROLE(data); + storageLocal().setItem("nowRole", data); +} + +export function removeEnterpriseInfo() { + storageLocal().removeItem("enterpriseInfo"); +} + /** 鍒犻櫎`token`浠ュ強key鍊间负`user-info`鐨刲ocalStorage淇℃伅 */ export function removeToken() { Cookies.remove(TokenKey); -- Gitblit v1.9.1