网站
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

120 righe
4.1 KiB

  1. define(['jquery', "template", "Tools",'swiper',], function ($, template, Tools, swiper) {
  2. //数据存储
  3. var module = {
  4. data: {
  5. //服务器地址
  6. serverApi: '',
  7. trainStudentsList:[{
  8. name:'',
  9. phone:'',
  10. sex: '',
  11. trainId:''
  12. }]
  13. },
  14. };
  15. var tools = new Tools();
  16. module.init = function (page) {
  17. //新闻管理列表
  18. tools.doGet(dictType + '/training_type', {}, module.dictType , true);
  19. tools.doGet(dictType + '/apply_state', {}, function(data){module.data.studentsTypeOptions = data.data;} , true);
  20. module.data.trainStudentsList[0].trainId = getQueryVariable('id');
  21. };
  22. module.dictType = function (data) {
  23. module.data.trainingTypeOptions = data.data;
  24. tools.doGet(supplyDetails + '/' + getQueryVariable('id'), {}, module.technologyTrainingDetails, true);
  25. }
  26. //获取地址栏参数
  27. function getQueryVariable(variable){
  28. var query = window.location.search.substring(1);
  29. var vars = query.split("&");
  30. for (var i=0;i<vars.length;i++) {
  31. var pair = vars[i].split("=");
  32. if(pair[0] == variable){return pair[1];}
  33. }
  34. return(false);
  35. }
  36. //焦点图滚动
  37. module.swiperBanner = function (type) {
  38. var viewSwiper = new Swiper('.view .swiper-container', {
  39. onSlideChangeStart: function() {
  40. updateNavPosition()
  41. }
  42. })
  43. $('.view .arrow-left,.preview .arrow-left').on('click', function(e) {
  44. e.preventDefault()
  45. if (viewSwiper.activeIndex == 0) {
  46. viewSwiper.swipeTo(viewSwiper.slides.length - 1, 1000);
  47. return
  48. }
  49. viewSwiper.swipePrev()
  50. })
  51. $('.view .arrow-right,.preview .arrow-right').on('click', function(e) {
  52. e.preventDefault()
  53. if (viewSwiper.activeIndex == viewSwiper.slides.length - 1) {
  54. viewSwiper.swipeTo(0, 1000);
  55. return
  56. }
  57. viewSwiper.swipeNext()
  58. })
  59. var previewSwiper = new Swiper('.preview .swiper-container', {
  60. visibilityFullFit: true,
  61. slidesPerView: 'auto',
  62. onlyExternal: true,
  63. onSlideClick: function() {
  64. viewSwiper.swipeTo(previewSwiper.clickedSlideIndex)
  65. }
  66. })
  67. function updateNavPosition() {
  68. $('.preview .active-nav').removeClass('active-nav')
  69. var activeNav = $('.preview .swiper-slide').eq(viewSwiper.activeIndex).addClass('active-nav')
  70. if (!activeNav.hasClass('swiper-slide-visible')) {
  71. if (activeNav.index() > previewSwiper.activeIndex) {
  72. var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1
  73. previewSwiper.swipeTo(activeNav.index() - thumbsPerNav)
  74. } else {
  75. previewSwiper.swipeTo(activeNav.index())
  76. }
  77. }
  78. }
  79. }
  80. //专家列表
  81. module.technologyTrainingDetails = function (data) {
  82. if (data.code == 200) {
  83. var content = data.data;
  84. content.trainingType = module.selectDictLabel(module.data.trainingTypeOptions,content.trainingType);
  85. const masterMapList = content.supplyMasterMap.split(",");
  86. for (var i = 0 ; i < masterMapList.length ; i++){
  87. masterMapList[i] = serverApi + masterMapList[i];
  88. }
  89. content.supplyMasterMap = masterMapList;
  90. module.data.technologyDetail = content;
  91. var technologyData = template('technologyData', module.data);
  92. $("#technologyContent").html(technologyData);
  93. module.swiperBanner();
  94. }
  95. }
  96. module.selectDictLabel = function (datas, value) {
  97. var actions = [];
  98. Object.keys(datas).some((key) => {
  99. if (datas[key].dictValue == ('' + value)) {
  100. actions.push(datas[key].dictLabel);
  101. return true;
  102. }
  103. })
  104. return actions.join('');
  105. }
  106. return module;
  107. })