Files
lucky_shop/pages_tool/card/apply.vue
ZF sun 53810114ed feat: 员工端申请名片入口与申请页(配合商家后台审批闭环)
- list.vue 空态新增「申请」入口(仅无名片时显示)
- 新增 apply.vue: 姓名+手机号提交 /card/api/apply/submit
- pages.json 注册 card/apply 路由
2026-10-13 14:58:59 +08:00

156 lines
3.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="card-apply">
<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>
<view class="save-bar">
<button class="save-btn" :disabled="submitting" @tap="submit">{{ submitting ? '提交中…' : '提交申请' }}</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
form: { name: '', mobile: '' },
submitting: false
};
},
onLoad() {
uni.setNavigationBarTitle({ title: '申请名片' });
},
methods: {
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>