This commit is contained in:
zhangjianjun 2026-08-26 18:25:16 +08:00
parent a2c8205dfe
commit fa5d736cae
6 changed files with 28 additions and 24 deletions

View File

@ -34,7 +34,7 @@ Native mini-program for map-label progress query. Pages in `src/app.config.ts`:
- API origin comes from `TARO_APP_API_ORIGIN`: `.env.development``http://corp-test.batiao8.com`, `.env.production``https://nb.zuom8.cn`.
- `x-host` prefers the H5 jump `host`, then `TARO_APP_API_HOST`.
- Map reverse geocode uses `TARO_APP_TIANDITU_KEY` against `api.tianditu.gov.cn` (add this request domain in WeChat admin).
- Missing launch query fields fall back to `DEFAULT_LAUNCH_SCHEME` in `src/lib/launch.ts` (`scene=/h/KZ9Q`, `host=nb.batiao8.com`, `package=10044`, `phone=17316703138`).
- Missing launch query fields fall back to `DEFAULT_LAUNCH_SCHEME` in `src/lib/launch.ts` (`scene=/h/KZ9Q`, `host=nb.batiao8.com`, `package=10044`).
- No token: `GET /api/user/config` then keep the returned guest token. Then `GET /api/h5/corp` for package/config.
- Shared client: `src/lib/request.ts` (same MD5 sign + AES decrypt as H5). Platform header is `wx-mp`.

View File

@ -14,15 +14,14 @@ describe('complaint types', () => {
})
describe('feedback image preview', () => {
it('prefers the uploaded URL over an Android temporary file path', () => {
it('uses the local preview path after upload, matching the storefront image preview', () => {
expect(getFeedbackImageSrc({
url: 'https://cdn.example/a.jpg',
preview: 'wxfile://tmp_android_a.jpg',
})).toBe('https://cdn.example/a.jpg')
preview: 'wxfile://tmp_a.jpg',
})).toBe('wxfile://tmp_a.jpg')
})
it('falls back to the local path before upload completes', () => {
expect(getFeedbackImageSrc({ preview: 'wxfile://tmp_a.jpg' })).toBe('wxfile://tmp_a.jpg')
it('does not use the private CDN URL for preview rendering', () => {
expect(getFeedbackImageSrc({ url: 'https://cdn.example/a.jpg' })).toBe('')
})
})

View File

@ -9,7 +9,7 @@ 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 || ''
return image.preview || ''
}
export type FeedbackOrder = {

View File

@ -12,10 +12,10 @@ describe('parseMiniProgramScheme', () => {
appId: 'wxf8a8961f30396c19',
path: 'pages/index/index',
scene: '/h/KZ9Q',
token: '6224a1fe-d88c-443c-8972-e6a0942d17fd',
token: '',
host: 'nb.batiao8.com',
package: '10044',
phone: '17316703138',
phone: '',
})
})
})
@ -65,14 +65,14 @@ describe('parseLaunchQuery', () => {
describe('resolveLaunchQuery', () => {
it('fills missing fields from the default scheme', () => {
expect(resolveLaunchQuery({})).toEqual({
token: '6224a1fe-d88c-443c-8972-e6a0942d17fd',
token: '',
host: 'nb.batiao8.com',
packageId: '10044',
scene: '/h/KZ9Q',
linkId: 'KZ9Q',
shareId: '',
prevId: '',
phone: '17316703138',
phone: '',
})
})
@ -96,7 +96,7 @@ describe('resolveLaunchQuery', () => {
linkId: '',
shareId: 'SHARE1',
prevId: '',
phone: '17316703138',
phone: '',
})
})
})

View File

@ -10,7 +10,7 @@ export type LaunchQuery = {
}
export const DEFAULT_LAUNCH_SCHEME =
'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'
'weixin://dl/business/?appid=wxf8a8961f30396c19&path=pages/index/index&query=scene%3D%2Fh%2FKZ9Q%26host%3Dnb.batiao8.com%26package%3D10044'
export function parseMiniProgramScheme (scheme: string) {
const search = scheme.split('?')[1] || ''

View File

@ -54,22 +54,27 @@ export default function ComplaintPage () {
const handleChooseImage = async () => {
if (uploading || images.length >= 5) return
const res = await Taro.chooseImage({
count: Math.max(1, 5 - images.length),
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
})
const paths = res.tempFilePaths || []
if (!paths.length) return
const filePath = res.tempFilePaths?.[0]
if (!filePath) return
setImages((current) => [
...current,
{ id: '', url: '', preview: filePath },
].slice(0, 5))
setUploading(true)
try {
const uploaded: UploadedImage[] = []
for (const filePath of paths) {
const result = await uploadImage(filePath)
uploaded.push({ id: result.id, url: result.url, preview: filePath })
}
setImages((current) => [...current, ...uploaded].slice(0, 5))
const result = await uploadImage(filePath)
setImages((current) => current.map((image) => (
image.preview === filePath
? { id: result.id, url: result.url, preview: filePath }
: image
)))
} catch (error) {
setImages((current) => current.filter((image) => image.preview !== filePath))
Taro.showToast({
title: error instanceof Error ? error.message : '图片上传失败',
icon: 'none',
@ -185,7 +190,7 @@ export default function ComplaintPage () {
</View>
<View className='complaint-uploads'>
{images.map((image, index) => (
<View className='complaint-upload' key={`${image.id}-${index}`}>
<View className='complaint-upload' key={image.preview || image.url || String(index)}>
<Image className='complaint-upload__image' src={getFeedbackImageSrc(image)} mode='aspectFill' />
<Image
className='complaint-upload__remove'