no message

This commit is contained in:
wangdongbo 2026-01-23 16:42:50 +08:00
parent 7f94fd2ee0
commit 119ada9434

View File

@ -220,59 +220,63 @@ const editPhrase = (phrase) => {
const savePhrase = async () => {
if (!phraseForm.value.content.trim()) {
uni.showToast({
title: "请输入内容",
icon: "none",
title: '请输入内容',
icon: 'none'
});
return;
}
try {
if (editingPhrase.value) {
//
await api("saveCommonPhrase", {
id: editingPhrase.value.id,
categoryId: editingPhrase.value.categoryId,
content: phraseForm.value.content,
corpId: uni.getStorageSync("corpId"),
const corpId = uni.getStorageSync('corpId');
const userId = uni.getStorageSync('userId');
if (!corpId || !userId) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
const index = phrases.value.findIndex(
(p) => p.id === editingPhrase.value.id
);
if (index !== -1) {
phrases.value[index].content = phraseForm.value.content;
}
} else {
//
const result = await api("saveCommonPhrase", {
categoryId: currentCategory.value,
content: phraseForm.value.content,
corpId: uni.getStorageSync("corpId"),
});
if (result.code === 200 && result.data) {
phrases.value.push(result.data);
} else {
// API使ID
phrases.value.push({
id: Date.now(),
categoryId: currentCategory.value,
content: phraseForm.value.content,
});
}
return;
}
uni.showToast({
title: editingPhrase.value ? "保存成功" : "添加成功",
icon: "success",
const result = await api('saveCommonPhrase', {
id: editingPhrase.value?.id,
categoryId: editingPhrase.value?.categoryId || currentCategory.value,
content: phraseForm.value.content,
corpId,
userId
});
closePopup();
if (result.code === 200) {
if (editingPhrase.value) {
//
const index = phrases.value.findIndex(p => p.id === editingPhrase.value.id);
if (index !== -1) {
phrases.value[index].content = phraseForm.value.content;
}
} else {
//
if (result.data) {
phrases.value.push(result.data);
}
}
uni.showToast({
title: editingPhrase.value ? '保存成功' : '添加成功',
icon: 'success'
});
closePopup();
} else {
uni.showToast({
title: result.message || '操作失败',
icon: 'none'
});
}
} catch (error) {
console.error("保存常用语失败:", error);
console.error('保存常用语失败:', error);
uni.showToast({
title: "操作失败",
icon: "none",
title: '操作失败',
icon: 'none'
});
}
};
@ -398,20 +402,52 @@ const closeCategoryPopup = () => {
//
const loadPhrases = async () => {
try {
const result = await api("getCommonPhrases", {
corpId: uni.getStorageSync("corpId"),
const corpId = uni.getStorageSync('corpId');
const userId = uni.getStorageSync('userId');
if (!corpId) {
uni.showToast({
title: '请先登录',
icon: 'none'
});
return;
}
const result = await api('getCommonPhrases', {
corpId,
userId
});
if (result.code === 200 && result.data) {
phrases.value = result.data;
} else {
// API使
phrases.value = getMockPhrases();
if (result.code === 200) {
//
if (Array.isArray(result.data)) {
phrases.value = result.data;
}
//
if (Array.isArray(result.categories)) {
const backendCategories = result.categories.map(cat => ({
id: cat.id,
name: cat.name,
deletable: true //
}));
// 使使
if (backendCategories.length > 0) {
categories.value = backendCategories;
//
if (!currentCategory.value || !categories.value.find(c => c.id === currentCategory.value)) {
currentCategory.value = categories.value[0].id;
}
}
}
}
} catch (error) {
console.error("加载常用语失败:", error);
// 使
phrases.value = getMockPhrases();
console.error('加载常用语失败:', error);
uni.showToast({
title: '加载失败',
icon: 'none'
});
}
};