Merge branch 'feat/camcard' of http://git.aigc-quickapp.com/Uniapp/lucky_shop into feat/camcard
This commit is contained in:
@@ -162,6 +162,9 @@
|
||||
*/
|
||||
import { SOCIAL_TYPES, CARD_FIELDS, RICH_FIELD_LIMITS } from '@/common/js/card-api.js';
|
||||
|
||||
// 注:telegram/messenger 已软下线(2026-10-13), 不再作为独立标量字段,
|
||||
// 统一在「社交媒体账号」动态行里以 SOCIAL_TYPES 中的类型方式添加。
|
||||
|
||||
// 上限与后端 CardRichFields::MAX_* 一致
|
||||
const MAX_MOBILES = RICH_FIELD_LIMITS.MAX_MOBILES;
|
||||
const MAX_SOCIALS = RICH_FIELD_LIMITS.MAX_SOCIALS;
|
||||
@@ -171,6 +174,8 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
cardId: '',
|
||||
// 新建模式: 无 card_id 进入, 提交 /card/api/card/create
|
||||
isCreate: false,
|
||||
form: {
|
||||
name: '', company: '', job_title: '', avatar: '',
|
||||
mobile: '', phone: '', email: '', website: '', wechat: '',
|
||||
@@ -190,7 +195,12 @@ export default {
|
||||
},
|
||||
onLoad(options) {
|
||||
this.cardId = decodeURIComponent(options.card_id || '');
|
||||
this.loadDetail();
|
||||
this.isCreate = this.cardId === '';
|
||||
if (this.isCreate) {
|
||||
uni.setNavigationBarTitle({ title: '新建名片' });
|
||||
} else {
|
||||
this.loadDetail();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadDetail() {
|
||||
@@ -352,17 +362,31 @@ export default {
|
||||
value: String(c.value || '').trim()
|
||||
}));
|
||||
|
||||
this.$cardApi.cardUpdate({
|
||||
data: {
|
||||
card_id: this.cardId,
|
||||
fields: fields
|
||||
},
|
||||
// 新建模式走 card/create, 编辑模式走 card/update(均经 $cardApi 收口层)
|
||||
const payload = this.isCreate
|
||||
? { fields: fields }
|
||||
: { card_id: this.cardId, fields: fields };
|
||||
(this.isCreate ? this.$cardApi.cardCreate : this.$cardApi.cardUpdate)({
|
||||
success: res => {
|
||||
this.saving = false;
|
||||
if (res.code == 0) {
|
||||
uni.showToast({ title: '保存成功', icon: 'success' });
|
||||
// 返回详情页; detail.vue 的 onShow 会自动刷新
|
||||
setTimeout(() => uni.navigateBack(), 600);
|
||||
uni.showToast({ title: this.isCreate ? '创建成功' : '保存成功', icon: 'success' });
|
||||
if (this.isCreate) {
|
||||
// 新建成功 → 跳详情页(redirectTo 替换当前编辑页, 返回栈回到列表)
|
||||
const newCardId = (res.data && res.data.card_id) || '';
|
||||
setTimeout(() => {
|
||||
if (newCardId) {
|
||||
uni.redirectTo({
|
||||
url: '/pages_tool/card/detail?card_id=' + encodeURIComponent(newCardId)
|
||||
});
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}, 600);
|
||||
} else {
|
||||
// 返回详情页; detail.vue 的 onShow 会自动刷新
|
||||
setTimeout(() => uni.navigateBack(), 600);
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: res.message || '保存失败', icon: 'none' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user