merge dev/1.0 into feat/camcard: resolve card list/detail conflicts keeping feat/camcard implementation

This commit is contained in:
2026-10-19 09:55:21 +08:00
2 changed files with 212 additions and 0 deletions

View File

@@ -1500,6 +1500,12 @@
"navigationBarTitleText": "编辑名片"
}
},
{
"path": "card/apply",
"style": {
"navigationBarTitleText": "申请名片"
}
},
{
"path": "card/leads",
"style": {

206
pages_tool/card/apply.vue Normal file
View File

@@ -0,0 +1,206 @@
<template>
<view class="card-apply">
<!-- 申请状态条: 提交过申请或已有名片时替代表单 -->
<view class="tips" v-if="statusLoaded && statusTip">
<text class="tips-title">{{ statusTip }}</text>
<text class="tips-sub" v-if="statusSub">{{ statusSub }}</text>
</view>
<template v-if="formEditable">
<view class="tips">
<text class="tips-title">向商家申请一张数字名片</text>
<text class="tips-sub">提交后商家会收到通知,同意后名片自动出现在你的名片夹</text>
</view>
<view class="form-group">
<view class="form-row">
<view class="row-label"><text class="req-star">*</text>姓名</view>
<input class="row-input" :value="form.name" placeholder="你希望名片上显示的姓名"
@input="e => form.name = e.detail.value" />
</view>
<view class="form-row">
<view class="row-label"><text class="req-star">*</text>手机号</view>
<input class="row-input" type="number" :value="form.mobile" placeholder="你注册本店使用的手机号"
@input="e => form.mobile = e.detail.value" />
</view>
</view>
</template>
<view class="save-bar" v-if="formEditable">
<button class="save-btn" :disabled="submitting" @tap="submit">{{ submitting ? '提交中…' : '提交申请' }}</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
form: { name: '', mobile: '' },
submitting: false,
// 状态回查: null=未加载, 否则 { apply, has_card }
applyStatus: null,
statusLoaded: false
};
},
computed: {
// 已有名片 / 申请待审 → 隐藏表单只显示状态; 被拒/无记录 → 允许(重新)提交
formEditable() {
const s = this.applyStatus;
if (!s) return true;
if (s.has_card) return false;
if (s.apply && s.apply.status === 0) return false; // 待审核
return true;
},
statusTip() {
const s = this.applyStatus;
if (!s) return '';
if (s.has_card) return '您已拥有名片,去名片夹查看吧';
if (s.apply && s.apply.status === 0) return '申请审核中,商家同意后名片会自动出现';
if (s.apply && s.apply.status === 2) return '上次申请未通过,可修改后重新提交';
return '';
},
statusSub() {
const s = this.applyStatus;
if (!s || !s.apply) return '';
if (s.apply.status === 2) return '提交于 ' + (s.apply.create_time_txt || '');
return s.apply.create_time_txt ? ('提交于 ' + s.apply.create_time_txt) : '';
}
},
onLoad() {
uni.setNavigationBarTitle({ title: '申请名片' });
this.loadStatus();
},
methods: {
loadStatus() {
this.$api.sendRequest({
url: '/card/api/apply/status',
success: res => {
if (res.code == 0 && res.data) {
this.applyStatus = res.data;
}
this.statusLoaded = true;
},
fail: () => {
// 回查失败不阻塞表单
this.statusLoaded = true;
}
});
},
submit() {
if (this.submitting) return;
const name = String(this.form.name || '').trim();
const mobile = String(this.form.mobile || '').trim();
if (!name) {
uni.showToast({ title: '请填写姓名', icon: 'none' });
return;
}
if (!/^1\d{10}$/.test(mobile)) {
uni.showToast({ title: '请填写正确的 11 位手机号', icon: 'none' });
return;
}
this.submitting = true;
this.$api.sendJson({
url: '/card/api/apply/submit',
data: { name: name, mobile: mobile },
success: res => {
this.submitting = false;
if (res.code == 0) {
uni.showToast({ title: '申请已提交', icon: 'success' });
setTimeout(() => uni.navigateBack(), 600);
} else {
uni.showToast({ title: res.message || '提交失败', icon: 'none' });
}
},
fail: () => {
this.submitting = false;
uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' });
}
});
}
}
};
</script>
<style lang="scss" scoped>
.card-apply {
min-height: 100vh;
background-color: #f6f7f9;
padding: 24rpx 24rpx 60rpx;
box-sizing: border-box;
}
.tips {
padding: 20rpx 8rpx 24rpx;
display: flex;
flex-direction: column;
.tips-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.tips-sub {
margin-top: 8rpx;
font-size: 24rpx;
color: #999;
line-height: 1.6;
}
}
.form-group {
background-color: #ffffff;
border-radius: 16rpx;
overflow: hidden;
.form-row {
display: flex;
align-items: center;
padding: 28rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: none;
}
.row-label {
width: 160rpx;
font-size: 28rpx;
color: #666;
flex-shrink: 0;
.req-star {
color: #f5222d;
margin-right: 4rpx;
font-weight: 600;
}
}
.row-input {
flex: 1;
font-size: 28rpx;
color: #333;
}
}
}
.save-bar {
padding: 40rpx 0 0;
.save-btn {
height: 88rpx;
line-height: 88rpx;
background-color: var(--main-color, #0054a5);
color: #ffffff;
font-size: 30rpx;
border-radius: 44rpx;
&[disabled] {
opacity: 0.6;
color: #ffffff;
background-color: var(--main-color, #0054a5);
}
}
}
</style>