|
|
@@ -4,6 +4,39 @@ import { Post } from "../../../../lib/request/method";
|
|
|
|
|
|
// module/chats/pages/analysis/analysis.ts
|
|
|
|
|
|
+interface IAnalysisData {
|
|
|
+ _lastResetTime: number;
|
|
|
+ uploadList: Array<{
|
|
|
+ target: string;
|
|
|
+ required: boolean;
|
|
|
+ label: string;
|
|
|
+ src: string;
|
|
|
+ }>;
|
|
|
+ thumbnail: string[];
|
|
|
+ original: string[];
|
|
|
+ status: boolean[];
|
|
|
+ _queue: Record<string, any>;
|
|
|
+ activeObj: Record<string, any>;
|
|
|
+ followObj: Record<string, any>;
|
|
|
+ workId: number;
|
|
|
+}
|
|
|
+
|
|
|
+interface IAnalysisProperties {
|
|
|
+ messageType: number;
|
|
|
+}
|
|
|
+
|
|
|
+type IAnalysisInstance = WechatMiniprogram.Component.Instance<
|
|
|
+ IAnalysisData,
|
|
|
+ IAnalysisProperties,
|
|
|
+ {
|
|
|
+ handle(event: WechatMiniprogram.TouchEvent): void;
|
|
|
+ _chooseMedia(index: number): Promise<string | null>;
|
|
|
+ _deleteMedia(index: number): void;
|
|
|
+ _uploadMedia(index: number, src?: string): void;
|
|
|
+ onSubmit(): Promise<void>;
|
|
|
+ }
|
|
|
+>;
|
|
|
+
|
|
|
Component({
|
|
|
behaviors: [PageContainerBehavior],
|
|
|
options: {},
|
|
|
@@ -11,6 +44,7 @@ Component({
|
|
|
messageType: { type: Number, value: 0 },
|
|
|
},
|
|
|
data: {
|
|
|
+ _lastResetTime: 0,
|
|
|
uploadList: [
|
|
|
{
|
|
|
target: "tongueImgUrl",
|
|
|
@@ -27,7 +61,7 @@ Component({
|
|
|
{
|
|
|
target: "faceImgUrl",
|
|
|
required: false,
|
|
|
- label: "面部图",
|
|
|
+ label: "正面面部图",
|
|
|
src: "../../assets/face-1.png",
|
|
|
},
|
|
|
],
|
|
|
@@ -46,6 +80,16 @@ Component({
|
|
|
followObj: wx.getStorageSync("followObj"),
|
|
|
workId: wx.getStorageSync("workId"),
|
|
|
});
|
|
|
+ // 确保按钮初始状态可用
|
|
|
+ setTimeout(() => {
|
|
|
+ console.log('[Analysis] Initializing button state...');
|
|
|
+ const submitBtn = this.selectComponent('#submitBtn');
|
|
|
+ console.log('[Analysis] Found submit button:', submitBtn);
|
|
|
+ if (submitBtn) {
|
|
|
+ console.log('[Analysis] Resetting button state');
|
|
|
+ submitBtn.resetState();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
},
|
|
|
methods: {
|
|
|
handle(event: WechatMiniprogram.TouchEvent) {
|
|
|
@@ -111,17 +155,51 @@ Component({
|
|
|
});
|
|
|
},
|
|
|
async onSubmit() {
|
|
|
+ console.log('[Analysis] Submit started');
|
|
|
+ const submitBtn = this.selectComponent('#submitBtn');
|
|
|
+ console.log('[Analysis] Found submit button:', submitBtn);
|
|
|
+
|
|
|
+ // Check if enough time has passed since the last reset
|
|
|
+ const now = Date.now();
|
|
|
+ if (now - this.data._lastResetTime < 100) {
|
|
|
+ console.log('[Analysis] Skipping disable - too soon after reset');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 开始提交时禁用按钮
|
|
|
+ if (submitBtn) {
|
|
|
+ console.log('[Analysis] Disabling button');
|
|
|
+ submitBtn.setData({ isDisabled: true });
|
|
|
+ }
|
|
|
+
|
|
|
const data = {
|
|
|
thumbnail: [] as any,
|
|
|
source: [] as any,
|
|
|
};
|
|
|
+
|
|
|
+ // 验证前重置按钮状态
|
|
|
+ const resetButton = () => {
|
|
|
+ console.log('[Analysis] Resetting button state');
|
|
|
+ const btn = this.selectComponent('#submitBtn');
|
|
|
+ console.log('[Analysis] Found submit button:', btn);
|
|
|
+ if (btn) {
|
|
|
+ this.setData({ _lastResetTime: Date.now() });
|
|
|
+ console.log('[Analysis] Calling resetState');
|
|
|
+ btn.resetState();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
for (let index = 0; index < this.data.uploadList.length; index++) {
|
|
|
const item = this.data.uploadList[index];
|
|
|
if (this.data._queue[index]) {
|
|
|
+ console.log('[Analysis] Upload in progress, resetting button');
|
|
|
wx.showToast({ title: `请等待图片上传完毕`, icon: "none" });
|
|
|
+ resetButton();
|
|
|
return;
|
|
|
} else if (item.required && !this.data.original[index]) {
|
|
|
+ console.log('[Analysis] Missing required image, resetting button');
|
|
|
wx.showToast({ title: `请上传${item.label}`, icon: "none" });
|
|
|
+ resetButton();
|
|
|
return;
|
|
|
}
|
|
|
if (this.data.original[index])
|
|
|
@@ -169,7 +247,9 @@ Component({
|
|
|
this.getOpenerEventChannel().emit("update", data);
|
|
|
wx.navigateBack();
|
|
|
} catch (error) {
|
|
|
- wx.showToast({ title: error.errMsg, icon: "error" });
|
|
|
+ console.log('[Analysis] Submit failed, resetting button');
|
|
|
+ wx.showToast({ title: error?.errMsg ?? "提交失败", icon: "none" });
|
|
|
+ resetButton();
|
|
|
}
|
|
|
} else {
|
|
|
// 对话管家
|