调整微信小程序的报错。
This commit is contained in:
380
unpackage/dist/dev/mp-weixin/common_begin_reception.js
vendored
Normal file
380
unpackage/dist/dev/mp-weixin/common_begin_reception.js
vendored
Normal file
@@ -0,0 +1,380 @@
|
||||
"use strict";
|
||||
const common_vendor = require("./common/vendor.js");
|
||||
const common_config = require("./common/config.js");
|
||||
const _sfc_main = {
|
||||
name: "ReceptionForm",
|
||||
props: {
|
||||
// 表单初始数据
|
||||
initialData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
genderOptions: ["男", "女"],
|
||||
customerSourceOptions: ["自然到店", "网络媒体", "其他类型"],
|
||||
showCustomerSourceDropdown: false,
|
||||
isFetchingContact: false,
|
||||
formData: {
|
||||
id: "",
|
||||
customerName: "",
|
||||
contact: "",
|
||||
customerSource: "",
|
||||
gender: "女",
|
||||
age: "",
|
||||
dealershipId: "",
|
||||
dealershipName: "",
|
||||
salesId: "",
|
||||
salesName: "",
|
||||
salesPhone: "",
|
||||
recordingCount: 0,
|
||||
intendedModel: "",
|
||||
infoCard: "",
|
||||
remark: "",
|
||||
detailedAddress: "",
|
||||
contactCount: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
initialData: {
|
||||
handler(newVal) {
|
||||
if (newVal && Object.keys(newVal).length > 0) {
|
||||
this.formData = { ...this.formData, ...newVal };
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadCurrentUserInfo();
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 加载当前登录用户信息,填充销售姓名和电话
|
||||
*/
|
||||
loadCurrentUserInfo() {
|
||||
try {
|
||||
const loginResponse = common_vendor.index.getStorageSync("backend-login-response") || {};
|
||||
if (loginResponse.userName) {
|
||||
this.formData.salesName = loginResponse.userName;
|
||||
}
|
||||
if (loginResponse.phone) {
|
||||
this.formData.salesPhone = loginResponse.phone;
|
||||
} else if (loginResponse.userName) {
|
||||
this.formData.salesPhone = loginResponse.userName;
|
||||
}
|
||||
if (loginResponse.userId) {
|
||||
this.formData.salesId = String(loginResponse.userId);
|
||||
}
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/furniture_reception/common_begin_reception.vue:239", "加载当前登录用户信息失败:", e);
|
||||
}
|
||||
},
|
||||
onGenderChange(e) {
|
||||
this.formData.gender = e.detail.value;
|
||||
},
|
||||
toggleCustomerSourceDropdown() {
|
||||
this.showCustomerSourceDropdown = !this.showCustomerSourceDropdown;
|
||||
},
|
||||
selectCustomerSource(option) {
|
||||
this.formData.customerSource = option;
|
||||
this.showCustomerSourceDropdown = false;
|
||||
},
|
||||
closeCustomerSourceDropdown() {
|
||||
this.showCustomerSourceDropdown = false;
|
||||
},
|
||||
onContactBlur() {
|
||||
var _a;
|
||||
const contact = (_a = this.formData.contact) == null ? void 0 : _a.trim();
|
||||
if (!contact) {
|
||||
return;
|
||||
}
|
||||
if (!this.isValidPhoneNumber(contact)) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入有效的手机号",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.fetchCustomerByContact();
|
||||
},
|
||||
isValidPhoneNumber(phone) {
|
||||
const normalizedPhone = phone == null ? void 0 : phone.trim();
|
||||
if (!normalizedPhone) {
|
||||
return false;
|
||||
}
|
||||
return /^1[3-9]\d{9}$/.test(normalizedPhone);
|
||||
},
|
||||
async fetchCustomerByContact() {
|
||||
var _a, _b, _c;
|
||||
const contact = (_a = this.formData.contact) == null ? void 0 : _a.trim();
|
||||
if (!contact || this.isFetchingContact) {
|
||||
return;
|
||||
}
|
||||
if (!this.isValidPhoneNumber(contact)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.isFetchingContact = true;
|
||||
const url = `${common_config.getApiUrl("/api/customerManagement/getByContact")}?contact=${encodeURIComponent(contact)}`;
|
||||
let tenantId = "";
|
||||
let token = "";
|
||||
try {
|
||||
tenantId = common_vendor.index.getStorageSync("backend-tenant-id") || "";
|
||||
token = common_vendor.index.getStorageSync("backend-token") || "";
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/furniture_reception/common_begin_reception.vue:296", "获取认证信息失败:", e);
|
||||
}
|
||||
const headers = {};
|
||||
if (token) {
|
||||
headers["Authorization"] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers["X-Tenant-Id"] = tenantId;
|
||||
}
|
||||
const res = await common_vendor.index.request({
|
||||
url,
|
||||
method: "GET",
|
||||
header: headers,
|
||||
timeout: 3e4
|
||||
// 增加超时时间到30秒
|
||||
});
|
||||
const list = (_b = res.data) == null ? void 0 : _b.data;
|
||||
if (res.statusCode === 200 && ((_c = res.data) == null ? void 0 : _c.success) && Array.isArray(list) && list.length) {
|
||||
const customer = list[0];
|
||||
const retrievedId = customer.id || customer.customerId || "";
|
||||
const resolvedSalesPhone = customer.salesPhone || customer.salesMobile || customer.salesTel || this.formData.salesPhone || "";
|
||||
this.formData = {
|
||||
...this.formData,
|
||||
id: retrievedId ? String(retrievedId) : this.formData.id,
|
||||
customerName: customer.customerName || this.formData.customerName,
|
||||
customerSource: customer.customerSource || this.formData.customerSource,
|
||||
dealershipId: customer.dealershipId ? String(customer.dealershipId) : this.formData.dealershipId,
|
||||
dealershipName: customer.dealershipName || this.formData.dealershipName,
|
||||
salesId: customer.salesId ? String(customer.salesId) : this.formData.salesId,
|
||||
salesName: customer.salesName || this.formData.salesName,
|
||||
salesPhone: String(resolvedSalesPhone),
|
||||
recordingCount: Number(customer.recordingCount) || 0,
|
||||
intendedModel: customer.intendedModel || this.formData.intendedModel,
|
||||
infoCard: customer.infoCard || this.formData.infoCard,
|
||||
remark: customer.remark || this.formData.remark,
|
||||
detailedAddress: customer.detailedAddress || this.formData.detailedAddress,
|
||||
contactCount: customer.contactCount ?? this.formData.contactCount
|
||||
};
|
||||
common_vendor.index.showToast({
|
||||
title: "已填充客户信息",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/furniture_reception/common_begin_reception.vue:348", "查询客户信息失败:", error);
|
||||
} finally {
|
||||
this.isFetchingContact = false;
|
||||
}
|
||||
},
|
||||
handleCancel() {
|
||||
this.formData = {
|
||||
id: "",
|
||||
customerName: "",
|
||||
contact: "",
|
||||
customerSource: "",
|
||||
gender: "女",
|
||||
age: "",
|
||||
dealershipId: "",
|
||||
dealershipName: "",
|
||||
salesId: "",
|
||||
salesName: "",
|
||||
salesPhone: "",
|
||||
recordingCount: 0,
|
||||
intendedModel: "",
|
||||
infoCard: "",
|
||||
remark: "",
|
||||
detailedAddress: "",
|
||||
contactCount: 0
|
||||
};
|
||||
this.loadCurrentUserInfo();
|
||||
this.$emit("cancel");
|
||||
common_vendor.index.showToast({
|
||||
title: "已取消",
|
||||
icon: "none"
|
||||
});
|
||||
},
|
||||
async handleSave(action = "save") {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
||||
const trimmedContact = (_a = this.formData.contact) == null ? void 0 : _a.trim();
|
||||
if (trimmedContact && !this.isValidPhoneNumber(trimmedContact)) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入有效的客户电话",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
const trimmedSalesPhone = (_b = this.formData.salesPhone) == null ? void 0 : _b.trim();
|
||||
if (trimmedSalesPhone && !this.isValidPhoneNumber(trimmedSalesPhone)) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入有效的销售电话",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
const normalizedCustomerId = ((_c = this.formData.id) == null ? void 0 : _c.toString().trim()) || "";
|
||||
const params = {
|
||||
id: normalizedCustomerId,
|
||||
customerName: (_d = this.formData.customerName) == null ? void 0 : _d.trim(),
|
||||
contact: trimmedContact,
|
||||
customerSource: ((_e = this.formData.customerSource) == null ? void 0 : _e.trim()) || "",
|
||||
dealershipId: String(this.formData.dealershipId || "").trim() || "",
|
||||
dealershipName: ((_f = this.formData.dealershipName) == null ? void 0 : _f.trim()) || "",
|
||||
salesId: String(this.formData.salesId || "").trim() || "",
|
||||
salesName: ((_g = this.formData.salesName) == null ? void 0 : _g.trim()) || "",
|
||||
recordingCount: Number(this.formData.recordingCount) || 0,
|
||||
intendedModel: ((_h = this.formData.intendedModel) == null ? void 0 : _h.trim()) || "",
|
||||
infoCard: ((_i = this.formData.infoCard) == null ? void 0 : _i.trim()) || "",
|
||||
remark: ((_j = this.formData.remark) == null ? void 0 : _j.trim()) || "",
|
||||
detailedAddress: ((_k = this.formData.detailedAddress) == null ? void 0 : _k.trim()) || "",
|
||||
salesPhone: trimmedSalesPhone || "",
|
||||
contactCount: Number(this.formData.contactCount) || 0,
|
||||
operationType: action,
|
||||
scenario: "furniture"
|
||||
};
|
||||
try {
|
||||
common_vendor.index.showLoading({
|
||||
title: "保存中..."
|
||||
});
|
||||
let tenantId = "";
|
||||
let token = "";
|
||||
try {
|
||||
tenantId = common_vendor.index.getStorageSync("backend-tenant-id") || "";
|
||||
token = common_vendor.index.getStorageSync("backend-token") || "";
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/furniture_reception/common_begin_reception.vue:437", "获取认证信息失败:", e);
|
||||
}
|
||||
const headers = {
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
if (token) {
|
||||
headers["Authorization"] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers["X-Tenant-Id"] = tenantId;
|
||||
}
|
||||
const res = await common_vendor.index.request({
|
||||
url: common_config.getApiUrl("/api/customerManagement/add"),
|
||||
method: "POST",
|
||||
data: params,
|
||||
header: headers,
|
||||
timeout: 3e4
|
||||
// 增加超时时间到30秒
|
||||
});
|
||||
common_vendor.index.hideLoading();
|
||||
if (res.statusCode === 200 && res.data && res.data.success) {
|
||||
common_vendor.index.showToast({
|
||||
title: "保存成功",
|
||||
icon: "success"
|
||||
});
|
||||
this.handleCancel();
|
||||
this.$emit("save-success", { action, data: params });
|
||||
} else {
|
||||
common_vendor.index.showToast({
|
||||
title: ((_l = res.data) == null ? void 0 : _l.message) || "保存失败",
|
||||
icon: "none"
|
||||
});
|
||||
this.$emit("save-error", { action, error: ((_m = res.data) == null ? void 0 : _m.message) || "保存失败" });
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("error", "at pages/furniture_reception/common_begin_reception.vue:480", "保存失败:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: "保存失败,请重试",
|
||||
icon: "none"
|
||||
});
|
||||
this.$emit("save-error", { action, error: error.message || "保存失败,请重试" });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||||
_easycom_uni_icons2();
|
||||
}
|
||||
const _easycom_uni_icons = () => "./uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
||||
if (!Math) {
|
||||
_easycom_uni_icons();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.t($data.formData.recordingCount || 0),
|
||||
b: $data.formData.customerName,
|
||||
c: common_vendor.o(($event) => $data.formData.customerName = $event.detail.value),
|
||||
d: common_vendor.o((...args) => $options.onContactBlur && $options.onContactBlur(...args)),
|
||||
e: $data.formData.contact,
|
||||
f: common_vendor.o(($event) => $data.formData.contact = $event.detail.value),
|
||||
g: common_vendor.t($data.formData.customerSource || "请选择客户来源"),
|
||||
h: common_vendor.n($data.formData.customerSource ? "form-item__picker-text" : "form-item__picker-placeholder"),
|
||||
i: common_vendor.p({
|
||||
type: "bottom",
|
||||
size: "16",
|
||||
color: "#9ca3af"
|
||||
}),
|
||||
j: common_vendor.o((...args) => $options.toggleCustomerSourceDropdown && $options.toggleCustomerSourceDropdown(...args)),
|
||||
k: $data.showCustomerSourceDropdown
|
||||
}, $data.showCustomerSourceDropdown ? {
|
||||
l: common_vendor.f($data.customerSourceOptions, (option, k0, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(option),
|
||||
b: option === $data.formData.customerSource ? 1 : "",
|
||||
c: option,
|
||||
d: common_vendor.o(($event) => $options.selectCustomerSource(option), option)
|
||||
};
|
||||
}),
|
||||
m: common_vendor.o(() => {
|
||||
})
|
||||
} : {}, {
|
||||
n: $data.formData.dealershipName,
|
||||
o: common_vendor.o(($event) => $data.formData.dealershipName = $event.detail.value),
|
||||
p: common_vendor.f($data.genderOptions, (option, index, i0) => {
|
||||
return {
|
||||
a: option,
|
||||
b: $data.formData.gender === option,
|
||||
c: common_vendor.t(option),
|
||||
d: index
|
||||
};
|
||||
}),
|
||||
q: common_vendor.o((...args) => $options.onGenderChange && $options.onGenderChange(...args)),
|
||||
r: $data.formData.age,
|
||||
s: common_vendor.o(($event) => $data.formData.age = $event.detail.value),
|
||||
t: $data.formData.salesName,
|
||||
v: common_vendor.o(($event) => $data.formData.salesName = $event.detail.value),
|
||||
w: $data.formData.salesPhone,
|
||||
x: common_vendor.o(($event) => $data.formData.salesPhone = $event.detail.value),
|
||||
y: $data.formData.remarks,
|
||||
z: common_vendor.o(($event) => $data.formData.remarks = $event.detail.value),
|
||||
A: common_vendor.p({
|
||||
type: "close",
|
||||
size: "16",
|
||||
color: "#007AFF"
|
||||
}),
|
||||
B: common_vendor.o((...args) => $options.handleCancel && $options.handleCancel(...args)),
|
||||
C: common_vendor.p({
|
||||
type: "checkmarkempty",
|
||||
size: "16",
|
||||
color: "#007AFF"
|
||||
}),
|
||||
D: common_vendor.o(($event) => $options.handleSave("save")),
|
||||
E: common_vendor.p({
|
||||
type: "checkmarkempty",
|
||||
size: "16",
|
||||
color: "#007AFF"
|
||||
}),
|
||||
F: common_vendor.o(($event) => $options.handleSave("start")),
|
||||
G: $data.showCustomerSourceDropdown
|
||||
}, $data.showCustomerSourceDropdown ? {
|
||||
H: common_vendor.o((...args) => $options.closeCustomerSourceDropdown && $options.closeCustomerSourceDropdown(...args))
|
||||
} : {});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
exports.MiniProgramPage = MiniProgramPage;
|
||||
//# sourceMappingURL=../.sourcemap/mp-weixin/common_begin_reception.js.map
|
||||
Reference in New Issue
Block a user