askbot-dragon 0.6.17 → 0.6.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +27 -27
  2. package/babel.config.js +5 -5
  3. package/dragon.iml +7 -7
  4. package/package.json +54 -52
  5. package/public/index.html +27 -26
  6. package/src/App.vue +31 -31
  7. package/src/api/index.js +1 -1
  8. package/src/api/mock.http +2 -2
  9. package/src/api/requestUrl.js +185 -185
  10. package/src/assets/less/common.css +6760 -6760
  11. package/src/assets/less/converSationContainer/common.less +4751 -4751
  12. package/src/assets/less/converSationContainer/converSatonContainer.less +492 -492
  13. package/src/assets/less/ticketMessage.less +319 -319
  14. package/src/components/ActionAlertIframe.vue +117 -117
  15. package/src/components/AskIFrame.vue +15 -15
  16. package/src/components/ConversationContainer.vue +1388 -1388
  17. package/src/components/FileType.vue +88 -88
  18. package/src/components/Message.vue +27 -27
  19. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  20. package/src/components/ask-components/Msgloading.vue +37 -37
  21. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  22. package/src/components/chatContent.vue +512 -512
  23. package/src/components/feedBack.vue +133 -133
  24. package/src/components/file/AliyunOssComponents.vue +109 -109
  25. package/src/components/formTemplate.vue +1898 -2039
  26. package/src/components/message/ActionAlertIframe.vue +116 -116
  27. package/src/components/message/ShopMessage.vue +168 -168
  28. package/src/components/message/TextMessage.vue +895 -895
  29. package/src/components/message/TicketMessage.vue +173 -173
  30. package/src/components/message/swiper/index.js +4 -4
  31. package/src/components/message/swiper/ticketSwiper.vue +530 -530
  32. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  33. package/src/components/selector/hOption.vue +20 -20
  34. package/src/components/selector/hSelector.vue +199 -199
  35. package/src/components/selector/hWrapper.vue +216 -216
  36. package/src/components/source/BotMessage.vue +24 -24
  37. package/src/components/source/CustomMessage.vue +24 -24
  38. package/src/components/test.vue +260 -260
  39. package/src/components/utils/AliyunIssUtil.js +72 -72
  40. package/src/components/utils/ckeditor.js +124 -0
  41. package/src/components/utils/format_date.js +18 -18
  42. package/src/components/utils/index.js +6 -6
  43. package/src/components/utils/math_utils.js +15 -15
  44. package/src/main.js +44 -43
  45. package/vue.config.js +34 -28
