123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
-
-
- Table.api.init({
- extend: {
- index_url: 'example/baidumap/index',
- add_url: 'example/baidumap/add',
- edit_url: 'example/baidumap/edit',
- del_url: 'example/baidumap/del',
- multi_url: 'example/baidumap/multi',
- table: '',
- }
- });
- var table = $("#table");
-
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: 'ID', operate: false},
- {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false},
- {field: 'username', title: __('Username'), formatter: Table.api.formatter.search},
- {field: 'title', title: __('Title')},
- {field: 'url', title: __('Url'), align: 'left'},
- {field: 'ip', title: __('IP')},
- {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
-
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- map: function () {
- Form.api.bindevent($("form[role=form]"));
- require(['async!BMap'], function () {
-
-
- var map = new BMap.Map("allmap");
- var point = new BMap.Point(116.404, 39.915);
- map.centerAndZoom(point, 13);
- var marker = new BMap.Marker(point);
- map.addOverlay(marker);
- marker.setAnimation(BMAP_ANIMATION_BOUNCE);
- map.enableDragging();
-
- map.enableScrollWheelZoom(true);
-
- var geolocation = new BMap.Geolocation();
- geolocation.getCurrentPosition(function (r) {
- if (this.getStatus() == BMAP_STATUS_SUCCESS) {
- var mk = new BMap.Marker(r.point);
- map.addOverlay(mk);
- map.panTo(r.point);
-
- } else {
- Layer.alert('failed' + this.getStatus());
- }
- }, {enableHighAccuracy: true});
-
-
- $(document).on('click', '.btn-search', function () {
-
- var myGeo = new BMap.Geocoder();
-
- myGeo.getPoint($("#searchaddress").val(), function (point) {
- if (point) {
- map.centerAndZoom(point, 16);
- map.addOverlay(new BMap.Marker(point));
- } else {
- Layer.alert("您选择地址没有解析到结果!");
- }
- });
- });
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|