liuyg
2021-06-15 ebefa651ad2d6edbfdb30fea3fc1ff97232a0aee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
///////////////////////////////////////////////////////////////////////////
// Copyright © 2019 zhongsong. All Rights Reserved.
// 模块描述:显示坐标
///////////////////////////////////////////////////////////////////////////
define([
    'dojo/_base/declare',
    'dojo/_base/lang',
    'dojo/_base/array',
    'dojo/_base/html',
    'dojo/topic',
    'jimu/BaseWidget',
    'jimu/utils',
    'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
    'libs/zTree_v3/js/jquery.ztree.all'
],
    function (declare,
        lang,
        array,
        html,
        topic,
        BaseWidget,
        aspect,
        string,
        utils
    ) {
        return declare([BaseWidget], {
            baseClass: 'jimu-widget-instructions',
            name: 'instructions',
            layers: {},
            startup: function () {
                // 暴露在外的接口
                var that = this
                    , url = 'http://171.34.76.171:8880/pyh-station/metaWetlandProtect/queryNameAndIdAssembleMap'
                    , token = "Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMzOTIwNTcsImV4cCI6MTYyNTk4NDA1N30.wyhtQWDfyBM4Wvu9x_GpzWErqDkZ3J-PWEjyzoaHT9w6mMBenso5q0ZdnFueCZaCOjsHM5AMwLawATT0Zqc4aQ"
                    ;
                axios.get(url, {
                    headers: {
                        "token": token
                    }
                }).then((res) => {
                    if (res.data.code == 200) {
                        var data = res.data.data;
                        // console.log(data, 99999);
                        that.beginLayuiDropdown(data)
 
                    
                    }
                })
 
            },
            beginLayuiDropdown: function (data) {
                var that = this;
                var d = [];
                for (var k in data) {
                    var obj = {
                        title: data[k].NAME,
                        id: data[k].id,
                    }
                    if (data[k].seviceUrl) {
                        obj.src = data[k].seviceUrl
                    } 
                    d.push(obj)
 
                    
                }
                layui.use(['dropdown', 'util', 'layer', 'table'], function () {
                    var dropdown = layui.dropdown
                        , util = layui.util
                        , layer = layui.layer
                        , table = layui.table
                        , $ = layui.jquery;
 
 
                    dropdown.render({
                        elem: '.demo1'
                        , data: d
                        ,trigger: 'hover'
                        , className: 'site-dropdown-demo'
                        , click: function (obj) {
                            //点击事件
                            // layer.tips('点击了:' + obj.title, this.elem, { tips: [1, '#5FB878'] })
                            var str = obj.title;
                        
                            $('.jimu-widget-instructions').find('.instructions-title').empty().append(str);
 
                            if (that[obj.id]) {
                                that.map.imageryLayers.remove(that[obj.id]);
                            }
 
                            if (obj.src) {
                                $.ajax({
                                    url: res.data[i].seviceUrl + '/maps.json',
                                    type: 'get',
                                    dataType: 'JSON',
                                    success: function (result) {
                                        console.log(res.data[i])
 
 
                                        that[res.data[i].id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
                                            url:  result[0].path,
                                        }));
                                        that[res.data[i].id].alpha = 1
 
                                    }
                                })
                            } else {
 
                                layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){
                                    //得到各种内置组件
                                    var layer = layui.layer //弹层
                                    // layer.msg('请先填写关键字', { icon: 1, time: 1000, shift: 6 });
                                    layer.tips('暂无该服务', '.jimu-widget-instructions', {
                                        tips: [2, '#FF5722']
                                    });
                                })
                            }
 
                                
 
                            
 
                        
                        }
                    });
                });
            },
            closeToolBox: function (item) {
            },
 
            onOpen: function () {
                //面板打开的时候触发 (when open this panel trigger)
            },
 
            onClose: function () {
                //面板关闭的时候触发 (when this panel is closed trigger)
            },
 
            onMinimize: function () {
                this.resize();
            },
 
            onMaximize: function () {
                this.resize();
            },
 
            resize: function () {
 
            },
            begin: function () {
            },
 
            destroy: function () {
                //销毁的时候触发
                //todo
                //do something before this func
                this.inherited(arguments);
            }
 
        });
    });