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">
...@@ -34,21 +35,21 @@ ...@@ -34,21 +35,21 @@
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>
...@@ -78,8 +79,8 @@ ...@@ -78,8 +79,8 @@
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 />
...@@ -89,7 +90,7 @@ ...@@ -89,7 +90,7 @@
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,43 +124,45 @@ onLoad((options) => { ...@@ -123,43 +124,45 @@ 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
......
...@@ -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!