bszn.js
4.26 KB
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
$(function () {
layui.use('element', function () {
var element = layui.element;
});
layui.use('element', function () {
var element = layui.element;
//监听Tab切换,以改变地址hash值
element.on('tab(navtab)', function () {
if (this.getAttribute('lay-id') == 1) {
$("body,html").animate({ scrollTop: $(".tudi").offset().top });
$(".online_business h2").removeClass('titleActive')
$(".tudi .online_business h2").addClass('titleActive')
} else if (this.getAttribute('lay-id') == 2) {
$("body,html").animate({ scrollTop: $(".jianzhu").offset().top });
$(".online_business h2").removeClass('titleActive')
$(".jianzhu .online_business h2").addClass('titleActive')
} else if (this.getAttribute('lay-id') == 3) {
$("body,html").animate({ scrollTop: $(".linmu").offset().top });
$(".online_business h2").removeClass('titleActive')
$(".linmu .online_business h2").addClass('titleActive')
} else if (this.getAttribute('lay-id') == 4) {
$("body,html").animate({ scrollTop: $(".qita").offset().top });
$(".online_business h2").removeClass('titleActive')
$(".qita .online_business h2").addClass('titleActive')
} else {
$("body,html").animate({ scrollTop: 0 });
$(".online_business h2").removeClass('titleActive')
}
});
element.on('tab(navtab1)', function () {
if (this.getAttribute('lay-id') == 1) {
$("body,html").animate({ scrollTop: $(".tudi1").offset().top });
$(".navtab1 h2").removeClass('titleActive')
$(".tudi1 .navtab1 h2").addClass('titleActive')
} else if (this.getAttribute('lay-id') == 2) {
$("body,html").animate({ scrollTop: $(".jianzhu1").offset().top });
$(".navtab1 h2").removeClass('titleActive')
$(".jianzhu1 .navtab1 h2").addClass('titleActive')
} else if (this.getAttribute('lay-id') == 3) {
$("body,html").animate({ scrollTop: $(".linmu1").offset().top });
$(".navtab1 h2").removeClass('titleActive')
$(".linmu1 .navtab1 h2").addClass('titleActive')
} else {
$("body,html").animate({ scrollTop: 0 });
$(".navtab1 h2").removeClass('titleActive')
}
});
});
layui.use('util', function () {
let util = layui.util;
//执行
util.fixbar({
bar1: true,
bar2: true,
top: true
, click: function (type) {
console.log(type);
if (type === 'bar1') {
alert('点击了bar1')
}
}
});
})
addTabs('#bszn')
_initData()
});
//config的设置是全局的
layui.config({
base: '../../staticJs/'
}).extend({ //设定模块别名
common: 'cityCommon'
});
$(document).on("click", ".area_list li", function (e) {
$(".area_list li").removeClass("active2")
$(this).addClass("active2");
_businessList($(this).attr("data-id"))
})
layui.use(['form', 'common'], function () {
var common = layui.common,
form = layui.form;
//三级地址联动
common.showCity('province', 'city');
//区域选择
form.on('select(selectCity)', function (data) {
return false;
});
});
// 初始化数据
function _initData() {
var area_list = $(".area_list");
area_list.empty();
var li
$.ajax({
type: "get", //提交方式
url: portal.api_url + "/cms/district/queryAllDistrict",//路径
dataType: "json",
//数据,这里使用的是Json格式进行传输
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data != null) {
let data = result.data[0].children[0].children
for (var i = 0; i < data.length; i++) {
li = '<li data-id="' + data[i].id + '">' + data[i].name + '</li>';
area_list.append(li);
}
}
}
})
}