| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const api_systemIndustry = require("../../api/systemIndustry.js");
- const _sfc_main = {
- setup() {
- const industryData = common_vendor.ref([]);
- const currentIndustry = common_vendor.ref("");
- const loadData = async (selectedVal) => {
- try {
- common_vendor.index.showLoading({ title: "加载中..." });
- const [indRes] = await Promise.all([
- api_systemIndustry.listIndustry()
- ]);
- if (indRes.code === 200) {
- const industries = indRes.rows || indRes.data || [];
- const level1 = industries.filter((i) => i.parentId == 0 || !i.parentId);
- const result = level1.map((l1) => {
- const level2 = industries.filter((i) => i.parentId == l1.industryId).map((i) => i.industryName);
- return {
- name: l1.industryName,
- expanded: false,
- children: level2
- };
- });
- if (selectedVal) {
- const parts = selectedVal.split("-");
- if (parts.length > 0) {
- result.forEach((item) => {
- item.expanded = item.name === parts[0];
- });
- }
- } else if (result.length > 0) {
- result[0].expanded = true;
- }
- industryData.value = result;
- }
- } catch (e) {
- common_vendor.index.__f__("error", "at pages/experience/industry-select.js:54", "加载行业数据失败", e);
- common_vendor.index.showToast({ title: "加载行业数据失败", icon: "none" });
- } finally {
- common_vendor.index.hideLoading();
- }
- };
- common_vendor.onLoad((options) => {
- let selectedParam = "";
- if (options && options.selected) {
- currentIndustry.value = decodeURIComponent(options.selected);
- selectedParam = currentIndustry.value;
- }
- common_vendor.index.setNavigationBarTitle({ title: "选择行业" });
- loadData(selectedParam);
- });
- const toggleCategory = (index) => {
- industryData.value[index].expanded = !industryData.value[index].expanded;
- };
- const selectIndustry = (primaryName, secondaryName) => {
- const industryVal = `${primaryName}-${secondaryName}`;
- currentIndustry.value = industryVal;
- common_vendor.index.$emit("select_industry", industryVal);
- common_vendor.index.navigateBack();
- };
- return {
- industryData,
- currentIndustry,
- toggleCategory,
- selectIndustry
- };
- }
- };
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return {
- a: common_vendor.f(_ctx.industryData, (category, cIdx, i0) => {
- return common_vendor.e({
- a: common_vendor.t(category.name),
- b: common_vendor.n(category.expanded ? "expanded" : ""),
- c: common_vendor.o(($event) => _ctx.toggleCategory(cIdx), cIdx),
- d: category.expanded
- }, category.expanded ? {
- e: common_vendor.f(category.children, (tag, tIdx, i1) => {
- return {
- a: common_vendor.t(tag),
- b: tIdx,
- c: common_vendor.n(_ctx.currentIndustry === category.name + "-" + tag ? "active" : ""),
- d: common_vendor.o(($event) => _ctx.selectIndustry(category.name, tag), tIdx)
- };
- })
- } : {}, {
- f: cIdx
- });
- })
- };
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-ccf07d08"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/experience/industry-select.js.map
|