😎增加获取不受限制的小程序码的接口

This commit is contained in:
zuohuaijun 2025-03-27 02:22:43 +08:00
parent 882a588abb
commit 8a24a07d31
8 changed files with 235 additions and 30 deletions

View File

@ -21,7 +21,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="3.1.1" /> <PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="3.1.2" />
<PackageReference Include="AlipaySDKNet.Standard" Version="4.9.448" /> <PackageReference Include="AlipaySDKNet.Standard" Version="4.9.448" />
<PackageReference Include="AngleSharp" Version="1.2.0" /> <PackageReference Include="AngleSharp" Version="1.2.0" />
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" /> <PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />

View File

@ -144,7 +144,7 @@ public class VerifySignatureInput
} }
/// <summary> /// <summary>
/// 生成带参数小程序二维码 /// 生成带参数小程序二维码(总共生成的码数量限制为 100,000
/// </summary> /// </summary>
public class GenerateQRImageInput public class GenerateQRImageInput
{ {
@ -162,4 +162,15 @@ public class GenerateQRImageInput
/// 图片宽度 默认430 /// 图片宽度 默认430
/// </summary> /// </summary>
public int Width { get; set; } = 430; public int Width { get; set; } = 430;
}
/// <summary>
/// 生成带参数小程序二维码(获取不受限制的小程序码)
/// </summary>
public class GenerateQRImageUnLimitInput : GenerateQRImageInput
{
/// <summary>
/// 二维码携带的参数 eg:a=1最大32个可见字符只支持数字大小写英文以及部分特殊字符!#$&'()*+,/:;=?@-._~
/// </summary>
public string Scene { get; set; }
} }

View File

@ -263,11 +263,11 @@ public class SysWxOpenService : IDynamicApiController, ITransient
} }
/// <summary> /// <summary>
/// 生成小程序二维码 🔖 /// 生成带参数小程序二维码(总共生成的码数量限制为 100,000 🔖
/// </summary> /// </summary>
/// <param name="input"> 扫码进入的小程序页面路径,最大长度 128 个字符,不能为空; eg: pages / index ? id = AY000001 </param> /// <param name="input"> 扫码进入的小程序页面路径,最大长度 128 个字符,不能为空; eg: pages / index ? id = AY000001 </param>
/// <returns></returns> /// <returns></returns>
[DisplayName("生成小程序二维码")] [DisplayName("生成带参数小程序二维码")]
[ApiDescriptionSettings(Name = "GenerateQRImage")] [ApiDescriptionSettings(Name = "GenerateQRImage")]
public async Task<GenerateQRImageOutput> GenerateQRImageAsync(GenerateQRImageInput input) public async Task<GenerateQRImageOutput> GenerateQRImageAsync(GenerateQRImageInput input)
{ {
@ -333,6 +333,83 @@ public class SysWxOpenService : IDynamicApiController, ITransient
return generateQRImageOutInput; return generateQRImageOutInput;
} }
/// <summary>
/// 生成二维码(获取不受限制的小程序码)
/// </summary>
/// <param name="input">入参</param>
/// <returns></returns>
[DisplayName("生成小程序二维码")]
[ApiDescriptionSettings(Name = "GenerateQRImageUnlimit")]
public async Task<GenerateQRImageOutput> GenerateQRImageUnlimitAsync(GenerateQRImageUnLimitInput input)
{
GenerateQRImageOutput generateQRImageOutInput = new GenerateQRImageOutput();
if (input.PagePath.IsNullOrEmpty())
{
generateQRImageOutInput.Message = $"生成失败,页面路径不能为空";
return generateQRImageOutInput;
}
if (input.Scene.Length > 32)
{
generateQRImageOutInput.Message = $"生成失败,携带的参数长度超过限制";
return generateQRImageOutInput;
}
if (input.ImageName.IsNullOrEmpty())
{
input.ImageName = DateTime.Now.ToString("yyyyMMddHHmmss");
}
var accessToken = await GetCgibinToken();
var request = new WxaGetWxaCodeRequest
{
AccessToken = accessToken,
Width = input.Width,
PagePath = input.PagePath,
};
var response = await _wechatApiClient.ExecuteWxaGetWxaCodeAsync(request);
if (response.IsSuccessful())
{
var QRImagePath = App.GetConfig<string>("Wechat:QRImagePath");
var relativeImgPath = string.Empty;
// 判断路径是绝对路径还是相对路径
var isPathRooted = Path.IsPathRooted(QRImagePath);
if (!isPathRooted)
{
// 相对路径
relativeImgPath = string.IsNullOrEmpty(QRImagePath) ? Path.Combine("upload", "QRImageUnLimit") : QRImagePath;
QRImagePath = Path.Combine(App.WebHostEnvironment.WebRootPath, relativeImgPath);
}
//判断文件存放路径是否存在
if (!Directory.Exists(QRImagePath))
{
Directory.CreateDirectory(QRImagePath);
}
// 将二维码图片数据保存为文件
var fileName = $"{input.ImageName.ToUpper()}.png";
var filePath = Path.Combine(QRImagePath, fileName);
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.WriteAllBytes(filePath, response.GetRawBytes());
generateQRImageOutInput.Success = true;
generateQRImageOutInput.ImgPath = filePath;
generateQRImageOutInput.RelativeImgPath = Path.Combine(relativeImgPath, fileName);
generateQRImageOutInput.Message = "生成成功";
}
else
{
// 处理错误情况
generateQRImageOutInput.Message = $"生成失败 错误代码:{response.ErrorCode} 错误描述:{response.ErrorMessage}";
}
return generateQRImageOutInput;
}
/// <summary> /// <summary>
/// 获取Access_token /// 获取Access_token
/// </summary> /// </summary>

