From 6e3818dff62cf1220a7bdd43bed4796f34a6a9cc Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Tue, 13 Oct 2026 10:29:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E5=90=8D=E7=89=87=E6=8C=89=E9=92=AE=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=A9=BA=E7=8A=B6=E6=80=81=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/card/edit.vue | 39 ++++++++++++++++++++++++++++++--------- pages_tool/card/list.vue | 16 ++++++++++++++-- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/pages_tool/card/edit.vue b/pages_tool/card/edit.vue index 023dc31..d511031 100644 --- a/pages_tool/card/edit.vue +++ b/pages_tool/card/edit.vue @@ -190,6 +190,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: '', @@ -209,7 +211,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() { @@ -372,18 +379,32 @@ export default { value: String(c.value || '').trim() })); + const payload = { fields: fields }; + if (!this.isCreate) payload.card_id = this.cardId; + this.$api.sendJson({ - url: '/card/api/card/update', - data: { - card_id: this.cardId, - fields: fields - }, + url: this.isCreate ? '/card/api/card/create' : '/card/api/card/update', + data: payload, 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' }); } diff --git a/pages_tool/card/list.vue b/pages_tool/card/list.vue index b592f02..ee2f730 100644 --- a/pages_tool/card/list.vue +++ b/pages_tool/card/list.vue @@ -8,6 +8,7 @@ ✕ + 新建 认领 @@ -53,7 +54,7 @@ export default { count: 0, keyword: '', isLoading: false, - emptyText: '暂无名片,点击右上角「认领」添加' + emptyText: '暂无名片,可点击右上角「新建」或「认领」添加' }; }, onLoad() { @@ -104,7 +105,7 @@ export default { this.list = pageNo === 1 ? rows : this.list.concat(rows); this.emptyText = this.keyword.trim() ? '未找到匹配的名片' - : '暂无名片,点击右上角「认领」添加'; + : '暂无名片,可点击右上角「新建」或「认领」添加'; } else { this.handleApiError(res); } @@ -124,6 +125,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: '认领名片', @@ -228,6 +234,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); + } } }