Skip to content

Commit be30fba

Browse files
committed
发票管理
1 parent 05a33ce commit be30fba

File tree

5 files changed

+315
-5
lines changed

5 files changed

+315
-5
lines changed

pages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@
288288
"style": {
289289
"navigationBarTitleText": "实名认证"
290290
}
291+
},
292+
{
293+
"path" : "pages/invoice/list",
294+
"style": {
295+
"navigationBarTitleText": "发票管理"
296+
}
297+
},
298+
{
299+
"path" : "pages/invoice/apply",
300+
"style": {
301+
"navigationBarTitleText": "申请发票"
302+
}
291303
}
292304
],
293305
"subPackages": [

pages/invoice/apply.vue

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<template>
2+
<view>
3+
<u-cell title="读取微信开票信息" isLink @click="chooseInvoiceTitle"></u-cell>
4+
<view class="form-box">
5+
<u-form ref="uForm" label-width="130rpx" :model="form">
6+
<u-form-item v-if="merchantId == 951" label="手机号码" prop="mobile" required>
7+
<u-input v-model="form.mobile" type="number" clearable placeholder="注册api工厂的手机号码"></u-input>
8+
</u-form-item>
9+
<u-form-item label="发票抬头" prop="comName" required>
10+
<u-input v-model="form.comName" type="text" clearable placeholder="公司名称"></u-input>
11+
</u-form-item>
12+
<u-form-item label="税号" prop="tfn" required>
13+
<u-input v-model="form.tfn" type="text" clearable placeholder="填写税号"></u-input>
14+
</u-form-item>
15+
<u-form-item label="发票内容" prop="consumption" required>
16+
<u-input v-model="form.consumption" type="text" clearable placeholder="发票上填写的服务内容"></u-input>
17+
</u-form-item>
18+
<u-form-item label="发票金额" prop="amount" required>
19+
<u-input v-model="form.amount" type="digit" clearable placeholder="申请开票金额"></u-input>
20+
</u-form-item>
21+
<u-form-item label="地址电话" prop="address">
22+
<u-input v-model="form.address" type="digit" clearable placeholder="发票栏目处填写的地址与电话"></u-input>
23+
</u-form-item>
24+
<u-form-item label="银行账号" prop="bank">
25+
<u-input v-model="form.bank" type="text" clearable placeholder="发票栏目处填写的开户行与账号"></u-input>
26+
</u-form-item>
27+
<u-form-item label="电子邮箱" prop="email" required>
28+
<u-input v-model="form.email" type="text" clearable placeholder="发票将通过邮件发送给你"></u-input>
29+
</u-form-item>
30+
<u-form-item label="备注" prop="remark">
31+
<u-input v-model="form.remark" type="text" clearable placeholder="如有特殊说明,请告诉我们"></u-input>
32+
</u-form-item>
33+
</u-form>
34+
</view>
35+
<view class="submit-btn">
36+
<u-button type="success" @click="submit">申请发票</u-button>
37+
</view>
38+
<view class="bottom">
39+
<u-cell title="发票管理" isLink url="/pages/invoice/list"></u-cell>
40+
</view>
41+
</view>
42+
</template>
43+
44+
<script>
45+
export default {
46+
data() {
47+
return {
48+
merchantId: undefined,
49+
rules: {
50+
mobile: [{
51+
required: true,
52+
message: '不能为空',
53+
// 可以单个或者同时写两个触发验证方式
54+
trigger: ['change', 'blur'],
55+
}],
56+
comName: [{
57+
required: true,
58+
message: '不能为空',
59+
// 可以单个或者同时写两个触发验证方式
60+
trigger: ['change', 'blur'],
61+
}],
62+
tfn: [{
63+
required: true,
64+
message: '不能为空',
65+
// 可以单个或者同时写两个触发验证方式
66+
trigger: ['change', 'blur'],
67+
}],
68+
consumption: [{
69+
required: true,
70+
message: '不能为空',
71+
// 可以单个或者同时写两个触发验证方式
72+
trigger: ['change', 'blur'],
73+
}],
74+
amount: [{
75+
required: true,
76+
message: '不能为空',
77+
// 可以单个或者同时写两个触发验证方式
78+
trigger: ['change', 'blur'],
79+
}],
80+
email: [{
81+
required: true,
82+
message: '不能为空',
83+
// 可以单个或者同时写两个触发验证方式
84+
trigger: ['change', 'blur'],
85+
}],
86+
},
87+
form: {
88+
mobile: null,
89+
comName: null,
90+
tfn: null,
91+
consumption: '服务费',
92+
amount: null,
93+
address: null,
94+
bank: null,
95+
email: null,
96+
remark: null,
97+
orderId: '',
98+
},
99+
}
100+
},
101+
created() {
102+
103+
},
104+
mounted() {
105+
106+
},
107+
onReady() {
108+
this.$refs.uForm.setRules(this.rules);
109+
},
110+
onLoad(e) {
111+
this.merchantId = getApp().globalData.merchantId
112+
if (e.orderId) {
113+
this.form.orderId = e.orderId
114+
this.orderDetail(e.orderId)
115+
}
116+
},
117+
onShow() {
118+
119+
},
120+
onShareAppMessage(e) {
121+
return {
122+
title: '申请开票',
123+
path: '/pages/invoice/apply?inviter_id=' + this.uid
124+
}
125+
},
126+
methods: {
127+
async orderDetail(orderId) {
128+
const res = await this.$wxapi.orderDetail(this.token, orderId)
129+
if (res.code == 0) {
130+
this.form.amount = res.data.orderInfo.amountReal + ''
131+
}
132+
},
133+
chooseInvoiceTitle() {
134+
uni.chooseInvoiceTitle({
135+
success: (res) => {
136+
this.form.comName = res.title
137+
this.form.tfn = res.taxNumber
138+
this.form.address = res.companyAddress + res.telephone
139+
this.form.bank = res.bankName + res.bankAccount
140+
},
141+
fail: err => {
142+
console.error(err);
143+
uni.showToast({
144+
title: '读取失败',
145+
icon: 'none'
146+
})
147+
}
148+
})
149+
},
150+
submit() {
151+
this.$refs.uForm.validate().then(res => {
152+
this._submit()
153+
}).catch(errors => {
154+
uni.showToast({
155+
title: '表单请填写完整',
156+
icon: 'none'
157+
})
158+
})
159+
},
160+
async _submit() {
161+
const extJsonStr = {}
162+
extJsonStr['api工厂账号'] = this.form.mobile
163+
extJsonStr['地址与电话'] = this.form.address
164+
extJsonStr['开户行与账号'] = this.form.bank
165+
const res = await this.$wxapi.invoiceApply({
166+
token: this.token,
167+
...this.form,
168+
extJsonStr: JSON.stringify(extJsonStr)
169+
})
170+
if (res.code == 0) {
171+
uni.showModal({
172+
title: '成功',
173+
content: '提交成功,请耐心等待我们处理!',
174+
showCancel: false,
175+
confirmText: '我知道了',
176+
success(res) {
177+
uni.navigateTo({
178+
url: "/pages/invoice/list"
179+
})
180+
}
181+
})
182+
} else {
183+
uni.showModal({
184+
title: '失败',
185+
content: res.msg,
186+
showCancel: false,
187+
confirmText: '我知道了'
188+
})
189+
}
190+
},
191+
}
192+
}
193+
</script>
194+
<style scoped lang="scss">
195+
.bottom {
196+
padding-bottom: 48rpx;
197+
}
198+
</style>

pages/invoice/list.vue

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<template>
2+
<view>
3+
<page-box-empty v-if="!invoiceList" title="暂无数据" sub-title="前往申请发票~" :show-btn="true" btn-name="申请发票" url="/pages/invoice/apply" />
4+
<u-cell-group v-for="(item,index) in invoiceList" :key="item.id" :title="item.comName">
5+
<u-cell title="金额" :value="item.amount"></u-cell>
6+
<u-cell title="内容" :value="item.consumption"></u-cell>
7+
<u-cell title="状态">
8+
<view slot="value">
9+
<u-tag v-if="item.status == 0" text="待处理"></u-tag>
10+
<u-tag v-if="item.status == 1" type="error" text="不通过"></u-tag>
11+
<u-tag v-if="item.status == 2" type="warning" text="开票中"></u-tag>
12+
<u-tag v-if="item.status == 3" type="success" text="已开票"></u-tag>
13+
</view>
14+
</u-cell>
15+
<u-cell v-if="item.email" title="邮箱" :value="item.email"></u-cell>
16+
<u-cell title="申请日期" :value="item.dateAdd"></u-cell>
17+
<u-cell v-if="item.file" title="查看" value="打开电子发票" isLink @click="download(item.file)"></u-cell>
18+
</u-cell-group>
19+
</view>
20+
</template>
21+
22+
<script>
23+
export default {
24+
data() {
25+
return {
26+
invoiceList: undefined
27+
28+
}
29+
},
30+
created() {
31+
32+
},
33+
mounted() {
34+
35+
},
36+
onReady() {
37+
38+
},
39+
onLoad(e) {
40+
this._invoiceList()
41+
},
42+
onShow() {
43+
44+
},
45+
methods: {
46+
async _invoiceList() {
47+
const res = await this.$wxapi.invoiceList({
48+
token: this.token
49+
})
50+
if (res.code == 0) {
51+
this.invoiceList = res.data.result
52+
}
53+
},
54+
download(file) {
55+
const _this = this
56+
uni.downloadFile({
57+
url: file,
58+
success (res) {
59+
const tempFilePath = res.tempFilePath
60+
console.log(tempFilePath);
61+
uni.openDocument({
62+
filePath: tempFilePath,
63+
showMenu: true,
64+
success: function (res) {
65+
console.log('打开文档成功')
66+
}
67+
})
68+
}
69+
})
70+
},
71+
}
72+
}
73+
</script>
74+
<style scoped lang="scss">
75+
76+
</style>

pages/my/index.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@
8686
<text class="txt">收货地址</text>
8787
</view>
8888
</u-grid-item>
89+
<u-grid-item name="/pages/invoice/list">
90+
<view class="grid_item">
91+
<u-icon name="red-packet" size="52rpx"></u-icon>
92+
<text class="txt">发票管理</text>
93+
</view>
94+
</u-grid-item>
95+
<u-grid-item name="/pages/invoice/apply">
96+
<view class="grid_item">
97+
<u-icon name="red-packet" size="52rpx"></u-icon>
98+
<text class="txt">申请发票</text>
99+
</view>
100+
</u-grid-item>
89101
</u-grid>
90102
<u-line></u-line>
91103
<u-gap height="5" bgColor="#EAEBEC"></u-gap>

pages/order/index.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@
5252
<u-button type="error" plain size="small" shape="circle" text="撤销售后"
5353
@click="refundCancel(item)"></u-button>
5454
</view>
55-
<view v-else class="btn-box">
56-
<u-button type="error" plain size="small" shape="circle" text="退换货" @click="refund(item)">
57-
</u-button>
55+
<view v-else class="btn-group">
56+
<view class="btn-box">
57+
<u-button type="error" plain size="small" shape="circle" text="退换货" @click="refund(item)"></u-button>
58+
</view>
59+
<view v-if="!item.invoiceId && item.status >= 3" class="btn-box">
60+
<u-button type="success" plain size="small" shape="circle" text="申请发票" @click="invoice(item)"></u-button>
61+
</view>
5862
</view>
5963
</view>
6064
</view>
@@ -302,7 +306,12 @@
302306
icon: 'none'
303307
})
304308
}
305-
}
309+
},
310+
invoice(item) {
311+
uni.navigateTo({
312+
url: '/pages/invoice/apply?orderId=' + item.id
313+
})
314+
},
306315
}
307316
};
308317
</script>
@@ -449,8 +458,11 @@
449458
.ml24 {
450459
margin-left: 24rpx;
451460
}
452-
461+
.btn-group {
462+
display: flex;
463+
}
453464
.btn-box {
465+
padding: 0 16rpx;
454466
width: 160rpx;
455467
}
456468
</style>

0 commit comments

Comments
 (0)