Browse Source

关于我们

gzb
guozhongbo 1 year ago
parent
commit
cac233384d
2 changed files with 121 additions and 64 deletions
  1. 30
    31
      css/about.css
  2. 91
    33
      js/about.js

+ 30
- 31
css/about.css View File

@@ -107,10 +107,10 @@
107 107
   left: 50%;
108 108
   transform: translate(-50%, 0);
109 109
 }
110
-.area_bot{
110
+.area_bot {
111 111
   margin-top: 0.3rem;
112 112
 }
113
-.ab_minsin{
113
+.ab_minsin {
114 114
   width: 100%;
115 115
   height: 3.2rem;
116 116
   position: absolute;
@@ -122,38 +122,38 @@
122 122
   left: 50%;
123 123
   transform: translateX(-50%);
124 124
 }
125
-.area_four{
125
+.area_four {
126 126
   display: flex;
127 127
   justify-content: space-between;
128 128
 }
129
-.area_fs{
129
+.area_fs {
130 130
   width: 2.8rem;
131
-  height: 3.2rem;
131
+  height: 3rem;
132 132
   background-color: white;
133 133
   color: #333333;
134 134
   text-align: center;
135 135
   padding: 0 0.1rem;
136 136
   box-sizing: border-box;
137 137
 }
138
-.area_fs img{
138
+.area_fs img {
139 139
   width: 0.9rem;
140 140
   height: 0.8rem;
141 141
   margin: 0 auto 0;
142 142
 }
143 143
 .area_fs div {
144 144
   font-size: 0.18rem;
145
-  line-height: 0.4rem;
145
+  line-height: 0.5rem;
146 146
 }
147 147
 .area_fs p {
148 148
   font-size: 0.14rem;
149 149
   line-height: 0.24rem;
150 150
   margin-top: 0;
151 151
 }
152
-.develop_container{
152
+.develop_container {
153 153
   height: 1.6rem;
154 154
   position: relative;
155 155
 }
156
-.jt{
156
+.jt {
157 157
   position: absolute;
158 158
   top: 50%;
159 159
   transform: translateY(-50%);
@@ -162,40 +162,41 @@
162 162
   cursor: pointer;
163 163
   z-index: 1000;
164 164
 }
165
-.leftjt{
165
+.leftjt {
166 166
   left: 0;
167 167
 }
168
-.rightjt{
168
+.rightjt {
169 169
   right: 0;
170 170
 }
171
-.showdata{
171
+.showdata {
172 172
   width: 90%;
173 173
   height: 1.6rem;
174 174
   margin: 0 auto;
175 175
   position: relative;
176
+  /* overflow: hidden; */
176 177
 }
177
-.line{
178
+.line {
178 179
   width: 100%;
179 180
   height: 0.04rem;
180 181
   background-color: #f3f4f8ff;
181 182
   position: absolute;
182 183
   top: 50%;
183
-    transform: translateY(-50%);
184
+  transform: translateY(-50%);
184 185
 }
185
-.rounds{
186
+.rounds {
186 187
   width: 100%;
187 188
   position: absolute;
188
-    top: 25%;
189
-    left: 0;
190
-    transform: translate(0, -50%);
191
-    white-space: nowrap;
189
+  top: 25%;
190
+  left: 0;
191
+  transform: translate(0, -50%);
192
+  white-space: nowrap;
192 193
 }
193
-.round_q{
194
+.round_q {
194 195
   display: inline-block;
195 196
   width: 2.34rem;
196 197
   height: 100%;
197 198
 }
198
-.round_item{
199
+.round_item {
199 200
   margin: 0 auto;
200 201
   width: 0.18rem;
201 202
   height: 0.18rem;
@@ -206,17 +207,17 @@
206 207
   position: relative;
207 208
   cursor: pointer;
208 209
 }
209
-.round_i{
210
+.round_i {
210 211
   position: absolute;
211 212
   top: 50%;
212 213
   left: 50%;
213
-  transform: translate(-50%,-50%);
214
+  transform: translate(-50%, -50%);
214 215
   width: 0.12rem;
215
-    height: 0.12rem; 
216
-    background-color: #e4e4e4ff;
217
-    border-radius: 50%;
216
+  height: 0.12rem;
217
+  background-color: #e4e4e4ff;
218
+  border-radius: 50%;
218 219
 }
219
-.round_d{
220
+.round_d {
220 221
   width: 0.9rem;
221 222
   text-align: center;
222 223
   font-size: 0.18rem;
@@ -225,16 +226,14 @@
225 226
   top: 0.4rem;
226 227
   left: -0.35rem;
227 228
 }
228
-.active .round_item{
229
+.active .round_item {
229 230
   border-color: #016cff;
230
-
231 231
 }
232 232
 .active .round_i {
233 233
   background-color: #016cff;
234
-
235 234
 }
236 235
 .active .round_d {
237 236
   color: #016cff;
238 237
   font-size: 0.36rem;
239 238
   font-weight: bold;
240
-}
239
+}

+ 91
- 33
js/about.js View File

@@ -1,15 +1,35 @@
1
+// 请求接口前缀
2
+var Baseurl = "https://xhwebapitest.xhkjedu.com/dh/list";
3
+// $.ajax({
4
+//   type: "POST",
5
+//   url: Baseurl,
6
+//   data: JSON.stringify({
7
+//     examid: 434,
8
+//     classid: 9666
9
+//   }),
10
+//   dataType: "json",
11
+//   contentType: "application/json; charset=utf-8",
12
+//   success: function (data) {
13
+//     if (data.code === 0) {
14
+//       loadSectionHtml(data.obj);
15
+//     } else {
16
+//       alert(data.msg);
17
+//     }
18
+//   }
19
+// });
1 20
 var datalist = [
2 21
   { time: 2023 },
3 22
   { time: 2022 },
4 23
   { time: 2021 },
5 24
   { time: 2020 },
6 25
   { time: 2019 },
7
-  { time: 2018 }
26
+  { time: 2018 },
27
+  { time: 2017 }
8 28
 ];
9 29
 
10 30
 var html = "";
11 31
 $.each(datalist, (idx, item) => {
12
-  html += `<div class="round_q">
32
+  html += `<div class="round_q" index = "${idx + 1}">
13 33
                     <div class="round_item">
14 34
                     <div class="round_i"></div>
15 35
                     <div class="round_d">${item.time}</div>
@@ -28,30 +48,51 @@ var prev = $(".leftjt");
28 48
 var next = $(".rightjt");
29 49
 
30 50
 var index = 1; //存放当前显示的图片的下标
31
-var len = 5;
51
+var len = 5; //显示数量
32 52
 var interval = 5000; //位移时间间隔
33 53
 var timer;
34
-
54
+var offsetpx = (datalist.length - len) * divwidth; //可偏移度
55
+var offleft = 0; //当前偏移量
56
+console.log(offsetpx);
35 57
 function animate(offset) {
36 58
   console.log(index);
37 59
   var left = parseInt(list.css("left")) + offset;
38 60
   console.log(left, offset);
61
+  var absnum = Math.abs(offset);
62
+  if (left < 0 - offsetpx) {
63
+    //右侧没有数据时不偏移
64
+    return;
65
+  }
39 66
   // 边界判断
40 67
   if (offset > 0) {
41 68
     offset = "+=" + offset;
69
+    offleft = offleft + absnum;
70
+    console.log(offset);
42 71
   } else {
43 72
     offset = "-=" + Math.abs(offset);
73
+    offleft = offleft - absnum;
74
+    console.log(0 - absnum, absnum);
75
+  }
76
+  // if (index == datalist.length) {
77
+  //   offset = 0 - (datalist.length - 5) * absnum;
78
+  //   offleft = offset;
79
+  //   console.log(offset);
80
+  // }
81
+  console.log(offset, offleft, "当前偏移量");
82
+  if (offset >= 0) {
83
+    console.log(44444);
84
+    return;
44 85
   }
45
-
46 86
   list.animate({ left: offset }, 300, function () {
47 87
     if (left > -200) {
48
-      console.log(22);
88
+      console.log(22, (0 - offset) * len);
49 89
       list.css("left", (0 - offset) * len);
50 90
     }
51
-    console.log(offset * len);
52
-    if (left < offset * len) {
53
-      console.log(111);
54
-      list.css("left", 0 - offset);
91
+    if (index == datalist.length) {
92
+      offset = 0 - (datalist.length - 5) * absnum;
93
+      offleft = offset;
94
+      list.css("left", offset);
95
+      console.log(offset, 1231312);
55 96
     }
56 97
   });
57 98
 }
@@ -59,7 +100,7 @@ function animate(offset) {
59 100
 //亮起小圆点
60 101
 function showButton() {
61 102
   //当前图片的小圆点亮起,其他小圆点不亮
62
-  console.log("gaoliang");
103
+  console.log(index, "gaoliang");
63 104
   buts
64 105
     .eq(index - 1)
65 106
     .addClass("active")
@@ -67,6 +108,12 @@ function showButton() {
67 108
     .removeClass("active");
68 109
 }
69 110
 
111
+$(".develop_container").bind("mouseenter", () => {
112
+  stop();
113
+});
114
+$(".develop_container").bind("mouseleave", () => {
115
+  play();
116
+});
70 117
 // 鼠标离开图片区域时,轮播继续
71 118
 function play() {
72 119
   timer = setTimeout(function () {
@@ -88,14 +135,19 @@ next.bind("click", function () {
88 135
   }
89 136
 
90 137
   // 判断当前图片是否是最后一张
91
-  if (index == 5) {
138
+  if (index == datalist.length) {
92 139
     index = 1;
140
+    console.log(222222);
141
+    offleft = 0;
142
+    list.animate({ left: 0 }, 300, () => {});
93 143
   } else {
94 144
     index += 1;
95 145
   }
146
+  console.log(offleft, "当前偏移量");
96 147
   console.log("you", index);
97 148
   animate(0 - divwidth);
98 149
   showButton();
150
+  stop();
99 151
 });
100 152
 
101 153
 // 左按钮事件
@@ -104,39 +156,45 @@ prev.bind("click", function () {
104 156
   if (list.is(":animated")) {
105 157
     return;
106 158
   }
107
-
159
+  console.log(index);
108 160
   // 判断当前图片是否是第一张
109 161
   if (index == 1) {
110
-    index = 5;
162
+    index = datalist.length;
111 163
   } else {
112 164
     index -= 1;
113 165
   }
114
-  console.log(zuo, index);
166
+  console.log("zuo", index);
167
+  console.log(offleft, "当前偏移量");
115 168
   animate(divwidth);
116 169
   showButton();
170
+  stop();
117 171
 });
118 172
 
119 173
 // 小圆点点击事件
120
-// buttons.each(function () {
121
-//   $(this).bind("click", function () {
122
-//     // 判断当前是否在进行动画
123
-//     if (list.is(":animated") || $(this).attr("class") == "on") {
124
-//       return;
125
-//     }
126
-//     // 获取属性
127
-//     var myIndex = parseInt($(this).attr("index"));
128
-
129
-//     //计算偏移量
130
-//     var offset = -600 * (myIndex - index);
131
-
132
-//     animate(offset);
174
+buts.each(function () {
175
+  $(this).bind("click", function () {
176
+    // 判断当前是否在进行动画
177
+    if (list.is(":animated") || $(this).attr("class") == "on") {
178
+      return;
179
+    }
180
+    // 获取属性
181
+    var myIndex = parseInt($(this).attr("index"));
182
+    console.log(myIndex);
183
+    //计算偏移量
184
+    var offset = (0 - divwidth) * (myIndex - index);
185
+    if (myIndex <= 2) {
186
+      offset = 0;
187
+      console.log(myIndex, 33333);
188
+    }
189
+    console.log(offleft, "当前偏移量");
190
+    animate(offset);
133 191
 
134
-//     //切换后,更新当前的偏移量
135
-//     index = myIndex;
192
+    //切换后,更新当前的偏移量
193
+    index = myIndex;
136 194
 
137
-//     showButton();
138
-//   });
139
-// });
195
+    showButton();
196
+  });
197
+});
140 198
 
141 199
 container.hover(stop, play);
142 200
 

Loading…
Cancel
Save