<template>
  <view>
    <div class="managementBody" v-show="userType == 2">
      <image
        src="https://www.idea-co-sf.com/gardenProduct/image/banner.png"
        class="banner"
      ></image>
      <div class="needBox">
        <div class="needLeft">
          <div
            class="needLeftLeft"
            @click="toMsgPage('/pages/subPackages/todo/index')"
          >
            <span style="color: #18172a; font-size: 4.5vw; margin-bottom: 1vw"
              >我的待办</span
            >
            <span style="color: #666666; font-size: 3.5vw"
              >需处理待办<span
                style="color: #0365f9; font-weight: 600; margin-left: 0.5vw"
                >3</span
              ></span
            >
          </div>
          <img
            src="https://www.idea-co-sf.com/gardenProduct/image/dbImage.png"
            class="needImg"
          />
        </div>
        <div
          class="needRight"
          @tap.stop="toMsgPage('/pages/subPackages/toread/index')"
        >
          <div class="needLeftLeft">
            <span style="color: #18172a; font-size: 4.5vw; margin-bottom: 1vw"
              >我的待阅</span
            >
            <span style="color: #666666; font-size: 3.5vw"
              >需处理待阅<span
                style="color: #22b565; font-weight: 600; margin-left: 0.5vw"
                >12</span
              ></span
            >
          </div>
          <img
            src="https://www.idea-co-sf.com/gardenProduct/image/dyImage.png"
            class="needImg"
          />
        </div>
      </div>
      <div class="titleTips">
        <div class="myLine"></div>
        <div>服务入口</div>
      </div>
      <div class="map">
        <div
          class="mapdom"
          style="float: left"
          v-for="(item, index) in mapList"
          :key="index"
          @click="jumpPage(item.path)"
        >
          <img class="mapIcon" :src="item.url" />
          <div class="maptxt">{{ item.label }}</div>
        </div>
      </div>
    </div>
    <!--    企业端页面-->
    <div class="enterpriseBody" v-show="userType == 1 || userType == 3">
      <enterprise-side></enterprise-side>
    </div>
  </view>
