| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const api_dict = require("../../api/dict.js");
- const api_student = require("../../api/student.js");
- const common_assets = require("../../common/assets.js");
- const StepLayout = () => "../../components/step-layout/step-layout.js";
- const _sfc_main = {
- components: {
- StepLayout
- },
- setup() {
- const intentions = common_vendor.ref([]);
- const arrivalTime = common_vendor.ref("");
- const internDuration = common_vendor.ref("");
- const arrivalTimeList = common_vendor.ref([]);
- const durationList = common_vendor.ref([]);
- const isIntern = common_vendor.computed(() => {
- var _a;
- return ((_a = intentions.value.find((item) => item.name === "实习")) == null ? void 0 : _a.selected) || false;
- });
- const arrivalTimeLabel = common_vendor.computed(() => {
- if (!arrivalTime.value)
- return "";
- const found = arrivalTimeList.value.find((d) => d.dictValue === arrivalTime.value);
- return found ? found.dictLabel : arrivalTime.value;
- });
- const internDurationLabel = common_vendor.computed(() => {
- if (!internDuration.value)
- return "";
- const found = durationList.value.find((d) => d.dictValue === internDuration.value);
- return found ? found.dictLabel : internDuration.value;
- });
- const jobTypes = common_vendor.ref([]);
- const targetCompanies = common_vendor.ref([]);
- const showModal = common_vendor.ref(false);
- const modalContent = common_vendor.ref("");
- let currentDeleteIndex = -1;
- const isEditMode = common_vendor.ref(false);
- const loadDicts = async () => {
- var _a, _b, _c;
- common_vendor.index.showLoading({ title: "加载中..." });
- try {
- const [arrRes, posTypeRes, posIntentionRes, durRes] = await Promise.all([
- api_dict.getDicts("main_arrival_time"),
- api_dict.getDicts("main_position_type"),
- api_dict.getDicts("main_position_intention"),
- api_dict.getDicts("main_internship_duration")
- ]);
- if (arrRes.code === 200) {
- arrivalTimeList.value = arrRes.data || arrRes.rows || [];
- if (arrivalTimeList.value.length > 0) {
- arrivalTime.value = ((_a = arrivalTimeList.value[1]) == null ? void 0 : _a.dictValue) || ((_b = arrivalTimeList.value[0]) == null ? void 0 : _b.dictValue) || "";
- }
- }
- if (durRes && durRes.code === 200) {
- durationList.value = durRes.data || durRes.rows || [];
- if (durationList.value.length > 0) {
- internDuration.value = ((_c = durationList.value[0]) == null ? void 0 : _c.dictValue) || "";
- }
- }
- if (posTypeRes.code === 200) {
- intentions.value = (posTypeRes.data || posTypeRes.rows || []).map((dict, idx) => ({
- name: dict.dictLabel,
- value: dict.dictValue,
- selected: idx === 0
- }));
- }
- if (posIntentionRes.code === 200) {
- jobTypes.value = (posIntentionRes.data || posIntentionRes.rows || []).map((dict, idx) => ({
- name: dict.dictLabel,
- value: dict.dictValue,
- selected: idx < 2
- // 默认随便选一两个
- }));
- }
- } catch (e) {
- common_vendor.index.__f__("error", "at pages/intention/intention.js:82", e);
- } finally {
- common_vendor.index.hideLoading();
- }
- };
- const loadStudentData = async () => {
- const userInfo = common_vendor.index.getStorageSync("userInfo");
- if (!userInfo || !userInfo.studentId)
- return;
- try {
- const res = await api_student.getStudent(userInfo.studentId);
- if (res.code === 200 && res.data) {
- const data = res.data;
- if (data.availability) {
- const found = arrivalTimeList.value.find((d) => d.dictValue === data.availability || d.dictLabel === data.availability);
- if (found)
- arrivalTime.value = found.dictValue;
- }
- if (data.internshipDuration) {
- const found = durationList.value.find((d) => d.dictValue === data.internshipDuration || d.dictLabel === data.internshipDuration);
- if (found)
- internDuration.value = found.dictValue;
- }
- if (data.jobType) {
- intentions.value.forEach((item) => {
- item.selected = item.value === data.jobType || item.name === data.jobType;
- });
- }
- if (data.jobIntention) {
- const selectedIntentions = data.jobIntention.split(",").map((s) => s.trim()).filter((s) => s);
- jobTypes.value.forEach((item) => {
- item.selected = selectedIntentions.includes(item.value) || selectedIntentions.includes(item.name);
- });
- }
- if (data.intentionCompanies) {
- const companyNames = data.intentionCompanies.split(",").map((s) => s.trim()).filter((s) => s);
- targetCompanies.value = companyNames.map((name) => ({ name }));
- }
- }
- } catch (err) {
- common_vendor.index.__f__("error", "at pages/intention/intention.js:132", "加载学员数据失败", err);
- }
- };
- common_vendor.onMounted(async () => {
- const options = getCurrentPages()[getCurrentPages().length - 1].options;
- if (options && options.editMode === "1") {
- isEditMode.value = true;
- }
- common_vendor.index.$on("submit_companies", (selectedCompanies) => {
- targetCompanies.value = [...selectedCompanies];
- });
- await loadDicts();
- if (isEditMode.value) {
- await loadStudentData();
- }
- });
- common_vendor.onUnmounted(() => {
- common_vendor.index.$off("submit_companies");
- });
- const openModal = (content, index) => {
- modalContent.value = content;
- currentDeleteIndex = index;
- showModal.value = true;
- };
- const closeModal = () => {
- showModal.value = false;
- };
- const confirmDelete = () => {
- if (currentDeleteIndex !== -1) {
- targetCompanies.value.splice(currentDeleteIndex, 1);
- }
- closeModal();
- };
- const toggleIntention = (index) => {
- intentions.value.forEach((item, i) => {
- item.selected = i === index;
- });
- };
- const selectInternDuration = () => {
- if (durationList.value.length === 0)
- return;
- common_vendor.index.showActionSheet({
- itemList: durationList.value.map((d) => d.dictLabel),
- success: (res) => {
- internDuration.value = durationList.value[res.tapIndex].dictValue;
- }
- });
- };
- const selectTime = () => {
- if (arrivalTimeList.value.length === 0)
- return;
- common_vendor.index.showActionSheet({
- itemList: arrivalTimeList.value.map((d) => d.dictLabel),
- success: (res) => {
- arrivalTime.value = arrivalTimeList.value[res.tapIndex].dictValue;
- }
- });
- };
- const toggleType = (index) => {
- jobTypes.value[index].selected = !jobTypes.value[index].selected;
- };
- const addCompany = () => {
- const selectedNames = targetCompanies.value.map((c) => c.name);
- common_vendor.index.setStorageSync("selected_companies", JSON.stringify(selectedNames));
- common_vendor.index.navigateTo({ url: "/pages/intention/company-select" });
- };
- const deleteCompany = (index) => {
- openModal("确定要删除这家意向公司吗?", index);
- };
- const onSubmit = async () => {
- var _a;
- common_vendor.index.__f__("log", "at pages/intention/intention.js:215", "intention.js: onSubmit called");
- common_vendor.index.showLoading({ title: "提交中..." });
- try {
- const userInfo = common_vendor.index.getStorageSync("userInfo");
- common_vendor.index.__f__("log", "at pages/intention/intention.js:219", "intention.js: userInfo from storage:", userInfo);
- const studentId = userInfo ? userInfo.studentId || userInfo.id : null;
- common_vendor.index.__f__("log", "at pages/intention/intention.js:221", "intention.js: studentId identified:", studentId);
- if (!studentId) {
- common_vendor.index.hideLoading();
- common_vendor.index.showToast({ title: "登录状态失效", icon: "none" });
- return;
- }
- const selectedJobIntention = ((_a = intentions.value.find((i) => i.selected)) == null ? void 0 : _a.value) || "";
- const selectedJobType = jobTypes.value.filter((i) => i.selected).map((i) => i.value).join(",");
- const companies = targetCompanies.value.map((c) => c.name).join(",");
- const reqData = {
- id: studentId,
- jobIntention: selectedJobType,
- // 求职意向类型(审计、咨询、税务等),传 dictValue
- intentionCompanies: companies,
- // 意向公司列表
- jobType: selectedJobIntention,
- // 求职类型(全职、实习、兼职),传 dictValue
- availability: arrivalTime.value,
- internshipDuration: isIntern.value ? internDuration.value : ""
- };
- common_vendor.index.__f__("log", "at pages/intention/intention.js:242", "intention.js: sending updateStudent request with data:", reqData);
- const res = await api_student.updateStudent(reqData);
- common_vendor.index.__f__("log", "at pages/intention/intention.js:245", "intention.js: updateStudent response:", res);
- common_vendor.index.hideLoading();
- if (res.code === 200) {
- common_vendor.index.showToast({
- title: isEditMode.value ? "保存成功" : "提交成功",
- icon: "success"
- });
- setTimeout(() => {
- common_vendor.index.reLaunch({
- url: "/pages/my/my",
- success: () => {
- setTimeout(() => {
- common_vendor.index.navigateTo({ url: "/pages/my/resume_view" });
- }, 100);
- }
- });
- }, 1e3);
- } else {
- common_vendor.index.showToast({ title: res.msg || "保存失败", icon: "none" });
- }
- } catch (e) {
- common_vendor.index.__f__("error", "at pages/intention/intention.js:268", e);
- common_vendor.index.hideLoading();
- common_vendor.index.showToast({ title: "网络异常", icon: "none" });
- }
- };
- const onSkip = () => {
- common_vendor.index.reLaunch({
- url: "/pages/my/my",
- success: () => {
- setTimeout(() => {
- common_vendor.index.navigateTo({ url: "/pages/my/resume_view" });
- }, 100);
- }
- });
- };
- return {
- intentions,
- arrivalTime,
- arrivalTimeLabel,
- internDuration,
- internDurationLabel,
- isIntern,
- jobTypes,
- targetCompanies,
- showModal,
- modalContent,
- closeModal,
- confirmDelete,
- toggleIntention,
- selectTime,
- selectInternDuration,
- toggleType,
- addCompany,
- deleteCompany,
- onSubmit,
- onSkip,
- isEditMode
- };
- }
- };
- if (!Array) {
- const _easycom_step_layout2 = common_vendor.resolveComponent("step-layout");
- _easycom_step_layout2();
- }
- const _easycom_step_layout = () => "../../components/step-layout/step-layout.js";
- if (!Math) {
- _easycom_step_layout();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: common_vendor.f(_ctx.intentions, (item, index, i0) => {
- return {
- a: common_vendor.t(item.name),
- b: index,
- c: common_vendor.n(item.selected ? "active" : ""),
- d: common_vendor.o(($event) => _ctx.toggleIntention(index), index)
- };
- }),
- b: _ctx.isIntern
- }, _ctx.isIntern ? {
- c: common_vendor.t(_ctx.internDurationLabel || "请选择"),
- d: common_vendor.n(!_ctx.internDuration ? "is-empty" : ""),
- e: common_vendor.o((...args) => _ctx.selectInternDuration && _ctx.selectInternDuration(...args))
- } : {}, {
- f: common_vendor.t(_ctx.arrivalTimeLabel || "1周内"),
- g: common_vendor.n(!_ctx.arrivalTime ? "is-empty" : ""),
- h: common_vendor.o((...args) => _ctx.selectTime && _ctx.selectTime(...args)),
- i: common_vendor.f(_ctx.jobTypes, (type, index, i0) => {
- return {
- a: common_vendor.t(type.name),
- b: index,
- c: common_vendor.n(type.selected ? "active" : ""),
- d: common_vendor.o(($event) => _ctx.toggleType(index), index)
- };
- }),
- j: common_vendor.o((...args) => _ctx.addCompany && _ctx.addCompany(...args)),
- k: _ctx.targetCompanies.length === 0
- }, _ctx.targetCompanies.length === 0 ? {
- l: common_assets._imports_0$1
- } : {}, {
- m: common_vendor.f(_ctx.targetCompanies, (comp, index, i0) => {
- return {
- a: common_vendor.o(($event) => _ctx.deleteCompany(index), index),
- b: common_vendor.t(comp.name),
- c: index
- };
- }),
- n: common_vendor.o((...args) => _ctx.closeModal && _ctx.closeModal(...args)),
- o: common_vendor.t(_ctx.modalContent),
- p: common_vendor.o((...args) => _ctx.closeModal && _ctx.closeModal(...args)),
- q: common_vendor.o((...args) => _ctx.confirmDelete && _ctx.confirmDelete(...args)),
- r: _ctx.showModal ? 1 : "",
- s: common_vendor.o(_ctx.onSubmit),
- t: common_vendor.o(_ctx.onSkip),
- v: common_vendor.p({
- title: "填写工作意向",
- nextText: "提交",
- showSkip: !_ctx.isEditMode,
- subtitle: "我们会妥善保护你的隐私,后续你也可以在设置中将简历隐藏"
- })
- });
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6e833e70"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/intention/intention.js.map
|