liuyg
2022-03-15 7366b0a279425cb6218bec8ba19774e5e8399b91
src/components/mobileActivity/index.vue
@@ -28,9 +28,7 @@
                        :key="index"
                    >
                        <span class="mobileActivity_insmallxiangqingIn_s">
                            {{
                            item.lable
                            }}
              {{ item.lable }}
                        </span>
                        : {{ item.value }}
                    </div>
@@ -43,9 +41,7 @@
                    :key="index"
                >
                    <span class="mobileActivity_insmallxiangqingIn_s">
                        {{
                        item.lable
                        }}
            {{ item.lable }}
                    </span>
                    : {{ item.value }}
                </div>
@@ -68,21 +64,21 @@
</template>
<script>
import { mapGetters } from 'vuex'
import moveWindow from './move'
import { mapGetters } from "vuex";
import moveWindow from "./move";
export default {
    name: 'mobileActivity',
  name: "mobileActivity",
    computed: {
        ...mapGetters([
            'showActivity',
            'showActivityData',
            'drawALineLayerMany',
            'drawAPointLayerMany'
        ])
      "showActivity",
      "showActivityData",
      // 'drawALineLayerMany',
      // 'drawAPointLayerMany'
    ]),
    },
    data () {
        const heig = 135
        const bottom = 150
    const heig = 135;
    const bottom = 150;
        return {
            useHeight: heig,
            height: heig,
@@ -92,33 +88,33 @@
            domMove: null,
            start: 0,
            end: 0,
            hdTitle: '',
      hdTitle: "",
            // url: "",
            // srcList: [],
            useData: {},
            leftNavData: [
                {
                    flag: true,
                    label: '线路',
          label: "线路",
                    // img: "/img/leftnav/tag.png",
                    img: '/img/leftnav/tag-checked.png',
                    normal: '/img/leftnav/tag.png',
                    checked: '/img/leftnav/tag-checked.png',
                    layer: 'tagLayer',
                    imgSrc: 'https://map.hit.edu.cn/images/tarrow_xq.png',
          img: "/img/leftnav/tag-checked.png",
          normal: "/img/leftnav/tag.png",
          checked: "/img/leftnav/tag-checked.png",
          layer: "tagLayer",
          imgSrc: "https://map.hit.edu.cn/images/tarrow_xq.png",
                    // imgSrc: "img/mobile/pink.png",
                    layer: 'drawALineLayerMany'
          layer: "drawALineLayerMany",
                },
                {
                    flag: true,
                    label: '标点',
                    img: '/img/leftnav/way-checked.png',
                    normal: '/img/leftnav/way.png',
                    checked: '/img/leftnav/way-checked.png',
                    layer: 'wayLayer',
                    imgSrc: 'img/mobile/green.png',
                    layer: 'drawAPointLayerMany'
                }
          label: "标点",
          img: "/img/leftnav/way-checked.png",
          normal: "/img/leftnav/way.png",
          checked: "/img/leftnav/way-checked.png",
          layer: "wayLayer",
          imgSrc: "img/mobile/green.png",
          layer: "drawAPointLayerMany",
        },
                // {
                //   flag: false,
                //   label: "实景",
@@ -129,8 +125,8 @@
                //   imgSrc: "img/leftnav/map-panorama.png",
                //   // imgSrc: "img/mobile/blue.png",
                // },
            ]
        }
      ],
    };
    },
    watch: {
        //   openValue() {
@@ -143,203 +139,203 @@
        //   },
        showActivity () {
            if (this.showActivity) {
                this.inToInit() // 初始化
                this.hdTitle = this.showActivityData.name
        this.inToInit(); // 初始化
        this.hdTitle = this.showActivityData.name;
                // new窗口对象
                const that = this
                const windowHeight = document.body.clientHeight
                this.doData(this.showActivityData) // 使用数据
        const that = this;
        const windowHeight = document.body.clientHeight;
        this.doData(this.showActivityData); // 使用数据
                // 获取最大高度避免数据过少,空格多
                // let heard = document.querySelector(".mobileActivity_heard");
                // let ins = document.querySelector(".mobileActivity_in");
                // console.log(heard, ins, 77777);
                this.checkDom('querySelector', '.mobileActivity_heard', (head) => {
                    this.checkDom('querySelector', '.mobileActivity_in', (ins) => {
                        console.log((head.offsetHeight + ins.offsetHeight) / 4)
                        doit(head.offsetHeight + ins.offsetHeight)
                    })
                })
        this.checkDom("querySelector", ".mobileActivity_heard", (head) => {
          this.checkDom("querySelector", ".mobileActivity_in", (ins) => {
            console.log((head.offsetHeight + ins.offsetHeight) / 4);
            doit(head.offsetHeight + ins.offsetHeight);
          });
        });
                // return;
                const doit = (maxheights) => {
                    this.domMove = new moveWindow({
                        id: 'mobileActivity',
            id: "mobileActivity",
                        minHeight: that.useHeight,
                        maxHeight: maxheights || windowHeight / 2,
                        critical: maxheights / 4,
                        fn: function (res) {
                            that.height = +res.height
                            that.bottom = +res.height + 15
              that.height = +res.height;
              that.bottom = +res.height + 15;
                            // console.log(+res.height, "=======");
                            if (res.state != 'on') {
                                that.openValue = res.state
              if (res.state != "on") {
                that.openValue = res.state;
                            }
                        }
                    })
                    this.domMove.init()
            },
          });
          this.domMove.init();
                    // console.log(this.domMove);
                    // 转移···添加点和线
                    const addressOur = this.changeData(
                        this.useData.query,
                        'addressname',
                        'address'
                    )
                    const lxOur = this.changeData(this.useData.query, 'lxname', 'lx')
            "addressname",
            "address"
          );
          const lxOur = this.changeData(this.useData.query, "lxname", "lx");
                    // console.log(addressOur, lxOur);
                    that.$store.dispatch('MSET_DRAWALINELAYERMANY', [
          that.$store.dispatch("MSET_DRAWALINELAYERMANY", [
                        lxOur,
                        addressOur,
                        this.useData.query,
                        function () {
                            that.domMove.opens(false, true)
              that.domMove.opens(false, true);
            },
          ]);
        };
                        }
                    ])
                }
            }
        }
    },
    },
    mounted () { },
    methods: {
        inToInit () {
            // 初始化
            this.openValue = false
            this.height = this.useHeight
            this.bottom = this.useBottom
      this.openValue = false;
      this.height = this.useHeight;
      this.bottom = this.useBottom;
            for (const k in this.leftNavData) {
                this.leftNavData[k].flag = true
                this.leftNavData[k].img = this.leftNavData[k].checked
        this.leftNavData[k].flag = true;
        this.leftNavData[k].img = this.leftNavData[k].checked;
            }
        },
        // 处理主数据
        doData (val) {
            const srcList = val.opendata.tpurl.split(',')
      const srcList = val.opendata.tpurl.split(",");
            this.useData = {
                data: val,
                url: srcList[0],
                srcList: srcList,
                smallData: [
                    {
                        lable: '主办方',
                        value: val.opendata.sponsor
            lable: "主办方",
            value: val.opendata.sponsor,
                    },
                    {
                        lable: '承办方',
                        value: val.opendata.undertake
                    }
            lable: "承办方",
            value: val.opendata.undertake,
          },
                ],
                detailedData: [
                    {
                        lable: '活动时间',
                        value: val.opendata.time
            lable: "活动时间",
            value: val.opendata.time,
                    },
                    {
                        lable: '活动详情',
                        value: val.opendata.context
                    }
            lable: "活动详情",
            value: val.opendata.context,
          },
                ],
                query: {
                    name: val.opendata.hdname,
                    bgImg: val.opendata.tpurl,
                    from: '活动',
          from: "活动",
                    websiteUrl: val.opendata.websiteurl,
                    telePhone: val.opendata.telephone,
                    introduce: val.opendata.context,
                    video: val.opendata.videourl,
                    // buts: ["定位"],
                    // 活动添加的字段
                    addressname: val.opendata.addressname.split(';'),
                    address: val.opendata.address.split(';'),
                    lxname: val.opendata.lxname.split(';'),
                    lx: val.opendata.lx.split(';'),
          addressname: val.opendata.addressname.split(";"),
          address: val.opendata.address.split(";"),
          lxname: val.opendata.lxname.split(";"),
          lx: val.opendata.lx.split(";"),
                    lntLat: [
                        val.opendata.address.split(';')[0].split(',')[0],
                        val.opendata.address.split(';')[0].split(',')[1]
            val.opendata.address.split(";")[0].split(",")[0],
            val.opendata.address.split(";")[0].split(",")[1],
                    ],
                    panoramaurl: val.opendata.panoramaurl // 全景
                }
            }
          panoramaurl: val.opendata.panoramaurl, // 全景
        },
      };
        },
        // 启动监听事件
        init () {
            this.domMove.init()
      this.domMove.init();
        },
        // 关闭监听事件
        closeInit () {
            this.domMove.closeInit()
      this.domMove.closeInit();
        },
        // 控制线路和点的显影
        mobileActivityCoutrolClick (item) {
            item.flag = !item.flag
      item.flag = !item.flag;
            if (item.flag == true) {
                item.img = item.checked
        item.img = item.checked;
            } else {
                item.img = item.normal
        item.img = item.normal;
            }
            this.$store.commit('showLineOrPoint', {
      this.$store.commit("showLineOrPoint", {
                layer: item.layer,
                flag: item.flag
            })
        flag: item.flag,
      });
        },
        changeData (data, name, value) {
            const arr = []
      const arr = [];
            for (const k in data[name]) {
                arr.push({
                    name: data[name][k],
                    value:
                        name == 'lxname'
            name == "lxname"
                            ? data[value][k]
                                .split('(')[1]
                                .split(')')[0]
                                .split(',')
                                .join(';')
                                .split(' ')
                                .join(',')
                            : [+data[value][k].split(',')[0], +data[value][k].split(',')[1]]
                })
                  .split("(")[1]
                  .split(")")[0]
                  .split(",")
                  .join(";")
                  .split(" ")
                  .join(",")
              : [+data[value][k].split(",")[0], +data[value][k].split(",")[1]],
        });
            }
            return arr
      return arr;
        },
        closeActivity () {
            this.$store.commit('set_showActivity', { state: false })
      this.$store.commit("set_showActivity", { state: false });
            if (this.domMove) {
                this.closeInit()
        this.closeInit();
            }
            // 关闭路线和点的图层
            this.$store.commit('removePolylineMany')
      this.$store.commit("removePolylineMany");
            // 关闭随地图弹窗
            this.$store.dispatch('closeMobileWindowsDom')
      this.$store.dispatch("closeMobileWindowsDom");
            // 显示右侧栏
            this.$store.commit('SET_SeeAndNotSee', true)
      this.$store.commit("SET_SeeAndNotSee", true);
        },
        checkDom (methods, name, fn) {
            //  声明定时器
            var timer = null
      var timer = null;
            //  检查dom是否执行完成
            function checkDom () {
                // let dom = that.$refs[name];
                const dom = document[methods](name)
        const dom = document[methods](name);
                if (dom) {
                    //  执行dom加载完成后的操作
                    //  清除定时器
                    if (!timer) {
                        clearTimeout(timer)
            clearTimeout(timer);
                    }
                    if (fn) {
                        // 回调函数
                        fn(dom)
            fn(dom);
                    } else {
                        return dom
            return dom;
                    }
                } else {
                    //  自我调用
                    timer = setTimeout(checkDom, 100)
          timer = setTimeout(checkDom, 100);
                }
            }
            //  首次执行
            checkDom()
        }
    }
}
      checkDom();
    },
  },
};
</script>
<style lang="scss">
@@ -423,7 +419,7 @@
.notOpens {
    &::after {
        content: '';
    content: "";
        display: block;
        width: 20px;
        height: 4px;
@@ -437,7 +433,7 @@
.isOpens {
    &::after {
        content: '';
    content: "";
        display: block;
        width: 13px;
        height: 4px;
@@ -449,7 +445,7 @@
        transform: rotate(30deg);
    }
    &::before {
        content: '';
    content: "";
        display: block;
        width: 13px;
        height: 4px;