askbot-dragon 0.9.11 → 0.9.13

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 (71) hide show
  1. package/README.md +27 -27
  2. package/babel.config.js +6 -6
  3. package/dragon.iml +7 -7
  4. package/package.json +55 -55
  5. package/public/index.html +43 -43
  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/js/AliyunlssUtil.js +92 -92
  11. package/src/assets/js/Base64Util.js +22 -22
  12. package/src/assets/js/script.js +36 -36
  13. package/src/assets/less/common.css +6773 -6773
  14. package/src/assets/less/converSationContainer/common.less +191 -191
  15. package/src/assets/less/converSationContainer/converSatonContainer.less +493 -493
  16. package/src/assets/less/iconfont.css +37 -37
  17. package/src/assets/less/ticketMessage.less +211 -211
  18. package/src/components/ActionAlertIframe.vue +112 -112
  19. package/src/components/AiGuide.vue +467 -467
  20. package/src/components/AskIFrame.vue +15 -15
  21. package/src/components/ConversationContainer.vue +3668 -1557
  22. package/src/components/FileType.vue +86 -86
  23. package/src/components/Message.vue +27 -27
  24. package/src/components/actionSatisfaction.vue +107 -107
  25. package/src/components/actionSendToBot.vue +62 -62
  26. package/src/components/answerDissatisfaction.vue +62 -62
  27. package/src/components/answerRadio.vue +76 -76
  28. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  29. package/src/components/ask-components/Msgloading.vue +37 -37
  30. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  31. package/src/components/askVideo.vue +138 -138
  32. package/src/components/assetDetails.vue +370 -370
  33. package/src/components/assetMessage.vue +228 -228
  34. package/src/components/associationIntention.vue +229 -229
  35. package/src/components/botActionSatisfactor.vue +68 -68
  36. package/src/components/chatContent.vue +513 -513
  37. package/src/components/feedBack.vue +136 -136
  38. package/src/components/file/AliyunOssComponents.vue +108 -108
  39. package/src/components/formTemplate.vue +3101 -2888
  40. package/src/components/loadingProcess.vue +164 -164
  41. package/src/components/message/ActionAlertIframe.vue +112 -112
  42. package/src/components/message/ShopMessage.vue +164 -164
  43. package/src/components/message/TextMessage.vue +924 -924
  44. package/src/components/message/TicketMessage.vue +177 -177
  45. package/src/components/message/swiper/index.js +4 -4
  46. package/src/components/message/swiper/ticketSwiper.vue +502 -502
  47. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  48. package/src/components/msgLoading.vue +231 -231
  49. package/src/components/myPopup.vue +70 -70
  50. package/src/components/popup.vue +227 -227
  51. package/src/components/recommend.vue +89 -89
  52. package/src/components/selector/hOption.vue +20 -20
  53. package/src/components/selector/hSelector.vue +199 -199
  54. package/src/components/selector/hWrapper.vue +216 -216
  55. package/src/components/senderMessagePlatform.vue +50 -0
  56. package/src/components/source/BotMessage.vue +24 -24
  57. package/src/components/source/CustomMessage.vue +24 -24
  58. package/src/components/test.vue +260 -260
  59. package/src/components/tree.vue +247 -185
  60. package/src/components/utils/AliyunIssUtil.js +72 -72
  61. package/src/components/utils/ckeditor.js +123 -123
  62. package/src/components/utils/command.js +87 -87
  63. package/src/components/utils/editing.js +11 -11
  64. package/src/components/utils/format_date.js +25 -25
  65. package/src/components/utils/index.js +6 -6
  66. package/src/components/utils/math_utils.js +29 -15
  67. package/src/components/utils/plugin-image.js +11 -11
  68. package/src/components/utils/toolbar-ui.js +41 -41
  69. package/src/components/voiceComponent.vue +119 -119
  70. package/src/main.js +45 -45
  71. package/vue.config.js +47 -47
