|
- define(['jquery', "template", "Tools",'swiper',], function ($, template, Tools, swiper) {
- //数据存储
- var module = {
- data: {
- //服务器地址
- serverApi: '',
- trainStudentsList:[{
- name:'',
- phone:'',
- sex: '',
- trainId:''
- }]
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- //新闻管理列表
- tools.doGet(dictType + '/training_type', {}, module.dictType , true);
- tools.doGet(dictType + '/apply_state', {}, function(data){module.data.studentsTypeOptions = data.data;} , true);
- module.data.trainStudentsList[0].trainId = getQueryVariable('id');
-
- };
-
- module.dictType = function (data) {
- module.data.trainingTypeOptions = data.data;
- tools.doGet(supplyDetails + '/' + getQueryVariable('id'), {}, module.technologyTrainingDetails, true);
- }
-
- //获取地址栏参数
- function getQueryVariable(variable){
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if(pair[0] == variable){return pair[1];}
- }
- return(false);
- }
-
- //焦点图滚动
- module.swiperBanner = function (type) {
- var viewSwiper = new Swiper('.view .swiper-container', {
- onSlideChangeStart: function() {
- updateNavPosition()
- }
- })
-
- $('.view .arrow-left,.preview .arrow-left').on('click', function(e) {
- e.preventDefault()
- if (viewSwiper.activeIndex == 0) {
- viewSwiper.swipeTo(viewSwiper.slides.length - 1, 1000);
- return
- }
- viewSwiper.swipePrev()
- })
- $('.view .arrow-right,.preview .arrow-right').on('click', function(e) {
- e.preventDefault()
- if (viewSwiper.activeIndex == viewSwiper.slides.length - 1) {
- viewSwiper.swipeTo(0, 1000);
- return
- }
- viewSwiper.swipeNext()
- })
-
- var previewSwiper = new Swiper('.preview .swiper-container', {
- visibilityFullFit: true,
- slidesPerView: 'auto',
- onlyExternal: true,
- onSlideClick: function() {
- viewSwiper.swipeTo(previewSwiper.clickedSlideIndex)
- }
- })
-
- function updateNavPosition() {
- $('.preview .active-nav').removeClass('active-nav')
- var activeNav = $('.preview .swiper-slide').eq(viewSwiper.activeIndex).addClass('active-nav')
- if (!activeNav.hasClass('swiper-slide-visible')) {
- if (activeNav.index() > previewSwiper.activeIndex) {
- var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1
- previewSwiper.swipeTo(activeNav.index() - thumbsPerNav)
- } else {
- previewSwiper.swipeTo(activeNav.index())
- }
- }
- }
- }
-
- //专家列表
- module.technologyTrainingDetails = function (data) {
- if (data.code == 200) {
- var content = data.data;
- content.trainingType = module.selectDictLabel(module.data.trainingTypeOptions,content.trainingType);
-
- const masterMapList = content.supplyMasterMap.split(",");
- for (var i = 0 ; i < masterMapList.length ; i++){
- masterMapList[i] = serverApi + masterMapList[i];
- }
- content.supplyMasterMap = masterMapList;
-
- module.data.technologyDetail = content;
- var technologyData = template('technologyData', module.data);
- $("#technologyContent").html(technologyData);
- module.swiperBanner();
- }
- }
-
- module.selectDictLabel = function (datas, value) {
- var actions = [];
- Object.keys(datas).some((key) => {
- if (datas[key].dictValue == ('' + value)) {
- actions.push(datas[key].dictLabel);
- return true;
- }
- })
- return actions.join('');
- }
-
- return module;
- })
|