applyFeisui.vue
7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<template>
<view class="invoice-apply">
<view class="content">
<!-- 发票信息标题 -->
<view class="section-header">
<text class="section-title">发票信息</text>
<text class="section-hint">请填写开票信息</text>
</view>
<!-- 发票类型 -->
<view class="form-item">
<text class="label">发票类型</text>
<view class="type-select">
<view
:class="{ active: form.type === '0' }"
class="type-option"
@click="form.type = '0'"
>
<view class="type-icon enterprise">
<text class="icon-text">企</text>
</view>
<view class="type-info">
<text class="type-name">企业单位</text>
</view>
</view>
<view
:class="{ active: form.type === '1' }"
class="type-option"
@click="form.type = '1'"
>
<view class="type-icon">
<text class="icon-text">个</text>
</view>
<view class="type-info">
<text class="type-name">个人/非企业</text>
</view>
</view>
</view>
</view>
<!-- 发票抬头 -->
<view class="form-item column">
<text class="label">发票抬头</text>
<input
v-model="form.name"
class="input"
:placeholder="form.type === '0' ? '请输入公司全称' : '请输入发票抬头'"
/>
<text class="hint">请确保发票抬头与公司营业执照或个人身份证上的名称一致</text>
</view>
<!-- 纳税人识别号(企业才显示) -->
<view v-if="form.type === '0'" class="form-item column">
<text class="label">纳税人识别号</text>
<input
v-model="form.taxno"
class="input"
maxlength="20"
placeholder="请输入纳税人识别号"
/>
<text class="hint">企业税务登记证上的号码,一般为 15、18 或 20 位</text>
</view>
<!-- 开票金额(只读) -->
<!-- <view class="form-item">
<text class="label">开票金额</text>
<text class="amount">¥ {{ (Number(form.amount || 0)).toFixed(2) }}</text>
</view> -->
</view>
<!-- 提交按钮 -->
<view class="btn-wrap">
<view :class="{ loading: submitting }" class="submit-btn" @click="handleSubmit">
{{ submitting ? '提交中...' : '提交申请' }}
</view>
</view>
</view>
</template>
<script setup>
import {ref, reactive} from 'vue';
import {onLoad} from '@dcloudio/uni-app';
import {outputInvoiceNoFeisui} from '@/common/api.js';
const submitting = ref(false);
// 表单数据
const form = reactive({
id: '', // 订单ID
name: '', // 发票抬头
taxno: '', // 纳税人识别号
type: '0', // 发票类型:1=个人 0=企业
amount: 0 // 金额
});
// 页面加载
onLoad((options) => {
if (options.id || options.orderId) {
form.id = options.id || options.orderId;
form.amount = options.amount || 0;
}
console.log('非税开票参数:', options)
});
// 表单验证
const validateForm = () => {
// 发票抬头校验
if (!form.name) {
uni.showToast({title: '请输入发票抬头', icon: 'none'});
return false;
}
if (form.name.length < 2 || form.name.length > 100) {
uni.showToast({title: '发票抬头长度在2-100个字符之间', icon: 'none'});
return false;
}
// 企业必须填纳税人识别号
if (form.type === '0' && !form.taxno) {
uni.showToast({title: '请输入纳税人识别号', icon: 'none'});
return false;
}
// 纳税人识别号格式校验
if (form.type === '0') {
const taxReg = /^[A-Z0-9]{15}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/;
if (!taxReg.test(form.taxno)) {
uni.showToast({title: '纳税人识别号格式不正确', icon: 'none'});
return false;
}
}
return true;
};
// 提交非税发票申请
const handleSubmit = async () => {
if (submitting.value) return;
if (!validateForm()) return;
submitting.value = true;
console.log('提交非税开票表单数据:', form);
try {
await outputInvoiceNoFeisui(form);
uni.showToast({
title: '开票申请提交成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
} catch (error) {
console.log('非税开票失败:', error);
submitting.value = false;
} finally {
submitting.value = false;
}
};
</script>
<style lang="scss" scoped>
.invoice-apply {
min-height: 100vh;
background: #f5f7fa;
// padding-bottom: 140rpx;
}
.content {
padding: 20rpx;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
margin-bottom: 10rpx;
.section-title {
font-size: 32rpx;
font-weight: 600;
color: #303133;
}
.section-hint {
font-size: 24rpx;
color: #909399;
padding: 6rpx 16rpx;
background: #f5f5f5;
border-radius: 8rpx;
}
}
.form-item {
background: #fff;
padding: 24rpx;
margin-bottom: 20rpx;
border-radius: 16rpx;
border: 1rpx solid #e9ecef;
&.column {
display: flex;
flex-direction: column;
}
.label {
font-size: 28rpx;
color: #333;
font-weight: 500;
margin-bottom: 16rpx;
}
.input {
width: 100%;
font-size: 28rpx;
color: #333;
padding: 0 24rpx;
box-sizing: border-box;
background: transparent;
min-width: 0;
text-align: left;
border: 1rpx solid #e4e7ed;
border-radius: 8rpx;
height: 80rpx;
line-height: 80rpx;
&::placeholder {
color: #999;
font-size: 28rpx;
}
}
.hint {
font-size: 24rpx;
color: #909399;
margin-top: 8rpx;
}
.amount {
font-size: 36rpx;
color: #AD181F;
font-weight: 600;
}
}
/* 发票类型选择 */
.type-select {
display: flex;
gap: 20rpx;
margin-top: 10rpx;
}
.type-option {
flex: 1;
display: flex;
align-items: center;
padding: 20rpx;
border: 2rpx solid #e4e7ed;
border-radius: 12rpx;
background: #faf4f4;
transition: all 0.3s;
&.active {
border-color: #AD181F;
background: #faf4f4;
}
.type-icon {
width: 60rpx;
height: 60rpx;
background: #fbd9d9;
border-radius: 8rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16rpx;
.icon-text {
font-size: 28rpx;
font-weight: 600;
color: #AD181F;
}
&.enterprise {
background: #fbd9d9;
.icon-text {
color: #AD181F;
}
}
}
&.active .type-icon {
background: #AD181F;
.icon-text {
color: #fff;
}
&.enterprise {
background: #AD181F;
}
}
.type-info {
display: flex;
flex-direction: column;
.type-name {
font-size: 28rpx;
font-weight: 600;
color: #303133;
}
}
}
/* 提交按钮 */
.btn-wrap {
width: 100%;
background-color: #fff;
padding: 30rpx;
position: fixed;
bottom: 0;
left: 0;
right: 0;
box-sizing: border-box;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.05);
}
.submit-btn {
height: 88rpx;
line-height: 88rpx;
border-radius: 44rpx;
width: 100%;
background: linear-gradient(135deg, #AD181F 0%, #c42a2a 100%);
color: #fff;
font-size: 32rpx;
text-align: center;
font-weight: 500;
&.loading {
background: #c0c4cc;
}
}
</style>