@zykjcommon/questions 0.0.40 → 0.0.42

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zykjcommon/questions",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "main": "src/components/questions/entry.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -888,7 +888,8 @@ function getDeviceEnv(){
888
888
  }
889
889
  }
890
890
  }
891
- return IsIPad
891
+ let touch = !!(('ontouchstart' in window) || (window.DocumentTouch && document instanceof window.DocumentTouch))
892
+ return IsIPad && touch
892
893
  }
893
894
  let env = ''
894
895
  let md= new MobileDetect(window.navigator.userAgent) //初始化mobile-detect
@@ -1,4 +1,4 @@
1
- $greenItemFontSize:0.14em;
1
+ $greenItemFontSize:0.13em;
2
2
  .zykjcommon-question{
3
3
  box-sizing: border-box;
4
4
  .editor-content{
@@ -354,7 +354,9 @@ $greenItemFontSize:0.14em;
354
354
  height: 100%;
355
355
  position: relative;
356
356
  /*background: url("../../img/classify-bg-seaworld.png") no-repeat center;*/
357
- /*background-size: 100% 100%;*/
357
+ background-repeat: no-repeat;
358
+ background-position: center;
359
+ background-size: 100% 100%;
358
360
  overflow: auto;
359
361
  .box{
360
362
  padding: 0 0.8em;
@@ -369,10 +371,10 @@ $greenItemFontSize:0.14em;
369
371
  display: flex;
370
372
  flex-direction: column;
371
373
  /*background: url("../../img/classify-boxitem-bg.png") no-repeat center;*/
372
- /*background-size: 100% 100%;*/
374
+ background-size: 100% 100%;
373
375
  }
374
376
  .main-block{
375
- margin:0.38em auto 0.1rem;
377
+ margin:0.38em auto 0.1em;
376
378
  width: 1.1em;
377
379
  height: 1.1em;
378
380
  background: #76d2ff;
@@ -389,7 +391,7 @@ $greenItemFontSize:0.14em;
389
391
  padding: 0 0.28em 0.15em 0.35em;
390
392
  flex: 1;
391
393
  .main-append{
392
- height: 2.77em;
394
+ height: 2.74em;
393
395
  overflow: auto;
394
396
  display: flex;
395
397
  flex-wrap: wrap;
@@ -402,8 +404,10 @@ $greenItemFontSize:0.14em;
402
404
  }
403
405
  }
404
406
  .append-item{
405
- /*background: url("../../img/classify-green-item.png") no-repeat center;
406
- background-size: 100% 100%;*/
407
+ /*background: url("../../img/classify-green-item.png") no-repeat center;*/
408
+ background-repeat: no-repeat;
409
+ background-position: center;
410
+ background-size: 100% 100%;
407
411
  width: 1.3em;
408
412
  height: 1.3em;
409
413
  margin-right: 0.1em;
@@ -446,7 +450,9 @@ $greenItemFontSize:0.14em;
446
450
  margin-left: -4.5em;
447
451
  width: 9em;
448
452
  /*background: url("../../img/classify-list-bg.png") no-repeat center;*/
449
- /*background-size: 100% 100%;*/
453
+ background-repeat: no-repeat;
454
+ background-position: center;
455
+ background-size: 100% 100%;
450
456
  .list{
451
457
  height: 1.5em;
452
458
  display: flex;
@@ -488,8 +494,10 @@ $greenItemFontSize:0.14em;
488
494
  }
489
495
  }
490
496
  .list-item{
491
- /*background: url("../../img/classify-green-item.png") no-repeat center;
492
- background-size: 100% 100%;*/
497
+ /*background: url("../../img/classify-green-item.png") no-repeat center;*/
498
+ background-repeat: no-repeat;
499
+ background-position: center;
500
+ background-size: 100% 100%;
493
501
  width: 1.3em;
494
502
  height: 1.3em;
495
503
  margin-right: 0.1em;
@@ -526,8 +534,10 @@ $greenItemFontSize:0.14em;
526
534
  }
527
535
  .question-classify-moveDiv{
528
536
  position: fixed;
529
- /*background: url("../../img/classify-green-item.png") no-repeat center;
530
- background-size: 100% 100%;*/
537
+ /*background: url("../../img/classify-green-item.png") no-repeat center;*/
538
+ background-repeat: no-repeat;
539
+ background-position: center;
540
+ background-size: 100% 100%;
531
541
  width: 1.3em;
532
542
  height: 1.3em;
533
543
  margin-right: 0.1em;
@@ -176,17 +176,18 @@ export default {
176
176
  let exam_options_data = nv.exam_options_data
177
177
  if(this.classify_question_info){
178
178
  if(this.classify_question_info.background_file){
179
- this.bigBgCss = `background: url(${this.classify_question_info.background_file.file_url}) no-repeat center;background-size: 100% 100%`
179
+ this.bigBgCss = `background-image: url(${this.classify_question_info.background_file.file_url});`
180
180
  }
181
181
  if(this.classify_question_info.bottom_img_file){
182
- this.bottomBgCss = `background: url(${this.classify_question_info.bottom_img_file.file_url}) no-repeat center;background-size: 100% 100%`
182
+ this.bottomBgCss = `background-image: url(${this.classify_question_info.bottom_img_file.file_url});`
183
183
  }
184
184
  let optionList = []
185
+ this.optionList = []
185
186
  exam_options_data.forEach((item)=>{
186
187
  optionList.push({
187
188
  content_type:item.data.content_type,
188
189
  content:item.data.option_content,
189
- bgUrlCss:`background: url(${item.data.file_url}) no-repeat center;background-size: 100% 100%;color:${item.data.font_color}`,
190
+ bgUrlCss:`background-image: url(${item.data.file_url});color:${item.data.font_color}`,
190
191
  idx:item.index
191
192
  })
192
193
  })
@@ -200,7 +201,7 @@ export default {
200
201
  bigBoxItemList.push({
201
202
  imgUrl:big_type_option_list[index].file_url,
202
203
  bgUrl:item.file_url,
203
- bgUrlCss:`background: url(${item.file_url}) no-repeat center;background-size: 100% 100%`
204
+ bgUrlCss:`background-image: url(${item.file_url});`
204
205
  })
205
206
  })
206
207
  this.bigBoxItemList = bigBoxItemList
@@ -215,6 +216,8 @@ export default {
215
216
  document.removeEventListener('gesturestart', this.gesturestartListener)
216
217
  $(this.$el).find('.question-classify .append-item').off(this.mousedown)
217
218
  $(this.$el).find('.question-classify .list-item').off(this.mousedown)
219
+ $(this.$el).find(`.question-classify .next`).off('click')
220
+ $(this.$el).find(`.question-classify .prev`).off('click')
218
221
  $(document).off(this.mouseup)
219
222
  let html = document.getElementsByTagName("html")[0];
220
223
  html.style.fontSize = "";
@@ -278,12 +281,12 @@ export default {
278
281
  self.p1.moveX = self.listItem.offset().left;
279
282
  self.p1.moveY = self.listItem.offset().top - 30;
280
283
  let idx = self.listItem.attr('idx')
281
- let itemBgCss = `${self.listItem.get(0).style.background}`
284
+ let itemBgCss = `${self.listItem.get(0).style.backgroundImage}`
282
285
  let itemColorCss = `${self.listItem.get(0).style.color}`
283
286
  let textDisplayCss = self.listItem.find('.list-item-text').get(0).style.display
284
287
  console.log(itemBgCss,1234);
285
288
  self.moveDiv = $(`<div class="question-classify-moveDiv" idx="${idx}"><div class="list-item-text" style="${textDisplayCss?'display:'+textDisplayCss:''}">${self.listItem.find('.list-item-text').text()}</div></div>`)
286
- self.moveDiv.css({left:`${self.p1.moveX}px`,top:`${self.p1.moveY}px`,background:itemBgCss,color:itemColorCss})
289
+ self.moveDiv.css({left:`${self.p1.moveX}px`,top:`${self.p1.moveY}px`,backgroundImage:itemBgCss,color:itemColorCss})
287
290
  $(self.$el).append(self.moveDiv)
288
291
  $(document).on(self.mousemove,function(e2){
289
292
  // e2.preventDefault()
@@ -299,6 +302,7 @@ export default {
299
302
 
300
303
  })
301
304
  }
305
+ appendItem.off(this.mousedown)
302
306
  appendItem.on(this.mousedown,function(e){
303
307
  if(env === 'mobile'){
304
308
  self.lazyDragTimer = setTimeout(()=>{
@@ -313,11 +317,11 @@ export default {
313
317
  let self = this
314
318
  self.listItem.remove()
315
319
  let idx = self.moveDiv.attr('idx')
316
- let itemBgCss = `${self.moveDiv.get(0).style.background}`
320
+ let itemBgCss = `${self.moveDiv.get(0).style.backgroundImage}`
317
321
  let itemColorCss = `${self.moveDiv.get(0).style.color}`
318
322
  let textDisplayCss = self.moveDiv.find('.list-item-text').get(0).style.display
319
323
  let appendItem = $(`<div class="${options.appendItemClassName}" idx="${idx}"><div class="list-item-text" style="${textDisplayCss?'display:'+textDisplayCss:''}">${self.moveDiv.find('.list-item-text').text()}</div></div>`)
320
- appendItem.css({opacity:0,background:itemBgCss,color:itemColorCss})
324
+ appendItem.css({opacity:0,backgroundImage:itemBgCss,color:itemColorCss})
321
325
  options.targetList.append(appendItem)
322
326
  options.targetList[options.scrollDirection](self.scrollDistance)
323
327
  let appendLeft = appendItem.offset().left
@@ -343,6 +347,7 @@ export default {
343
347
  },
344
348
  bindNextPrevEvent(type){
345
349
  let self = this
350
+ $(this.$el).find(`.question-classify .${type}`).off('click')
346
351
  $(this.$el).find(`.question-classify .${type}`).on('click',function(e){
347
352
  e.stopPropagation()
348
353
  e.preventDefault()
@@ -360,6 +365,7 @@ export default {
360
365
  this.setAnswerDo()
361
366
  }
362
367
  self.bindDragDomEvent($(this.$el).find('.question-classify .list-item'),'go')
368
+ $(document).off(self.mouseup)
363
369
  $(document).on(self.mouseup,function(e){
364
370
  env === 'mobile' && self.stopLazyDrag()
365
371
  if(self.animationing){
@@ -430,12 +436,14 @@ export default {
430
436
  return false
431
437
  }
432
438
  if(env === 'mobile'){
433
- $('.list').scroll(function(e){
439
+ $('.list').off('scroll')
440
+ $('.list').on('scroll',function(){
434
441
  if(!self.dragingStart){
435
442
  self.stopLazyDrag()
436
443
  }
437
444
  }).addClass('noScrollBar')
438
- $('.main-append').scroll(function(e){
445
+ $('.main-append').off('scroll')
446
+ $('.main-append').on('scroll',function(e){
439
447
  if(!self.dragingStart){
440
448
  self.stopLazyDrag()
441
449
  }
@@ -473,6 +481,8 @@ export default {
473
481
  $(this.$el).find('.question-classify .list-item').each((index,item)=>{
474
482
  listItemIds.push(Number($(item).attr('idx')))
475
483
  })
484
+ // 如果两个上一题下一题切换组件,两个又是同一类型的组件,需要清空一下dom,以防两题篡了
485
+ $(this.$el).find('.main-append').empty()
476
486
  this.answerMap.classify_mapping_list.forEach((item,index)=>{
477
487
  item.small_type_index_list.forEach((subItem)=>{
478
488
  let idx = listItemIds.findIndex((i)=>{
@@ -482,13 +492,13 @@ export default {
482
492
  //找到一个删掉一个,要不会有问题
483
493
  listItemIds.splice(idx,1)
484
494
  let listItemDom = $(this.$el).find('.question-classify .list-item').eq(idx)
485
- let itemBgCss = `${listItemDom.get(0).style.background}`
495
+ let itemBgCss = `${listItemDom.get(0).style.backgroundImage}`
486
496
  let itemColorCss = `${listItemDom.get(0).style.color}`
487
497
  let textDisplayCss = listItemDom.find('.list-item-text').get(0).style.display
488
498
  let attrIdx = listItemDom.attr('idx')
489
499
  let appendItem = $(`<div class="append-item" idx="${attrIdx}"><div class="list-item-text" style="${textDisplayCss?'display:'+textDisplayCss:''}">${listItemDom.find('.list-item-text').text()}</div></div>`)
490
500
  appendItem.css({
491
- background:itemBgCss,
501
+ backgroundImage:itemBgCss,
492
502
  color:itemColorCss
493
503
  })
494
504
  self.bindDragDomEvent(appendItem,'back')