修改发票下载查询和发票信息修改

This commit is contained in:
qiaomu 2024-06-05 16:16:21 +08:00
parent 8ecb1e5977
commit 8b970f2b8f
5 changed files with 70 additions and 37 deletions

View File

@ -1,5 +1,5 @@
import { getInvoiceInfoDetail, downloadInvoice } from "../../service/invoice";
import { alertInfo, loadingFunc } from "../../utils/index";
import { alertError, alertInfo, loadingFunc } from "../../utils/index";
import request from '../../utils/request'
const { OK } = request;
// pages/invoiceInfo/index.js
@ -43,22 +43,34 @@ Page({
alertInfo(message)
return;
}
if (!data) {
alertInfo("暂无文档信息")
return
}
wx.downloadFile({
url: data,
success(res) {
if (res.statusCode === 200) {
if (!res.tempFilePath) {
alertError("没有开票信息")
return;
}
wx.openDocument({
filePath: res.tempFilePath,
fileType: [res.tapIndex === 0 ? 'xml' : "pdf"], // 3. 这个必须写合法类型,不然下载不了
success: function (res) {
},
fail: function (e) {
alertError("打开失败")
console.log('打开失败错误为', e)
}
})
}
},
fail: (e) => {
console.log('e', e)
alertInfo("下载文件失败")
}
})
})

View File

@ -30,4 +30,10 @@
.invoiceContent, .invoiceType, .time {
margin-top: 30rpx;
font-size: 32rpx;
}
.operate {
display: flex;
flex-direction: column;
justify-content: flex-end;
}

View File

@ -1,6 +1,6 @@
import { getInvoiceInfo, updateInvoiceInfo } from "../../../../service/invoice"
import { getUserInfo } from "../../../../service/user";
import { alertInfo, alertSuccess } from "../../../../utils/index";
import { alertInfo, alertSuccess, isValidPhoneNumber } from "../../../../utils/index";
import request from '../../../../utils/request'
const { OK } = request
@ -93,9 +93,9 @@ Component({
// alertInfo("请输入地址")
// return;
// }
if (!phone) {
alertInfo("请输入电话")
return;
if (phone && !isValidPhoneNumber(phone)) {
alertInfo("手机号格式不正确")
return
}
if (!bank) {
alertInfo("请输入开户行")

View File

@ -121,23 +121,7 @@
<view> {{detail.address || '-'}} </view>
</view>
</van-field>
<van-field
label="电话"
wx:if="{{(detail.headerType === 0)}}"
placeholder="{{editType === 'edit' ? '请输入电话' : ''}}"
custom-style="padding-left: 0; padding-right: 0;"
readonly="{{editType === 'detail'}}"
autosize="{{true}}"
type="textarea"
title-width="132rpx"
border="{{ editType === 'detail' ? false : true }}"
bind:change="onChangeText"
data-name="phone"
>
<view slot="input" style="margin-top: -10rpx;">
<view> {{detail.phone || '-'}} </view>
</view>
</van-field>
<van-field
label="备注"
wx:if="{{editType === 'detail' }}"
@ -255,17 +239,7 @@
data-name="address"
/>
<van-field
value="{{formData.phone }}"
label="电话"
wx:if="{{(formData.headerType === 0) }}"
placeholder="{{ '请输入电话'}}"
custom-style="padding-left: 0; padding-right: 0;"
title-width="132rpx"
border="{{ true }}"
bind:change="onChangeText"
data-name="phone"
/>
<van-field
value="{{formData.remark}}"
@ -285,6 +259,38 @@
<view class="cardWrapper" style="margin-bottom: 40rpx;">
<card title="接收信息">
<view slot="content">
<view wx:if="{{editType === 'detail'}}">
<van-field
label="手机号"
wx:if="{{(detail.headerType === 0)}}"
placeholder="{{editType === 'edit' ? '请输入手机号' : ''}}"
custom-style="padding-left: 0; padding-right: 0;"
readonly="{{editType === 'detail'}}"
autosize="{{true}}"
type="textarea"
title-width="132rpx"
border="{{ editType === 'detail' ? false : true }}"
bind:change="onChangeText"
data-name="phone"
>
<view slot="input" style="margin-top: -10rpx;">
<view> {{detail.phone || '-'}} </view>
</view>
</van-field>
</view>
<view wx:else>
<van-field
value="{{formData.phone }}"
label="手机号"
wx:if="{{(formData.headerType === 0) }}"
placeholder="{{ '请输入手机号' }}"
custom-style="padding-left: 0; padding-right: 0;"
title-width="132rpx"
border="{{ true }}"
bind:change="onChangeText"
data-name="phone"
/>
</view>
<van-field
value="{{detail.email || '--'}}"
wx:if="{{editType === 'detail'}}"
@ -297,7 +303,11 @@
border="{{ editType === 'detail' ? false : true }}"
bind:change="onChangeText"
data-name="email"
/>
>
<view slot="input" style="margin-top: -10rpx;">
<view> {{detail.email || '-'}} </view>
</view>
</van-field>
<van-field
value="{{formData.email}}"
wx:else

View File

@ -233,3 +233,8 @@ export const getPixelRatio = () => {
})
return pixelRatio
}
export function isValidPhoneNumber(phoneNumber) {
return /^1\d{10}$/.test(phoneNumber);
}