Merge branch 'aigc' of https://git.nianxx.cn/zoujing/YGChatCS into home3.0

This commit is contained in:
2026-07-23 15:07:48 +08:00
5 changed files with 39 additions and 21 deletions

View File

@@ -32,6 +32,7 @@ import { onLoad, onShareAppMessage, onShow } from "@dcloudio/uni-app";
import Privacy from "@/components/Privacy/index.vue"; import Privacy from "@/components/Privacy/index.vue";
import AigcTopBar from "@/pages-aigc/components/AigcTopBar/index.vue"; import AigcTopBar from "@/pages-aigc/components/AigcTopBar/index.vue";
import { useCurrentCredit } from "@/pages-aigc/hooks/useCurrentCredit.js"; import { useCurrentCredit } from "@/pages-aigc/hooks/useCurrentCredit.js";
import { getWechatLoginCode } from "@/pages-aigc/services/wechatLogin.js";
import { import {
createAigcGeneratorTask, createAigcGeneratorTask,
createAigcGeneratorTaskShare, createAigcGeneratorTaskShare,
@@ -535,9 +536,11 @@ const handleConfirmRegenerate = async () => {
}); });
try { try {
const wxLoginCode = await getWechatLoginCode();
const res = await createAigcGeneratorTask({ const res = await createAigcGeneratorTask({
templateItemId, templateItemId,
imageUrlList: [imageResultUrl], imageUrlList: [imageResultUrl],
wxLoginCode,
}); });
const nextTaskId = String(res?.data || "").trim(); const nextTaskId = String(res?.data || "").trim();

View File

@@ -3,6 +3,8 @@ import {
normalizeWechatClientPlatform, normalizeWechatClientPlatform,
} from "../utils/virtualRecharge.js"; } from "../utils/virtualRecharge.js";
export { getWechatLoginCode } from "../../services/wechatLogin.js";
const MIN_VIRTUAL_PAYMENT_SDK_VERSION = "2.19.2"; const MIN_VIRTUAL_PAYMENT_SDK_VERSION = "2.19.2";
const getWechatApi = () => { const getWechatApi = () => {
@@ -65,26 +67,6 @@ export function getWechatClientPlatform(wechatApi = getWechatApi()) {
return clientPlatform; return clientPlatform;
} }
export function getWechatLoginCode(wechatApi = getWechatApi()) {
if (!wechatApi || typeof wechatApi.login !== "function") {
return Promise.reject(new Error("当前环境无法获取微信登录凭证"));
}
return new Promise((resolve, reject) => {
wechatApi.login({
success: (result) => {
const code = String(result?.code || "").trim();
if (code) {
resolve(code);
return;
}
reject(new Error("微信登录凭证获取失败"));
},
fail: () => reject(new Error("微信登录凭证获取失败")),
});
});
}
export function requestWechatVirtualPayment(paymentData, wechatApi = getWechatApi()) { export function requestWechatVirtualPayment(paymentData, wechatApi = getWechatApi()) {
assertWechatVirtualPaymentCapability(wechatApi); assertWechatVirtualPaymentCapability(wechatApi);
const order = normalizeVirtualPaymentOrder(paymentData); const order = normalizeVirtualPaymentOrder(paymentData);

View File

@@ -0,0 +1,26 @@
const getWechatApi = () => {
// #ifdef MP-WEIXIN
if (typeof wx !== "undefined") return wx;
// #endif
return null;
};
export function getWechatLoginCode(wechatApi = getWechatApi()) {
if (!wechatApi || typeof wechatApi.login !== "function") {
return Promise.reject(new Error("当前环境无法获取微信登录凭证"));
}
return new Promise((resolve, reject) => {
wechatApi.login({
success: (result) => {
const code = String(result?.code || "").trim();
if (code) {
resolve(code);
return;
}
reject(new Error("微信登录凭证获取失败"));
},
fail: () => reject(new Error("微信登录凭证获取失败")),
});
});
}

View File

@@ -46,6 +46,7 @@ import { onLoad, onShow } from "@dcloudio/uni-app";
import Privacy from "@/components/Privacy/index.vue"; import Privacy from "@/components/Privacy/index.vue";
import AigcTopBar from "@/pages-aigc/components/AigcTopBar/index.vue"; import AigcTopBar from "@/pages-aigc/components/AigcTopBar/index.vue";
import { useCurrentCredit } from "@/pages-aigc/hooks/useCurrentCredit.js"; import { useCurrentCredit } from "@/pages-aigc/hooks/useCurrentCredit.js";
import { getWechatLoginCode } from "@/pages-aigc/services/wechatLogin.js";
import { import {
createAigcGeneratorTask, createAigcGeneratorTask,
getAigcTemplateItemList, getAigcTemplateItemList,
@@ -356,9 +357,11 @@ const handleGenerate = async () => {
}); });
try { try {
const wxLoginCode = await getWechatLoginCode();
const res = await createAigcGeneratorTask({ const res = await createAigcGeneratorTask({
templateItemId, templateItemId,
imageUrlList: [uploadedImageUrl.value], imageUrlList: [uploadedImageUrl.value],
wxLoginCode,
}); });
const taskId = String(res?.data || "").trim(); const taskId = String(res?.data || "").trim();

View File

@@ -17,7 +17,11 @@ function getAigcGeneratorTaskDetail(args) {
} }
function createAigcGeneratorTask(args) { function createAigcGeneratorTask(args) {
return request.post("/hotelBiz/aigcGeneratorTask/createAigcGeneratorTask", args); return request.post(
"/hotelBiz/aigcGeneratorTask/createAigcGeneratorTask",
args,
{ sensitive: true }
);
} }
function getCurrentCredit() { function getCurrentCredit() {