diff --git a/AGENTS.md b/AGENTS.md index 28395f1..fd5408d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,7 +17,7 @@ pnpm dev:h5 / build:h5 # H5 target Other targets follow `pnpm dev:` / `pnpm build:` (`alipay`, `swan`, `tt`, `qq`, `jd`, `rn`, `harmony-hybrid`). -**Running the mini-program:** builds output to `./dist`. Open `./dist` in WeChat DevTools (`project.config.json` already points `miniprogramRoot` there; appId `wx6d4f6f29c41aff93`). +**Running the mini-program:** builds output to `./dist`. Open `./dist` in WeChat DevTools (`project.config.json` already points `miniprogramRoot` there; appId `wxf8a8961f30396c19`). **There is no test runner and no lint script in `package.json`.** ESLint (`taro/react`) and Stylelint are configured but run manually. The only enforced gate is a Husky `commit-msg` hook running **commitlint** (Conventional Commits) — non-conforming commit messages are rejected. diff --git a/project.config.json b/project.config.json index e72c835..2f9e575 100644 --- a/project.config.json +++ b/project.config.json @@ -2,7 +2,7 @@ "miniprogramRoot": "./dist", "projectname": "corp-mp", "description": "", - "appid": "wx6d4f6f29c41aff93", + "appid": "wxf8a8961f30396c19", "setting": { "urlCheck": true, "es6": false, diff --git a/src/lib/feedback.test.ts b/src/lib/feedback.test.ts index d3f0295..74fa79c 100644 --- a/src/lib/feedback.test.ts +++ b/src/lib/feedback.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { buildFeedbackPayload, COMPLAINT_TYPES } from './feedback' +import { buildFeedbackPayload, COMPLAINT_TYPES, getFeedbackImageSrc } from './feedback' describe('complaint types', () => { it('uses the five Chinese labels from the design as type values', () => { @@ -13,6 +13,19 @@ describe('complaint types', () => { }) }) +describe('feedback image preview', () => { + it('prefers the uploaded URL over an Android temporary file path', () => { + expect(getFeedbackImageSrc({ + url: 'https://cdn.example/a.jpg', + preview: 'wxfile://tmp_android_a.jpg', + })).toBe('https://cdn.example/a.jpg') + }) + + it('falls back to the local path before upload completes', () => { + expect(getFeedbackImageSrc({ preview: 'wxfile://tmp_a.jpg' })).toBe('wxfile://tmp_a.jpg') + }) +}) + describe('buildFeedbackPayload', () => { it('sends contact, content, images, Chinese type and order identifiers', () => { expect(buildFeedbackPayload({ diff --git a/src/lib/feedback.ts b/src/lib/feedback.ts index edd3888..88be2ea 100644 --- a/src/lib/feedback.ts +++ b/src/lib/feedback.ts @@ -8,6 +8,10 @@ export const COMPLAINT_TYPES = [ export type ComplaintType = (typeof COMPLAINT_TYPES)[number]['value'] +export function getFeedbackImageSrc (image: { url?: string, preview?: string }) { + return image.url || image.preview || '' +} + export type FeedbackOrder = { order_id?: string out_trade_no?: string diff --git a/src/lib/launch.test.ts b/src/lib/launch.test.ts index a3c8b3e..feab87a 100644 --- a/src/lib/launch.test.ts +++ b/src/lib/launch.test.ts @@ -9,7 +9,7 @@ import { describe('parseMiniProgramScheme', () => { it('reads the default weixin business scheme query', () => { expect(parseMiniProgramScheme(DEFAULT_LAUNCH_SCHEME)).toEqual({ - appId: 'wx6d4f6f29c41aff93', + appId: 'wxf8a8961f30396c19', path: 'pages/index/index', scene: '/h/KZ9Q', token: '6224a1fe-d88c-443c-8972-e6a0942d17fd', diff --git a/src/lib/launch.ts b/src/lib/launch.ts index 98c1185..709c0fc 100644 --- a/src/lib/launch.ts +++ b/src/lib/launch.ts @@ -10,7 +10,7 @@ export type LaunchQuery = { } export const DEFAULT_LAUNCH_SCHEME = - 'weixin://dl/business/?appid=wx6d4f6f29c41aff93&path=pages/index/index&query=scene%3D%2Fh%2FKZ9Q%26token%3D6224a1fe-d88c-443c-8972-e6a0942d17fd%26host%3Dnb.batiao8.com%26package%3D10044%26phone%3D17316703138' + 'weixin://dl/business/?appid=wxf8a8961f30396c19&path=pages/index/index&query=scene%3D%2Fh%2FKZ9Q%26token%3D6224a1fe-d88c-443c-8972-e6a0942d17fd%26host%3Dnb.batiao8.com%26package%3D10044%26phone%3D17316703138' export function parseMiniProgramScheme (scheme: string) { const search = scheme.split('?')[1] || '' diff --git a/src/pages/complaint/index.tsx b/src/pages/complaint/index.tsx index 97918bc..41968ee 100644 --- a/src/pages/complaint/index.tsx +++ b/src/pages/complaint/index.tsx @@ -3,7 +3,7 @@ import Taro, { useLoad } from '@tarojs/taro' import { useState } from 'react' import { report, uploadImage } from '@/api/user' import { LOCAL_IMAGES } from '@/lib/assets' -import { buildFeedbackPayload, COMPLAINT_TYPES, type ComplaintType } from '@/lib/feedback' +import { buildFeedbackPayload, COMPLAINT_TYPES, getFeedbackImageSrc, type ComplaintType } from '@/lib/feedback' import { getOrderDraft } from '@/lib/orderDraft' import { getOrderDisplayName, type OrderLike, type UploadedImage } from '@/lib/order' import './index.scss' @@ -186,7 +186,7 @@ export default function ComplaintPage () { {images.map((image, index) => ( - + { + async function queryOrders (phone: string) { if (!phone) { Taro.showToast({ title: '请输入联系电话', icon: 'none' }) return