Merge pull request 'Dev' (#107) from dev into sit
自动发布测试环境 Nacos 配置 / publish (push) Successful in 30s
自动发布测试环境 Nacos 配置 / publish (push) Successful in 30s
Reviewed-on: #107
This commit was merged in pull request #107.
This commit is contained in:
-3
@@ -390,7 +390,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
String validatedPhone = validateUserPhone(userDTO.getPhone(), null, true);
|
||||
Integer userType = userDTO.getType();
|
||||
String validatedWechatId = UserProfileFieldSupport.normalizeOptionalText(userDTO.getWechatId());
|
||||
UserProfileFieldSupport.requireWechatIdForServiceUser(userType, validatedWechatId);
|
||||
|
||||
/**
|
||||
* Run business method `ensureShopBindingRequirement`.
|
||||
@@ -598,7 +597,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
userDO.setVipId(userDTO.getVipId());
|
||||
}
|
||||
Integer targetUserType = userDO.getType();
|
||||
UserProfileFieldSupport.requireWechatIdForServiceUser(targetUserType, userDO.getWechatId());
|
||||
List<Long> validatedShopIds = null;
|
||||
boolean shopBindingChanged = userDTO.getShopIds() != null || userDTO.getShopId() != null;
|
||||
if (shopBindingChanged) {
|
||||
@@ -1732,7 +1730,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
if (userDTO.getWechatQrCode() != null) {
|
||||
userDO.setWechatQrCode(normalizeStoredProfileImage(userDTO.getWechatQrCode()));
|
||||
}
|
||||
UserProfileFieldSupport.requireWechatIdForServiceUser(userDO.getType(), userDO.getWechatId());
|
||||
|
||||
userDO.setUpdateTime(LocalDateTime.now());
|
||||
boolean updated = userMapper.updateById(userDO) > 0;
|
||||
|
||||
-7
@@ -13,11 +13,4 @@ public final class UserProfileFieldSupport {
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
public static void requireWechatIdForServiceUser(Integer userType, String wechatId) {
|
||||
if ((Integer.valueOf(2).equals(userType) || Integer.valueOf(3).equals(userType))
|
||||
&& !StringUtils.hasText(wechatId)) {
|
||||
throw new IllegalArgumentException("店长和美甲师的微信号不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,8 +193,8 @@
|
||||
<a-form-item label="生日">
|
||||
<a-input v-model:value="editForm.birthday" type="date" style="width: 100%" />
|
||||
</a-form-item>
|
||||
<a-form-item label="微信号" :required="isServiceUser">
|
||||
<a-input v-model:value="editForm.wechatId" placeholder="请输入微信号" />
|
||||
<a-form-item label="微信号">
|
||||
<a-input v-model:value="editForm.wechatId" placeholder="选填" />
|
||||
</a-form-item>
|
||||
<a-form-item label="微信二维码">
|
||||
<div class="qr-upload-section">
|
||||
@@ -211,7 +211,7 @@
|
||||
<a-button v-if="editForm.wechatQrCode" type="text" danger size="small" @click="handleDeleteWechatQr">
|
||||
删除二维码
|
||||
</a-button>
|
||||
<small v-if="isServiceUser">店长和美甲师需填写微信号,二维码可选。</small>
|
||||
<small v-if="isServiceUser">微信号与二维码均为选填。</small>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
@@ -738,11 +738,6 @@ const handleSaveProfile = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
if (isServiceUser.value && !editForm.wechatId.trim()) {
|
||||
message.error('店长和美甲师必须填写微信号')
|
||||
return
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
await runWithGlobalLoading(async () => {
|
||||
|
||||
+2
-5
@@ -809,14 +809,11 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
String title = trimToNull(dto.getManualProductTitle());
|
||||
String imageFileIds = trimToNull(dto.getManualProductImageFileIds());
|
||||
if (!hasText(title)) {
|
||||
title = firstNonBlank(dto.getCustomerName(), hasText(imageFileIds) ? "散客款式" : null);
|
||||
}
|
||||
if (!hasText(title) && !hasText(imageFileIds)) {
|
||||
throw new RuntimeException("请填写美甲款式名称或上传款式图片");
|
||||
throw new RuntimeException("请填写美甲款式名称");
|
||||
}
|
||||
BigDecimal price = dto.getManualProductPrice() == null ? dto.getAmount() : dto.getManualProductPrice();
|
||||
if (price == null) {
|
||||
throw new RuntimeException("成交金额不能为空");
|
||||
price = BigDecimal.ZERO;
|
||||
}
|
||||
if (price.compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new RuntimeException("成交金额不能小于0");
|
||||
|
||||
+3
-2
@@ -451,7 +451,7 @@ class PlanningServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsWalkInAppointmentWithoutCustomerUsingWalkInStyleTitle() {
|
||||
void createsWalkInAppointmentWithManualStyleTitle() {
|
||||
service = spy(service);
|
||||
UserDO operator = new UserDO();
|
||||
operator.setType(2);
|
||||
@@ -481,6 +481,7 @@ class PlanningServiceImplTest {
|
||||
|
||||
PlanningAppointmentCreateDTO dto = new PlanningAppointmentCreateDTO();
|
||||
dto.setCreateCustomerRecord(false);
|
||||
dto.setManualProductTitle("手绘款");
|
||||
dto.setManualProductImageFileIds("file-43");
|
||||
dto.setAmount(java.math.BigDecimal.valueOf(88));
|
||||
dto.setAppointmentDate(java.time.LocalDate.now().plusDays(2).toString());
|
||||
@@ -491,7 +492,7 @@ class PlanningServiceImplTest {
|
||||
|
||||
ArgumentCaptor<ProductDO> productCaptor = ArgumentCaptor.forClass(ProductDO.class);
|
||||
verify(productMapper).insert(productCaptor.capture());
|
||||
assertEquals("散客款式", productCaptor.getValue().getTitle());
|
||||
assertEquals("手绘款", productCaptor.getValue().getTitle());
|
||||
|
||||
ArgumentCaptor<OrderDO> orderCaptor = ArgumentCaptor.forClass(OrderDO.class);
|
||||
verify(orderMapper).insert(orderCaptor.capture());
|
||||
|
||||
+11
-7
@@ -2,19 +2,23 @@ package com.xiaowang.jayucloud.salon.core.modules.user.support;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class UserProfileFieldSupportTest {
|
||||
|
||||
/**
|
||||
* 微信号已改为选填:空值与空白统一归一为 null,不再抛出必填异常。
|
||||
*/
|
||||
@Test
|
||||
void nailArtistWechatIdIsOptional() {
|
||||
assertDoesNotThrow(() -> UserProfileFieldSupport.requireWechatIdForServiceUser(3, null));
|
||||
void blankWechatIdIsNormalizedToNull() {
|
||||
assertNull(UserProfileFieldSupport.normalizeOptionalText(null));
|
||||
assertNull(UserProfileFieldSupport.normalizeOptionalText(""));
|
||||
assertNull(UserProfileFieldSupport.normalizeOptionalText(" "));
|
||||
}
|
||||
|
||||
@Test
|
||||
void managerWechatIdRemainsRequired() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> UserProfileFieldSupport.requireWechatIdForServiceUser(2, null));
|
||||
void nonBlankWechatIdIsTrimmed() {
|
||||
assertEquals("wx_123", UserProfileFieldSupport.normalizeOptionalText(" wx_123 "));
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+7
@@ -13,6 +13,7 @@
|
||||
"ant-design-vue": "^4.2.6",
|
||||
"axios": "^1.13.5",
|
||||
"element-plus": "^2.13.2",
|
||||
"heic2any": "^0.0.4",
|
||||
"pinia": "^3.0.4",
|
||||
"vue": "^3.5.25",
|
||||
"vue-router": "^4.6.4"
|
||||
@@ -2693,6 +2694,12 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/heic2any": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/heic2any/-/heic2any-0.0.4.tgz",
|
||||
"integrity": "sha512-3lLnZiDELfabVH87htnRolZ2iehX9zwpRyGNz22GKXIu0fznlblf0/ftppXKNqS26dqFSeqfIBhAmAj/uSp0cA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/hookable": {
|
||||
"version": "5.5.3",
|
||||
"resolved": "https://registry.npmmirror.com/hookable/-/hookable-5.5.3.tgz",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"ant-design-vue": "^4.2.6",
|
||||
"axios": "^1.13.5",
|
||||
"element-plus": "^2.13.2",
|
||||
"heic2any": "^0.0.4",
|
||||
"pinia": "^3.0.4",
|
||||
"vue": "^3.5.25",
|
||||
"vue-router": "^4.6.4"
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { createChunkUploadTask, type ChunkUploadApi } from './chunk-upload'
|
||||
import {
|
||||
assertChunkUploadFileSize,
|
||||
CHUNK_UPLOAD_TOO_LARGE_MESSAGE,
|
||||
MAX_CHUNK_UPLOAD_TOTAL_SIZE,
|
||||
createChunkUploadTask,
|
||||
shouldUseChunkUpload,
|
||||
type ChunkUploadApi
|
||||
} from './chunk-upload'
|
||||
|
||||
const createFile = (size: number) => new File([new Uint8Array(size)], 'large.png', {
|
||||
type: 'image/png',
|
||||
lastModified: 1
|
||||
})
|
||||
|
||||
const createFileWithSize = (size: number) => {
|
||||
const file = createFile(1)
|
||||
Object.defineProperty(file, 'size', { value: size })
|
||||
return file
|
||||
}
|
||||
|
||||
describe('chunk-upload', () => {
|
||||
it('uploads chunks with the requested concurrency', async () => {
|
||||
const releaseCallbacks: Array<() => void> = []
|
||||
@@ -81,4 +94,18 @@ describe('chunk-upload', () => {
|
||||
expect.any(Object)
|
||||
)
|
||||
})
|
||||
|
||||
it('小文件走直传,超过 5MB 走分片', () => {
|
||||
const fiveMb = 5 * 1024 * 1024
|
||||
|
||||
expect(shouldUseChunkUpload(createFileWithSize(fiveMb - 1))).toBe(false)
|
||||
expect(shouldUseChunkUpload(createFileWithSize(fiveMb))).toBe(false)
|
||||
expect(shouldUseChunkUpload(createFileWithSize(fiveMb + 1))).toBe(true)
|
||||
})
|
||||
|
||||
it('分片总量超过 500MB 才提示', () => {
|
||||
expect(() => assertChunkUploadFileSize(createFileWithSize(MAX_CHUNK_UPLOAD_TOTAL_SIZE))).not.toThrow()
|
||||
expect(() => assertChunkUploadFileSize(createFileWithSize(MAX_CHUNK_UPLOAD_TOTAL_SIZE + 1)))
|
||||
.toThrow(CHUNK_UPLOAD_TOO_LARGE_MESSAGE)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
import type { AxiosProgressEvent } from 'axios'
|
||||
import { MAX_IMAGE_UPLOAD_SIZE } from '@/utils/image-upload'
|
||||
import { convertHeicToJpegFile } from '@/utils/heic-image'
|
||||
|
||||
/** 单文件超过直传上限(Nacos max-file-size 5MB)时改走分片上传。 */
|
||||
export const shouldUseChunkUpload = (file: File) => file.size > MAX_IMAGE_UPLOAD_SIZE
|
||||
|
||||
/** 分片任务总量上限,与后端 UploadSecurityProperties.maxTotalSize 一致。 */
|
||||
export const MAX_CHUNK_UPLOAD_TOTAL_SIZE = 500 * 1024 * 1024
|
||||
export const CHUNK_UPLOAD_TOO_LARGE_MESSAGE = '图片超过 500MB 上限,请压缩后上传'
|
||||
|
||||
export const assertChunkUploadFileSize = (file: File) => {
|
||||
if (file.size > MAX_CHUNK_UPLOAD_TOTAL_SIZE) {
|
||||
throw new Error(CHUNK_UPLOAD_TOO_LARGE_MESSAGE)
|
||||
}
|
||||
}
|
||||
|
||||
/** 分片前的统一预处理:HEIC/HEIF 先转 JPEG,再校验分片总量上限。 */
|
||||
export const prepareChunkUploadFile = async (file: File) => {
|
||||
const prepared = await convertHeicToJpegFile(file)
|
||||
assertChunkUploadFileSize(prepared)
|
||||
return prepared
|
||||
}
|
||||
|
||||
export interface ChunkUploadSession {
|
||||
uploadId: string
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const convertMock = vi.hoisted(() => vi.fn())
|
||||
|
||||
vi.mock('heic2any', () => ({
|
||||
default: convertMock
|
||||
}))
|
||||
|
||||
import {
|
||||
convertHeicToJpegFile,
|
||||
HEIC_CONVERT_FAILED_MESSAGE,
|
||||
isHeicFile
|
||||
} from './heic-image'
|
||||
|
||||
const createHeicFile = (name = 'live.heic', type = 'image/heic') => new File(
|
||||
[new Uint8Array(8)],
|
||||
name,
|
||||
{ type, lastModified: 1 }
|
||||
)
|
||||
|
||||
describe('heic-image', () => {
|
||||
beforeEach(() => {
|
||||
convertMock.mockReset()
|
||||
})
|
||||
|
||||
it('识别 HEIC/HEIF 的 MIME 与扩展名', () => {
|
||||
expect(isHeicFile(createHeicFile('a.heic', 'image/heic'))).toBe(true)
|
||||
expect(isHeicFile(createHeicFile('a.heif', 'image/heif'))).toBe(true)
|
||||
expect(isHeicFile(createHeicFile('a.HEIC', ''))).toBe(true)
|
||||
expect(isHeicFile(createHeicFile('a.heif', ''))).toBe(true)
|
||||
expect(isHeicFile(createHeicFile('a.jpg', 'image/jpeg'))).toBe(false)
|
||||
expect(isHeicFile(createHeicFile('a.png', 'image/png'))).toBe(false)
|
||||
})
|
||||
|
||||
it('非 HEIC 文件原样返回且不加载转换库', async () => {
|
||||
const file = createHeicFile('photo.jpg', 'image/jpeg')
|
||||
|
||||
await expect(convertHeicToJpegFile(file)).resolves.toBe(file)
|
||||
expect(convertMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('HEIC 转换成功时输出 JPEG File', async () => {
|
||||
convertMock.mockResolvedValue(new Blob([new Uint8Array(4)], { type: 'image/jpeg' }))
|
||||
const file = createHeicFile('live.heic', 'image/heic')
|
||||
|
||||
const converted = await convertHeicToJpegFile(file)
|
||||
|
||||
expect(converted.name).toBe('live.jpg')
|
||||
expect(converted.type).toBe('image/jpeg')
|
||||
expect(converted.size).toBe(4)
|
||||
expect(converted.lastModified).toBe(1)
|
||||
expect(convertMock).toHaveBeenCalledWith({ blob: file, toType: 'image/jpeg', quality: 0.92 })
|
||||
})
|
||||
|
||||
it('转换失败时抛出明确提示', async () => {
|
||||
convertMock.mockRejectedValue(new Error('decode failed'))
|
||||
|
||||
await expect(convertHeicToJpegFile(createHeicFile())).rejects.toThrow(HEIC_CONVERT_FAILED_MESSAGE)
|
||||
})
|
||||
|
||||
it('转换结果为空时抛出明确提示', async () => {
|
||||
convertMock.mockResolvedValue(new Blob([]))
|
||||
|
||||
await expect(convertHeicToJpegFile(createHeicFile())).rejects.toThrow(HEIC_CONVERT_FAILED_MESSAGE)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,64 @@
|
||||
const HEIC_EXTENSIONS = ['.heic', '.heif']
|
||||
const HEIC_MIME_TYPES = new Set(['image/heic', 'image/heif', 'image/heic-sequence', 'image/heif-sequence'])
|
||||
|
||||
export const HEIC_CONVERT_FAILED_MESSAGE = '该图片格式无法转换,请导出为 JPG 后再上传'
|
||||
|
||||
type HeicConverter = (options: {
|
||||
blob: Blob
|
||||
toType?: string
|
||||
quality?: number
|
||||
multiple?: boolean
|
||||
gifInterval?: number
|
||||
}) => Promise<Blob | Blob[]>
|
||||
|
||||
/** 识别 HEIC/HEIF:优先看 MIME,部分系统给不到 MIME 时按扩展名兜底。 */
|
||||
export const isHeicFile = (file: File) => {
|
||||
const type = (file.type || '').toLowerCase()
|
||||
if (HEIC_MIME_TYPES.has(type)) {
|
||||
return true
|
||||
}
|
||||
const name = (file.name || '').toLowerCase().split(/[?#]/)[0] || ''
|
||||
return HEIC_EXTENSIONS.some(extension => name.endsWith(extension))
|
||||
}
|
||||
|
||||
const buildJpegFileName = (fileName: string) => {
|
||||
const dotIndex = fileName.lastIndexOf('.')
|
||||
const baseName = dotIndex > -1 ? fileName.slice(0, dotIndex) : fileName
|
||||
return `${baseName || 'image'}.jpg`
|
||||
}
|
||||
|
||||
/** 按需加载 libheif WASM 转换库,只有真正选择 HEIC/HEIF 时才进入首屏之外的异步 chunk。 */
|
||||
const loadHeicConverter = async () => {
|
||||
const heic2anyModule = await import('heic2any')
|
||||
return (heic2anyModule as unknown as { default: HeicConverter }).default
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 HEIC/HEIF 静态帧转成 JPEG 的 File,非 HEIC/HEIF 原样返回。
|
||||
* 转换失败时抛出带明确提示的 Error,调用方不得继续上传。
|
||||
*/
|
||||
export const convertHeicToJpegFile = async (file: File): Promise<File> => {
|
||||
if (!isHeicFile(file)) {
|
||||
return file
|
||||
}
|
||||
|
||||
let convertedBlob: Blob | null = null
|
||||
try {
|
||||
const convert = await loadHeicConverter()
|
||||
const result = await convert({ blob: file, toType: 'image/jpeg', quality: 0.92 })
|
||||
convertedBlob = Array.isArray(result) ? result[0] ?? null : result
|
||||
} catch {
|
||||
throw new Error(HEIC_CONVERT_FAILED_MESSAGE)
|
||||
}
|
||||
|
||||
if (!convertedBlob || convertedBlob.size === 0) {
|
||||
throw new Error(HEIC_CONVERT_FAILED_MESSAGE)
|
||||
}
|
||||
|
||||
const convertedFile = new File([convertedBlob], buildJpegFileName(file.name), {
|
||||
type: 'image/jpeg',
|
||||
lastModified: file.lastModified
|
||||
})
|
||||
|
||||
return convertedFile
|
||||
}
|
||||
@@ -41,7 +41,7 @@
|
||||
<a-textarea v-model:value="form.content" :rows="4" :maxlength="1000" placeholder="支持 HTML / Markdown,也可以直接输入纯文本" />
|
||||
</a-form-item>
|
||||
<a-form-item label="图片">
|
||||
<a-upload :show-upload-list="false" accept="image/jpeg,image/png,image/webp,image/gif" :before-upload="uploadAnnouncementImage">
|
||||
<a-upload :show-upload-list="false" accept="image/jpeg,image/png,image/webp,image/gif,image/heic,image/heif,.heic,.heif" :before-upload="uploadAnnouncementImage">
|
||||
<a-button :loading="imageUploading">添加图片</a-button>
|
||||
</a-upload>
|
||||
<a-space v-if="form.imageFileIds.length" wrap class="announcement-images">
|
||||
@@ -79,6 +79,7 @@ import { message, Modal } from 'ant-design-vue'
|
||||
*/
|
||||
import { adminAnnouncementApi, adminFileApi, type AnnouncementVO, type MessageTargetOptionsVO } from '@/api/admin'
|
||||
import { extractRichText, renderRichContent } from '@/utils/rich-content'
|
||||
import { createChunkUploadTask, prepareChunkUploadFile, shouldUseChunkUpload } from '@/utils/chunk-upload'
|
||||
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
@@ -157,10 +158,28 @@ const openCreate = () => {
|
||||
formOpen.value = true
|
||||
}
|
||||
|
||||
const uploadAnnouncementImageInChunks = async (file: File) => {
|
||||
const { response } = await createChunkUploadTask({
|
||||
file,
|
||||
scene: 'admin-announcement-image',
|
||||
concurrency: 3,
|
||||
api: {
|
||||
initUpload: adminFileApi.initChunkUpload,
|
||||
uploadChunk: adminFileApi.uploadChunk,
|
||||
completeUpload: adminFileApi.completeChunkUpload,
|
||||
cancelUpload: adminFileApi.cancelChunkUpload
|
||||
}
|
||||
}).promise
|
||||
return response
|
||||
}
|
||||
|
||||
const uploadAnnouncementImage = async (file: File) => {
|
||||
imageUploading.value = true
|
||||
try {
|
||||
const uploaded = await adminFileApi.uploadFile(file)
|
||||
const uploadCandidate = await prepareChunkUploadFile(file)
|
||||
const uploaded = shouldUseChunkUpload(uploadCandidate)
|
||||
? await uploadAnnouncementImageInChunks(uploadCandidate)
|
||||
: await adminFileApi.uploadFile(uploadCandidate)
|
||||
if (uploaded?.id) form.imageFileIds.push(uploaded.id)
|
||||
message.success('图片已上传,提交后会进入审核')
|
||||
} catch (error) {
|
||||
|
||||
@@ -292,7 +292,7 @@
|
||||
<div class="upload-tip">首页轮播图,建议尺寸 750x300 像素</div>
|
||||
<a-upload
|
||||
v-model:file-list="bannerFileList"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/heic,image/heif,.heic,.heif"
|
||||
list-type="picture-card"
|
||||
:custom-request="handleUploadBanner"
|
||||
:before-upload="beforeUpload"
|
||||
@@ -314,7 +314,7 @@
|
||||
<div class="upload-tip">店铺详情展示图</div>
|
||||
<a-upload
|
||||
v-model:file-list="imageFileList"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/heic,image/heif,.heic,.heif"
|
||||
list-type="picture-card"
|
||||
:custom-request="handleUploadImage"
|
||||
:before-upload="beforeUpload"
|
||||
@@ -421,7 +421,7 @@
|
||||
<a-form-item label="背景图">
|
||||
<a-upload
|
||||
v-model:file-list="themeBackgroundFileList"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/heic,image/heif,.heic,.heif"
|
||||
list-type="picture-card"
|
||||
:custom-request="handleUploadThemeBackground"
|
||||
:before-upload="beforeUpload"
|
||||
@@ -646,7 +646,8 @@ import { adminShopApi, adminFileApi, adminSecureIntegrationConfigApi, type Shop
|
||||
* Purpose: ChunkUploadTask supports ShopsView.vue by holding or executing the chunk upload task page or API role.
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { createChunkUploadTask, type ChunkUploadTask } from '@/utils/chunk-upload'
|
||||
import { createChunkUploadTask, prepareChunkUploadFile, type ChunkUploadTask } from '@/utils/chunk-upload'
|
||||
import { isHeicFile } from '@/utils/heic-image'
|
||||
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
@@ -1764,7 +1765,7 @@ const handleTableChange = async (pag: AdminTablePaginationChange) => {
|
||||
|
||||
/** beforeUpload is a local helper used by this page script. */
|
||||
const beforeUpload = (file: File) => {
|
||||
const isImage = file.type.startsWith('image/')
|
||||
const isImage = file.type.startsWith('image/') || isHeicFile(file)
|
||||
if (!isImage) {
|
||||
message.error('只能上传图片文件')
|
||||
}
|
||||
@@ -1781,6 +1782,7 @@ const handleUploadBanner: UploadProps['customRequest'] = async (options) => {
|
||||
file: uploadFile,
|
||||
scene: 'admin-shop-banner',
|
||||
concurrency: 3,
|
||||
preprocessFile: prepareChunkUploadFile,
|
||||
api: {
|
||||
initUpload: adminFileApi.initChunkUpload,
|
||||
uploadChunk: adminFileApi.uploadChunk,
|
||||
@@ -1862,6 +1864,7 @@ const handleUploadImage: UploadProps['customRequest'] = async (options) => {
|
||||
file: uploadFile,
|
||||
scene: 'admin-shop-image',
|
||||
concurrency: 3,
|
||||
preprocessFile: prepareChunkUploadFile,
|
||||
api: {
|
||||
initUpload: adminFileApi.initChunkUpload,
|
||||
uploadChunk: adminFileApi.uploadChunk,
|
||||
@@ -1943,6 +1946,7 @@ const handleUploadThemeBackground: UploadProps['customRequest'] = async (options
|
||||
file: uploadFile,
|
||||
scene: 'admin-shop-theme-background',
|
||||
concurrency: 3,
|
||||
preprocessFile: prepareChunkUploadFile,
|
||||
api: {
|
||||
initUpload: adminFileApi.initChunkUpload,
|
||||
uploadChunk: adminFileApi.uploadChunk,
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</a-form-item>
|
||||
<a-form-item label="消息图片">
|
||||
<div class="image-upload-row">
|
||||
<a-upload accept="image/jpeg,image/png,image/webp,image/gif" list-type="picture-card" :show-upload-list="false" :custom-request="handleImageUpload">
|
||||
<a-upload accept="image/jpeg,image/png,image/webp,image/gif,image/heic,image/heif,.heic,.heif" list-type="picture-card" :show-upload-list="false" :custom-request="handleImageUpload">
|
||||
<div v-if="!imagePreviewUrl" class="upload-placeholder">
|
||||
<PictureOutlined />
|
||||
<span>上传图片</span>
|
||||
@@ -169,7 +169,8 @@ import SystemMessageCard from '@/components/SystemMessageCard.vue'
|
||||
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
import { adminFileApi, adminSystemMessageApi, type SystemMessageCreateRequest, type SystemMessageVO } from '@/api/admin'
|
||||
import { createChunkUploadTask } from '@/utils/chunk-upload'
|
||||
import { createChunkUploadTask, prepareChunkUploadFile } from '@/utils/chunk-upload'
|
||||
import { isHeicFile } from '@/utils/heic-image'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
/**
|
||||
@@ -391,7 +392,7 @@ const resetForm = () => {
|
||||
*/
|
||||
const handleImageUpload = async (options: any) => {
|
||||
const file = options.file as File
|
||||
if (!file?.type?.startsWith('image/')) {
|
||||
if (!file?.type?.startsWith('image/') && !isHeicFile(file)) {
|
||||
message.warning('请上传图片文件')
|
||||
options.onError?.(new Error('invalid image'))
|
||||
return
|
||||
@@ -402,6 +403,7 @@ const handleImageUpload = async (options: any) => {
|
||||
file,
|
||||
scene: 'admin-system-message-image',
|
||||
concurrency: 3,
|
||||
preprocessFile: prepareChunkUploadFile,
|
||||
api: {
|
||||
initUpload: adminFileApi.initChunkUpload,
|
||||
uploadChunk: adminFileApi.uploadChunk,
|
||||
|
||||
@@ -359,6 +359,7 @@ import { sameId } from '@/utils/id'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||||
import { createChunkUploadTask } from '@/utils/chunk-upload'
|
||||
import { isHeicFile } from '@/utils/heic-image'
|
||||
import { useAdminViewport } from '@/composables/useAdminViewport'
|
||||
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
|
||||
import AdminMobileFab from '@/components/admin/AdminMobileFab.vue'
|
||||
@@ -658,7 +659,7 @@ const handlePhoneFocus = () => {
|
||||
|
||||
/** beforeUploadWechatQr validates QR image files before upload. */
|
||||
const beforeUploadWechatQr = (file: File) => {
|
||||
const isImage = file.type.startsWith('image/') && file.type !== 'image/gif'
|
||||
const isImage = file.type.startsWith('image/') && file.type !== 'image/gif' && !isHeicFile(file)
|
||||
if (!isImage) {
|
||||
message.error('二维码仅支持 JPG、PNG 或 WebP 图片')
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ export default defineConfig(({ mode }) => {
|
||||
return undefined
|
||||
}
|
||||
const normalizedId = id.replaceAll('\\', '/')
|
||||
if (normalizedId.includes('heic2any')) {
|
||||
return 'heic2any'
|
||||
}
|
||||
if (normalizedId.includes('@ant-design/icons-vue')) {
|
||||
return 'antdv-icons'
|
||||
}
|
||||
|
||||
@@ -1306,32 +1306,42 @@ Page({
|
||||
},
|
||||
|
||||
confirmManualProduct() {
|
||||
if (!this.data.form.productId) {
|
||||
const hasTitle = Boolean(String(this.data.form.manualProductTitle || '').trim())
|
||||
const hasImage = (this.data.form.manualProductImages || []).length > 0 || Boolean(String(this.data.form.manualProductImageFileIds || '').trim())
|
||||
const hasFallbackName = Boolean(String(this.data.form.customerName || '').trim())
|
||||
if (!hasTitle && !hasImage && !hasFallbackName) {
|
||||
wx.showToast({ title: '请填写款式名称或添加图片', icon: 'none' })
|
||||
const form = this.data.form
|
||||
if (!form.productId) {
|
||||
const hasTitle = Boolean(String(form.manualProductTitle || '').trim())
|
||||
if (!hasTitle) {
|
||||
wx.showToast({ title: '请填写款式名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
}
|
||||
const amountText = String(this.data.form.amount === undefined || this.data.form.amount === null ? '' : this.data.form.amount).trim()
|
||||
const amount = Number(amountText)
|
||||
if (!amountText || !Number.isFinite(amount) || amount < 0) {
|
||||
const amountText = String(form.amount === undefined || form.amount === null ? '' : form.amount).trim()
|
||||
const amount = amountText ? Number(amountText) : 0
|
||||
if (amountText && (!Number.isFinite(amount) || amount < 0)) {
|
||||
wx.showToast({ title: '请输入不小于0的预约金额', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!normalizeDuration(this.data.form.durationMinutes)) {
|
||||
const durationText = String(form.durationMinutes === undefined || form.durationMinutes === null ? '' : form.durationMinutes).trim()
|
||||
const durationMinutes = durationText ? normalizeDuration(durationText) : 60
|
||||
if (!durationMinutes) {
|
||||
wx.showToast({ title: '请输入大于0分钟的预计时长', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.data.form.productId) {
|
||||
this.setData({ manualProductSheetVisible: false })
|
||||
const defaults = {}
|
||||
if (!amountText) defaults['form.amount'] = '0'
|
||||
if (!durationText) defaults['form.durationMinutes'] = '60'
|
||||
if (form.productId) {
|
||||
this.setData({ ...defaults, manualProductSheetVisible: false })
|
||||
this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
return
|
||||
}
|
||||
this.setData({ 'form.productId': '', selectedProduct: {}, selectedProductPriceText: '', manualProductSheetVisible: false })
|
||||
this.setData({
|
||||
...defaults,
|
||||
'form.productId': '',
|
||||
selectedProduct: {},
|
||||
selectedProductPriceText: '',
|
||||
manualProductSheetVisible: false
|
||||
})
|
||||
this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
},
|
||||
@@ -1971,16 +1981,19 @@ Page({
|
||||
return
|
||||
}
|
||||
const manualProductTitle = String(form.manualProductTitle || '').trim()
|
||||
const manualProductImageFileIds = String(form.manualProductImageFileIds || '').trim()
|
||||
const hasManualProduct = Boolean(manualProductTitle || manualProductImageFileIds || String(form.customerName || '').trim())
|
||||
const amountText = String(form.amount === undefined || form.amount === null ? '' : form.amount).trim()
|
||||
const amount = Number(amountText)
|
||||
const durationMinutes = normalizeDuration(form.durationMinutes)
|
||||
if ((!form.productId && !hasManualProduct) || !form.appointmentDate || !form.appointmentTime || !amountText) {
|
||||
const amount = amountText ? Number(amountText) : 0
|
||||
const durationText = String(form.durationMinutes === undefined || form.durationMinutes === null ? '' : form.durationMinutes).trim()
|
||||
const durationMinutes = durationText ? normalizeDuration(durationText) : 60
|
||||
if (!form.productId && !manualProductTitle) {
|
||||
wx.showToast({ title: '请填写款式名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.appointmentDate || !form.appointmentTime) {
|
||||
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!Number.isFinite(amount) || amount < 0) {
|
||||
if (amountText && (!Number.isFinite(amount) || amount < 0)) {
|
||||
wx.showToast({ title: '请输入不小于0的成交金额', icon: 'none' })
|
||||
return
|
||||
}
|
||||
@@ -1996,6 +2009,10 @@ Page({
|
||||
wx.showToast({ title: '请填写预约时长', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const defaults = {}
|
||||
if (!amountText) defaults['form.amount'] = '0'
|
||||
if (!durationText) defaults['form.durationMinutes'] = '60'
|
||||
if (Object.keys(defaults).length) this.setData(defaults)
|
||||
const availability = await this.checkAvailability()
|
||||
if (!availability.ok) {
|
||||
wx.showToast({ title: availability.tip || '该时段已被预约', icon: 'none' })
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<view class="field-text">
|
||||
<text wx:if="{{form.manualProductTitle}}" class="field-value">{{form.manualProductTitle}}</text>
|
||||
<text wx:elif="{{form.manualProductImages.length}}" class="field-value">已添加 {{form.manualProductImages.length}} 张款式图片</text>
|
||||
<text wx:else class="field-value placeholder">填写款式名称或添加图片</text>
|
||||
<text wx:else class="field-value placeholder">填写款式名称</text>
|
||||
<text wx:if="{{form.amount || form.durationMinutes}}" class="field-meta">{{form.amount || '待填'}} 元 · 预计 {{form.durationMinutes || '60'}} 分钟</text>
|
||||
<text class="field-label">{{form.manualProductImages.length ? '已添加 ' + form.manualProductImages.length + ' 张图片 · 点击可编辑' : '点击可手动录入,提交后自动保存到本店款式库'}}</text>
|
||||
</view>
|
||||
@@ -32,7 +32,7 @@
|
||||
<view class="selected-style-copy"><text class="selected-style-title">{{selectedProduct.title}}</text><text class="selected-style-meta">参考价 {{selectedProductPriceText || '待定'}} · 本次 {{form.amount || '待填'}} 元 · {{form.durationMinutes || '60'}} 分钟</text></view>
|
||||
<button class="switch-manual-action" catchtap="openManualProduct">调整</button>
|
||||
</view>
|
||||
<text class="style-hint">名称和图片至少填写一项;名称为空时会使用客户姓名或“散客款式”。</text>
|
||||
<text class="style-hint">款式名称为必填项;款式图片可按需添加。</text>
|
||||
<text class="style-hint">手动录入款式在预约提交成功后自动保存到本店款式库,仅门店可见,不会公开展示。</text>
|
||||
</view>
|
||||
|
||||
@@ -43,18 +43,18 @@
|
||||
<picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange">
|
||||
<view class="field-card appointment-field-card">
|
||||
<view class="field-icon">▣</view>
|
||||
<view class="field-text"><text class="field-label">预约日期</text><text class="field-value">{{appointmentDateLong}}</text></view>
|
||||
<view class="field-text"><text class="field-label"><text class="required-mark required-mark-before">*</text>预约日期</text><text class="field-value">{{appointmentDateLong}}</text></view>
|
||||
<text class="chevron">›</text>
|
||||
</view>
|
||||
</picker>
|
||||
<view class="field-card appointment-field-card" bindtap="openTimeSheet">
|
||||
<view class="field-icon">◷</view>
|
||||
<view class="field-text"><text class="field-label">预约时间</text><text wx:if="{{form.appointmentTime}}" class="field-value">{{appointmentDayLabel}} {{form.appointmentTime}} · {{form.durationMinutes}}分钟</text><text wx:else class="field-value placeholder">{{timeSelectTip}}</text><text wx:if="{{form.appointmentTime}}" class="field-meta">{{selectedArtist.name || '暂不分配美甲师'}}</text></view>
|
||||
<view class="field-text"><text class="field-label"><text class="required-mark required-mark-before">*</text>预约时间</text><text wx:if="{{form.appointmentTime}}" class="field-value">{{appointmentDayLabel}} {{form.appointmentTime}} · {{form.durationMinutes}}分钟</text><text wx:else class="field-value placeholder">{{timeSelectTip}}</text><text wx:if="{{form.appointmentTime}}" class="field-meta">{{selectedArtist.name || '暂不分配美甲师'}}</text></view>
|
||||
<text class="chevron">›</text>
|
||||
</view>
|
||||
<view class="field-card appointment-field-card" bindtap="openArtistSheet">
|
||||
<view class="field-icon">♙</view>
|
||||
<view class="field-text"><text class="field-label">服务美甲师</text><text wx:if="{{selectedArtist.id === '__unassigned__'}}" class="field-value">已选择暂不分配美甲师</text><text wx:else class="field-value {{selectedArtist.name ? '' : 'placeholder'}}">{{selectedArtist.name || '请选择美甲师或暂不分配'}}</text></view>
|
||||
<view class="field-text"><text class="field-label">服务美甲师(选填)</text><text wx:if="{{selectedArtist.id === '__unassigned__'}}" class="field-value">已选择暂不分配美甲师</text><text wx:else class="field-value {{selectedArtist.name ? '' : 'placeholder'}}">{{selectedArtist.name || '请选择美甲师或暂不分配'}}</text></view>
|
||||
<text class="chevron">›</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -65,9 +65,9 @@
|
||||
</view>
|
||||
<view class="customer-entry">
|
||||
<view class="customer-fields">
|
||||
<input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="客户姓名(可选)" />
|
||||
<input class="customer-wechat-input" value="{{form.wechatId}}" data-field="wechatId" bindinput="onCustomerInput" placeholder="微信号(可选)" />
|
||||
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(可选)" />
|
||||
<input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="客户姓名(选填)" />
|
||||
<input class="customer-wechat-input" value="{{form.wechatId}}" data-field="wechatId" bindinput="onCustomerInput" placeholder="微信号(选填)" />
|
||||
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(选填)" />
|
||||
</view>
|
||||
<button class="customer-library-btn" aria-label="选择已有客户" catchtap="openCustomerSheet"><text class="customer-library-icon">⌕</text></button>
|
||||
</view>
|
||||
@@ -84,27 +84,26 @@
|
||||
|
||||
<view wx:if="{{manualProductSheetVisible}}" class="modal-mask manual-product-mask" bindtap="closeManualProduct" catchtouchmove="stopTouchMove">
|
||||
<view class="manual-style-sheet" catchtap="stopTap" catchtouchmove="stopTouchMove">
|
||||
<view class="modal-head"><view><text class="modal-title">{{form.productId ? '调整预约款式' : '录入本次美甲款式'}}</text><text class="modal-subtitle">{{form.productId ? '可调整本次价格和预计时长' : '名称或图片至少填写一项 · 可添加多张图片'}}</text></view><view class="modal-close" bindtap="closeManualProduct" aria-label="关闭款式录入"></view></view>
|
||||
<view class="modal-head"><view><text class="modal-title">{{form.productId ? '调整预约款式' : '录入本次美甲款式'}}</text><text class="modal-subtitle">{{form.productId ? '可调整本次价格和预计时长' : '款式名称为必填项 · 可添加多张图片'}}</text></view><view class="modal-close" bindtap="closeManualProduct" aria-label="关闭款式录入"></view></view>
|
||||
<scroll-view class="manual-style-content" scroll-y enhanced show-scrollbar="{{false}}">
|
||||
<view class="manual-style-name-field">
|
||||
<view class="manual-style-field-heading"><text>名称</text><text class="manual-style-character-count">
|
||||
<view class="manual-style-field-heading"><text class="required-mark required-mark-before">*</text><text>款式名称</text><text class="manual-style-character-count">
|
||||
{{manualProductTitleLength}} / 100</text></view>
|
||||
<input class="manual-style-title-input" value="{{form.productId ? selectedProduct.title : form.manualProductTitle}}" maxlength="100" disabled="{{form.productId}}" bindinput="onStyleTitleInput" placeholder="留空时默认使用客户姓名" />
|
||||
<input class="manual-style-title-input" value="{{form.productId ? selectedProduct.title : form.manualProductTitle}}" maxlength="100" disabled="{{form.productId}}" bindinput="onStyleTitleInput" placeholder="请输入款式名称" />
|
||||
</view>
|
||||
<text class="manual-style-hint">没有填写名称时,会使用客户姓名;没有选择客户时,会采取散客预约模式,名称采用“散客款式”。</text>
|
||||
|
||||
<view class="manual-style-price-duration-row">
|
||||
<view class="manual-style-compact-field">
|
||||
<text class="manual-style-field-label">价格</text>
|
||||
<text class="manual-style-field-label">价格(选填)</text>
|
||||
<view class="manual-style-input-wrap"><input type="digit" value="{{form.amount}}" data-field="amount" bindinput="onInput" placeholder="例如 268" /><text>元</text></view>
|
||||
</view>
|
||||
<view class="manual-style-compact-field">
|
||||
<text class="manual-style-field-label">预计时长</text>
|
||||
<text class="manual-style-field-label">预计时长(选填)</text>
|
||||
<view class="manual-style-input-wrap"><input type="number" value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" placeholder="60" /><text>分钟</text></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="manual-style-images">
|
||||
<view class="manual-style-image-heading"><text>款式图片</text><text class="manual-style-image-count">{{form.manualProductImages.length}} / 9</text></view>
|
||||
<view class="manual-style-image-heading"><text>款式图片(选填)</text><text class="manual-style-image-count">{{form.manualProductImages.length}} / 9</text></view>
|
||||
<scroll-view class="manual-style-image-scroll" scroll-x="true" enhanced="true" show-scrollbar="false">
|
||||
<view class="manual-style-image-grid">
|
||||
<view wx:for="{{form.manualProductImages}}" wx:key="fileId" class="manual-style-image-tile">
|
||||
@@ -122,7 +121,7 @@
|
||||
<textarea value="{{unifiedStyleDescription}}" bindinput="onUnifiedStyleDescriptionInput" placeholder="可填写颜色、工艺、特殊要求等备注" maxlength="500" />
|
||||
</view>
|
||||
<view class="manual-style-more">
|
||||
<view class="manual-style-more-toggle" bindtap="toggleManualProductMore"><text>点击展开补充信息</text><text class="manual-style-more-arrow">{{manualProductMoreVisible ? '⌃' : '⌄'}}</text></view>
|
||||
<view class="manual-style-more-toggle" bindtap="toggleManualProductMore"><text>点击展开补充信息(选填)</text><text class="manual-style-more-arrow">{{manualProductMoreVisible ? '⌃' : '⌄'}}</text></view>
|
||||
<view wx:if="{{manualProductMoreVisible}}" class="manual-style-more-fields">
|
||||
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔" />
|
||||
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群" />
|
||||
|
||||
@@ -783,6 +783,11 @@ button.link-action {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.required-mark-before {
|
||||
margin-left: 0;
|
||||
margin-right: 5rpx;
|
||||
}
|
||||
|
||||
.link-action {
|
||||
min-width: 144rpx;
|
||||
max-width: none;
|
||||
|
||||
@@ -114,16 +114,19 @@ page.data.form.manualProductImageFileIds = ''
|
||||
page.openManualProduct()
|
||||
page.confirmManualProduct()
|
||||
assert.strictEqual(page.data.manualProductSheetVisible, true)
|
||||
assert.strictEqual(toastMessages.pop(), '请填写款式名称或添加图片')
|
||||
assert.strictEqual(toastMessages.pop(), '请填写款式名称')
|
||||
|
||||
page.data.form.manualProductTitle = '手绘款'
|
||||
page.data.form.amount = ''
|
||||
page.data.form.durationMinutes = ''
|
||||
page.openManualProduct()
|
||||
page.confirmManualProduct()
|
||||
assert.strictEqual(page.data.manualProductSheetVisible, true)
|
||||
assert.strictEqual(toastMessages.pop(), '请输入不小于0的预约金额')
|
||||
assert.strictEqual(page.data.manualProductSheetVisible, false)
|
||||
assert.strictEqual(page.data.form.amount, '0')
|
||||
assert.strictEqual(page.data.form.durationMinutes, '60')
|
||||
page.data.form.amount = '128'
|
||||
page.data.form.durationMinutes = '0'
|
||||
page.openManualProduct()
|
||||
page.confirmManualProduct()
|
||||
assert.strictEqual(page.data.manualProductSheetVisible, true)
|
||||
assert.strictEqual(toastMessages.pop(), '请输入大于0分钟的预计时长')
|
||||
@@ -136,14 +139,17 @@ const wxss = require('fs').readFileSync(require('path').join(__dirname, 'index.w
|
||||
assert.ok(wxml.indexOf('美甲款式') < wxml.indexOf('预约信息'))
|
||||
assert.ok(wxml.indexOf('预约信息') < wxml.indexOf('>客户</text>'))
|
||||
assert.match(wxml, /class="appointment-hero"/)
|
||||
assert.match(wxml, /placeholder="留空时默认使用客户姓名"/)
|
||||
assert.match(wxml, /placeholder="请输入款式名称"/)
|
||||
assert.match(wxml, /appointmentDateBadge/)
|
||||
assert.match(wxml, /class="customer-fields"/)
|
||||
assert.match(wxml, /class="manual-style-sheet"/)
|
||||
assert.match(wxml, /名称<\/text><text class="manual-style-character-count">\s*\{\{manualProductTitleLength\}\} \/ 100/)
|
||||
assert.match(wxml, /class="required-mark required-mark-before">\*<\/text><text>款式名称<\/text><text class="manual-style-character-count">\s*\{\{manualProductTitleLength\}\} \/ 100/)
|
||||
assert.match(wxml, /maxlength="100"[^>]*bindinput="onStyleTitleInput"/)
|
||||
assert.match(wxml, /disabled="\{\{form\.productId\}\}" bindinput="onStyleTitleInput"/)
|
||||
assert.match(wxml, /class="manual-style-price-duration-row"/)
|
||||
assert.match(wxml, /价格(选填)/)
|
||||
assert.match(wxml, /预计时长(选填)/)
|
||||
assert.match(wxml, /款式图片(选填)/)
|
||||
assert.match(wxml, /data-field="amount" bindinput="onInput" placeholder="例如 268" \/><text>元/)
|
||||
assert.match(wxml, /data-field="durationMinutes" bindinput="onInput" placeholder="60" \/><text>分钟/)
|
||||
assert.match(wxml, /class="manual-style-description-field"/)
|
||||
|
||||
@@ -182,6 +182,29 @@ async function run() {
|
||||
assert.strictEqual(walkInPayload.createCustomerRecord, false)
|
||||
assert.strictEqual(walkInPayload.artistId, undefined)
|
||||
assert.strictEqual(walkInPayload.appointmentTime, '15:00')
|
||||
|
||||
const manualDefaultPage = createPage()
|
||||
manualDefaultPage.data.businessStartTime = '09:30'
|
||||
manualDefaultPage.data.businessEndTime = '18:00'
|
||||
Object.assign(manualDefaultPage.data.form, {
|
||||
productId: '',
|
||||
manualProductTitle: '手绘款',
|
||||
appointmentDate: futureDate,
|
||||
appointmentTime: '16:00',
|
||||
amount: '',
|
||||
durationMinutes: '',
|
||||
artistId: ''
|
||||
})
|
||||
let manualDefaultPayload
|
||||
planningApi.createAppointment = async payload => {
|
||||
manualDefaultPayload = payload
|
||||
return { orderItemId: 63 }
|
||||
}
|
||||
await manualDefaultPage.submit()
|
||||
|
||||
assert.strictEqual(manualDefaultPayload.amount, 0)
|
||||
assert.strictEqual(manualDefaultPayload.durationMinutes, 60)
|
||||
assert.strictEqual(manualDefaultPayload.manualProductTitle, '手绘款')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user