feat: 本次提交更新内容如下
弹窗二维码搞定
This commit is contained in:
40
Cunkebao/.eslintrc.js
Normal file
40
Cunkebao/.eslintrc.js
Normal file
@@ -0,0 +1,40 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint', 'react'],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:react/recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'react-app',
|
||||
'react-app/jest',
|
||||
],
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
|
||||
],
|
||||
'react/prop-types': 'off',
|
||||
'no-console': 'warn',
|
||||
'no-debugger': 'warn',
|
||||
},
|
||||
ignorePatterns: ['node_modules/', 'build/', 'dist/'],
|
||||
};
|
||||
@@ -315,14 +315,13 @@ export async function updateScenarioPlan(planId: number | string, data: any) {
|
||||
* @param taskid 任务ID
|
||||
* @returns base64二维码
|
||||
*/
|
||||
export const getWxMinAppCode = async (taskId: string): Promise<{ code: number; base64?: string; msg?: string }> => {
|
||||
export const getWxMinAppCode = async (taskId: string): Promise<{ code: number; data?: string; msg?: string }> => {
|
||||
try {
|
||||
return await get<{ code: number; base64?: string; msg?: string }>(
|
||||
return await get<{ code: number; data?: string; msg?: string }>(
|
||||
`/v1/plan/getWxMinAppCode?taskId=${ taskId }`,
|
||||
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('获取小程序二维码失败:', error);
|
||||
return { code: 500, msg: '获取小程序二维码失败' };
|
||||
}
|
||||
};
|
||||
@@ -71,7 +71,6 @@ export default function ScenarioDetail() {
|
||||
const [showQrDialog, setShowQrDialog] = useState(false);
|
||||
const [qrLoading, setQrLoading] = useState(false);
|
||||
const [qrImg, setQrImg] = useState("");
|
||||
const [qrTaskId, setQrTaskId] = useState("");
|
||||
|
||||
// 获取渠道中文名称
|
||||
const getChannelName = (channel: string) => {
|
||||
@@ -257,29 +256,6 @@ export default function ScenarioDetail() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleStatusChange = async (taskId: string, newStatus: 1 | 0) => {
|
||||
try {
|
||||
// 这里应该调用状态切换API,暂时模拟
|
||||
setTasks((prev) =>
|
||||
prev.map((task) =>
|
||||
task.id === taskId ? { ...task, status: newStatus } : task
|
||||
)
|
||||
);
|
||||
|
||||
toast({
|
||||
title: "状态已更新",
|
||||
description: `计划已${newStatus === 1 ? "启动" : "暂停"}`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("状态切换失败:", error);
|
||||
toast({
|
||||
title: "状态切换失败",
|
||||
description: "请稍后重试",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenApiSettings = async (taskId: string) => {
|
||||
try {
|
||||
const response = await fetchPlanDetail(taskId);
|
||||
@@ -318,18 +294,17 @@ export default function ScenarioDetail() {
|
||||
};
|
||||
|
||||
const handleShowQrCode = async (taskId: string) => {
|
||||
setQrTaskId(taskId);
|
||||
setShowQrDialog(true);
|
||||
setQrLoading(true);
|
||||
setQrImg("");
|
||||
try {
|
||||
const data = await getWxMinAppCode(taskId);
|
||||
if (data && data.base64) {
|
||||
setQrImg(`data:image/png;base64,${data.base64}`);
|
||||
const res = await getWxMinAppCode(taskId);
|
||||
if (res.data) {
|
||||
setQrImg(res.data);
|
||||
} else {
|
||||
toast({
|
||||
title: "获取二维码失败",
|
||||
description: data?.msg || "未知错误",
|
||||
description: res?.msg || "未知错误",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
@@ -708,7 +683,6 @@ export default function ScenarioDetail() {
|
||||
<span className="text-2xl">×</span>
|
||||
</button>
|
||||
<div className="mb-4 flex flex-col items-center">
|
||||
<QrCode className="h-8 w-8 text-blue-600 mb-2" />
|
||||
<div className="text-lg font-semibold mb-1">小程序二维码</div>
|
||||
<div className="text-gray-500 text-xs mb-2">
|
||||
可扫码进入对应计划
|
||||
|
||||
Reference in New Issue
Block a user