This commit is contained in:
parent
a2c8205dfe
commit
fa5d736cae
|
|
@ -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`.
|
- 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`.
|
- `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).
|
- 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.
|
- 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`.
|
- Shared client: `src/lib/request.ts` (same MD5 sign + AES decrypt as H5). Platform header is `wx-mp`.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,14 @@ describe('complaint types', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('feedback image preview', () => {
|
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({
|
expect(getFeedbackImageSrc({
|
||||||
url: 'https://cdn.example/a.jpg',
|
preview: 'wxfile://tmp_a.jpg',
|
||||||
preview: 'wxfile://tmp_android_a.jpg',
|
})).toBe('wxfile://tmp_a.jpg')
|
||||||
})).toBe('https://cdn.example/a.jpg')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('falls back to the local path before upload completes', () => {
|
it('does not use the private CDN URL for preview rendering', () => {
|
||||||
expect(getFeedbackImageSrc({ preview: 'wxfile://tmp_a.jpg' })).toBe('wxfile://tmp_a.jpg')
|
expect(getFeedbackImageSrc({ url: 'https://cdn.example/a.jpg' })).toBe('')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export const COMPLAINT_TYPES = [
|
||||||
export type ComplaintType = (typeof COMPLAINT_TYPES)[number]['value']
|
export type ComplaintType = (typeof COMPLAINT_TYPES)[number]['value']
|
||||||
|
|
||||||
export function getFeedbackImageSrc (image: { url?: string, preview?: string }) {
|
export function getFeedbackImageSrc (image: { url?: string, preview?: string }) {
|
||||||
return image.url || image.preview || ''
|
return image.preview || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FeedbackOrder = {
|
export type FeedbackOrder = {
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ describe('parseMiniProgramScheme', () => {
|
||||||
appId: 'wxf8a8961f30396c19',
|
appId: 'wxf8a8961f30396c19',
|
||||||
path: 'pages/index/index',
|
path: 'pages/index/index',
|
||||||
scene: '/h/KZ9Q',
|
scene: '/h/KZ9Q',
|
||||||
token: '6224a1fe-d88c-443c-8972-e6a0942d17fd',
|
token: '',
|
||||||
host: 'nb.batiao8.com',
|
host: 'nb.batiao8.com',
|
||||||
package: '10044',
|
package: '10044',
|
||||||
phone: '17316703138',
|
phone: '',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
@ -65,14 +65,14 @@ describe('parseLaunchQuery', () => {
|
||||||
describe('resolveLaunchQuery', () => {
|
describe('resolveLaunchQuery', () => {
|
||||||
it('fills missing fields from the default scheme', () => {
|
it('fills missing fields from the default scheme', () => {
|
||||||
expect(resolveLaunchQuery({})).toEqual({
|
expect(resolveLaunchQuery({})).toEqual({
|
||||||
token: '6224a1fe-d88c-443c-8972-e6a0942d17fd',
|
token: '',
|
||||||
host: 'nb.batiao8.com',
|
host: 'nb.batiao8.com',
|
||||||
packageId: '10044',
|
packageId: '10044',
|
||||||
scene: '/h/KZ9Q',
|
scene: '/h/KZ9Q',
|
||||||
linkId: 'KZ9Q',
|
linkId: 'KZ9Q',
|
||||||
shareId: '',
|
shareId: '',
|
||||||
prevId: '',
|
prevId: '',
|
||||||
phone: '17316703138',
|
phone: '',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ describe('resolveLaunchQuery', () => {
|
||||||
linkId: '',
|
linkId: '',
|
||||||
shareId: 'SHARE1',
|
shareId: 'SHARE1',
|
||||||
prevId: '',
|
prevId: '',
|
||||||
phone: '17316703138',
|
phone: '',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export type LaunchQuery = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_LAUNCH_SCHEME =
|
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) {
|
export function parseMiniProgramScheme (scheme: string) {
|
||||||
const search = scheme.split('?')[1] || ''
|
const search = scheme.split('?')[1] || ''
|
||||||
|
|
|
||||||
|
|
@ -54,22 +54,27 @@ export default function ComplaintPage () {
|
||||||
const handleChooseImage = async () => {
|
const handleChooseImage = async () => {
|
||||||
if (uploading || images.length >= 5) return
|
if (uploading || images.length >= 5) return
|
||||||
const res = await Taro.chooseImage({
|
const res = await Taro.chooseImage({
|
||||||
count: Math.max(1, 5 - images.length),
|
count: 1,
|
||||||
sizeType: ['compressed'],
|
sizeType: ['compressed'],
|
||||||
sourceType: ['album', 'camera'],
|
sourceType: ['album', 'camera'],
|
||||||
})
|
})
|
||||||
const paths = res.tempFilePaths || []
|
const filePath = res.tempFilePaths?.[0]
|
||||||
if (!paths.length) return
|
if (!filePath) return
|
||||||
|
|
||||||
|
setImages((current) => [
|
||||||
|
...current,
|
||||||
|
{ id: '', url: '', preview: filePath },
|
||||||
|
].slice(0, 5))
|
||||||
setUploading(true)
|
setUploading(true)
|
||||||
try {
|
try {
|
||||||
const uploaded: UploadedImage[] = []
|
const result = await uploadImage(filePath)
|
||||||
for (const filePath of paths) {
|
setImages((current) => current.map((image) => (
|
||||||
const result = await uploadImage(filePath)
|
image.preview === filePath
|
||||||
uploaded.push({ id: result.id, url: result.url, preview: filePath })
|
? { id: result.id, url: result.url, preview: filePath }
|
||||||
}
|
: image
|
||||||
setImages((current) => [...current, ...uploaded].slice(0, 5))
|
)))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
setImages((current) => current.filter((image) => image.preview !== filePath))
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: error instanceof Error ? error.message : '图片上传失败',
|
title: error instanceof Error ? error.message : '图片上传失败',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
|
|
@ -185,7 +190,7 @@ export default function ComplaintPage () {
|
||||||
</View>
|
</View>
|
||||||
<View className='complaint-uploads'>
|
<View className='complaint-uploads'>
|
||||||
{images.map((image, index) => (
|
{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__image' src={getFeedbackImageSrc(image)} mode='aspectFill' />
|
||||||
<Image
|
<Image
|
||||||
className='complaint-upload__remove'
|
className='complaint-upload__remove'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue