112 lines
3.7 KiB
JavaScript
112 lines
3.7 KiB
JavaScript
|
"use strict";
|
||
|
var __async = (__this, __arguments, generator) => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
var fulfilled = (value) => {
|
||
|
try {
|
||
|
step(generator.next(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var rejected = (value) => {
|
||
|
try {
|
||
|
step(generator.throw(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||
|
});
|
||
|
};
|
||
|
const common_vendor = require("../../common/vendor.js");
|
||
|
const utils_http = require("../../utils/http.js");
|
||
|
const utils_commUtils = require("../../utils/commUtils.js");
|
||
|
if (!Array) {
|
||
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
||
|
_component_layout_default_uni();
|
||
|
}
|
||
|
const _sfc_main = {
|
||
|
__name: "pet-sitter",
|
||
|
setup(__props) {
|
||
|
const positionOptions = [
|
||
|
"宠托师",
|
||
|
"宠物营养师",
|
||
|
"宠物陪伴师",
|
||
|
"宠物心理健康指导员",
|
||
|
"宠物达人",
|
||
|
"其他宠物师"
|
||
|
];
|
||
|
const application = common_vendor.ref({
|
||
|
typeIndex: 0,
|
||
|
// 存储选择的职位索引
|
||
|
content: "",
|
||
|
imageUrls: []
|
||
|
// 存储图片文件路径
|
||
|
});
|
||
|
const pickerTypeChange = (e) => {
|
||
|
application.value.typeIndex = e.detail.value;
|
||
|
};
|
||
|
const chooseImages = () => {
|
||
|
common_vendor.index.chooseImage({
|
||
|
count: 6 - application.value.imageUrls.length,
|
||
|
// 最多选择的图片数量
|
||
|
success: (res) => {
|
||
|
application.value.imageUrls.push(...res.tempFilePaths);
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
const submitApplication = () => __async(this, null, function* () {
|
||
|
try {
|
||
|
application.value.imageUrls = yield utils_http.httpUploadMultipleFiles(
|
||
|
"/file/upload",
|
||
|
application.value.imageUrls
|
||
|
);
|
||
|
application.value.type = positionOptions[application.value.typeIndex];
|
||
|
const response = yield utils_http.httpPost("/petInfo/apply", application.value);
|
||
|
console.log(response);
|
||
|
if (response.code == 200) {
|
||
|
common_vendor.index.showToast({ title: "申请已提交", icon: "none" });
|
||
|
application.value = {
|
||
|
typeIndex: 0,
|
||
|
content: "",
|
||
|
imageUrls: []
|
||
|
};
|
||
|
} else {
|
||
|
common_vendor.index.showToast({ title: "提交失败 " + response.message, icon: "none" });
|
||
|
if (response.message.includes("未实名认证")) {
|
||
|
yield new Promise((resolve) => setTimeout(resolve, 500));
|
||
|
utils_commUtils.toPath("/pages/permission/real-name-auth");
|
||
|
}
|
||
|
}
|
||
|
} catch (err) {
|
||
|
common_vendor.index.showToast({ title: "提交失败", icon: "none" });
|
||
|
}
|
||
|
});
|
||
|
return (_ctx, _cache) => {
|
||
|
return common_vendor.e({
|
||
|
a: common_vendor.t(positionOptions[application.value.typeIndex] || "请选择职位"),
|
||
|
b: positionOptions,
|
||
|
c: application.value.typeIndex,
|
||
|
d: common_vendor.o(pickerTypeChange),
|
||
|
e: application.value.content,
|
||
|
f: common_vendor.o(($event) => application.value.content = $event.detail.value),
|
||
|
g: common_vendor.f(application.value.imageUrls, (image, index, i0) => {
|
||
|
return {
|
||
|
a: image,
|
||
|
b: index
|
||
|
};
|
||
|
}),
|
||
|
h: application.value.imageUrls.length < 6
|
||
|
}, application.value.imageUrls.length < 6 ? {
|
||
|
i: common_vendor.o(chooseImages)
|
||
|
} : {}, {
|
||
|
j: common_vendor.o(submitApplication)
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e4e8aecc"]]);
|
||
|
wx.createPage(MiniProgramPage);
|
||
|
//# sourceMappingURL=pet-sitter.js.map
|