View File

@ -24,6 +24,7 @@ import { AdminNETResultSysFile } from '../models';
import { AdminNETResultWxOpenIdOutput } from '../models'; import { AdminNETResultWxOpenIdOutput } from '../models';
import { AdminNETResultWxPhoneOutput } from '../models'; import { AdminNETResultWxPhoneOutput } from '../models';
import { GenerateQRImageInput } from '../models'; import { GenerateQRImageInput } from '../models';
import { GenerateQRImageUnLimitInput } from '../models';
import { SendSubscribeMessageInput } from '../models'; import { SendSubscribeMessageInput } from '../models';
import { SetNickNameInput } from '../models'; import { SetNickNameInput } from '../models';
import { WxOpenIdLoginInput } from '../models'; import { WxOpenIdLoginInput } from '../models';
@ -83,7 +84,7 @@ export const SysWxOpenApiAxiosParamCreator = function (configuration?: Configura
}, },
/** /**
* *
* @summary 🔖 * @summary 100,000 🔖
* @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001 * @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -129,6 +130,54 @@ export const SysWxOpenApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions, options: localVarRequestOptions,
}; };
}, },
/**
*
* @summary
* @param {GenerateQRImageUnLimitInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysWxOpenGenerateQRImageUnlimitPost: async (body?: GenerateQRImageUnLimitInput, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysWxOpen/generateQRImageUnlimit`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication Bearer required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
localVarHeaderParameter['Content-Type'] = 'application/json-patch+json';
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/** /**
* *
* @summary 🔖 * @summary 🔖
@ -633,7 +682,7 @@ export const SysWxOpenApiFp = function(configuration?: Configuration) {
}, },
/** /**
* *
* @summary 🔖 * @summary 100,000 🔖
* @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001 * @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -645,6 +694,20 @@ export const SysWxOpenApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs); return axios.request(axiosRequestArgs);
}; };
}, },
/**
*
* @summary
* @param {GenerateQRImageUnLimitInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysWxOpenGenerateQRImageUnlimitPost(body?: GenerateQRImageUnLimitInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>>> {
const localVarAxiosArgs = await SysWxOpenApiAxiosParamCreator(configuration).apiSysWxOpenGenerateQRImageUnlimitPost(body, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/** /**
* *
* @summary 🔖 * @summary 🔖
@ -798,7 +861,7 @@ export const SysWxOpenApiFactory = function (configuration?: Configuration, base
}, },
/** /**
* *
* @summary 🔖 * @summary 100,000 🔖
* @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001 * @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -806,6 +869,16 @@ export const SysWxOpenApiFactory = function (configuration?: Configuration, base
async apiSysWxOpenGenerateQRImagePost(body?: GenerateQRImageInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> { async apiSysWxOpenGenerateQRImagePost(body?: GenerateQRImageInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> {
return SysWxOpenApiFp(configuration).apiSysWxOpenGenerateQRImagePost(body, options).then((request) => request(axios, basePath)); return SysWxOpenApiFp(configuration).apiSysWxOpenGenerateQRImagePost(body, options).then((request) => request(axios, basePath));
}, },
/**
*
* @summary
* @param {GenerateQRImageUnLimitInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysWxOpenGenerateQRImageUnlimitPost(body?: GenerateQRImageUnLimitInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> {
return SysWxOpenApiFp(configuration).apiSysWxOpenGenerateQRImageUnlimitPost(body, options).then((request) => request(axios, basePath));
},
/** /**
* *
* @summary 🔖 * @summary 🔖
@ -925,7 +998,7 @@ export class SysWxOpenApi extends BaseAPI {
} }
/** /**
* *
* @summary 🔖 * @summary 100,000 🔖
* @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001 * @param {GenerateQRImageInput} [body] 128 eg: pages / index ? id &#x3D; AY000001
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -934,6 +1007,17 @@ export class SysWxOpenApi extends BaseAPI {
public async apiSysWxOpenGenerateQRImagePost(body?: GenerateQRImageInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> { public async apiSysWxOpenGenerateQRImagePost(body?: GenerateQRImageInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> {
return SysWxOpenApiFp(this.configuration).apiSysWxOpenGenerateQRImagePost(body, options).then((request) => request(this.axios, this.basePath)); return SysWxOpenApiFp(this.configuration).apiSysWxOpenGenerateQRImagePost(body, options).then((request) => request(this.axios, this.basePath));
} }
/**
*
* @summary
* @param {GenerateQRImageUnLimitInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysWxOpenApi
*/
public async apiSysWxOpenGenerateQRImageUnlimitPost(body?: GenerateQRImageUnLimitInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> {
return SysWxOpenApiFp(this.configuration).apiSysWxOpenGenerateQRImageUnlimitPost(body, options).then((request) => request(this.axios, this.basePath));
}
/** /**
* *
* @summary 🔖 * @summary 🔖

View File

@ -13,7 +13,7 @@
*/ */
/** /**
* * ( 100,000)
* *
* @export * @export
* @interface GenerateQRImageInput * @interface GenerateQRImageInput

View File

@ -0,0 +1,52 @@
/* tslint:disable */
/* eslint-disable */
/**
* Admin.NET
* .NET <br/><u><b><font color='FF0000'> 👮</font></b></u>
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/**
* ()
*
* @export
* @interface GenerateQRImageUnLimitInput
*/
export interface GenerateQRImageUnLimitInput {
/**
* 128 eg: pages/index?id=0001
*
* @type {string}
* @memberof GenerateQRImageUnLimitInput
*/
pagePath?: string | null;
/**
*
*
* @type {string}
* @memberof GenerateQRImageUnLimitInput
*/
imageName?: string | null;
/**
* 430
*
* @type {number}
* @memberof GenerateQRImageUnLimitInput
*/
width?: number;
/**
* @type {string}
* @memberof GenerateQRImageUnLimitInput
*/
scene?: string | null;
}

View File

@ -241,6 +241,7 @@ export * from './gen-org-input';
export * from './gender-enum'; export * from './gender-enum';
export * from './generate-qrimage-input'; export * from './generate-qrimage-input';
export * from './generate-qrimage-output'; export * from './generate-qrimage-output';
export * from './generate-qrimage-un-limit-input';
export * from './generate-signature-input'; export * from './generate-signature-input';
export * from './generic-parameter-attributes'; export * from './generic-parameter-attributes';
export * from './get-refund-domestic-refund-by-out-refund-number-response'; export * from './get-refund-domestic-refund-by-out-refund-number-response';

View File

@ -38,20 +38,7 @@ export const useUserInfo = defineStore('userInfo', {
var dictList = await getAPI(SysDictTypeApi) var dictList = await getAPI(SysDictTypeApi)
.apiSysDictTypeAllDictListGet() .apiSysDictTypeAllDictListGet()
.then((res) => res.data.result ?? {}); .then((res) => res.data.result ?? {});
var dictListTemp = JSON.parse(JSON.stringify(dictList)); this.dictList = JSON.parse(JSON.stringify(dictList));
// await Promise.all(
// Object.keys(dictList).map(async (key) => {
// dictList[key].forEach((da: any, index: any) => {
// setDictLangMessageAsync(dictListTemp[key][index]);
// });
// // 如果 key 以 "Enum" 结尾,则转换 value 为数字
// if (key.endsWith('Enum')) {
// dictListTemp[key].forEach((e: any) => (e.value = Number(e.value)));
// }
// })
// );
this.dictList = dictListTemp;
}, },
// 存储用户表格列到浏览器缓存 // 存储用户表格列到浏览器缓存
@ -178,10 +165,3 @@ export const useUserInfo = defineStore('userInfo', {
}, },
}, },
}); });
// 处理字典国际化, 默认显示字典中的label值
const setDictLangMessageAsync = async (dict: any) => {
dict.langMessage = `message.dictType.${dict.typeCode}_${dict.value}`;
const text = t(dict.langMessage);
dict.label = text !== dict.langMessage ? text : dict.label;
};