@@ -1,502 +1,502 @@
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='calc(100vw - 110px)'
341
- let swiper=document.getElementsByClassName('swiper')
342
- for (let i=0;i<swiper.length;i++)
343
- {
344
- swiper[i].style.width='calc(100vw - 110px)'
345
- }
346
-
347
-
348
- }else{
349
- this.device='PC'
350
- let el=this.$el
351
- this.isPc=true
352
- el.style.width='300px'
353
- let swiper=document.getElementsByClassName('swiper')
354
-
355
- /* let pnm_swiper=document.getElementById('pnm_swiper')*/
356
- /*pnm_swiper.style.width='300px'*/
357
- for (let i=0;i<swiper.length;i++)
358
- {
359
- swiper[i].style.width='300px'
360
- }
361
- }
362
-
363
- },
364
- isIosOrIsAndroid(){
365
- var u = navigator.userAgent;
366
- var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
367
- var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
368
- if(isAndroid){
369
- this.isAndroid=true
370
- }
371
- if(isiOS){
372
-
373
- this.isIos=true
374
-
375
- }
376
- },
377
- }
378
- };
379
- </script>
380
- <style lang="less">
381
-
382
- #pnm_swiper {
383
- overflow: hidden;
384
- position: relative;
385
- margin: 0 auto;
386
- padding: 10px 0;
387
- -webkit-overflow-scrolling: touch;
388
- }
389
- .swiper {
390
- display: flex;
391
- align-items: center;
392
- }
393
- .bullet {
394
- z-index: 999;
395
- display: flex;
396
- position: absolute;
397
- bottom: 0.1rem;
398
- /* 下方2个配合起来可以达到让弹性盒子子元素真正居中 */
399
- justify-content: center;
400
- width: 100%;
401
- }
402
- //机器人中样式
403
- .isPcClass{
404
- .bullet_item {
405
- color: white;
406
- /* background-color: white;*/
407
- border: 1.5px solid #EAEDF3 !important;
408
- border-radius: 0.2rem;
409
- width: 4px;
410
- height: 4px;
411
- margin: 0 3px;
412
- background-color: #EAEDF3;
413
- }
414
- }
415
- /*.typeClassRem{
416
- .bullet_item {
417
- color: white;
418
- background-color: white;
419
- border: 1.5px solid #AAAAAA !important;
420
- border-radius: 0.2rem;
421
- width: 0.08rem;
422
- height: 0.08rem;
423
- margin: 0 0.03rem;
424
- }
425
- }*/
426
- //企业微信的样式
427
- .isAndroidClass{
428
- .bullet_item {
429
- color: white;
430
- background-color: #EAEDF3;
431
- border: 1.5px solid #EAEDF3 !important;
432
- border-radius: 0.2rem;
433
- width: 4px;
434
- height: 4px;
435
- margin: 0 3px;
436
- }
437
- }
438
- .isIosClass{
439
- .bullet_item {
440
- color: white;
441
- background-color: #EAEDF3;
442
- border: 1.5px solid #EAEDF3 !important;
443
- border-radius: 0.2rem;
444
- width: 4px;
445
- height: 4px;
446
- margin: 0 3px;
447
- }
448
- }
449
- .bullet_item.active {
450
- background-color: #366AFF;
451
- border: 1.5px solid #366AFF !important;
452
- }
453
-
454
- .preBtn{
455
- border: none;
456
- outline: none;
457
- padding: 0;
458
- margin: 0;
459
- height: 36px;
460
- width: 36px;
461
- cursor: pointer;
462
- transition: .3s;
463
- border-radius: 50%;
464
- background-color: rgba(31,45,61,.11);
465
- color: #fff;
466
- position: absolute;
467
- top: 50%;
468
- z-index: 10;
469
- transform: translateY(-50%);
470
- text-align: center;
471
- font-size: 12px
472
- }
473
- .nextBtn{
474
- border: none;
475
- outline: none;
476
- padding: 0;
477
- margin: 0;
478
- height: 36px;
479
- width: 36px;
480
- cursor: pointer;
481
- transition: .3s;
482
- border-radius: 50%;
483
- background-color: rgba(31,45,61,.11);
484
- color: #fff;
485
- position: absolute;
486
- top: 50%;
487
- right: 0;
488
- z-index: 10;
489
- transform: translateY(-50%);
490
- text-align: center;
491
- font-size: 12px
492
- }
493
- #pnm_swiper:hover .clickBtn{
494
-
495
- opacity: 1;
496
- transition: opacity 1s;
497
- }
498
- #pnm_swiper .clickBtn{
499
- opacity: 0;
500
- transition: opacity 1s;
501
- }
502
- </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='calc(100vw - 110px)'
341
+ let swiper=document.getElementsByClassName('swiper')
342
+ for (let i=0;i<swiper.length;i++)
343
+ {
344
+ swiper[i].style.width='calc(100vw - 110px)'
345
+ }
346
+
347
+
348
+ }else{
349
+ this.device='PC'
350
+ let el=this.$el
351
+ this.isPc=true
352
+ el.style.width='300px'
353
+ let swiper=document.getElementsByClassName('swiper')
354
+
355
+ /* let pnm_swiper=document.getElementById('pnm_swiper')*/
356
+ /*pnm_swiper.style.width='300px'*/
357
+ for (let i=0;i<swiper.length;i++)
358
+ {
359
+ swiper[i].style.width='300px'
360
+ }
361
+ }
362
+
363
+ },
364
+ isIosOrIsAndroid(){
365
+ var u = navigator.userAgent;
366
+ var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
367
+ var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
368
+ if(isAndroid){
369
+ this.isAndroid=true
370
+ }
371
+ if(isiOS){
372
+
373
+ this.isIos=true
374
+
375
+ }
376
+ },
377
+ }
378
+ };
379
+ </script>
380
+ <style lang="less">
381
+
382
+ #pnm_swiper {
383
+ overflow: hidden;
384
+ position: relative;
385
+ margin: 0 auto;
386
+ padding: 10px 0;
387
+ -webkit-overflow-scrolling: touch;
388
+ }
389
+ .swiper {
390
+ display: flex;
391
+ align-items: center;
392
+ }
393
+ .bullet {
394
+ z-index: 999;
395
+ display: flex;
396
+ position: absolute;
397
+ bottom: 0.1rem;
398
+ /* 下方2个配合起来可以达到让弹性盒子子元素真正居中 */
399
+ justify-content: center;
400
+ width: 100%;
401
+ }
402
+ //机器人中样式
403
+ .isPcClass{
404
+ .bullet_item {
405
+ color: white;
406
+ /* background-color: white;*/
407
+ border: 1.5px solid #EAEDF3 !important;
408
+ border-radius: 0.2rem;
409
+ width: 4px;
410
+ height: 4px;
411
+ margin: 0 3px;
412
+ background-color: #EAEDF3;
413
+ }
414
+ }
415
+ /*.typeClassRem{
416
+ .bullet_item {
417
+ color: white;
418
+ background-color: white;
419
+ border: 1.5px solid #AAAAAA !important;
420
+ border-radius: 0.2rem;
421
+ width: 0.08rem;
422
+ height: 0.08rem;
423
+ margin: 0 0.03rem;
424
+ }
425
+ }*/
426
+ //企业微信的样式
427
+ .isAndroidClass{
428
+ .bullet_item {
429
+ color: white;
430
+ background-color: #EAEDF3;
431
+ border: 1.5px solid #EAEDF3 !important;
432
+ border-radius: 0.2rem;
433
+ width: 4px;
434
+ height: 4px;
435
+ margin: 0 3px;
436
+ }
437
+ }
438
+ .isIosClass{
439
+ .bullet_item {
440
+ color: white;
441
+ background-color: #EAEDF3;
442
+ border: 1.5px solid #EAEDF3 !important;
443
+ border-radius: 0.2rem;
444
+ width: 4px;
445
+ height: 4px;
446
+ margin: 0 3px;
447
+ }
448
+ }
449
+ .bullet_item.active {
450
+ background-color: #366AFF;
451
+ border: 1.5px solid #366AFF !important;
452
+ }
453
+
454
+ .preBtn{
455
+ border: none;
456
+ outline: none;
457
+ padding: 0;
458
+ margin: 0;
459
+ height: 36px;
460
+ width: 36px;
461
+ cursor: pointer;
462
+ transition: .3s;
463
+ border-radius: 50%;
464
+ background-color: rgba(31,45,61,.11);
465
+ color: #fff;
466
+ position: absolute;
467
+ top: 50%;
468
+ z-index: 10;
469
+ transform: translateY(-50%);
470
+ text-align: center;
471
+ font-size: 12px
472
+ }
473
+ .nextBtn{
474
+ border: none;
475
+ outline: none;
476
+ padding: 0;
477
+ margin: 0;
478
+ height: 36px;
479
+ width: 36px;
480
+ cursor: pointer;
481
+ transition: .3s;
482
+ border-radius: 50%;
483
+ background-color: rgba(31,45,61,.11);
484
+ color: #fff;
485
+ position: absolute;
486
+ top: 50%;
487
+ right: 0;
488
+ z-index: 10;
489
+ transform: translateY(-50%);
490
+ text-align: center;
491
+ font-size: 12px
492
+ }
493
+ #pnm_swiper:hover .clickBtn{
494
+
495
+ opacity: 1;
496
+ transition: opacity 1s;
497
+ }
498
+ #pnm_swiper .clickBtn{
499
+ opacity: 0;
500
+ transition: opacity 1s;
501
+ }
502
+ </style>