Newer
Older
XiaoGanWXMini / unpackage / dist / dev / mp-weixin / pages / projectHM / projectAll.js
@zhangdeliang zhangdeliang on 29 Jul 11 KB 迁移
"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_homeApi = require("../../utils/homeApi.js");
const common_assets = require("../../common/assets.js");
if (!Array) {
  const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
  const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  (_easycom_uni_easyinput2 + _easycom_uni_popup2 + _easycom_uni_forms_item2 + _easycom_uni_forms2)();
}
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
if (!Math) {
  (_easycom_uni_easyinput + _easycom_uni_popup + _easycom_uni_forms_item + UploadImage + _easycom_uni_forms)();
}
const UploadImage = () => "../components/imageUpload.js";
const _sfc_main = {
  __name: "projectAll",
  setup(__props) {
    const projectList = common_vendor.ref([]);
    const projectName = common_vendor.ref("");
    const projectTypeId = common_vendor.ref("");
    const mapContext = common_vendor.ref(null);
    const longitude = common_vendor.ref(113.943);
    const latitude = common_vendor.ref(30.926);
    const markerList = common_vendor.ref([]);
    const ifStar = common_vendor.ref("0");
    const projectObj = common_vendor.ref({ sysFileList: [] });
    const popup = common_vendor.ref(null);
    const popupDetail = common_vendor.ref(null);
    const popupImg = common_vendor.ref(null);
    const largeImg = common_vendor.ref("");
    const valiForm = common_vendor.ref(null);
    const imagesUp = common_vendor.ref(null);
    const projectTypes = common_vendor.ref([
      { name: "GIS平台", id: "1701129308194377729", iconUrl: common_assets.gisIcon, imgUrl: "/static/images/gisType.png" },
      { name: "管网排查", id: "1701129031496142849", iconUrl: common_assets.gwpcIcon, imgUrl: "/static/images/gwpcType.png" },
      { name: "道路广场", id: "1701128777853997058", iconUrl: common_assets.landIcon, imgUrl: "/static/images/landType.png" },
      { name: "公园绿地", id: "1701128863459741697", iconUrl: common_assets.parkIcon, imgUrl: "/static/images/parkType.png" },
      { name: "建筑社区", id: "1701128641279070210", iconUrl: common_assets.buildIcon, imgUrl: "/static/images/buildType.png" },
      { name: "水系统", id: "1701128943340261378", iconUrl: common_assets.waterIcon, imgUrl: "/static/images/waterType.png" },
      { name: "管网泵站", id: "1701129103495565313", iconUrl: common_assets.gwbzIcon, imgUrl: "/static/images/gwbzType.png" }
    ]);
    const formData = common_vendor.ref({
      coverPhotosFileList: [],
      desc: "",
      title: null,
      projectId: null,
      wechatMiniuserId: common_vendor.index.getStorageSync("userIdXGWXMN")
    });
    const rules = common_vendor.ref({
      title: {
        rules: [{ required: true, errorMessage: "标题不能为空" }]
      },
      desc: {
        rules: [{ required: true, errorMessage: "描述不能为空" }]
      },
      coverPhotosFileList: {
        rules: [{ required: true, type: "array", errorMessage: "请上传图片" }]
      }
    });
    function initMap() {
      mapContext.value = common_vendor.index.createMapContext("mapProjectAll");
      mapContext.value.moveToLocation({
        longitude: longitude.value,
        latitude: latitude.value
      });
    }
    function getDataList() {
      let params = {
        pageNum: 1,
        pageSize: 999,
        projectName: projectName.value,
        //项目名称
        projectTypeId: projectTypeId.value,
        //项目类型id
        wechatMiniuserId: common_vendor.index.getStorageSync("userIdXGWXMN")
      };
      utils_homeApi.projectInfoAll(params).then((res) => {
        projectList.value = res.data || [];
        setProject();
      });
    }
    function searchProject() {
      projectTypeId.value = "";
      getDataList();
      if (projectList.value.length > 0) {
        longitude.value = projectList.value[0].projectLocation.split(",")[0];
        latitude.value = projectList.value[0].projectLocation.split(",")[1];
      }
    }
    function changeType(item) {
      projectTypeId.value = item.id;
      console.log(projectTypeId.value);
      setProject();
    }
    function setProject() {
      markerList.value = [];
      let markerArr = [];
      let projectArr = JSON.parse(JSON.stringify(projectList.value));
      if (projectTypeId.value == "") {
        markerArr = projectArr;
      } else {
        markerArr = projectArr.filter((item) => item.projectTypeId == projectTypeId.value);
      }
      markerArr && markerArr.map((item, index) => {
        let iconPath = projectTypes.value.filter((val) => val.id == item.projectTypeId)[0].iconUrl;
        markerList.value.push({
          id: index,
          projectNo: item.projectNo,
          longitude: item.projectLocation.split(",")[0],
          latitude: item.projectLocation.split(",")[1],
          width: 24,
          height: 33,
          iconPath,
          callout: {
            content: item.projectName,
            borderRadius: 8,
            bgColor: "#fff",
            padding: 6,
            display: "ALWAYS"
          }
        });
      });
      initMap();
    }
    function markerClick(item) {
      let projectNo = markerList.value[item.markerId].projectNo;
      projectObj.value = projectList.value.filter((val) => val.projectNo == projectNo)[0];
      projectObj.value.sysFileList = projectObj.value.sysFileList || [];
      popupDetail.value.open();
    }
    function collect() {
      let params = {
        projectId: projectObj.value.id,
        //项目id
        wechatMiniuserId: common_vendor.index.getStorageSync("userIdXGWXMN")
      };
      if (ifStar.value == 0) {
        utils_homeApi.projectInfoCollect(params).then((res) => {
          ifStar.value = "1";
        });
      } else {
        utils_homeApi.projectInfoRemove(params).then((res) => {
          ifStar.value = "0";
        });
      }
    }
    async function checkLarge(url) {
      largeImg.value = url;
      popupImg.value.open();
    }
    function gotoSay() {
      popup.value.open();
      formData.value.coverPhotosFileList = [];
      formData.value.desc = null;
      formData.value.title = null;
      formData.value.projectId = projectObj.value.id;
    }
    function submitData() {
      valiForm.value.validate().then((res) => {
        utils_homeApi.projectCommentAdd(formData.value).then((res2) => {
          common_vendor.index.showToast({
            icon: "none",
            title: "提交成功"
          });
          popup.value.close();
          imagesUp.value.clearImages();
        });
      }).catch((err) => {
        console.log("err", err);
      });
    }
    common_vendor.onShow(() => {
      searchProject();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: longitude.value,
        b: latitude.value,
        c: markerList.value,
        d: common_vendor.o(markerClick),
        e: common_vendor.o(searchProject),
        f: common_vendor.o(($event) => projectName.value = $event),
        g: common_vendor.p({
          suffixIcon: "search",
          placeholder: "请输入项目名称",
          modelValue: projectName.value
        }),
        h: common_vendor.f(projectTypes.value, (item, k0, i0) => {
          return {
            a: item.imgUrl,
            b: common_vendor.n(projectTypeId.value == item.id ? "active" : ""),
            c: item.id,
            d: common_vendor.o(($event) => changeType(item), item.id)
          };
        }),
        i: common_vendor.t(projectObj.value.projectName),
        j: ifStar.value == 0
      }, ifStar.value == 0 ? {
        k: common_vendor.o(($event) => collect())
      } : {}, {
        l: ifStar.value == 1
      }, ifStar.value == 1 ? {
        m: common_vendor.o(($event) => collect())
      } : {}, {
        n: common_vendor.t(projectObj.value.projectOverview),
        o: projectObj.value.sysFileList.length > 0
      }, projectObj.value.sysFileList.length > 0 ? {
        p: common_vendor.f(projectObj.value.sysFileList, (item, k0, i0) => {
          return {
            a: item.url,
            b: item.id,
            c: common_vendor.o(($event) => checkLarge(item.url), item.id)
          };
        })
      } : {}, {
        q: projectObj.value.sysFileList.length == 0
      }, projectObj.value.sysFileList.length == 0 ? {} : {}, {
        r: common_vendor.o(($event) => gotoSay()),
        s: common_vendor.sr(popupDetail, "983ea8fa-1", {
          "k": "popupDetail"
        }),
        t: common_vendor.p({
          type: "bottom",
          ["mask-click"]: true
        }),
        v: common_vendor.o(($event) => formData.value.title = $event),
        w: common_vendor.p({
          type: "text",
          autoHeight: true,
          placeholder: "请输入",
          modelValue: formData.value.title
        }),
        x: common_vendor.p({
          label: "留言标题",
          required: true,
          ["label-width"]: "100%",
          name: "title"
        }),
        y: common_vendor.o(($event) => formData.value.desc = $event),
        z: common_vendor.p({
          type: "textarea",
          autoHeight: true,
          placeholder: "请输入",
          modelValue: formData.value.desc
        }),
        A: common_vendor.p({
          label: "具体描述",
          required: true,
          ["label-width"]: "100%",
          name: "desc"
        }),
        B: common_vendor.sr(imagesUp, "983ea8fa-9,983ea8fa-8", {
          "k": "imagesUp"
        }),
        C: common_vendor.p({
          saveFileArr: formData.value.coverPhotosFileList,
          limit: 3,
          refField: "commentPhotos",
          refType: "public_project_miniuser_comment"
        }),
        D: common_vendor.p({
          label: "现场图片(最多3张)",
          required: true,
          ["label-width"]: "100%",
          name: "coverPhotosFileList"
        }),
        E: common_vendor.o(submitData),
        F: common_vendor.sr(valiForm, "983ea8fa-3,983ea8fa-2", {
          "k": "valiForm"
        }),
        G: common_vendor.p({
          modelValue: formData.value,
          rules: rules.value
        }),
        H: common_vendor.sr(popup, "983ea8fa-2", {
          "k": "popup"
        }),
        I: common_vendor.p({
          type: "bottom",
          ["mask-click"]: true
        }),
        J: largeImg.value,
        K: common_vendor.sr(popupImg, "983ea8fa-10", {
          "k": "popupImg"
        }),
        L: common_vendor.p({
          type: "center",
          ["mask-click"]: true
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/项目/孝感海绵城市/XiaoGanWXMini/pages/projectHM/projectAll.vue"]]);
_sfc_main.__runtimeHooks = 2;
wx.createPage(MiniProgramPage);