@@ -1,530 +1,530 @@
1
- <template>
2
- <div id="pnm_swiper">
3
- <div
4
- class="swiper"
5
- @touchstart="touchStart"
6
- @touchmove="touchMove"
7
- @touchend="touchEnd"
8
-
9
- >
10
- <slot></slot>
11
- </div>
12
- <div v-if="device==='PC'&&content.multiple===true" class="clickBtn">
13
- <div class="preBtn" @click="preClick" style="display: flex">
14
- <i class="el-icon-arrow-left" style="font-size: 0.3rem;font-weight:800;align-self: center;margin: auto"></i>
15
- </div>
16
- <div class="nextBtn" @click="nextClick" style="display: flex">
17
- <i class="el-icon-arrow-right" style="font-size: 0.3rem;font-weight:800;align-self: center;margin: auto" ></i></div>
18
- </div>
19
- <div class="bullet" :class="{isPhoneClass:isPhone===true,isPcClass:isPc===true,isAndroidClass:isAndroid===true,isIosClass:isIos===true}">
20
- <div
21
- class="bullet_item"
22
- v-show="slideCount > 1&&content.multiple===true"
23
- v-for="(item, slideIndex) in slideCount"
24
- :class="setBulletActive(slideIndex)"
25
- :key="slideIndex"
26
- ></div>
27
- </div>
28
- </div>
29
-
30
- </template>
31
- <script>
32
- export default {
33
- data() {
34
- return {
35
- currIndex: 1,
36
- swiperStyle: {}, //swiper样式
37
- slideWidth: null, //一张slide的宽度
38
- moveTimer: null,
39
- startPos: 0,
40
- distance: 0,
41
- slideCount: 0,
42
- device:'',
43
- IsmouseOver:false,
44
- IsShowArrowHead:false,
45
- isPhone:false,
46
- isPc:false,
47
- isAndroid:false,
48
- isIos:false,
49
- startX:'',
50
- startY:'',
51
- startTime:''
52
-
53
-
54
- };
55
- },
56
- props: {
57
- moveRatio: {
58
- type: Number,
59
- default: 0.2
60
- },
61
- animDuration: {
62
- type: Number,
63
- default: 300
64
- },
65
- content:{
66
- type:Object,
67
- default(){
68
- return {}
69
- }
70
- },
71
- type:String
72
- },
73
- mounted() {
74
- this.slideOn();
75
- this.isIosOrIsAndroid()
76
-
77
- },
78
- methods: {
79
- // 0. 启动函数
80
-
81
- slideOn() {
82
- this.initDom();
83
- let swiperEls = this.$el;
84
- var touchElement = {};
85
- swiperEls.addEventListener('touchstart',function (e) {
86
- touchElement.startX = e.touches[0].clientX;
87
- touchElement.startY = e.touches[0].clientY;
88
- if (this.slideCount > 1) {
89
- clearInterval(this.moveTimer);
90
- this.startPos = e.touches[0].pageX;
91
- }
92
- })
93
- swiperEls.addEventListener('touchmove',function (e) {
94
- var deltaX = e.touches[0].clientX - touchElement.startX;
95
- var deltaY = e.touches[0].clientY - touchElement.startY;
96
- if (Math.abs(Math.asin(deltaY/deltaX)) <= 15/180*Math.PI && e.cancelable) {
97
- e.preventDefault();
98
- }
99
- if (this.slideCount > 1) {
100
- let movePos = e.touches[0].pageX;
101
- this.distance = movePos - this.startPos;
102
- let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
103
- this.setTransform(moveDistance);
104
- }
105
- })
106
- swiperEls.addEventListener('touchend',function (e) {
107
- if(e.cancelable)
108
- {
109
- e.preventDefault()
110
- }
111
- if (this.slideCount > 1) {
112
- let _Dis = Math.abs(this.distance); //绝对值求出移动的距离
113
- if (this.distance == 0) {
114
- return;
115
- } else if (
116
- this.distance > 0 &&
117
- _Dis > this.slideWidth * this.moveRatio
118
- ) {
119
- this.currIndex--;
120
- console.debug(this.currIndex)
121
- } else if (
122
- this.distance < 0 &&
123
- _Dis > this.slideWidth * this.moveRatio
124
- ) {
125
- this.currIndex++;
126
- }
127
- //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
128
- this.scrollCheck();
129
- //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
130
- /*this.moveAuto();*/
131
- }
132
-
133
-
134
-
135
- })
136
-
137
- },
138
-
139
- // 1. 初始化DOM,并获取必要的数据
140
- initDom() {
141
- this.isMobile()
142
- let swiperEls = this.$el;
143
- console.debug('swiperEls',swiperEls);
144
- let swiperEl=swiperEls.querySelector('.swiper')
145
-
146
- let slides = swiperEl.querySelectorAll(".slide");
147
- this.swiperStyle = swiperEl.style;
148
- this.slideCount = slides.length;
149
- this.slideWidth = swiperEl.offsetWidth;
150
-
151
-
152
- if (this.slideCount > 1) {
153
- let firstSlide = slides[0].cloneNode(true);
154
- let lastSlide = slides[this.slideCount - 1].cloneNode(true);
155
- swiperEl.appendChild(firstSlide);
156
- swiperEl.insertBefore(lastSlide, slides[0]);
157
- //设置开头位置
158
- this.setTransform(-this.slideWidth);
159
- }
160
- console.debug(swiperEl)
161
-
162
- },
163
-
164
- // 2. 自动滚动
165
- /* moveAuto() {
166
- this.moveTimer = setInterval(() => {
167
- this.currIndex++;
168
- //每次滚动都需要先进行检测,真正滚动也会在检测里完成
169
- this.scrollCheck();
170
- }, 1000);
171
- },*/
172
-
173
- // 3. 滚动检测(检测是第一张还是最后一张,让其回滚到正确的位置)
174
- scrollCheck() {
175
- // 开启过渡动画并开始滚动
176
- this.swiperStyle.transition = "transform " + this.animDuration + "ms";
177
- this.setTransform(-this.currIndex * this.slideWidth);
178
-
179
- //设置一个定时器,等过渡动画结束后执行(判断所处位置是第几张)
180
- setTimeout(() => {
181
- this.swiperStyle.transition = "0ms";
182
- //判断第一张,和最后一张
183
- if (this.currIndex <= 0) {
184
- this.currIndex = this.slideCount;
185
- this.setTransform(-this.currIndex * this.slideWidth);
186
- } else if (this.currIndex >= this.slideCount + 1) {
187
- this.currIndex = 1;
188
- this.setTransform(-this.slideWidth);
189
- }
190
- }, this.animDuration);
191
- },
192
-
193
- //设置swiper的transform的滚动距离
194
- setTransform(pos) {
195
- this.swiperStyle.transform = `translateX(${pos}px)`;
196
- },
197
-
198
- //重置子弹的active
199
- setBulletActive(index) {
200
- if (this.currIndex >= this.slideCount + 1) {
201
- //最后一张的情况
202
- return { active: index == 0 };
203
- } else if (this.currIndex <= 0) {
204
- //第0张的情况
205
- return { active: index == this.slideCount - 1 };
206
- } else {
207
- //一般情况
208
- return { active: index == this.currIndex - 1 };
209
- }
210
-
211
- },
212
-
213
- /*
214
- 触屏事件
215
- */
216
-
217
- touchStart(e) {
218
- // 记录下触发的坐标和时间
219
- this.startTime = (new Date()).getTime();
220
- this.startX = e.targetTouches[0].clientX;
221
- this.startY = e.targetTouches[0].clientY;
222
- if (this.slideCount > 1) {
223
- clearInterval(this.moveTimer);
224
- this.startPos = e.touches[0].pageX;
225
- }
226
- },
227
- touchMove(e) {
228
- if (this.slideCount > 1) {
229
- let movePos = e.touches[0].pageX;
230
- this.distance = movePos - this.startPos;
231
- let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
232
- this.setTransform(moveDistance);
233
- this.$emit('touchMove',e)
234
- }
235
- },
236
- touchEnd(e) {
237
- if(e.cancelable)
238
- {
239
- e.preventDefault()
240
- }
241
- var now = (new Date()).getTime();
242
- // 小于300ms可以识别为点击事件的范围 然后判断触摸点的移动距离
243
- if (now - this.startTime < 300) {
244
- var x = (Math.abs(this.startX - e.changedTouches[0].clientX) < 30);
245
- var y = (Math.abs(this.startY - e.changedTouches[0].clientY) < 30);
246
- if (x && y) {
247
- e.changedTouches[0].target.click();
248
- }
249
- else {
250
-
251
- if (this.slideCount > 1) {
252
- let _Dis = Math.abs(this.distance); //绝对值求出移动的距离
253
- if (this.distance == 0) {
254
- return;
255
- } else if (
256
- this.distance > 0 &&
257
- _Dis > this.slideWidth * this.moveRatio
258
- ) {
259
- this.currIndex--;
260
- } else if (
261
- this.distance < 0 &&
262
- _Dis > this.slideWidth * this.moveRatio
263
- ) {
264
- this.currIndex++;
265
- }
266
- //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
267
- this.scrollCheck();
268
- //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
269
- /*this.moveAuto();*/
270
- }
271
- }
272
- this.$emit('touchEnd',this.currIndex)
273
-
274
- }
275
- else {
276
- if (this.slideCount > 1) {
277
- let _Dis = Math.abs(this.distance); //绝对值求出移动的距离
278
-
279
- if (this.distance == 0) {
280
- return;
281
- } else if (
282
- this.distance > 0 &&
283
- _Dis > this.slideWidth * this.moveRatio
284
- ) {
285
- this.currIndex--;
286
- console.debug(this.currIndex)
287
- } else if (
288
- this.distance < 0 &&
289
- _Dis > this.slideWidth * this.moveRatio
290
- ) {
291
- this.currIndex++;
292
- }
293
- //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
294
- this.scrollCheck();
295
- //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
296
- /*this.moveAuto();*/
297
- }
298
- }
299
- },
300
-
301
- preClick(e){
302
- if (this.slideCount > 1) {
303
- let movePos = e.pageX;
304
- this.distance = movePos - this.startPos;
305
- let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
306
- this.setTransform(moveDistance);
307
- }
308
- this.currIndex--;
309
- if (this.slideCount > 1) {
310
-
311
- //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
312
- this.scrollCheck();
313
- //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
314
- /*this.moveAuto();*/
315
- }
316
- },
317
-
318
- nextClick(e){
319
- if (this.slideCount > 1) {
320
- let movePos = e.pageX;
321
- this.distance = movePos - this.startPos;
322
- let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
323
- this.setTransform(moveDistance);
324
- }
325
- if (this.slideCount > 1) {
326
- this.currIndex++;
327
-
328
- //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
329
- this.scrollCheck();
330
- //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
331
- /*this.moveAuto();*/
332
- }
333
- },
334
- //检测设备是PC端还是移动端
335
- isMobile() {
336
- let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
337
- if(flag){
338
- this.isPhone=true
339
- let el=this.$el
340
- el.style.width='80vw'
341
- let swiper=document.getElementsByClassName('swiper')
342
- for (let i=0;i<swiper.length;i++)
343
- {
344
- swiper[i].style.width='80vw'
345
- console.log(swiper[i].style.width)
346
- }
347
-
348
-
349
- }else{
350
- this.device='PC'
351
- let el=this.$el
352
- this.isPc=true
353
- el.style.width='300px'
354
- let swiper=document.getElementsByClassName('swiper')
355
-
356
- let pnm_swiper=document.getElementById('pnm_swiper')
357
- console.log(pnm_swiper)
358
- /*pnm_swiper.style.width='300px'*/
359
- for (let i=0;i<swiper.length;i++)
360
- {
361
- swiper[i].style.width='300px'
362
- }
363
- }
364
-
365
- },
366
- isIosOrIsAndroid(){
367
- var u = navigator.userAgent;
368
- var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
369
- var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
370
- if(isAndroid){
371
- this.isAndroid=true
372
- }
373
- if(isiOS){
374
-
375
- this.isIos=true
376
-
377
- }
378
- },
379
- }
380
- };
381
- </script>
382
- <style lang="less">
383
-
384
- #pnm_swiper {
385
- overflow: hidden;
386
- position: relative;
387
- margin: 0 auto;
388
- padding: 10px 0;
389
- -webkit-overflow-scrolling: touch;
390
- }
391
- .swiper {
392
- display: flex;
393
- align-items: center;
394
- }
395
- .bullet {
396
- z-index: 999;
397
- display: flex;
398
- position: absolute;
399
- bottom: 0.1rem;
400
- /* 下方2个配合起来可以达到让弹性盒子子元素真正居中 */
401
- justify-content: center;
402
- width: 100%;
403
- }
404
- /*.isPhoneClass{
405
- .bullet_item{
406
- width: 0.1rem;
407
- height: 0.1rem;
408
- margin: 0 0.1rem;
409
- }
410
- }*/
411
- /*.isAndroidClass,.isPcClass{
412
- !*.bullet_item{
413
- width: 0.05rem;
414
- height: 0.05rem;
415
- margin: 0 0.03rem;
416
- }*!
417
- .bullet_item {
418
- color: white;
419
- background-color: white;
420
- border: 1.5px solid #AAAAAA !important;
421
- border-radius: 0.2rem;
422
- width: 3px;
423
- height: 3px;
424
- margin: 0 2px;
425
- }
426
- }*/
427
- //机器人中样式
428
- .isPcClass{
429
- .bullet_item {
430
- color: white;
431
- background-color: white;
432
- border: 1.5px solid #AAAAAA !important;
433
- border-radius: 0.2rem;
434
- width: 4px;
435
- height: 4px;
436
- margin: 0 3px;
437
- }
438
- }
439
- /*.typeClassRem{
440
- .bullet_item {
441
- color: white;
442
- background-color: white;
443
- border: 1.5px solid #AAAAAA !important;
444
- border-radius: 0.2rem;
445
- width: 0.08rem;
446
- height: 0.08rem;
447
- margin: 0 0.03rem;
448
- }
449
- }*/
450
- //企业微信的样式
451
- .isAndroidClass{
452
- .bullet_item {
453
- color: white;
454
- background-color: white;
455
- border: 1.5px solid #AAAAAA !important;
456
- border-radius: 0.2rem;
457
- width: 4px;
458
- height: 4px;
459
- margin: 0 3px;
460
- }
461
- }
462
- .isIosClass{
463
- .bullet_item {
464
- color: white;
465
- background-color: white;
466
- border: 1.5px solid #AAAAAA !important;
467
- border-radius: 0.2rem;
468
- width: 4px;
469
- height: 4px;
470
- margin: 0 3px;
471
- }
472
- }
473
- /*.bullet_item {
474
- color: white;
475
- border: 1px solid #AAAAAA !important;
476
- border-radius: 0.2rem;
477
- }*/
478
- .bullet_item.active {
479
- background-color: #AAAAAA;
480
- }
481
-
482
- .preBtn{
483
- border: none;
484
- outline: none;
485
- padding: 0;
486
- margin: 0;
487
- height: 36px;
488
- width: 36px;
489
- cursor: pointer;
490
- transition: .3s;
491
- border-radius: 50%;
492
- background-color: rgba(31,45,61,.11);
493
- color: #fff;
494
- position: absolute;
495
- top: 50%;
496
- z-index: 10;
497
- transform: translateY(-50%);
498
- text-align: center;
499
- font-size: 12px
500
- }
501
- .nextBtn{
502
- border: none;
503
- outline: none;
504
- padding: 0;
505
- margin: 0;
506
- height: 36px;
507
- width: 36px;
508
- cursor: pointer;
509
- transition: .3s;
510
- border-radius: 50%;
511
- background-color: rgba(31,45,61,.11);
512
- color: #fff;
513
- position: absolute;
514
- top: 50%;
515
- right: 0;
516
- z-index: 10;
517
- transform: translateY(-50%);
518
- text-align: center;
519
- font-size: 12px
520
- }
521
- #pnm_swiper:hover .clickBtn{
522
-
523
- opacity: 1;
524
- transition: opacity 1s;
525
- }
526
- #pnm_swiper .clickBtn{
527
- opacity: 0;
528
- transition: opacity 1s;
529
- }
530
- </style>
1
+ <template>
2
+ <div id="pnm_swiper">
3
+ <div
4
+ class="swiper"
5
+ @touchstart="touchStart"
6
+ @touchmove="touchMove"
7
+ @touchend="touchEnd"
8
+
9
+ >
10
+ <slot></slot>
11
+ </div>
12
+ <div v-if="device==='PC'&&content.multiple===true" class="clickBtn">
13
+ <div class="preBtn" @click="preClick" style="display: flex">
14
+ <i class="el-icon-arrow-left" style="font-size: 0.3rem;font-weight:800;align-self: center;margin: auto"></i>
15
+ </div>
16
+ <div class="nextBtn" @click="nextClick" style="display: flex">
17
+ <i class="el-icon-arrow-right" style="font-size: 0.3rem;font-weight:800;align-self: center;margin: auto" ></i></div>
18
+ </div>
19
+ <div class="bullet" :class="{isPhoneClass:isPhone===true,isPcClass:isPc===true,isAndroidClass:isAndroid===true,isIosClass:isIos===true}">
20
+ <div
21
+ class="bullet_item"
22
+ v-show="slideCount > 1&&content.multiple===true"
23
+ v-for="(item, slideIndex) in slideCount"
24
+ :class="setBulletActive(slideIndex)"
25
+ :key="slideIndex"
26
+ ></div>
27
+ </div>
28
+ </div>
29
+
30
+ </template>
31
+ <script>
32
+ export default {
33
+ data() {
34
+ return {
35
+ currIndex: 1,
36
+ swiperStyle: {}, //swiper样式
37
+ slideWidth: null, //一张slide的宽度
38
+ moveTimer: null,
39
+ startPos: 0,
40
+ distance: 0,
41
+ slideCount: 0,
42
+ device:'',
43
+ IsmouseOver:false,
44
+ IsShowArrowHead:false,
45
+ isPhone:false,
46
+ isPc:false,
47
+ isAndroid:false,
48
+ isIos:false,
49
+ startX:'',
50
+ startY:'',
51
+ startTime:''
52
+
53
+
54
+ };
55
+ },
56
+ props: {
57
+ moveRatio: {
58
+ type: Number,
59
+ default: 0.2
60
+ },
61
+ animDuration: {
62
+ type: Number,
63
+ default: 300
64
+ },
65
+ content:{
66
+ type:Object,
67
+ default(){
68
+ return {}
69
+ }
70
+ },
71
+ type:String
72
+ },
73
+ mounted() {
74
+ this.slideOn();
75
+ this.isIosOrIsAndroid()
76
+
77
+ },
78
+ methods: {
79
+ // 0. 启动函数
80
+
81
+ slideOn() {
82
+ this.initDom();
83
+ let swiperEls = this.$el;
84
+ var touchElement = {};
85
+ swiperEls.addEventListener('touchstart',function (e) {
86
+ touchElement.startX = e.touches[0].clientX;
87
+ touchElement.startY = e.touches[0].clientY;
88
+ if (this.slideCount > 1) {
89
+ clearInterval(this.moveTimer);
90
+ this.startPos = e.touches[0].pageX;
91
+ }
92
+ })
93
+ swiperEls.addEventListener('touchmove',function (e) {
94
+ var deltaX = e.touches[0].clientX - touchElement.startX;
95
+ var deltaY = e.touches[0].clientY - touchElement.startY;
96
+ if (Math.abs(Math.asin(deltaY/deltaX)) <= 15/180*Math.PI && e.cancelable) {
97
+ e.preventDefault();
98
+ }
99
+ if (this.slideCount > 1) {
100
+ let movePos = e.touches[0].pageX;
101
+ this.distance = movePos - this.startPos;
102
+ let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
103
+ this.setTransform(moveDistance);
104
+ }
105
+ })
106
+ swiperEls.addEventListener('touchend',function (e) {
107
+ if(e.cancelable)
108
+ {
109
+ e.preventDefault()
110
+ }
111
+ if (this.slideCount > 1) {
112
+ let _Dis = Math.abs(this.distance); //绝对值求出移动的距离
113
+ if (this.distance == 0) {
114
+ return;
115
+ } else if (
116
+ this.distance > 0 &&
117
+ _Dis > this.slideWidth * this.moveRatio
118
+ ) {
119
+ this.currIndex--;
120
+ console.debug(this.currIndex)
121
+ } else if (
122
+ this.distance < 0 &&
123
+ _Dis > this.slideWidth * this.moveRatio
124
+ ) {
125
+ this.currIndex++;
126
+ }
127
+ //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
128
+ this.scrollCheck();
129
+ //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
130
+ /*this.moveAuto();*/
131
+ }
132
+
133
+
134
+
135
+ })
136
+
137
+ },
138
+
139
+ // 1. 初始化DOM,并获取必要的数据
140
+ initDom() {
141
+ this.isMobile()
142
+ let swiperEls = this.$el;
143
+ console.debug('swiperEls',swiperEls);
144
+ let swiperEl=swiperEls.querySelector('.swiper')
145
+
146
+ let slides = swiperEl.querySelectorAll(".slide");
147
+ this.swiperStyle = swiperEl.style;
148
+ this.slideCount = slides.length;
149
+ this.slideWidth = swiperEl.offsetWidth;
150
+
151
+
152
+ if (this.slideCount > 1) {
153
+ let firstSlide = slides[0].cloneNode(true);
154
+ let lastSlide = slides[this.slideCount - 1].cloneNode(true);
155
+ swiperEl.appendChild(firstSlide);
156
+ swiperEl.insertBefore(lastSlide, slides[0]);
157
+ //设置开头位置
158
+ this.setTransform(-this.slideWidth);
159
+ }
160
+ console.debug(swiperEl)
161
+
162
+ },
163
+
164
+ // 2. 自动滚动
165
+ /* moveAuto() {
166
+ this.moveTimer = setInterval(() => {
167
+ this.currIndex++;
168
+ //每次滚动都需要先进行检测,真正滚动也会在检测里完成
169
+ this.scrollCheck();
170
+ }, 1000);
171
+ },*/
172
+
173
+ // 3. 滚动检测(检测是第一张还是最后一张,让其回滚到正确的位置)
174
+ scrollCheck() {
175
+ // 开启过渡动画并开始滚动
176
+ this.swiperStyle.transition = "transform " + this.animDuration + "ms";
177
+ this.setTransform(-this.currIndex * this.slideWidth);
178
+
179
+ //设置一个定时器,等过渡动画结束后执行(判断所处位置是第几张)
180
+ setTimeout(() => {
181
+ this.swiperStyle.transition = "0ms";
182
+ //判断第一张,和最后一张
183
+ if (this.currIndex <= 0) {
184
+ this.currIndex = this.slideCount;
185
+ this.setTransform(-this.currIndex * this.slideWidth);
186
+ } else if (this.currIndex >= this.slideCount + 1) {
187
+ this.currIndex = 1;
188
+ this.setTransform(-this.slideWidth);
189
+ }
190
+ }, this.animDuration);
191
+ },
192
+
193
+ //设置swiper的transform的滚动距离
194
+ setTransform(pos) {
195
+ this.swiperStyle.transform = `translateX(${pos}px)`;
196
+ },
197
+
198
+ //重置子弹的active
199
+ setBulletActive(index) {
200
+ if (this.currIndex >= this.slideCount + 1) {
201
+ //最后一张的情况
202
+ return { active: index == 0 };
203
+ } else if (this.currIndex <= 0) {
204
+ //第0张的情况
205
+ return { active: index == this.slideCount - 1 };
206
+ } else {
207
+ //一般情况
208
+ return { active: index == this.currIndex - 1 };
209
+ }
210
+
211
+ },
212
+
213
+ /*
214
+ 触屏事件
215
+ */
216
+
217
+ touchStart(e) {
218
+ // 记录下触发的坐标和时间
219
+ this.startTime = (new Date()).getTime();
220
+ this.startX = e.targetTouches[0].clientX;
221
+ this.startY = e.targetTouches[0].clientY;
222
+ if (this.slideCount > 1) {
223
+ clearInterval(this.moveTimer);
224
+ this.startPos = e.touches[0].pageX;
225
+ }
226
+ },
227
+ touchMove(e) {
228
+ if (this.slideCount > 1) {
229
+ let movePos = e.touches[0].pageX;
230
+ this.distance = movePos - this.startPos;
231
+ let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
232
+ this.setTransform(moveDistance);
233
+ this.$emit('touchMove',e)
234
+ }
235
+ },
236
+ touchEnd(e) {
237
+ if(e.cancelable)
238
+ {
239
+ e.preventDefault()
240
+ }
241
+ var now = (new Date()).getTime();
242
+ // 小于300ms可以识别为点击事件的范围 然后判断触摸点的移动距离
243
+ if (now - this.startTime < 300) {
244
+ var x = (Math.abs(this.startX - e.changedTouches[0].clientX) < 30);
245
+ var y = (Math.abs(this.startY - e.changedTouches[0].clientY) < 30);
246
+ if (x && y) {
247
+ e.changedTouches[0].target.click();
248
+ }
249
+ else {
250
+
251
+ if (this.slideCount > 1) {
252
+ let _Dis = Math.abs(this.distance); //绝对值求出移动的距离
253
+ if (this.distance == 0) {
254
+ return;
255
+ } else if (
256
+ this.distance > 0 &&
257
+ _Dis > this.slideWidth * this.moveRatio
258
+ ) {
259
+ this.currIndex--;
260
+ } else if (
261
+ this.distance < 0 &&
262
+ _Dis > this.slideWidth * this.moveRatio
263
+ ) {
264
+ this.currIndex++;
265
+ }
266
+ //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
267
+ this.scrollCheck();
268
+ //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
269
+ /*this.moveAuto();*/
270
+ }
271
+ }
272
+ this.$emit('touchEnd',this.currIndex)
273
+
274
+ }
275
+ else {
276
+ if (this.slideCount > 1) {
277
+ let _Dis = Math.abs(this.distance); //绝对值求出移动的距离
278
+
279
+ if (this.distance == 0) {
280
+ return;
281
+ } else if (
282
+ this.distance > 0 &&
283
+ _Dis > this.slideWidth * this.moveRatio
284
+ ) {
285
+ this.currIndex--;
286
+ console.debug(this.currIndex)
287
+ } else if (
288
+ this.distance < 0 &&
289
+ _Dis > this.slideWidth * this.moveRatio
290
+ ) {
291
+ this.currIndex++;
292
+ }
293
+ //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
294
+ this.scrollCheck();
295
+ //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
296
+ /*this.moveAuto();*/
297
+ }
298
+ }
299
+ },
300
+
301
+ preClick(e){
302
+ if (this.slideCount > 1) {
303
+ let movePos = e.pageX;
304
+ this.distance = movePos - this.startPos;
305
+ let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
306
+ this.setTransform(moveDistance);
307
+ }
308
+ this.currIndex--;
309
+ if (this.slideCount > 1) {
310
+
311
+ //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
312
+ this.scrollCheck();
313
+ //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
314
+ /*this.moveAuto();*/
315
+ }
316
+ },
317
+
318
+ nextClick(e){
319
+ if (this.slideCount > 1) {
320
+ let movePos = e.pageX;
321
+ this.distance = movePos - this.startPos;
322
+ let moveDistance = -(this.currIndex * this.slideWidth) + this.distance;
323
+ this.setTransform(moveDistance);
324
+ }
325
+ if (this.slideCount > 1) {
326
+ this.currIndex++;
327
+
328
+ //在触碰结束时,由于会触碰第一张或者最后一张,所以需要来一个滚动检测
329
+ this.scrollCheck();
330
+ //上述检测完毕,让其在正确位置之后,在执行 自动翻滚
331
+ /*this.moveAuto();*/
332
+ }
333
+ },
334
+ //检测设备是PC端还是移动端
335
+ isMobile() {
336
+ let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
337
+ if(flag){
338
+ this.isPhone=true
339
+ let el=this.$el
340
+ el.style.width='80vw'
341
+ let swiper=document.getElementsByClassName('swiper')
342
+ for (let i=0;i<swiper.length;i++)
343
+ {
344
+ swiper[i].style.width='80vw'
345
+ console.log(swiper[i].style.width)
346
+ }
347
+
348
+
349
+ }else{
350
+ this.device='PC'
351
+ let el=this.$el
352
+ this.isPc=true
353
+ el.style.width='300px'
354
+ let swiper=document.getElementsByClassName('swiper')
355
+
356
+ let pnm_swiper=document.getElementById('pnm_swiper')
357
+ console.log(pnm_swiper)
358
+ /*pnm_swiper.style.width='300px'*/
359
+ for (let i=0;i<swiper.length;i++)
360
+ {
361
+ swiper[i].style.width='300px'
362
+ }
363
+ }
364
+
365
+ },
366
+ isIosOrIsAndroid(){
367
+ var u = navigator.userAgent;
368
+ var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
369
+ var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
370
+ if(isAndroid){
371
+ this.isAndroid=true
372
+ }
373
+ if(isiOS){
374
+
375
+ this.isIos=true
376
+
377
+ }
378
+ },
379
+ }
380
+ };
381
+ </script>
382
+ <style lang="less">
383
+
384
+ #pnm_swiper {
385
+ overflow: hidden;
386
+ position: relative;
387
+ margin: 0 auto;
388
+ padding: 10px 0;
389
+ -webkit-overflow-scrolling: touch;
390
+ }
391
+ .swiper {
392
+ display: flex;
393
+ align-items: center;
394
+ }
395
+ .bullet {
396
+ z-index: 999;
397
+ display: flex;
398
+ position: absolute;
399
+ bottom: 0.1rem;
400
+ /* 下方2个配合起来可以达到让弹性盒子子元素真正居中 */
401
+ justify-content: center;
402
+ width: 100%;
403
+ }
404
+ /*.isPhoneClass{
405
+ .bullet_item{
406
+ width: 0.1rem;
407
+ height: 0.1rem;
408
+ margin: 0 0.1rem;
409
+ }
410
+ }*/
411
+ /*.isAndroidClass,.isPcClass{
412
+ !*.bullet_item{
413
+ width: 0.05rem;
414
+ height: 0.05rem;
415
+ margin: 0 0.03rem;
416
+ }*!
417
+ .bullet_item {
418
+ color: white;
419
+ background-color: white;
420
+ border: 1.5px solid #AAAAAA !important;
421
+ border-radius: 0.2rem;
422
+ width: 3px;
423
+ height: 3px;
424
+ margin: 0 2px;
425
+ }
426
+ }*/
427
+ //机器人中样式
428
+ .isPcClass{
429
+ .bullet_item {
430
+ color: white;
431
+ background-color: white;
432
+ border: 1.5px solid #AAAAAA !important;
433
+ border-radius: 0.2rem;
434
+ width: 4px;
435
+ height: 4px;
436
+ margin: 0 3px;
437
+ }
438
+ }
439
+ /*.typeClassRem{
440
+ .bullet_item {
441
+ color: white;
442
+ background-color: white;
443
+ border: 1.5px solid #AAAAAA !important;
444
+ border-radius: 0.2rem;
445
+ width: 0.08rem;
446
+ height: 0.08rem;
447
+ margin: 0 0.03rem;
448
+ }
449
+ }*/
450
+ //企业微信的样式
451
+ .isAndroidClass{
452
+ .bullet_item {
453
+ color: white;
454
+ background-color: white;
455
+ border: 1.5px solid #AAAAAA !important;
456
+ border-radius: 0.2rem;
457
+ width: 4px;
458
+ height: 4px;
459
+ margin: 0 3px;
460
+ }
461
+ }
462
+ .isIosClass{
463
+ .bullet_item {
464
+ color: white;
465
+ background-color: white;
466
+ border: 1.5px solid #AAAAAA !important;
467
+ border-radius: 0.2rem;
468
+ width: 4px;
469
+ height: 4px;
470
+ margin: 0 3px;
471
+ }
472
+ }
473
+ /*.bullet_item {
474
+ color: white;
475
+ border: 1px solid #AAAAAA !important;
476
+ border-radius: 0.2rem;
477
+ }*/
478
+ .bullet_item.active {
479
+ background-color: #AAAAAA;
480
+ }
481
+
482
+ .preBtn{
483
+ border: none;
484
+ outline: none;
485
+ padding: 0;
486
+ margin: 0;
487
+ height: 36px;
488
+ width: 36px;
489
+ cursor: pointer;
490
+ transition: .3s;
491
+ border-radius: 50%;
492
+ background-color: rgba(31,45,61,.11);
493
+ color: #fff;
494
+ position: absolute;
495
+ top: 50%;
496
+ z-index: 10;
497
+ transform: translateY(-50%);
498
+ text-align: center;
499
+ font-size: 12px
500
+ }
501
+ .nextBtn{
502
+ border: none;
503
+ outline: none;
504
+ padding: 0;
505
+ margin: 0;
506
+ height: 36px;
507
+ width: 36px;
508
+ cursor: pointer;
509
+ transition: .3s;
510
+ border-radius: 50%;
511
+ background-color: rgba(31,45,61,.11);
512
+ color: #fff;
513
+ position: absolute;
514
+ top: 50%;
515
+ right: 0;
516
+ z-index: 10;
517
+ transform: translateY(-50%);
518
+ text-align: center;
519
+ font-size: 12px
520
+ }
521
+ #pnm_swiper:hover .clickBtn{
522
+
523
+ opacity: 1;
524
+ transition: opacity 1s;
525
+ }
526
+ #pnm_swiper .clickBtn{
527
+ opacity: 0;
528
+ transition: opacity 1s;
529
+ }
530
+ </style>