11fa3904 by 张猛

开票

1 parent ef5fda73
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
6 <text class="label">发票类型</text> 6 <text class="label">发票类型</text>
7 <view class="type-select"> 7 <view class="type-select">
8 <view 8 <view
9 :class="{ active: form.invoiceType === '2' }"
9 class="type-option" 10 class="type-option"
10 :class="{ active: form.invoiceType === '1' }" 11 @click="form.invoiceType = '2'"
11 @click="form.invoiceType = '1'"
12 > 12 >
13 <view class="type-icon"></view> 13 <view class="type-icon"></view>
14 <view class="type-info"> 14 <view class="type-info">
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
17 </view> 17 </view>
18 </view> 18 </view>
19 <view 19 <view
20 v-if="type==0"
21 :class="{ active: form.invoiceType === '1' }"
20 class="type-option" 22 class="type-option"
21 :class="{ active: form.invoiceType === '2' }" 23 @click="form.invoiceType = '1'"
22 @click="form.invoiceType = '2'"
23 > 24 >
24 <view class="type-icon enterprise"></view> 25 <view class="type-icon enterprise"></view>
25 <view class="type-info"> 26 <view class="type-info">
...@@ -29,30 +30,30 @@ ...@@ -29,30 +30,30 @@
29 </view> 30 </view>
30 </view> 31 </view>
31 </view> 32 </view>
32 33
33 <!-- 发票抬头 --> 34 <!-- 发票抬头 -->
34 <view class="form-item column"> 35 <view class="form-item column">
35 <text class="label">发票抬头</text> 36 <text class="label">发票抬头</text>
36 <input 37 <input
37 class="input"
38 v-model="form.name" 38 v-model="form.name"
39 class="input"
39 placeholder="请输入公司全称或个人姓名" 40 placeholder="请输入公司全称或个人姓名"
40 /> 41 />
41 <text class="hint">请确保发票抬头与公司营业执照或个人身份证上的名称一致。</text> 42 <text class="hint">请确保发票抬头与公司营业执照或个人身份证上的名称一致。</text>
42 </view> 43 </view>
43 44
44 <!-- 纳税人识别号(企业才显示) --> 45 <!-- 纳税人识别号(企业才显示) -->
45 <view class="form-item column" v-if="form.invoiceType === '2'"> 46 <view v-if="form.invoiceType === '1'" class="form-item column">
46 <text class="label">纳税人识别号</text> 47 <text class="label">纳税人识别号</text>
47 <input 48 <input
48 class="input"
49 v-model="form.taxno" 49 v-model="form.taxno"
50 placeholder="请输入纳税人识别号" 50 class="input"
51 maxlength="20" 51 maxlength="20"
52 placeholder="请输入纳税人识别号"
52 /> 53 />
53 <text class="hint">企业税务登记证上的号码,一般为 15、18 或 20 位</text> 54 <text class="hint">企业税务登记证上的号码,一般为 15、18 或 20 位</text>
54 </view> 55 </view>
55 56
56 <!-- 接收方式 --> 57 <!-- 接收方式 -->
57 <view class="form-item"> 58 <view class="form-item">
58 <text class="label">接收方式</text> 59 <text class="label">接收方式</text>
...@@ -67,29 +68,29 @@ ...@@ -67,29 +68,29 @@
67 </view> 68 </view>
68 </view> 69 </view>
69 </view> 70 </view>
70 71
71 <!-- 开票金额 --> 72 <!-- 开票金额 -->
72 <!-- <view class="form-item"> 73 <!-- <view class="form-item">
73 <text class="label">开票金额</text> 74 <text class="label">开票金额</text>
74 <text class="amount">¥ {{ (Number(form.amount)).toFixed(2) }}</text> 75 <text class="amount">¥ {{ (Number(form.amount)).toFixed(2) }}</text>
75 </view> --> 76 </view> -->
76 77
77 <!-- 接收邮箱 --> 78 <!-- 接收邮箱 -->
78 <view class="form-item column"> 79 <view class="form-item column">
79 <text class="label">接收邮箱号码</text> 80 <text class="label">接收邮箱号码</text>
80 <input 81 <input
81 class="input"
82 v-model="form.phone" 82 v-model="form.phone"
83 class="input"
83 placeholder="请输入接收发票的邮箱号码" 84 placeholder="请输入接收发票的邮箱号码"
84 type="text" 85 type="text"
85 /> 86 />
86 <text class="hint">电子发票将在 3-5 个工作日内发送至该邮箱</text> 87 <text class="hint">电子发票将在 3-5 个工作日内发送至该邮箱</text>
87 </view> 88 </view>
88 </view> 89 </view>
89 90
90 <!-- 提交按钮 --> 91 <!-- 提交按钮 -->
91 <view class="btn-wrap"> 92 <view class="btn-wrap">
92 <view class="submit-btn" :class="{ loading: submitting }" @click="handleSubmit"> 93 <view :class="{ loading: submitting }" class="submit-btn" @click="handleSubmit">
93 {{ submitting ? '提交中...' : '提交申请' }} 94 {{ submitting ? '提交中...' : '提交申请' }}
94 </view> 95 </view>
95 </view> 96 </view>
...@@ -97,15 +98,15 @@ ...@@ -97,15 +98,15 @@
97 </template> 98 </template>
98 99
99 <script setup> 100 <script setup>
100 import { ref, reactive } from 'vue'; 101 import {ref, reactive} from 'vue';
101 import { onLoad } from '@dcloudio/uni-app'; 102 import {onLoad} from '@dcloudio/uni-app';
102 import { outputInvoiceNo } from '@/common/api.js'; 103 import {outputInvoiceNo} from '@/common/api.js';
103 104
104 const submitting = ref(false); 105 const submitting = ref(false);
105 106 const type = ref(0) //1个人订单只开普票
106 // 表单数据(与PC端字段完全对齐) 107 // 表单数据(与PC端字段完全对齐)
107 const form = reactive({ 108 const form = reactive({
108 invoiceType: '1', // 1=个人 2=企业 109 invoiceType: '2', // 1=企业 2=个人
109 deliveryMethod: '1', // 接收方式:1=电子发票 110 deliveryMethod: '1', // 接收方式:1=电子发票
110 name: '', // 发票抬头 111 name: '', // 发票抬头
111 taxno: '', // 纳税人识别号 112 taxno: '', // 纳税人识别号
...@@ -123,46 +124,48 @@ onLoad((options) => { ...@@ -123,46 +124,48 @@ onLoad((options) => {
123 if (options.invoiceType) { 124 if (options.invoiceType) {
124 form.invoiceType = options.invoiceType; 125 form.invoiceType = options.invoiceType;
125 } 126 }
127 type.value = options.type ?? 0
128 console.log(options)
126 }); 129 });
127 130
128 // 表单验证 131 // 表单验证
129 const validateForm = () => { 132 const validateForm = () => {
130 // 发票抬头校验 133 // 发票抬头校验
131 if (!form.name) { 134 if (!form.name) {
132 uni.showToast({ title: '请输入发票抬头', icon: 'none' }); 135 uni.showToast({title: '请输入发票抬头', icon: 'none'});
133 return false; 136 return false;
134 } 137 }
135 if (form.name.length < 2 || form.name.length > 100) { 138 if (form.name.length < 2 || form.name.length > 100) {
136 uni.showToast({ title: '发票抬头长度在2-100个字符之间', icon: 'none' }); 139 uni.showToast({title: '发票抬头长度在2-100个字符之间', icon: 'none'});
137 return false; 140 return false;
138 } 141 }
139 142
140 // 企业必须填纳税人识别号 143 // 企业必须填纳税人识别号
141 if (form.invoiceType === '2' && !form.taxno) { 144 if (form.invoiceType === '1' && !form.taxno) {
142 uni.showToast({ title: '请输入纳税人识别号', icon: 'none' }); 145 uni.showToast({title: '请输入纳税人识别号', icon: 'none'});
143 return false; 146 return false;
144 } 147 }
145 148
146 // 纳税人识别号格式校验(同PC) 149 // 纳税人识别号格式校验(同PC)
147 if (form.invoiceType === '2') { 150 if (form.invoiceType === '1') {
148 const taxReg = /^[A-Z0-9]{15}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/; 151 const taxReg = /^[A-Z0-9]{15}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/;
149 if (!taxReg.test(form.taxno)) { 152 if (!taxReg.test(form.taxno)) {
150 uni.showToast({ title: '纳税人识别号格式不正确', icon: 'none' }); 153 uni.showToast({title: '纳税人识别号格式不正确', icon: 'none'});
151 return false; 154 return false;
152 } 155 }
153 } 156 }
154 157
155 // 邮箱校验 158 // 邮箱校验
156 if (!form.phone) { 159 if (!form.phone) {
157 uni.showToast({ title: '请输入接收邮箱', icon: 'none' }); 160 uni.showToast({title: '请输入接收邮箱', icon: 'none'});
158 return false; 161 return false;
159 } 162 }
160 const phoneReg = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; 163 const phoneReg = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
161 if (!phoneReg.test(form.phone)) { 164 if (!phoneReg.test(form.phone)) {
162 uni.showToast({ title: '请输入正确的邮箱地址', icon: 'none' }); 165 uni.showToast({title: '请输入正确的邮箱地址', icon: 'none'});
163 return false; 166 return false;
164 } 167 }
165 168
166 return true; 169 return true;
167 }; 170 };
168 171
...@@ -170,7 +173,7 @@ const validateForm = () => { ...@@ -170,7 +173,7 @@ const validateForm = () => {
170 const handleSubmit = async () => { 173 const handleSubmit = async () => {
171 if (submitting.value) return; 174 if (submitting.value) return;
172 if (!validateForm()) return; 175 if (!validateForm()) return;
173 176
174 submitting.value = true; 177 submitting.value = true;
175 console.log('提交表单数据:', form); 178 console.log('提交表单数据:', form);
176 try { 179 try {
...@@ -206,19 +209,19 @@ const handleSubmit = async () => { ...@@ -206,19 +209,19 @@ const handleSubmit = async () => {
206 padding: 24rpx; 209 padding: 24rpx;
207 margin-bottom: 20rpx; 210 margin-bottom: 20rpx;
208 border-radius: 16rpx; 211 border-radius: 16rpx;
209 212
210 &.column { 213 &.column {
211 display: flex; 214 display: flex;
212 flex-direction: column; 215 flex-direction: column;
213 } 216 }
214 217
215 .label { 218 .label {
216 font-size: 28rpx; 219 font-size: 28rpx;
217 color: #333; 220 color: #333;
218 font-weight: 500; 221 font-weight: 500;
219 margin-bottom: 16rpx; 222 margin-bottom: 16rpx;
220 } 223 }
221 224
222 .input { 225 .input {
223 width: 100%; 226 width: 100%;
224 font-size: 28rpx; 227 font-size: 28rpx;
...@@ -239,18 +242,18 @@ const handleSubmit = async () => { ...@@ -239,18 +242,18 @@ const handleSubmit = async () => {
239 line-height: 80rpx; 242 line-height: 80rpx;
240 } 243 }
241 } 244 }
242 245
243 .form-item.column .input { 246 .form-item.column .input {
244 width: 100%; 247 width: 100%;
245 display: block; 248 display: block;
246 } 249 }
247 250
248 .hint { 251 .hint {
249 font-size: 24rpx; 252 font-size: 24rpx;
250 color: #909399; 253 color: #909399;
251 margin-top: 8rpx; 254 margin-top: 8rpx;
252 } 255 }
253 256
254 .amount { 257 .amount {
255 font-size: 32rpx; 258 font-size: 32rpx;
256 color: #AD181F; 259 color: #AD181F;
...@@ -273,12 +276,12 @@ const handleSubmit = async () => { ...@@ -273,12 +276,12 @@ const handleSubmit = async () => {
273 border: 2rpx solid #e4e7ed; 276 border: 2rpx solid #e4e7ed;
274 border-radius: 12rpx; 277 border-radius: 12rpx;
275 background: #fafafa; 278 background: #fafafa;
276 279
277 &.active { 280 &.active {
278 border-color: #AD181F; 281 border-color: #AD181F;
279 background: #FFF5F5; 282 background: #FFF5F5;
280 } 283 }
281 284
282 .type-icon { 285 .type-icon {
283 width: 60rpx; 286 width: 60rpx;
284 height: 60rpx; 287 height: 60rpx;
...@@ -291,28 +294,28 @@ const handleSubmit = async () => { ...@@ -291,28 +294,28 @@ const handleSubmit = async () => {
291 color: #409eff; 294 color: #409eff;
292 font-weight: 600; 295 font-weight: 600;
293 margin-right: 16rpx; 296 margin-right: 16rpx;
294 297
295 &.enterprise { 298 &.enterprise {
296 background: #f0f6ff; 299 background: #f0f6ff;
297 color: #1561CB; 300 color: #1561CB;
298 } 301 }
299 } 302 }
300 303
301 &.active .type-icon { 304 &.active .type-icon {
302 background: #AD181F; 305 background: #AD181F;
303 color: #fff; 306 color: #fff;
304 } 307 }
305 308
306 .type-info { 309 .type-info {
307 display: flex; 310 display: flex;
308 flex-direction: column; 311 flex-direction: column;
309 312
310 .type-name { 313 .type-name {
311 font-size: 28rpx; 314 font-size: 28rpx;
312 font-weight: 600; 315 font-weight: 600;
313 color: #303133; 316 color: #303133;
314 } 317 }
315 318
316 .type-desc { 319 .type-desc {
317 font-size: 22rpx; 320 font-size: 22rpx;
318 color: #909399; 321 color: #909399;
...@@ -333,12 +336,12 @@ const handleSubmit = async () => { ...@@ -333,12 +336,12 @@ const handleSubmit = async () => {
333 border: 2rpx solid #e4e7ed; 336 border: 2rpx solid #e4e7ed;
334 border-radius: 12rpx; 337 border-radius: 12rpx;
335 background: #fafafa; 338 background: #fafafa;
336 339
337 &.active { 340 &.active {
338 border-color: #AD181F; 341 border-color: #AD181F;
339 background: #FFF5F5; 342 background: #FFF5F5;
340 } 343 }
341 344
342 .method-icon { 345 .method-icon {
343 width: 60rpx; 346 width: 60rpx;
344 height: 60rpx; 347 height: 60rpx;
...@@ -352,30 +355,30 @@ const handleSubmit = async () => { ...@@ -352,30 +355,30 @@ const handleSubmit = async () => {
352 font-weight: 600; 355 font-weight: 600;
353 margin-right: 16rpx; 356 margin-right: 16rpx;
354 } 357 }
355 358
356 &.active .method-icon { 359 &.active .method-icon {
357 background: #AD181F; 360 background: #AD181F;
358 color: #fff; 361 color: #fff;
359 } 362 }
360 363
361 .method-info { 364 .method-info {
362 flex: 1; 365 flex: 1;
363 display: flex; 366 display: flex;
364 flex-direction: column; 367 flex-direction: column;
365 368
366 .method-name { 369 .method-name {
367 font-size: 28rpx; 370 font-size: 28rpx;
368 font-weight: 600; 371 font-weight: 600;
369 color: #303133; 372 color: #303133;
370 } 373 }
371 374
372 .method-desc { 375 .method-desc {
373 font-size: 22rpx; 376 font-size: 22rpx;
374 color: #909399; 377 color: #909399;
375 margin-top: 4rpx; 378 margin-top: 4rpx;
376 } 379 }
377 } 380 }
378 381
379 .method-tag { 382 .method-tag {
380 font-size: 20rpx; 383 font-size: 20rpx;
381 color: #67C23A; 384 color: #67C23A;
...@@ -407,7 +410,7 @@ const handleSubmit = async () => { ...@@ -407,7 +410,7 @@ const handleSubmit = async () => {
407 font-size: 32rpx; 410 font-size: 32rpx;
408 text-align: center; 411 text-align: center;
409 font-weight: 500; 412 font-weight: 500;
410 413
411 &.loading { 414 &.loading {
412 background: #c0c4cc; 415 background: #c0c4cc;
413 } 416 }
......
...@@ -269,7 +269,7 @@ const handlePay = async (item) => { ...@@ -269,7 +269,7 @@ const handlePay = async (item) => {
269 269
270 // 申请开票 270 // 申请开票
271 const makeInvoiceFN = (item) => { 271 const makeInvoiceFN = (item) => {
272 uni.navigateTo({url: `/pages/invoice/apply?orderId=${item.id}amount=${item.price}`}); 272 uni.navigateTo({url: `/pages/invoice/apply?orderId=${item.id}&amount=${item.price}&type=1`});
273 }; 273 };
274 274
275 // 取消订单 275 // 取消订单
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!