324 lines
11 KiB
JavaScript
324 lines
11 KiB
JavaScript
|
|
"use strict";
|
|||
|
|
const common_vendor = require("../../common/vendor.js");
|
|||
|
|
const request_index = require("../../request/index.js");
|
|||
|
|
const pages_addsupplier_api_api = require("./api/api.js");
|
|||
|
|
if (!Array) {
|
|||
|
|
const _easycom_u_select2 = common_vendor.resolveComponent("u-select");
|
|||
|
|
const _easycom_u_action_sheet2 = common_vendor.resolveComponent("u-action-sheet");
|
|||
|
|
(_easycom_u_select2 + _easycom_u_action_sheet2)();
|
|||
|
|
}
|
|||
|
|
const _easycom_u_select = () => "../../uni_modules/vk-uview-ui/components/u-select/u-select.js";
|
|||
|
|
const _easycom_u_action_sheet = () => "../../uni_modules/vk-uview-ui/components/u-action-sheet/u-action-sheet.js";
|
|||
|
|
if (!Math) {
|
|||
|
|
(_easycom_u_select + _easycom_u_action_sheet)();
|
|||
|
|
}
|
|||
|
|
const _sfc_main = {
|
|||
|
|
__name: "information",
|
|||
|
|
setup(__props) {
|
|||
|
|
const uping = common_vendor.ref(true);
|
|||
|
|
const showmarry = common_vendor.ref(false);
|
|||
|
|
const showmarrylist = common_vendor.reactive(
|
|||
|
|
[
|
|||
|
|
{
|
|||
|
|
value: "代理商",
|
|||
|
|
label: "代理商"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
value: "批发商",
|
|||
|
|
label: "批发商"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
value: "制造商",
|
|||
|
|
label: "制造商"
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
);
|
|||
|
|
const bottomlist = [{
|
|||
|
|
text: "拍摄图片",
|
|||
|
|
fontSize: 40
|
|||
|
|
}, {
|
|||
|
|
text: "图片预览",
|
|||
|
|
fontSize: 40
|
|||
|
|
}];
|
|||
|
|
const confirmmarry = (item) => {
|
|||
|
|
form.name = item[0].value;
|
|||
|
|
form.suppliersNature = String(item[0].index + 1);
|
|||
|
|
};
|
|||
|
|
const form = common_vendor.reactive({
|
|||
|
|
// 供应商名称
|
|||
|
|
suppliersName: "",
|
|||
|
|
suppliersNature: ``,
|
|||
|
|
//供应商性质 1代理商 2批发商 3制造商
|
|||
|
|
// 供应商地址
|
|||
|
|
suppliersAddress: "",
|
|||
|
|
// 负责人
|
|||
|
|
personInCharge: "",
|
|||
|
|
// 联系电话
|
|||
|
|
contactNumber: "",
|
|||
|
|
// 开户行
|
|||
|
|
openingBank: "",
|
|||
|
|
// 开户行账号
|
|||
|
|
openingBankNo: "",
|
|||
|
|
// 资质照片
|
|||
|
|
imgPath: "",
|
|||
|
|
name: "",
|
|||
|
|
openId: common_vendor.index.getStorageSync("openid")
|
|||
|
|
});
|
|||
|
|
const bottomshow = common_vendor.ref(false);
|
|||
|
|
const selectphoto = () => {
|
|||
|
|
if (!uping.value) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (form.imgPath) {
|
|||
|
|
bottomshow.value = true;
|
|||
|
|
} else {
|
|||
|
|
getMessage();
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
const photoclick = (element) => {
|
|||
|
|
if (element) {
|
|||
|
|
common_vendor.index.previewImage({
|
|||
|
|
urls: [`${request_index.media_base_url}${form.imgPath}`],
|
|||
|
|
// 必填,所有要预览的图片地址数组
|
|||
|
|
// current: headImge.value, // 可选,当前显示图片的地址,默认是 urls[0]
|
|||
|
|
indicator: "default",
|
|||
|
|
// 可选,指示器样式,H5/App 有效,值为 'default'(圆点)或 'number'(数字)
|
|||
|
|
longPressActions: {
|
|||
|
|
// 可选,仅 App 支持,长按图片时弹出的操作项
|
|||
|
|
itemList: ["保存图片到相册"]
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
getMessage();
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
function getMessage() {
|
|||
|
|
common_vendor.index.chooseImage({
|
|||
|
|
count: 1,
|
|||
|
|
sourceType: ["album", "camera"],
|
|||
|
|
success: (chooseRes) => {
|
|||
|
|
common_vendor.index.navigateTo({
|
|||
|
|
url: `/compontent/public/camera?url=${chooseRes.tempFilePaths[0]}&type=0&size=1`
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
fail: (err) => {
|
|||
|
|
common_vendor.index.__f__("error", "at pages/addsupplier/information.vue:202", "拍照失败:", err);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
common_vendor.onShow(() => {
|
|||
|
|
const img = common_vendor.index.getStorageSync("imgkey0");
|
|||
|
|
if (img) {
|
|||
|
|
savephoto(img);
|
|||
|
|
common_vendor.index.removeStorageSync("imgkey0");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
const savephoto = (filePath) => {
|
|||
|
|
uping.value = false;
|
|||
|
|
const now = /* @__PURE__ */ new Date();
|
|||
|
|
const yyyy = now.getFullYear();
|
|||
|
|
const mm = String(now.getMonth() + 1).padStart(2, "0");
|
|||
|
|
let path = "";
|
|||
|
|
switch ("") {
|
|||
|
|
case "jg":
|
|||
|
|
path = `${yyyy}/${mm}/jgxx/jg`;
|
|||
|
|
break;
|
|||
|
|
case "yg":
|
|||
|
|
path = `${yyyy}/${mm}/ygxx/yg`;
|
|||
|
|
break;
|
|||
|
|
case "zz":
|
|||
|
|
path = `${yyyy}/${mm}/zzxx/zz`;
|
|||
|
|
break;
|
|||
|
|
case "jhr":
|
|||
|
|
path = `${yyyy}/${mm}/zzxx/jhr`;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
path = `${yyyy}/${mm}/temp`;
|
|||
|
|
}
|
|||
|
|
common_vendor.index.uploadFile({
|
|||
|
|
url: `${request_index.base_url}/sys/common/upload`,
|
|||
|
|
// 替换为您的POST接口地址
|
|||
|
|
filePath,
|
|||
|
|
name: "file",
|
|||
|
|
// 后端接收时的字段名
|
|||
|
|
header: {
|
|||
|
|
"X-Access-Token": common_vendor.index.getStorageSync("token") || ""
|
|||
|
|
},
|
|||
|
|
formData: {
|
|||
|
|
biz: path
|
|||
|
|
},
|
|||
|
|
success: (uploadRes) => {
|
|||
|
|
form.imgPath = JSON.parse(uploadRes.data).message;
|
|||
|
|
uping.value = true;
|
|||
|
|
common_vendor.index.hideLoading();
|
|||
|
|
},
|
|||
|
|
fail: (err) => {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "上传出错",
|
|||
|
|
icon: "error"
|
|||
|
|
});
|
|||
|
|
common_vendor.index.hideLoading();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
function isValid11DigitNumber(val) {
|
|||
|
|
return /^1[3-9]\d{9}$/.test(val);
|
|||
|
|
}
|
|||
|
|
const next = () => {
|
|||
|
|
if (!uping.value) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
common_vendor.index.__f__("log", "at pages/addsupplier/information.vue:273", "form", form);
|
|||
|
|
if (!form.suppliersName) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请填写供应商名称",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!form.suppliersNature) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请填写供应商性质",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!form.suppliersAddress) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请填写供应商地址",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!form.personInCharge) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请填写负责人",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!form.contactNumber) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请填写手机号",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!isValid11DigitNumber(form.contactNumber)) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "手机号格式错误",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!form.openingBank) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请填写开户行",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!form.openingBankNo) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请填写开户行账号",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else if (!form.imgPath) {
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "请上传资质照片",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
gotopush();
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
const gotopush = () => {
|
|||
|
|
if (form.id) {
|
|||
|
|
pages_addsupplier_api_api.editSuppliers(form).then((res) => {
|
|||
|
|
if (res.code == 200) {
|
|||
|
|
common_vendor.index.setStorageSync(
|
|||
|
|
"isstaffchange",
|
|||
|
|
true
|
|||
|
|
);
|
|||
|
|
common_vendor.index.reLaunch({
|
|||
|
|
url: `/pages/addsupplier/successpush`
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
pages_addsupplier_api_api.addSuppliers(form).then((res) => {
|
|||
|
|
let data = {
|
|||
|
|
orgCode: common_vendor.index.getStorageSync("nostaffmessage"),
|
|||
|
|
openId: common_vendor.index.getStorageSync("openid")
|
|||
|
|
};
|
|||
|
|
pages_addsupplier_api_api.applySupOrg(data).then((data2) => {
|
|||
|
|
if (data2.success) {
|
|||
|
|
common_vendor.index.requestSubscribeMessage({
|
|||
|
|
// 这里填后台申请好的 templateId 数组
|
|||
|
|
tmplIds: ["cWVzXm1C-iitx1gNFn1nZdijq9R_3fCv8vLbiqs9zww"],
|
|||
|
|
success: (res2) => {
|
|||
|
|
setTimeout(
|
|||
|
|
() => {
|
|||
|
|
common_vendor.index.setStorageSync(
|
|||
|
|
"isstaffchange",
|
|||
|
|
false
|
|||
|
|
);
|
|||
|
|
common_vendor.index.reLaunch({
|
|||
|
|
url: `/pages/addsupplier/successpush`
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
1e3
|
|||
|
|
);
|
|||
|
|
},
|
|||
|
|
fail: (err) => {
|
|||
|
|
common_vendor.index.__f__("error", "at pages/addsupplier/information.vue:367", "订阅接口调用失败:", err);
|
|||
|
|
common_vendor.index.showToast({
|
|||
|
|
title: "订阅失败",
|
|||
|
|
icon: "none"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
const goBack = () => {
|
|||
|
|
common_vendor.index.navigateBack();
|
|||
|
|
};
|
|||
|
|
common_vendor.onLoad((param) => {
|
|||
|
|
Object.assign(form, JSON.parse(param.element));
|
|||
|
|
form.name = showmarrylist[Number(form.suppliersNature) - 1].value;
|
|||
|
|
});
|
|||
|
|
return (_ctx, _cache) => {
|
|||
|
|
return common_vendor.e({
|
|||
|
|
a: common_vendor.o(goBack),
|
|||
|
|
b: `${common_vendor.index.getStorageSync("moveHeight") + 40}px`,
|
|||
|
|
c: `${common_vendor.index.getStorageSync("moveHeight") + 40}px`,
|
|||
|
|
d: form.suppliersName,
|
|||
|
|
e: common_vendor.o(($event) => form.suppliersName = $event.detail.value),
|
|||
|
|
f: form.name,
|
|||
|
|
g: common_vendor.o(($event) => form.name = $event.detail.value),
|
|||
|
|
h: common_vendor.o(($event) => showmarry.value = true),
|
|||
|
|
i: common_vendor.o(confirmmarry),
|
|||
|
|
j: common_vendor.o(($event) => showmarry.value = $event),
|
|||
|
|
k: common_vendor.p({
|
|||
|
|
list: showmarrylist,
|
|||
|
|
modelValue: showmarry.value
|
|||
|
|
}),
|
|||
|
|
l: form.suppliersAddress,
|
|||
|
|
m: common_vendor.o(($event) => form.suppliersAddress = $event.detail.value),
|
|||
|
|
n: form.personInCharge,
|
|||
|
|
o: common_vendor.o(($event) => form.personInCharge = $event.detail.value),
|
|||
|
|
p: form.contactNumber,
|
|||
|
|
q: common_vendor.o(($event) => form.contactNumber = $event.detail.value),
|
|||
|
|
r: form.openingBank,
|
|||
|
|
s: common_vendor.o(($event) => form.openingBank = $event.detail.value),
|
|||
|
|
t: form.openingBankNo,
|
|||
|
|
v: common_vendor.o(($event) => form.openingBankNo = $event.detail.value),
|
|||
|
|
w: form.imgPath ? `${common_vendor.unref(request_index.media_base_url)}${form.imgPath}` : `https://www.focusnu.com/media/directive/index/zizhi.png`,
|
|||
|
|
x: form.imgPath ? `` : `https://www.focusnu.com/media/directive/index/bian.png`,
|
|||
|
|
y: !form.imgPath
|
|||
|
|
}, !form.imgPath ? {} : {}, {
|
|||
|
|
z: common_vendor.o(($event) => selectphoto()),
|
|||
|
|
A: common_vendor.o(next),
|
|||
|
|
B: common_vendor.o(photoclick),
|
|||
|
|
C: common_vendor.o(($event) => bottomshow.value = $event),
|
|||
|
|
D: common_vendor.p({
|
|||
|
|
list: bottomlist,
|
|||
|
|
modelValue: bottomshow.value
|
|||
|
|
})
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bb247bfc"]]);
|
|||
|
|
wx.createPage(MiniProgramPage);
|
|||
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/addsupplier/information.js.map
|