Merge branch 'feat/camcard' of http://git.aigc-quickapp.com/Uniapp/lucky_shop into feat/camcard

This commit is contained in:
2026-10-13 10:50:59 +08:00
2 changed files with 47 additions and 11 deletions

View File

@@ -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' });
}

View File

@@ -8,6 +8,7 @@
<text v-if="keyword" class="search-clear" @tap="clearKeyword">✕</text>
<text class="iconfont icon-sousuo3" @tap="onSearch"></text>
</view>
<view class="claim-btn create-btn" @tap="goCreate">新建</view>
<view class="claim-btn" @tap="onClaimTap">认领</view>
</view>
@@ -53,7 +54,7 @@ export default {
count: 0,
keyword: '',
isLoading: false,
emptyText: '暂无名片,点击右上角「认领」添加'
emptyText: '暂无名片,可点击右上角「新建」或「认领」添加'
};
},
onLoad() {
@@ -103,7 +104,7 @@ export default {
this.list = pageNo === 1 ? rows : this.list.concat(rows);
this.emptyText = this.keyword.trim()
? '未找到匹配的名片'
: '暂无名片,点击右上角「认领」添加';
: '暂无名片,可点击右上角「新建」或「认领」添加';
} else {
this.handleApiError(res);
}
@@ -123,6 +124,11 @@ export default {
url: '/pages_tool/card/detail?card_id=' + encodeURIComponent(item.card_id)
});
},
goCreate() {
uni.navigateTo({
url: '/pages_tool/card/edit'
});
},
onClaimTap() {
uni.showModal({
title: '认领名片',
@@ -226,6 +232,12 @@ export default {
color: #ffffff;
font-size: 28rpx;
border-radius: 36rpx;
/* 「新建」次级按钮: 主按钮同构, 淡底弱化一档 */
&.create-btn {
background-color: var(--main-color-shallow, #e8f1fb);
color: var(--main-color, #0054a5);
}
}
}