文件
yjyf/pages/merchant/apply.vue
linda c6c2583dfc feat(merchant): 入驻页展示关联账号数量
已入驻商家在资料页可直接看到关联账号数量,并进入工作台管理绑定关系
2026-10-28 19:23:16 +08:00

142 行
7.7 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view class="page">
<view class="hero">
<text class="hero-t">商家入驻</text>
<text class="hero-s">企业账号可批量下单、按月对账、开具发票</text>
</view>
<view class="status" v-if="info">
<text class="st-t">{{ info.merchant.is_owner === false ? '关联账号' : '主账号' }} · 当前状态:{{ statusText }}</text>
<text class="st-m" v-if="info.merchant.audit_msg">审核意见:{{ info.merchant.audit_msg }}</text>
</view>
<view class="card" v-if="canEdit">
<view class="block-title">企业信息</view>
<view class="fi"><text class="fk">企业名称</text><input class="fv" v-model="form.name" placeholder="与营业执照一致" /></view>
<view class="fi"><text class="fk">信用代码</text><input class="fv" v-model="form.license_no" maxlength="18" placeholder="统一社会信用代码" /></view>
<view class="fi"><text class="fk">法人代表</text><input class="fv" v-model="form.legal_person" placeholder="法人姓名" /></view>
<view class="block-title">联系方式</view>
<view class="fi"><text class="fk">联系人</text><input class="fv" v-model="form.contact" placeholder="对接人姓名" /></view>
<view class="fi"><text class="fk">联系电话</text><input class="fv" v-model="form.mobile" type="number" maxlength="11" placeholder="手机号" /></view>
<view class="fi"><text class="fk">经营地址</text><input class="fv" v-model="form.address" placeholder="门店 / 办公地址" /></view>
<view class="block-title">开票与结算</view>
<view class="fi"><text class="fk">发票抬头</text><input class="fv" v-model="form.invoice_title" placeholder="不填默认同企业名称" /></view>
<view class="fi"><text class="fk">税号</text><input class="fv" v-model="form.invoice_tax_no" placeholder="纳税人识别号" /></view>
<view class="fi"><text class="fk">结算方式</text>
<view class="seg">
<view class="seg-i" :class="{ on: form.settle_type === 'prepay' }" @tap="form.settle_type = 'prepay'">预付</view>
<view class="seg-i" :class="{ on: form.settle_type === 'monthly' }" @tap="form.settle_type = 'monthly'">月结</view>
</view>
</view>
<view class="hint">营业执照照片上传将在正式版接入 chooseMedia(当前以文本占位)</view>
<view class="submit" :class="{ disabled: submitting }" @tap="submit">{{ submitting ? '提交中...' : '提交审核' }}</view>
</view>
<view class="card" v-else>
<view class="li"><text class="k">企业名称</text><text class="v">{{ info.merchant.name }}</text></view>
<view class="li"><text class="k">信用代码</text><text class="v">{{ info.merchant.license_no }}</text></view>
<view class="li"><text class="k">联系人</text><text class="v">{{ info.merchant.contact }} {{ info.merchant.mobile }}</text></view>
<view class="li"><text class="k">经营地址</text><text class="v">{{ info.merchant.address }}</text></view>
<view class="li"><text class="k">累计订单</text><text class="v">{{ info.merchant.order_count }} 单</text></view>
<view class="li"><text class="k">累计金额</text><text class="v">¥{{ info.merchant.total_amount }}</text></view>
<view class="li"><text class="k">关联账号</text><text class="v">{{ info.merchant.member_count || 0 }} 个 · 工作台管理</text></view>
<view class="hint" v-if="info.merchant.is_owner === false">当前账号为关联账号,企业资料由主账号维护;订单、账单、开票数据与主账号实时同步。</view>
<view class="go" @tap="goWorkbench">进入商家工作台 ›</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive, computed } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { isLogin, toLogin, getUser } from '@/utils/request.js';
const info = ref(null);
const submitting = ref(false);
const form = reactive({
name: '', license_no: '', legal_person: '', contact: '', mobile: '',
province: '贵州省', city: '遵义市', district: '', address: '',
invoice_title: '', invoice_tax_no: '', settle_type: 'prepay'
});
const statusText = computed(() => {
if (!info.value || !info.value.merchant) return '未入驻';
const s = info.value.merchant.verify_status;
return { pending: '待审核', pass: '已通过', reject: '未通过' }[s] || s;
});
const canEdit = computed(() => !info.value || !info.value.applied || info.value.merchant.verify_status === 'reject');
function goWorkbench() { uni.redirectTo({ url: '/pages/merchant/workbench' }); }
async function load() {
if (!isLogin()) { toLogin(); return; }
const res = await api.merchantInfo();
info.value = res.applied ? res : null;
if (res.applied) {
const m = res.merchant;
form.name = m.name;
form.license_no = m.license_no;
form.legal_person = m.legal_person;
form.contact = m.contact;
form.mobile = m.mobile;
form.address = m.address;
form.invoice_title = m.invoice_title;
form.invoice_tax_no = m.invoice_tax_no;
form.settle_type = m.settle_type;
} else {
const u = getUser();
if (u) form.mobile = u.mobile || '';
}
}
async function submit() {
if (submitting.value) return;
if (!form.name || !form.license_no || !form.contact || !form.mobile) {
uni.showToast({ title: '请填写企业名称/信用代码/联系人/电话', icon: 'none' });
return;
}
submitting.value = true;
try {
await api.merchantApply(form);
uni.showToast({ title: '已提交,等待审核' });
load();
} catch (e) {
} finally {
submitting.value = false;
}
}
onShow(() => load());
</script>
<style scoped>
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 60rpx; }
.hero { padding: 40rpx 36rpx; background: linear-gradient(160deg,#FFB85C 0%,#F98D25 60%,#ED6F0E 100%); }
.hero-t { display: block; font-size: 40rpx; font-weight: 700; color: #fff; }
.hero-s { display: block; margin-top: 10rpx; font-size: 24rpx; color: rgba(255,255,255,.9); }
.status { margin: 22rpx 28rpx 0; padding: 20rpx 24rpx; background: #FFF7F0; border-radius: 16rpx; display: flex; flex-direction: column; }
.st-t { font-size: 26rpx; color: #C4580A; font-weight: 600; }
.st-m { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; }
.card { margin: 22rpx 28rpx 0; padding: 22rpx 24rpx; background: #fff; border-radius: 20rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,.06); }
.block-title { margin: 18rpx 0 4rpx; font-size: 26rpx; font-weight: 700; color: #1F1F1F; }
.block-title:first-child { margin-top: 0; }
.fi { display: flex; align-items: center; min-height: 88rpx; border-bottom: 1rpx solid #F4F4F4; }
.fk { width: 160rpx; font-size: 26rpx; color: #666; }
.fv { flex: 1; height: 88rpx; font-size: 28rpx; color: #222; }
.seg { display: flex; }
.seg-i { padding: 0 28rpx; line-height: 56rpx; margin-right: 12rpx; border-radius: 28rpx; background: #F5F5F5; font-size: 24rpx; color: #666; }
.seg-i.on { background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); color: #fff; }
.hint { margin-top: 16rpx; font-size: 20rpx; color: #BDBDBD; line-height: 30rpx; }
.submit { height: 92rpx; margin-top: 24rpx; display: flex; align-items: center; justify-content: center; border-radius: 46rpx; color: #fff; font-size: 30rpx; font-weight: 600; background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); }
.submit.disabled { opacity: .7; }
.li { display: flex; justify-content: space-between; padding: 14rpx 0; border-bottom: 1rpx solid #F4F4F4; }
.k { flex-shrink: 0; width: 150rpx; font-size: 26rpx; color: #666; }
.v { flex: 1; text-align: right; font-size: 26rpx; color: #333; }
.go { margin-top: 24rpx; height: 84rpx; display: flex; align-items: center; justify-content: center; border-radius: 42rpx; background: #FFF3E6; color: #E36B0C; font-size: 28rpx; font-weight: 600; }
</style>