</template>
<script>
// import {demo} from "@/js_sdk/http"
import { getUserPower, getUserLocalStorageInfo } from "@/js_sdk/http";
import EnterpriseSide from "./components/enterpriseSide.vue";
export default {
  components: { EnterpriseSide },
  data() {
    return {
      userType: false,
      mapList: [
        // {
        //   label: "智慧党建",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/1@2x.png",
        //   path: "/pages/subPackages/buildmap/index",
        // },
        // {
        //   label: "经发填报",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/1@2x.png",
        //   path: "/pages/subPackages/companyHouse/companyHouse",
        // },
        {
          label: "企业库",
          url: "https://www.idea-co-sf.com/gardenProduct/image/qyk.png",
          path: "/pages/subPackages/companyHouse/companyHouse",
        },
        {
          label: "走访上报",
          url: "https://www.idea-co-sf.com/gardenProduct/image/zfsb.png",
          path: "/pages/subPackages/companyreport/companyreport",
        },
        {
          label: "会议室审核",
          url: "https://www.idea-co-sf.com/gardenProduct/image/tupian1.png",
        },
        // {
        //   label: "上市跟进",
        //   url:  https://www.idea-co-sf.com/gardenProduct/image/ssgj.png"),
        // },
        {
          label: "招商管理",
          url: "https://www.idea-co-sf.com/gardenProduct/image/zsgl.png",
          path: "/pages/subPackages/merchants/merchants",
        },
        // {
        //   label: "活动发布",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/3@2x.png",
        //   path: "/pages/subPackages/eventRelease/index",
        // },
        // {
        //   label: "安全管理自检",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/8@2x.png",
        //   path: "/pages/subPackages/secureselftest2/index",
        // },
        // {
        //   label: "安全管理统计",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/8@2x.png",
        //   path: "/pages/subPackages/secureselftest/index",
        // },
        // {
        //   label: "安全自检计划",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/9@2x.png",
        //   path: "/pages/subPackages/secureselfplan/index",
        // },

        {
          label: "报修派单",
          url: "https://www.idea-co-sf.com/gardenProduct/image/bxpd.png",
          path: "/pages/subPackages/repairDispatch-app/index",
        },
        {
          label: "报修处理",
          url: "https://www.idea-co-sf.com/gardenProduct/image/bxcl.png",
          path: "/pages/subPackages/repairprocessing-app/index",
        },
        {
          label: "房间管理",
          url: "https://www.idea-co-sf.com/gardenProduct/image/fjgl.png",
          // path: "/pages/subPackages/repairprocessing-app/index",
        },
        {
          label: "园区通知",
          url: "https://www.idea-co-sf.com/gardenProduct/image/tzfb.png",
          // path: "",
        },
        {
          label: "物业通知",
          url: "https://www.idea-co-sf.com/gardenProduct/image/tupian2.png",
          // path: "",
        },
        {
          label: "活动发布",
          url: "https://www.idea-co-sf.com/gardenProduct/image/hdfb.png",
          path: "/pages/subPackages/activityPromulgate/list",
        },
        // {
        //   label: "周边发布",
        //   url: https://www.idea-co-sf.com/gardenProduct/image/zbfb.png"),
        //   path: "/pages/subPackages/repairprocessing-app/index",
        // },

        // {
        //   label: "整改填报",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/15@2x.png",
        //   path: "/pages/subPackages/modifyReport/index",
        // },
        // {
        //   label: "整改派单",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/14@2x.png",
        //   path: "/pages/subPackages/modifySend/index",
        // },
        // {
        //   label: "整改处理",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/13@2x.png",
        //   path: "/pages/subPackages/modifyHandle/index",
        // },
        // {
        //   label: "活动核销",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/1@2x.png",
        //   path: "/pages/subPackages/activity/index",
        // },
        // {
        //   label: "可视化大屏",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/1@2x.png",
        //   path: "/pages/subPackages/bigscreen/bigscreen",
        // },
        // {
        //   label: "场馆审核",
        //   url: "https://hswkxc.idea-sf.com/fileService/static/slices/1@2x.png",
        //   path: "/pages/subPackages/venueRoom/meetingroom",
        // },
      ],
    };
  },
  onShareAppMessage() {},
  mounted() {
    // demo();
  },
  onShow() {
    this.getUserPower();
  },
  onLoad(e) {
    // uni.$on("userType", (userType) => {
    //   if (userType === "OK") {
    //     this.userType = !this.userType;
    //   }
    // });
  },
  methods: {
    toMsgPage(e) {
      uni.navigateTo({
        url: e,
        fail: (fail) => {},
      });
    },
    // getUserLocalStorageInfo
    async getUserPower() {
      let that = this;
      console.log('getUserLocalStorageInfo',getUserLocalStorageInfo());
      that.userType = getUserLocalStorageInfo().userType;
      if (that.userType == 3) {
        uni.showModal({
          title: "提示",
          cancelText: "暂不",
          confirmText: "去切换",
          content: "您还不是企业用户，请切换登录身份后再进行相关操作。",
          success: function (res) {
            if (res.confirm) {
              uni.navigateTo({
                url: "/pages/login2/login",
                success: function (e) {
                  // uni.$emit('userType', 'OK')
                },
              });
            } else if (res.cancel) {
              console.log("用户点击取消");
            }
          },
        });
      }
      // if (getUserLocalStorageInfo().user.id == 1) return;

      // let newList = [];
      // let { data } = await getUserPower(getUserLocalStorageInfo().user.id);
      // for (let i = 0; i < that.mapList.length; i++) {
      //   let index = data.findIndex((e) => e == that.mapList[i].label);
      //   if (index != -1) {
      //     newList.push(that.mapList[i]);
      //   }
      // }
      // that.mapList = newList;
    },
    jumpPage(path) {
      uni.navigateTo({
        url: path,
        fail: (fail) => {},
      });
    },
  },
};
</script>

<style lang="scss">
page {
  background: white;
}
.managementBody {
  padding: 4vw;
}
.banner {
  width: 92vw;
  height: 250rpx;
  //position: absolute;
  z-index: 1;
}
.mapdom {
  width: 25%;
  height: 184rpx;
}
.maptxt {
  width: 100%;
  height: 34rpx;
  font-size: 24rpx;
  font-family: PingFang SC-Medium, PingFang SC;
  font-weight: 500;
  color: #18172a;
  text-align: center;
  margin-top: 8rpx;
}
.mapIcon {
  width: 65rpx;
  height: 80rpx;
  //background: linear-gradient(141deg, #89BCFF 0%, #2782FA 100%);
  display: block;
  margin: auto;
}
.map {
  //position: absolute;
  z-index: 2;
  width: calc(100% - 24rpx);
  //height: 770rpx;
  border-radius: 48rpx 48rpx 0rpx 0rpx;
  background: white;
  //margin-top: 402rpx;
  padding: 24rpx 12rpx;
  overflow-y: auto;
}
.needBox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2vw 0;
  .needLeft {
    display: flex;
    justify-content: space-around;
    background: rgba(238, 244, 255, 1);
    border-radius: 8rpx;
    align-items: center;
    width: 45vw;
    height: 23vw;
  }
  .needRight {
    display: flex;
    justify-content: space-around;
    background: #def6f8;
    border-radius: 8rpx;
    align-items: center;
    width: 45vw;
    height: 23vw;
  }
  .needLeftLeft {
    display: flex;
    flex-direction: column;
  }
  .needImg {
    width: 100rpx;
    height: 100rpx;
  }
}
.titleTips {
  display: flex;
  align-items: center;
  font-size: 4.7vw;
  font-weight: 600;
  color: #18172a;
  margin: 4vw 0 2vw 0;
  .myLine {
    width: 13rpx;
    height: 40rpx;
    background: linear-gradient(180deg, #509fff 0%, #034df7 100%);
    margin-right: 20rpx;
  }
}
</style>
