😎增加获取不受限制的小程序码的接口
This commit is contained in:
parent
882a588abb
commit
8a24a07d31
@ -21,7 +21,7 @@
|
||||
</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="AngleSharp" Version="1.2.0" />
|
||||
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
|
||||
|
||||
@ -144,7 +144,7 @@ public class VerifySignatureInput
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成带参数小程序二维码
|
||||
/// 生成带参数小程序二维码(总共生成的码数量限制为 100,000)
|
||||
/// </summary>
|
||||
public class GenerateQRImageInput
|
||||
{
|
||||
@ -163,3 +163,14 @@ public class GenerateQRImageInput
|
||||
/// </summary>
|
||||
public int Width { get; set; } = 430;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成带参数小程序二维码(获取不受限制的小程序码)
|
||||
/// </summary>
|
||||
public class GenerateQRImageUnLimitInput : GenerateQRImageInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 二维码携带的参数 eg:a=1(最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~)
|
||||
/// </summary>
|
||||
public string Scene { get; set; }
|
||||
}
|
||||
@ -263,11 +263,11 @@ public class SysWxOpenService : IDynamicApiController, ITransient
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成小程序二维码 🔖
|
||||
/// 生成带参数小程序二维码(总共生成的码数量限制为 100,000) 🔖
|
||||
/// </summary>
|
||||
/// <param name="input"> 扫码进入的小程序页面路径,最大长度 128 个字符,不能为空; eg: pages / index ? id = AY000001 </param>
|
||||
/// <returns></returns>
|
||||
[DisplayName("生成小程序二维码")]
|
||||
[DisplayName("生成带参数小程序二维码")]
|
||||
[ApiDescriptionSettings(Name = "GenerateQRImage")]
|
||||
public async Task<GenerateQRImageOutput> GenerateQRImageAsync(GenerateQRImageInput input)
|
||||
{
|
||||
@ -333,6 +333,83 @@ public class SysWxOpenService : IDynamicApiController, ITransient
|
||||
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>
|
||||
/// 获取Access_token
|
||||
/// </summary>
|
||||
|
||||
@ -24,6 +24,7 @@ import { AdminNETResultSysFile } from '../models';
|
||||
import { AdminNETResultWxOpenIdOutput } from '../models';
|
||||
import { AdminNETResultWxPhoneOutput } from '../models';
|
||||
import { GenerateQRImageInput } from '../models';
|
||||
import { GenerateQRImageUnLimitInput } from '../models';
|
||||
import { SendSubscribeMessageInput } from '../models';
|
||||
import { SetNickNameInput } 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 = AY000001
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
@ -129,6 +130,54 @@ export const SysWxOpenApiAxiosParamCreator = function (configuration?: Configura
|
||||
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 获取订阅消息模板列表 🔖
|
||||
@ -633,7 +682,7 @@ export const SysWxOpenApiFp = function(configuration?: Configuration) {
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 生成小程序二维码 🔖
|
||||
* @summary 生成带参数小程序二维码(总共生成的码数量限制为 100,000) 🔖
|
||||
* @param {GenerateQRImageInput} [body] 扫码进入的小程序页面路径,最大长度 128 个字符,不能为空; eg: pages / index ? id = AY000001
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
@ -645,6 +694,20 @@ export const SysWxOpenApiFp = function(configuration?: Configuration) {
|
||||
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 获取订阅消息模板列表 🔖
|
||||
@ -798,7 +861,7 @@ export const SysWxOpenApiFactory = function (configuration?: Configuration, base
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 生成小程序二维码 🔖
|
||||
* @summary 生成带参数小程序二维码(总共生成的码数量限制为 100,000) 🔖
|
||||
* @param {GenerateQRImageInput} [body] 扫码进入的小程序页面路径,最大长度 128 个字符,不能为空; eg: pages / index ? id = AY000001
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
@ -806,6 +869,16 @@ export const SysWxOpenApiFactory = function (configuration?: Configuration, base
|
||||
async apiSysWxOpenGenerateQRImagePost(body?: GenerateQRImageInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> {
|
||||
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 获取订阅消息模板列表 🔖
|
||||
@ -925,7 +998,7 @@ export class SysWxOpenApi extends BaseAPI {
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @summary 生成小程序二维码 🔖
|
||||
* @summary 生成带参数小程序二维码(总共生成的码数量限制为 100,000) 🔖
|
||||
* @param {GenerateQRImageInput} [body] 扫码进入的小程序页面路径,最大长度 128 个字符,不能为空; eg: pages / index ? id = AY000001
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
@ -934,6 +1007,17 @@ export class SysWxOpenApi extends BaseAPI {
|
||||
public async apiSysWxOpenGenerateQRImagePost(body?: GenerateQRImageInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultGenerateQRImageOutput>> {
|
||||
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 获取订阅消息模板列表 🔖
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* 生成带参数小程序二维码
|
||||
* 生成带参数小程序二维码(总共生成的码数量限制为 100,000)
|
||||
*
|
||||
* @export
|
||||
* @interface GenerateQRImageInput
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -241,6 +241,7 @@ export * from './gen-org-input';
|
||||
export * from './gender-enum';
|
||||
export * from './generate-qrimage-input';
|
||||
export * from './generate-qrimage-output';
|
||||
export * from './generate-qrimage-un-limit-input';
|
||||
export * from './generate-signature-input';
|
||||
export * from './generic-parameter-attributes';
|
||||
export * from './get-refund-domestic-refund-by-out-refund-number-response';
|
||||
|
||||
@ -38,20 +38,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
var dictList = await getAPI(SysDictTypeApi)
|
||||
.apiSysDictTypeAllDictListGet()
|
||||
.then((res) => res.data.result ?? {});
|
||||
var dictListTemp = 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;
|
||||
this.dictList = JSON.parse(JSON.stringify(dictList));
|
||||
},
|
||||
|
||||
// 存储用户表格列到浏览器缓存
|
||||
@ -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;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user