From 6d5d2e21f176e387aecfdfdb400b639b3b252e16 Mon Sep 17 00:00:00 2001 From: danial Date: Sat, 5 Apr 2025 17:36:53 +0800 Subject: [PATCH] refactor(api): update JD cookie management and related components This commit refactors the JD cookie management API and associated components to improve maintainability and consistency. Key changes include: - Updated API client to include `CkApi` for JD cookie operations. - Added new models and updated existing ones for JD cookie management. - Refactored components to use the updated API and models. - Removed unused code and streamlined the logic for adding, updating, and deleting JD cookies. --- src/api/generated/.openapi-generator/FILES | 3 +- src/api/generated/apis/ck-api.ts | 345 ++++++++++++------ src/api/generated/models/index.ts | 3 +- ...i-api-card-redeem-jd-v1-account-add-req.ts | 9 +- ...i-api-card-redeem-jd-v1-account-get-res.ts | 14 +- ...-api-card-redeem-jd-v1-account-list-res.ts | 6 +- ...pi-card-redeem-jd-v1-account-status-req.ts | 41 +++ ...pi-card-redeem-jd-v1-account-update-req.ts | 9 +- .../kami-api-card-redeem-jd-v1-cookie-info.ts | 83 +++++ src/api/index.ts | 4 +- .../account/components/add-modal.vue | 145 ++------ .../account/components/component.tsx | 9 +- src/views/card-jd-ck/account/index.vue | 192 +++------- 13 files changed, 477 insertions(+), 386 deletions(-) create mode 100644 src/api/generated/models/kami-api-card-redeem-jd-v1-account-status-req.ts create mode 100644 src/api/generated/models/kami-api-card-redeem-jd-v1-cookie-info.ts diff --git a/src/api/generated/.openapi-generator/FILES b/src/api/generated/.openapi-generator/FILES index e1827f8..0c06120 100644 --- a/src/api/generated/.openapi-generator/FILES +++ b/src/api/generated/.openapi-generator/FILES @@ -206,7 +206,9 @@ models/kami-api-card-redeem-jd-v1-account-get-req.ts models/kami-api-card-redeem-jd-v1-account-get-res.ts models/kami-api-card-redeem-jd-v1-account-list-req.ts models/kami-api-card-redeem-jd-v1-account-list-res.ts +models/kami-api-card-redeem-jd-v1-account-status-req.ts models/kami-api-card-redeem-jd-v1-account-update-req.ts +models/kami-api-card-redeem-jd-v1-cookie-info.ts models/kami-api-channel-v2-entrance-create-req.ts models/kami-api-channel-v2-entrance-delete-req.ts models/kami-api-channel-v2-entrance-list-req.ts @@ -314,7 +316,6 @@ models/kami-internal-model-entity-v1-card-apple-history-info.ts models/kami-internal-model-entity-v1-card-apple-recharge-info.ts models/kami-internal-model-entity-v1-card-redeem-account-group.ts models/kami-internal-model-entity-v1-card-redeem-account-history.ts -models/kami-internal-model-entity-v1-card-redeem-cookie-info.ts models/kami-internal-model-entity-v1-card-redeem-order-history.ts models/kami-internal-model-entity-v1-card-redeem-order-info.ts models/kami-internal-model-entity-v1-merchant-hidden-record.ts diff --git a/src/api/generated/apis/ck-api.ts b/src/api/generated/apis/ck-api.ts index d9993ba..b83c458 100644 --- a/src/api/generated/apis/ck-api.ts +++ b/src/api/generated/apis/ck-api.ts @@ -45,6 +45,8 @@ import type { KamiApiCardRedeemJdV1AccountGetRes } from '../models'; // @ts-ignore import type { KamiApiCardRedeemJdV1AccountListRes } from '../models'; // @ts-ignore +import type { KamiApiCardRedeemJdV1AccountStatusReq } from '../models'; +// @ts-ignore import type { KamiApiCardRedeemJdV1AccountUpdateReq } from '../models'; /** * CkApi - axios parameter creator @@ -52,53 +54,6 @@ import type { KamiApiCardRedeemJdV1AccountUpdateReq } from '../models'; */ export const CkApiAxiosParamCreator = function (configuration?: Configuration) { return { - /** - * - * @summary 获取京东ck - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiCookieInfoIdAccountGetGet: async ( - id: number, - options: RawAxiosRequestConfig = {} - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists('apiCookieInfoIdAccountGetGet', 'id', id); - const localVarPath = `/api/cookieInfo/id/account/get`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { - method: 'GET', - ...baseOptions, - ...options - }; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - if (id !== undefined) { - localVarQueryParameter['id'] = id; - } - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers - }; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions - }; - }, /** * * @summary 添加京东ck @@ -194,6 +149,53 @@ export const CkApiAxiosParamCreator = function (configuration?: Configuration) { options: localVarRequestOptions }; }, + /** + * + * @summary 获取京东ck + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiCookieInfoJdAccountGetGet: async ( + id: number, + options: RawAxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiCookieInfoJdAccountGetGet', 'id', id); + const localVarPath = `/api/cookieInfo/jd/account/get`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { + method: 'GET', + ...baseOptions, + ...options + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (id !== undefined) { + localVarQueryParameter['id'] = id; + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions + }; + }, /** * * @summary 获取京东ck列表 @@ -249,6 +251,54 @@ export const CkApiAxiosParamCreator = function (configuration?: Configuration) { options: localVarRequestOptions }; }, + /** + * + * @summary 修改京东ck状态 + * @param {KamiApiCardRedeemJdV1AccountStatusReq} [kamiApiCardRedeemJdV1AccountStatusReq] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiCookieInfoJdAccountStatusPut: async ( + kamiApiCardRedeemJdV1AccountStatusReq?: KamiApiCardRedeemJdV1AccountStatusReq, + options: RawAxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/api/cookieInfo/jd/account/status`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { + method: 'PUT', + ...baseOptions, + ...options + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers + }; + localVarRequestOptions.data = serializeDataIfNeeded( + kamiApiCardRedeemJdV1AccountStatusReq, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions + }; + }, /** * * @summary 更新京东ck @@ -307,40 +357,6 @@ export const CkApiAxiosParamCreator = function (configuration?: Configuration) { export const CkApiFp = function (configuration?: Configuration) { const localVarAxiosParamCreator = CkApiAxiosParamCreator(configuration); return { - /** - * - * @summary 获取京东ck - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiCookieInfoIdAccountGetGet( - id: number, - options?: RawAxiosRequestConfig - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiCookieInfoIdAccountGetGet( - id, - options - ); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = - operationServerMap['CkApi.apiCookieInfoIdAccountGetGet']?.[ - localVarOperationServerIndex - ]?.url; - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration - )(axios, localVarOperationServerBasePath || basePath); - }, /** * * @summary 添加京东ck @@ -403,6 +419,40 @@ export const CkApiFp = function (configuration?: Configuration) { configuration )(axios, localVarOperationServerBasePath || basePath); }, + /** + * + * @summary 获取京东ck + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiCookieInfoJdAccountGetGet( + id: number, + options?: RawAxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.apiCookieInfoJdAccountGetGet( + id, + options + ); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = + operationServerMap['CkApi.apiCookieInfoJdAccountGetGet']?.[ + localVarOperationServerIndex + ]?.url; + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + )(axios, localVarOperationServerBasePath || basePath); + }, /** * * @summary 获取京东ck列表 @@ -440,6 +490,37 @@ export const CkApiFp = function (configuration?: Configuration) { configuration )(axios, localVarOperationServerBasePath || basePath); }, + /** + * + * @summary 修改京东ck状态 + * @param {KamiApiCardRedeemJdV1AccountStatusReq} [kamiApiCardRedeemJdV1AccountStatusReq] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiCookieInfoJdAccountStatusPut( + kamiApiCardRedeemJdV1AccountStatusReq?: KamiApiCardRedeemJdV1AccountStatusReq, + options?: RawAxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.apiCookieInfoJdAccountStatusPut( + kamiApiCardRedeemJdV1AccountStatusReq, + options + ); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = + operationServerMap['CkApi.apiCookieInfoJdAccountStatusPut']?.[ + localVarOperationServerIndex + ]?.url; + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + )(axios, localVarOperationServerBasePath || basePath); + }, /** * * @summary 更新京东ck @@ -485,21 +566,6 @@ export const CkApiFactory = function ( ) { const localVarFp = CkApiFp(configuration); return { - /** - * - * @summary 获取京东ck - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiCookieInfoIdAccountGetGet( - id: number, - options?: RawAxiosRequestConfig - ): AxiosPromise { - return localVarFp - .apiCookieInfoIdAccountGetGet(id, options) - .then(request => request(axios, basePath)); - }, /** * * @summary 添加京东ck @@ -533,6 +599,21 @@ export const CkApiFactory = function ( .apiCookieInfoJdAccountDeleteDelete(id, options) .then(request => request(axios, basePath)); }, + /** + * + * @summary 获取京东ck + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiCookieInfoJdAccountGetGet( + id: number, + options?: RawAxiosRequestConfig + ): AxiosPromise { + return localVarFp + .apiCookieInfoJdAccountGetGet(id, options) + .then(request => request(axios, basePath)); + }, /** * * @summary 获取京东ck列表 @@ -550,6 +631,24 @@ export const CkApiFactory = function ( .apiCookieInfoJdAccountListGet(current, pageSize, options) .then(request => request(axios, basePath)); }, + /** + * + * @summary 修改京东ck状态 + * @param {KamiApiCardRedeemJdV1AccountStatusReq} [kamiApiCardRedeemJdV1AccountStatusReq] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiCookieInfoJdAccountStatusPut( + kamiApiCardRedeemJdV1AccountStatusReq?: KamiApiCardRedeemJdV1AccountStatusReq, + options?: RawAxiosRequestConfig + ): AxiosPromise { + return localVarFp + .apiCookieInfoJdAccountStatusPut( + kamiApiCardRedeemJdV1AccountStatusReq, + options + ) + .then(request => request(axios, basePath)); + }, /** * * @summary 更新京东ck @@ -578,23 +677,6 @@ export const CkApiFactory = function ( * @extends {BaseAPI} */ export class CkApi extends BaseAPI { - /** - * - * @summary 获取京东ck - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof CkApi - */ - public apiCookieInfoIdAccountGetGet( - id: number, - options?: RawAxiosRequestConfig - ) { - return CkApiFp(this.configuration) - .apiCookieInfoIdAccountGetGet(id, options) - .then(request => request(this.axios, this.basePath)); - } - /** * * @summary 添加京东ck @@ -632,6 +714,23 @@ export class CkApi extends BaseAPI { .then(request => request(this.axios, this.basePath)); } + /** + * + * @summary 获取京东ck + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CkApi + */ + public apiCookieInfoJdAccountGetGet( + id: number, + options?: RawAxiosRequestConfig + ) { + return CkApiFp(this.configuration) + .apiCookieInfoJdAccountGetGet(id, options) + .then(request => request(this.axios, this.basePath)); + } + /** * * @summary 获取京东ck列表 @@ -651,6 +750,26 @@ export class CkApi extends BaseAPI { .then(request => request(this.axios, this.basePath)); } + /** + * + * @summary 修改京东ck状态 + * @param {KamiApiCardRedeemJdV1AccountStatusReq} [kamiApiCardRedeemJdV1AccountStatusReq] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CkApi + */ + public apiCookieInfoJdAccountStatusPut( + kamiApiCardRedeemJdV1AccountStatusReq?: KamiApiCardRedeemJdV1AccountStatusReq, + options?: RawAxiosRequestConfig + ) { + return CkApiFp(this.configuration) + .apiCookieInfoJdAccountStatusPut( + kamiApiCardRedeemJdV1AccountStatusReq, + options + ) + .then(request => request(this.axios, this.basePath)); + } + /** * * @summary 更新京东ck diff --git a/src/api/generated/models/index.ts b/src/api/generated/models/index.ts index 10c720f..57bdb79 100644 --- a/src/api/generated/models/index.ts +++ b/src/api/generated/models/index.ts @@ -194,7 +194,9 @@ export * from './kami-api-card-redeem-jd-v1-account-get-req'; export * from './kami-api-card-redeem-jd-v1-account-get-res'; export * from './kami-api-card-redeem-jd-v1-account-list-req'; export * from './kami-api-card-redeem-jd-v1-account-list-res'; +export * from './kami-api-card-redeem-jd-v1-account-status-req'; export * from './kami-api-card-redeem-jd-v1-account-update-req'; +export * from './kami-api-card-redeem-jd-v1-cookie-info'; export * from './kami-api-channel-v2-entrance-create-req'; export * from './kami-api-channel-v2-entrance-delete-req'; export * from './kami-api-channel-v2-entrance-list-req'; @@ -302,7 +304,6 @@ export * from './kami-internal-model-entity-v1-card-apple-history-info'; export * from './kami-internal-model-entity-v1-card-apple-recharge-info'; export * from './kami-internal-model-entity-v1-card-redeem-account-group'; export * from './kami-internal-model-entity-v1-card-redeem-account-history'; -export * from './kami-internal-model-entity-v1-card-redeem-cookie-info'; export * from './kami-internal-model-entity-v1-card-redeem-order-history'; export * from './kami-internal-model-entity-v1-card-redeem-order-info'; export * from './kami-internal-model-entity-v1-merchant-hidden-record'; diff --git a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-add-req.ts b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-add-req.ts index 2b050d6..ac6b51d 100644 --- a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-add-req.ts +++ b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-add-req.ts @@ -36,10 +36,17 @@ export interface KamiApiCardRedeemJdV1AccountAddReq { * @memberof KamiApiCardRedeemJdV1AccountAddReq */ status: KamiApiCardRedeemJdV1AccountAddReqStatusEnum; + /** + * 备注 + * @type {string} + * @memberof KamiApiCardRedeemJdV1AccountAddReq + */ + notes?: string; } export const KamiApiCardRedeemJdV1AccountAddReqStatusEnum = { - Jd: 'jd' + Disable: 'disable', + Normal: 'normal' } as const; export type KamiApiCardRedeemJdV1AccountAddReqStatusEnum = diff --git a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-get-res.ts b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-get-res.ts index 5ee17c1..439c7f8 100644 --- a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-get-res.ts +++ b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-get-res.ts @@ -1,5 +1,5 @@ /* tslint:disable */ - +/* eslint-disable */ /** * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) @@ -43,11 +43,11 @@ export interface KamiApiCardRedeemJdV1AccountGetRes { */ notes?: string; /** - * + * 状态 * @type {string} * @memberof KamiApiCardRedeemJdV1AccountGetRes */ - status?: string; + status?: KamiApiCardRedeemJdV1AccountGetResStatusEnum; /** * * @type {string} @@ -73,3 +73,11 @@ export interface KamiApiCardRedeemJdV1AccountGetRes { */ deletedAt?: string; } + +export const KamiApiCardRedeemJdV1AccountGetResStatusEnum = { + Disable: 'disable', + Normal: 'normal' +} as const; + +export type KamiApiCardRedeemJdV1AccountGetResStatusEnum = + (typeof KamiApiCardRedeemJdV1AccountGetResStatusEnum)[keyof typeof KamiApiCardRedeemJdV1AccountGetResStatusEnum]; diff --git a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-list-res.ts b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-list-res.ts index 1052e28..b7ddc29 100644 --- a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-list-res.ts +++ b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-list-res.ts @@ -14,7 +14,7 @@ // May contain unused imports in some cases // @ts-ignore -import type { KamiInternalModelEntityV1CardRedeemCookieInfo } from './kami-internal-model-entity-v1-card-redeem-cookie-info'; +import type { KamiApiCardRedeemJdV1CookieInfo } from './kami-api-card-redeem-jd-v1-cookie-info'; /** * @@ -30,8 +30,8 @@ export interface KamiApiCardRedeemJdV1AccountListRes { total?: number; /** * - * @type {Array} + * @type {Array} * @memberof KamiApiCardRedeemJdV1AccountListRes */ - list?: Array; + list?: Array; } diff --git a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-status-req.ts b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-status-req.ts new file mode 100644 index 0000000..3eb71ef --- /dev/null +++ b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-status-req.ts @@ -0,0 +1,41 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * + * @export + * @interface KamiApiCardRedeemJdV1AccountStatusReq + */ +export interface KamiApiCardRedeemJdV1AccountStatusReq { + /** + * + * @type {number} + * @memberof KamiApiCardRedeemJdV1AccountStatusReq + */ + id: number; + /** + * 状态 + * @type {string} + * @memberof KamiApiCardRedeemJdV1AccountStatusReq + */ + status: KamiApiCardRedeemJdV1AccountStatusReqStatusEnum; +} + +export const KamiApiCardRedeemJdV1AccountStatusReqStatusEnum = { + Disable: 'disable', + Normal: 'normal' +} as const; + +export type KamiApiCardRedeemJdV1AccountStatusReqStatusEnum = + (typeof KamiApiCardRedeemJdV1AccountStatusReqStatusEnum)[keyof typeof KamiApiCardRedeemJdV1AccountStatusReqStatusEnum]; diff --git a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-update-req.ts b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-update-req.ts index 2a2bf32..800f345 100644 --- a/src/api/generated/models/kami-api-card-redeem-jd-v1-account-update-req.ts +++ b/src/api/generated/models/kami-api-card-redeem-jd-v1-account-update-req.ts @@ -36,6 +36,12 @@ export interface KamiApiCardRedeemJdV1AccountUpdateReq { * @memberof KamiApiCardRedeemJdV1AccountUpdateReq */ status: KamiApiCardRedeemJdV1AccountUpdateReqStatusEnum; + /** + * 备注 + * @type {string} + * @memberof KamiApiCardRedeemJdV1AccountUpdateReq + */ + notes?: string; /** * * @type {number} @@ -45,7 +51,8 @@ export interface KamiApiCardRedeemJdV1AccountUpdateReq { } export const KamiApiCardRedeemJdV1AccountUpdateReqStatusEnum = { - Jd: 'jd' + Disable: 'disable', + Normal: 'normal' } as const; export type KamiApiCardRedeemJdV1AccountUpdateReqStatusEnum = diff --git a/src/api/generated/models/kami-api-card-redeem-jd-v1-cookie-info.ts b/src/api/generated/models/kami-api-card-redeem-jd-v1-cookie-info.ts new file mode 100644 index 0000000..292c3a6 --- /dev/null +++ b/src/api/generated/models/kami-api-card-redeem-jd-v1-cookie-info.ts @@ -0,0 +1,83 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * + * @export + * @interface KamiApiCardRedeemJdV1CookieInfo + */ +export interface KamiApiCardRedeemJdV1CookieInfo { + /** + * + * @type {number} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + id?: number; + /** + * + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + name?: string; + /** + * + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + cookie?: string; + /** + * + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + notes?: string; + /** + * 状态 + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + status?: KamiApiCardRedeemJdV1CookieInfoStatusEnum; + /** + * + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + category?: string; + /** + * + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + createdAt?: string; + /** + * + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + updatedAt?: string; + /** + * + * @type {string} + * @memberof KamiApiCardRedeemJdV1CookieInfo + */ + deletedAt?: string; +} + +export const KamiApiCardRedeemJdV1CookieInfoStatusEnum = { + Disable: 'disable', + Normal: 'normal' +} as const; + +export type KamiApiCardRedeemJdV1CookieInfoStatusEnum = + (typeof KamiApiCardRedeemJdV1CookieInfoStatusEnum)[keyof typeof KamiApiCardRedeemJdV1CookieInfoStatusEnum]; diff --git a/src/api/index.ts b/src/api/index.ts index 99ffe98..f0a8b4b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,4 +1,6 @@ import axios from 'axios'; -import { Configuration, DefaultApi } from './generated'; +import { Configuration, DefaultApi, CkApi } from './generated'; export const apiClient = new DefaultApi(new Configuration(), '', axios); + +export const apiCkClient = new CkApi(new Configuration(), '', axios); diff --git a/src/views/card-jd-ck/account/components/add-modal.vue b/src/views/card-jd-ck/account/components/add-modal.vue index 6a56cc3..e8d7579 100644 --- a/src/views/card-jd-ck/account/components/add-modal.vue +++ b/src/views/card-jd-ck/account/components/add-modal.vue @@ -5,7 +5,7 @@ draggable @cancel="handleCancel" > - + @@ -22,76 +22,25 @@ /> - - - - - - - + - - - - - - - + + @@ -102,18 +51,13 @@ import useLoading from '@/hooks/loading'; import { FormInstance } from '@arco-design/web-vue'; import { ref, PropType, watch, reactive } from 'vue'; import { isNull } from '@/utils/is.ts'; -import { apiClient } from '@/api/index.ts'; -import { - addWalmartCard, - detectCookie, - updateWalmartCard -} from '@/api/card-walmart-account'; -import { notification } from './component.tsx'; -import { - KamiApiCardInfoWalmartV1AccountCreateReq, - KamiApiCardInfoWalmartV1AccountListRecord +import { apiCkClient } from '@/api/index.ts'; +import { KamiApiCardRedeemJdV1AccountAddReqStatusEnum } from '@/api/generated/index.ts'; +import type { + KamiApiCardRedeemJdV1AccountAddReq, + KamiApiCardRedeemJdV1CookieInfo } from '@/api/generated/index.ts'; -import type { KamiInternalModelEntityV1CardRedeemAccountGroup } from '@/api/generated/index.ts'; +import { isNaN } from 'lodash'; const props = defineProps({ visible: { @@ -121,29 +65,24 @@ const props = defineProps({ default: false }, id: { - type: String, - default: '' + type: Number, + default: null }, account: { - type: Object as PropType< - Required - >, + type: Object as PropType>, default: null } }); const generateFormData = () => { return { - status: 1, - maxAmountLimit: 0, - maxCountLimit: 0, + name: '', cookie: '', - remark: '', - name: '' + notes: '', + status: KamiApiCardRedeemJdV1AccountAddReqStatusEnum.Normal }; }; -const formData = - ref(generateFormData()); +const formData = ref(generateFormData()); const formDataRef = ref(); const { loading, setLoading } = useLoading(false); @@ -153,7 +92,6 @@ const renderData = reactive<{ cookieStatus: boolean; loading: boolean }>({ }); const emit = defineEmits(['update:visible']); -const groupList = ref([]); const handleOk = () => { if (formData.value) { @@ -161,10 +99,13 @@ const handleOk = () => { if (res) return; setLoading(true); try { - if (props.id === '') { - await addWalmartCard(formData.value); + if (isNull(props.id)) { + await apiCkClient.apiCookieInfoJdAccountAddPost(formData.value); } else { - await updateWalmartCard({ id: props.id, ...formData.value }); + await apiCkClient.apiCookieInfoJdAccountUpdatePut({ + id: props.id, + ...formData.value + }); } emit('update:visible', false); formData.value = generateFormData(); @@ -194,38 +135,6 @@ watch( renderData.cookieStatus = false; } ); - -const checkCookie = async () => { - renderData.loading = false; - try { - const cookieResp = await detectCookie({ - cookie: formData.value.cookie.trim() - }); - if (cookieResp.data.isAvailable) { - notification( - true, - cookieResp.data.nickname, - cookieResp.data.balance, - cookieResp.data.isExist - ); - renderData.cookieStatus = true; - if (props.id === '') { - renderData.cookieStatus = !cookieResp.data.isExist; - } - } else { - notification(false); - } - } finally { - renderData.loading = false; - } -}; - -const getAllGroupList = () => { - apiClient.apiCardInfoWalmartGroupAllListGet().then(res => { - groupList.value = res.data.list; - }); -}; -getAllGroupList();