Files
gxtyzx-uniapp/dist/dev/mp-weixin/package/user/invoice.js
T

396 lines
12 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const store_modules_user = require("../../store/modules/user.js");
const api_booking_userInvoice_index = require("../../api/booking/userInvoice/index.js");
const utils_common = require("../../utils/common.js");
const store_modules_tenant = require("../../store/modules/tenant.js");
store_modules_tenant.useTenantStore();
const userStore = store_modules_user.useUserStore();
const _sfc_main = {
data() {
return {
orderId: 0,
list: [],
statusBarHeight: 104,
isLogin: false,
fields: {},
logo: "",
bookingUser: {},
server: [],
order: [],
// 表单数据
formData: {
type: 0,
invoiceType: 0
},
// 发票类型
type: [
{
text: "电子",
value: 0
},
{
text: "纸质",
value: 1
}
],
// 开票类型
invoiceType: [
{
text: "普票",
value: 0
},
{
text: "专票",
value: 1
}
],
rules: {
// 对name字段进行必填验证
name: {
rules: [
{
required: true,
errorMessage: "请输入开票名称"
}
]
},
// 对email字段进行必填验证
email: {
rules: [
{
format: "email",
errorMessage: "请输入正确的邮箱地址"
}
]
}
}
};
},
onLoad(e) {
this.orderId = e.id;
},
onShow() {
this.reload();
},
methods: {
async reload(e) {
const app = this;
const userInfo = await userStore.fetchUserInfo();
if (Object.keys(userInfo).length > 0) {
app.isLogin = true;
app.userInfo = userInfo;
} else {
app.isLogin = false;
}
api_booking_userInvoice_index.pageUserInvoice({
userId: userInfo.userId,
limit: 1
}).then((res) => {
if (res.count > 0 && !app.formData.id) {
app.formData = res.list[0];
app.formData.orderId = app.orderId;
}
});
},
navTo(item) {
if (!this.isLogin) {
this.$refs.login.open("bottom");
return false;
}
utils_common.openUrl(item);
},
// 弹出登录提示框
openLogin() {
if (!this.isLogin) {
this.$refs.login.open("bottom");
return false;
}
},
editInvoice() {
common_vendor.index.navigateTo({
url: `/package/user/invoice-edit?id=${this.formData.id}`
});
},
add() {
this.$refs.addForm.open("center");
},
onDel(item) {
const app = this;
common_vendor.index.showModal({
title: "确定要删除吗?",
success(o) {
if (o.confirm) {
common_vendor.index.showLoading({
title: "请求中."
});
api_booking_userInvoice_index.removeUserInvoice(item.id).then((res) => {
common_vendor.index.showToast({
title: "操作成功",
icon: "none"
});
});
app.reload();
}
}
});
},
/**
* 复写 binddata 方法,如果只是为了校验,无复杂自定义操作,可忽略此方法
* @param {String} name 字段名称
* @param {String} value 表单域的值
*/
// binddata(name,value){
// // 通过 input 事件设置表单指定 name 的值
// this.$refs.form.setValue(name, value)
// },
// 触发提交表单
submit() {
const { formData } = this;
this.$refs.form.validate().then((res) => {
api_booking_userInvoice_index.doInvoice(formData).then((message) => {
console.log("message: ", message);
common_vendor.index.showToast({
title: "开票成功",
icon: "success"
});
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1e3);
}).catch((err) => {
console.log(err);
});
console.log("表单数据信息:", res);
}).catch((err) => {
console.log("表单错误信息:", err);
});
}
}
};
if (!Array) {
const _easycom_uv_icon2 = common_vendor.resolveComponent("uv-icon");
const _easycom_uv_cell2 = common_vendor.resolveComponent("uv-cell");
const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card");
const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
const _easycom_uv_input2 = common_vendor.resolveComponent("uv-input");
const _easycom_uv_textarea2 = common_vendor.resolveComponent("uv-textarea");
const _easycom_uv_button2 = common_vendor.resolveComponent("uv-button");
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
(_easycom_uv_icon2 + _easycom_uv_cell2 + _easycom_uni_card2 + _easycom_uni_data_checkbox2 + _easycom_uni_forms_item2 + _easycom_uv_input2 + _easycom_uv_textarea2 + _easycom_uv_button2 + _easycom_uni_forms2)();
}
const _easycom_uv_icon = () => "../../uni_modules/uv-icon/components/uv-icon/uv-icon.js";
const _easycom_uv_cell = () => "../../uni_modules/uv-cell/components/uv-cell/uv-cell.js";
const _easycom_uni_card = () => "../../uni_modules/uni-card/components/uni-card/uni-card.js";
const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
const _easycom_uv_input = () => "../../uni_modules/uv-input/components/uv-input/uv-input.js";
const _easycom_uv_textarea = () => "../../uni_modules/uv-textarea/components/uv-textarea/uv-textarea.js";
const _easycom_uv_button = () => "../../uni_modules/uv-button/components/uv-button/uv-button.js";
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
if (!Math) {
(_easycom_uv_icon + _easycom_uv_cell + _easycom_uni_card + _easycom_uni_data_checkbox + _easycom_uni_forms_item + _easycom_uv_input + _easycom_uv_textarea + _easycom_uv_button + _easycom_uni_forms)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.p({
name: "arrow-right"
}),
b: common_vendor.o($options.editInvoice),
c: common_vendor.p({
title: `${$data.formData.name ? $data.formData.name : "请填写开票信息"}`,
label: `${$data.formData.isCompany == 1 ? "单位" : "个人"}`,
cellStyle: {
padding: "5px 0"
},
border: false
}),
d: common_vendor.p({
border: false,
["is-shadow"]: false
}),
e: $data.formData.name
}, $data.formData.name ? common_vendor.e({
f: common_vendor.o(($event) => $data.formData.type = $event),
g: common_vendor.p({
localdata: $data.type,
modelValue: $data.formData.type
}),
h: common_vendor.p({
label: "发票类型",
name: "type"
}),
i: common_vendor.o(($event) => $data.formData.invoiceType = $event),
j: common_vendor.p({
localdata: $data.invoiceType,
modelValue: $data.formData.invoiceType
}),
k: common_vendor.p({
label: "开票类型",
name: "invoiceType"
}),
l: $data.formData.isCompany == 0
}, $data.formData.isCompany == 0 ? {
m: common_vendor.o(($event) => $data.formData.name = $event),
n: common_vendor.p({
disabled: true,
type: "text",
modelValue: $data.formData.name
}),
o: common_vendor.p({
label: "名称",
name: "name",
required: true
}),
p: common_vendor.o(($event) => $data.formData.phone = $event),
q: common_vendor.p({
disabled: true,
type: "text",
placeholder: "手机号码",
modelValue: $data.formData.phone
}),
r: common_vendor.p({
label: "手机号码",
name: "phone",
required: true
}),
s: common_vendor.o(($event) => $data.formData.email = $event),
t: common_vendor.p({
disabled: true,
type: "text",
placeholder: "电子邮箱",
modelValue: $data.formData.email
}),
v: common_vendor.p({
label: "电子邮箱",
name: "email",
required: true
})
} : {}, {
w: $data.formData.isCompany == 1
}, $data.formData.isCompany == 1 ? {
x: common_vendor.o(($event) => $data.formData.name = $event),
y: common_vendor.p({
type: "text",
placeholder: "单位名称(必填)",
modelValue: $data.formData.name
}),
z: common_vendor.p({
label: "名称",
name: "name",
required: true
}),
A: common_vendor.o(($event) => $data.formData.invoiceCode = $event),
B: common_vendor.p({
type: "text",
placeholder: "纳税人识别号(必填)",
modelValue: $data.formData.invoiceCode
}),
C: common_vendor.p({
label: "税号",
name: "invoiceCode",
required: true
}),
D: common_vendor.o(($event) => $data.formData.phone = $event),
E: common_vendor.p({
type: "text",
placeholder: "手机号码",
modelValue: $data.formData.phone
}),
F: common_vendor.p({
label: "手机号码",
name: "phone",
required: true
}),
G: common_vendor.o(($event) => $data.formData.email = $event),
H: common_vendor.p({
type: "text",
placeholder: "电子邮箱",
modelValue: $data.formData.email
}),
I: common_vendor.p({
label: "电子邮箱",
name: "email",
required: true
}),
J: common_vendor.o(($event) => $data.formData.bankName = $event),
K: common_vendor.p({
type: "text",
placeholder: "开户银行名称",
modelValue: $data.formData.bankName
}),
L: common_vendor.p({
label: "开户行",
name: "bankName",
required: true
}),
M: common_vendor.o(($event) => $data.formData.bankAccount = $event),
N: common_vendor.p({
type: "text",
placeholder: "开户银行账号",
modelValue: $data.formData.bankAccount
}),
O: common_vendor.p({
label: "银行账号",
name: "bankAccount",
required: true
}),
P: common_vendor.o(($event) => $data.formData.address = $event),
Q: common_vendor.p({
type: "text",
placeholder: "单位地址",
modelValue: $data.formData.address
}),
R: common_vendor.p({
label: "单位地址",
name: "address",
required: true
}),
S: common_vendor.o(($event) => $data.formData.tel = $event),
T: common_vendor.p({
type: "text",
placeholder: "单位电话",
modelValue: $data.formData.tel
}),
U: common_vendor.p({
label: "单位电话",
name: "tel",
required: true
}),
V: common_vendor.o(($event) => $data.formData.comments = $event),
W: common_vendor.p({
placeholder: "请输入备注信息",
["auto-height"]: true,
modelValue: $data.formData.comments
}),
X: common_vendor.p({
label: "备注",
name: "comments"
})
} : {}, {
Y: common_vendor.o($options.submit),
Z: common_vendor.p({
customStyle: {
background: "linear-gradient(to right, #70b915, #008e04)",
borderRadius: "30px",
color: "#ffffff"
},
text: "确认开票"
}),
aa: common_vendor.sr("form", "87ef8712-4,87ef8712-3"),
ab: common_vendor.p({
modelValue: $data.formData,
rules: $data.rules,
["label-width"]: 100,
["label-position"]: "left"
}),
ac: common_vendor.p({
border: false,
["is-shadow"]: false,
padding: 20
})
}) : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/package/user/invoice.vue"]]);
wx.createPage(MiniProgramPage);