angular.module('push')
.controller('resourceLibrarySendMessageCtrl', function ($q, $scope, $ionicActionSheet, $ionicSlideBoxDelegate, ResourceLibraryService, $stateParams, $timeout, $ionicScrollDelegate,
UtilService, $ionicPopup, resourceLibraryTempData, $ionicListDelegate, AuthorityService,
UserService, taskModuleService, ConfigService, ActivityService, ConstantService, dataToolsService, CommonService, $ionicModal, $ionicHistory) {
//TODO
if ($scope.app) {
$scope.setStatusBar(1);
}
//是否全选
$scope.isChoiceAll = false;
$scope.isWeb = !$scope.isapp;
$scope.labelKeys = '';
// $scope.comfromWeb=sessionStorage.comfrom=='web';
// sessionStorage.comfrom='';
console.log($stateParams);
$scope.libtype = $stateParams.libtype;
var category = $stateParams.category;
$scope.authority = false;
$scope.authority = $stateParams.authority == 'true';
if ($stateParams.libtype == 3 || $stateParams.libtype == 30 || $stateParams.libtype == 31 || $stateParams.libtype == 32 || $stateParams.libtype == 33 || $stateParams.libtype == 34) {
$scope.canDelete = $stateParams.authority == 'true';
}
$scope.hasAuth = false;
ResourceLibraryService.judgeManager(UserService.id, 10501).then(function (res) {
$scope.hasAuth = res.data;
})
taskModuleService.thisUserIsAdmin().then(function (res) {
if (res.code == 3350) {
$scope.isAdmin = res.data;
}
})
//加载等待页
$scope.isloadingPageFloor = false;
//全部企业加载失败页
$scope.isloadingPageFailAll = false;
//我的企业加载失败页
$scope.isloadingPageFail = false;
console.log($stateParams);
//1:需求,2:成果,6:企业,8:人才
var reclib = angular.fromJson($stateParams.reclib);
//TODO
$scope.reclibid = reclib.parentid;// 资源库文件夹id
$scope.moduleid = reclib.moduleid;// 资源库类别
var pagenum = $scope.pagenum = 0;// 索引库分页索引值,默认第一页:0
var userid = $scope.userid = UserService.id;//查询时需的用户id
var modlibid = $scope.modlibid = $stateParams.modlibid;
var libtype = $scope.libtype = $stateParams.libtype;
$scope.keyfilter = {
key: ""// 搜索关键词
}
$scope.name = reclib.name;
// console.log(reclib.parentid,reclib.moduleid,$scope.modlibid,$scope.libtype,$scope.name);
// 需求库名称
$scope.privateName = $stateParams.privateName;
// 我的XX/全部XX XX→需求、成果
$scope.privateContent = $stateParams.privateContent;
var checkedresource = {};//单个分享时选中的资源
var checkedindex = -1;//多个分享时第一个选择的索引
$scope.checkedresourcelist = [];//多个分享时选中的资源
$scope.tabs = [];
var chooseIndex = resourceLibraryTempData.getCategoryIndex();//当前频道索引
$scope.index = chooseIndex;
$scope.checked = resourceLibraryTempData.getChecked();
$scope.checked.classificationType = libtype;
//通过浏览器地址栏里面的参数来获取moduleid和restype
var href = window.location.href;
var splitArr = href.split('privateResource');
if (splitArr.length >= 2) {
//重写返回功能
$scope.goback = function () {
$scope.go("tab.resourceLibrary");
}
var split = splitArr[1].split('/');
if (split.length >= 2) {
$scope.reclibid = split[1];
$scope.moduleid = split[2];
if ($scope.moduleid == "0") {
$scope.privateName = '科创联盟入驻企业库';
}
if ($scope.moduleid == "1") {
$scope.privateName = '需求库';
}
if ($scope.moduleid == "2") {
$scope.privateName = '成果库';
}
if ($scope.moduleid == "3") {
$scope.privateName = '政策库';
}
if ($scope.moduleid == "6") {
$scope.privateName = '企业库';
}
if ($scope.moduleid == "7") {
$scope.privateName = '高校库';
}
if ($scope.moduleid == "8") {
$scope.privateName = '人才库';
}
if ($scope.moduleid == "35") {
$scope.privateName = '技术经纪人库';
}
if ($scope.moduleid == "36") {
$scope.privateName = '产学研备案库库';
}
if ($scope.moduleid == "43") {
$scope.privateName = '武进区科技创新创业联盟库';
}
if ($scope.moduleid == "44") {
$scope.privateName = '创新创业联盟导师库';
}
$scope.privateContent = $scope.privateName.substring(0, $scope.privateName.length - 1);
}
}
if ($scope.reclibid != undefined && $scope.moduleid != undefined) {
sessionStorage.reclibid = $scope.reclibid.toString();
sessionStorage.moduleid = $scope.moduleid;
}
if ($scope.privateName == null || $scope.privateName == undefined || $scope.privateName == "") {
if (sessionStorage.moduleid == "0") {
$scope.privateName = '科创联盟入驻企业库';
}
if (sessionStorage.moduleid == "1") {
$scope.privateName = '需求库';
}
if (sessionStorage.moduleid == "2") {
$scope.privateName = '成果库';
}
if (sessionStorage.moduleid == "3") {
$scope.privateName = '政策库';
}
if (sessionStorage.moduleid == "6") {
$scope.privateName = '企业库';
}
if (sessionStorage.moduleid == "7") {
$scope.privateName = '高校库';
}
if (sessionStorage.moduleid == "8") {
$scope.privateName = '人才库';
}
if (sessionStorage.moduleid == "35") {
$scope.privateName = '技术经纪人库';
}
if (sessionStorage.moduleid == "36") {
$scope.privateName = '产学研备案库库';
}
if (sessionStorage.moduleid == "43") {
$scope.privateName = '武进区科技创新创业联盟库';
}
if (sessionStorage.moduleid == "44") {
$scope.privateName = '创新创业联盟导师库';
}
$scope.privateContent = $scope.privateName.substring(0, $scope.privateName.length - 1);
}
// 我的企业-分页
$scope.mypages = {
allFlag: true,
currentPage: 0,
pageSize: 4,
totalPage: 0,
totalCount: 0,
startIndex: 0,
sortKeys: ""
};
// 所有企业-分页
$scope.allpages = {
allFlag: true,
currentPage: 0,
pageSize: 4,
totalPage: 0,
totalCount: 0,
startIndex: 0,
sortKeys: ""
};
$scope.keyfilter = {key: ""};//搜索关键词
var activity = ['task', 'mytask'];
$scope.act = activity[1];//默认选择全部资源
$scope.changeAct = function (num) {
$scope.islogin = ConfigService.islogin;
$scope.act = activity[num];
if (num == 0) {
if (!$scope.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$ionicPopup.alert({
title: '提示',
template: '请先关注微信公众号"' + title + '"!'
});
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.selCom.show();
return;
}
}
}
} else {
$scope.selCom.show();
return;
}
} else {
// 我的企业则userid要传递
$scope.act = activity[num];
//TODO
userid = UserService.id;
// userid = 859;
}
} else if (num == 1) {
$scope.act = activity[num];
userid = 0;
}
};
//虚拟搜索框
$scope.isShowSearchButton = true;
$scope.keyfilter = {key: ""};//搜索关键词
$scope.showSearchButtonLeft = function () {
$scope.isShowSearchButton = false;
$(".showSearchInputForResLibrary").focus();
};
//清空搜索内容
$scope.clearSearch = function () {
$scope.isShowSearchButton = true;
$scope.keyfilter.key = "";
};
//TODO 放开注释
if ($scope.app) {
if (device.platform != "Android") {
$scope.isIos = true;
} else {
$scope.isIos = false;
}
}
/*{
SortType: 0,
classificationType: libtype,
starType: 0,
MaturityType: 0,
RightType: 0,
ModelType: 0,
BudgetType: 0,
ScaleType: 0,
EnterpriseType: 0,
DegreeType: 0,
sexType: 0,
TitleType: 0
}*/
//排序初始化
// $scope.sorts = [
// {name: "热门", type: 0, value: "visitcount,DESC"},
// {name: "最新", type: 1, value: "timestamp,DESC"},
// {name: "综合", type: 2, value: "compositescore,DESC"}
// ];
// var checkedsort = $scope.sorts[0].value;
//分类初始化
/*$scope.classification = [
{name: "不限", type: 0},
{name: "成果", type: 2},
{name: "需求", type: 1},
{name: "企业", type: 6},
{name: "人才", type: 8}
];
//地区初始化
$scope.checkedlocationtype = 1;
$scope.chooeslocation = [
{name: "不限"},
{name: "常州"},
{name: "定位"}
];*/
if (libtype == 2) {
//成熟度初始化
$scope.chooesMaturity = [
{name: "不限", type: 0},
{name: "正在研发", type: 1},
{name: "已有小样", type: 2},
{name: "通过小试", type: 3},
{name: "通过中试", type: 4},
{name: "可以量产", type: 5}
];
//知识产权初始化
$scope.chooesRight = [
{name: "不限", type: 0},
{name: "有", type: 1},
{name: "无", type: 2}
];
//合作模式初始化
$scope.chooesModel = [
{name: "不限", type: 0},
{name: "委托开发", type: 1},
{name: "合作研发", type: 2},
{name: "成果转让", type: 3},
{name: "技术入股", type: 4},
{name: "技术咨询", type: 5},
{name: "其他", type: 6}
];
} else if (libtype == 1) {
//合作模式初始化
$scope.chooesModel = [
{name: "不限", type: 0},
{name: "委托开发", type: 1},
{name: "合作研发", type: 2},
{name: "成果转让", type: 3},
{name: "技术入股", type: 4},
{name: "技术咨询", type: 5},
{name: "其他", type: 6}
];
//投入预算
$scope.inputBudget = [
{name: "不限", type: 0},
{name: "1000万以上", type: 9},
{name: "500万-1000万", type: 8},
{name: "200万-500万", type: 7},
{name: "100万-200万", type: 6},
{name: "50万-100万", type: 5},
{name: "10万-50万", type: 4},
{name: "10万以下", type: 3},
{name: "面议", type: 2}
]
} else if (libtype == 6) {
//企业规模
$scope.enterpriseScale = [
{name: "不限", type: 0},
{name: "少于50人", type: 1},
{name: "50-150人", type: 2},
{name: "150-500人", type: 3},
{name: "500-1000人", type: 4},
{name: "1000-5000人", type: 5},
{name: "5000-10000人", type: 6},
{name: "10000人以上", type: 7}
];
//企业类型
$scope.enterpriseType = [
{name: "不限", type: 0},
{name: "国有企业", type: 1},
{name: "集体所有制企业", type: 2},
{name: "私营企业", type: 3},
{name: "股份制企业", type: 4},
{name: "联营企业", type: 5},
{name: "外商投资企业", type: 6},
{name: "港澳台企业", type: 7},
{name: "股份合作企业", type: 8}
];
$scope.starType = [
{name: "不限", type: 0},
{name: "是", type: 1},
{name: "否", type: 2}
];
} else if (libtype == 8) {
//学位
$scope.academicDegree = [
{name: "不限", type: 0},
{name: "博士后", type: 7},
{name: "博士", type: 6},
{name: "硕士", type: 5},
{name: "学士", type: 4},
{name: "其他", type: 8}
];
$scope.sexType = [
{name: "不限", type: 0},
{name: "男", type: 1},
{name: "女", type: 2}
];
//职称
$scope.occupationalTitle = [
{name: "不限", type: 0},
{name: "正高", type: 1},
{name: "副高", type: 2},
{name: "中级", type: 3},
{name: "副级", type: 4},
{name: "无", type: 5}
];
} else if (libtype == 7) {
//学校类别
$scope.universitytype = [
{name: "不限", type: 0},
{name: "985工程院校暨211工程院校", type: 600},
{name: "985工程院校", type: 601},
{name: "211工程院校", type: 602},
{name: "普通本科院校", type: 604},
{name: "高职专科院校", type: 606}
];
}
// 我的企业
$scope.contentlist = [];
// 全部企业
$scope.allcontentlist = [];
// 获取排序选项列表
var checkedsort = '';
var getResourceSortList = function () {
var deferred = $q.defer();
ResourceLibraryService.getResourceSortList(libtype).then(function (res) {
console.log(res);
if (res.code == 3350) {
$scope.sortList = res.data[0];
angular.forEach($scope.sortList.items, function (val, index) {
val.selected = index == 0;
})
checkedsort = $scope.sortList.items.length > 0 ? $scope.sortList.items[0].labelKey : 'timestamp,desc';
deferred.resolve('sucess');
}
})
return deferred.promise;
};
// 获取资源库下行业分类列表
var getCategoryList = function () {
/*ResourceLibraryService.getCategoryList(1001, reclibid, modlibid).then(function (response) {
// console.log(response);
$scope.categorylist = [{
appModuleName: "全部",
by1: ""
}];
$scope.categorylist = $scope.categorylist.concat(response.channelList);
angular.forEach($scope.categorylist, function (value, index) {
$scope.contentlist.push({isload: false, currentPage: 1, reslist: []});
});
$timeout(function () {
$ionicSlideBoxDelegate.slide(chooseIndex);
$scope.getPrivateResourceList();
}, 100);
}, function () {
UtilService.showMess("网络不给力,请重试");
})*/
// 获取资源列表-全部企业
getResourceSortList().then(function (res) {
$scope.getAllPrivateResourceList(0);
})
};
//获取资源列表-全部企业
$scope.getAllPrivateResourceList = function (id) {
$scope.isloadingPageFloor = true;
// $scope.showLoadingToast();
console.log(id);
ResourceLibraryService.getFirstResourceListForAll(sessionStorage.moduleid, sessionStorage.reclibid, $scope.pagenum, $scope.keyfilter.key, checkedsort, id, 0, category, $scope.labelKeys).then(function (response) {
console.log(response);
$scope.hideLoadingToast();
$scope.resourceLength = response.data == null ? 0 : response.data.length;
if ($stateParams.libtype == 30) {
angular.forEach(response.data, function (res) {
if (!res.title) {
dataToolsService.getWebCascade(res.type, 0).then(function (resp) {
if (resp.code == 3350 && resp.data.length > 0) {
var temp = resp.data.filter(function (val) {
return val.code == res.primTag;
})
if (temp.length > 0) {
res.title = temp[0].name;
}
}
}, function () {
})
}
})
}
var tempreslib = angular.fromJson(response.data);
angular.forEach(tempreslib, function (val) {
if (val.labelObj) {
val.labelObj = val.labelObj.slice(0, 3);
// angular.forEach(val.otherObj,function(vv){
// vv.labelName=vv.labelKey=='企业规模'?vv.labelKey+vv.labelName:vv.labelName=='是'?vv.labelKey.slice(2):vv.labelName;
// })
}
})
$scope.allpages = angular.fromJson(response.page);
// console.log(tempreslib);
var temppage = angular.fromJson(response.page);
var totalPage = Math.ceil(temppage == null ? 0 : temppage.totalCount / 4);
console.log(totalPage);
$scope.allcontentlist[chooseIndex].reslist = tempreslib;
var trHtml = "
更新了" + $scope.allcontentlist[chooseIndex].reslist == null ? 0 : ($scope.allcontentlist[chooseIndex].reslist.length == null ? 0 : $scope.allcontentlist[chooseIndex].reslist.length) + "条内容
";
$timeout(function () {
$(".resourcelistDiv .list").prepend(trHtml);
$(".refresh_tip_div").animate({width: 100 + "%"}, 150);
}, 800);
$timeout(function () {
$(".refresh_tip_div").slideUp();
}, 1200);
//判断是否有下一页
$timeout(function () {
$timeout(function () {
if ($scope.allcontentlist[chooseIndex].currentPage >= totalPage) {
$scope.allcontentlist[chooseIndex].isload = false;
} else {
$scope.allcontentlist[chooseIndex].isload = true;
}
$scope.allcontentlist[chooseIndex].currentPage = 1;
}, 0);
$scope.hideLoadingToast();
$ionicSlideBoxDelegate.update();
$ionicScrollDelegate.$getByHandle("privateContent").scrollTo(0, 0);
}, 50);
$scope.isloadingPageFloor = false;
$scope.isloadingPageFail = false;
$scope.isloadingPageFailAll = false;
}, function () {
$scope.hideLoadingToast();
$scope.isloadingPageFloor = false;
$scope.isloadingPageFail = false;
$scope.isloadingPageFailAll = true;
}).finally(function () {
$scope.$broadcast('scroll.refreshComplete');
});
};
//重新加载全部企业
$scope.repeatLoadAll = function () {
$scope.isloadingPageFailAll = false;
$scope.getAllPrivateResourceList(0);
};
getCategoryList();
$scope.islogin = ConfigService.islogin;
// 进入资源详情
$scope.goResourceDetail = function (resource, ind) {
console.log(resource);
console.log($stateParams.libtype);
if (!$scope.islogin && ($stateParams.libtype != 30 && $stateParams.libtype != 31 && $stateParams.libtype != 32 && $stateParams.libtype != 33 && $stateParams.libtype != 34)) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$ionicPopup.alert({
title: '提示',
template: '请先关注微信公众号"' + title + '"!'
});
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.selCom.show();
return;
}
}
}
} else {
$scope.selCom.show();
return;
}
} else {
if (selectflg) {
selectResource(resource, ind);
} else {
resourceLibraryTempData.setCategoryIndex(chooseIndex);
resourceLibraryTempData.setChecked($scope.checked);
if (resource.groupid == "0") {
$scope.go('resourceDetails', {
recourceid: resource.unique,
recourcetype: resource.type,
recourcecomefrom: resource.source,
title: resource.title
});
} else {
$scope.go('resourceCommonDetailsPage', {
recourceid: resource.unique,
recourcetype: resource.type,
recourcecomefrom: resource.source,
creator: resource.clickthrough,
title: resource.title,
orgtype: 0,
// comfrom:$scope.comfrom,
pagecode: 0,
label: JSON.stringify(resource.otherObj)
});
}
}
}
};
var editSlide = function (index) {
var tablength = $scope.categorylist.length;//标题个数
var middlewidth = $(window).width() / 2;//获取当前手机屏幕宽度一般
var OffLeft = $(".Chanel_scroll_a").eq(index).offset().left;//获取当前点击标题距离父容器左边框的距离
var SelfWidth = $(".Chanel_scroll_a").eq(index).width();//获取当前点击标题宽度
var startTranform = $("#p_Chanel .scroll").offset().left;
var movewidth = OffLeft - middlewidth + SelfWidth / 2;
startTranform -= movewidth;
if (startTranform <= 0) {
if (index < tablength - 2) {
$('#p_Chanel .scroll').css({
'transform': 'translate3d(' + startTranform + 'px,0,0)'
});
}
} else if (index < 4) {
$('#p_Chanel .scroll').css({
'transform': 'translate3d(0,0,0)'
});
}
$(".Chanel_scroll_a").eq(index).addClass("scroll_a_on").siblings().removeClass("scroll_a_on");
};
$scope.selectCategory = function (index) {
editSlide(index);
$(".Chanel_scroll_a").eq(index).addClass("scroll_a_on").siblings().removeClass("scroll_a_on");
if (index == chooseIndex) {
return;
}
chooseIndex = index;
$scope.index = chooseIndex;
$scope.getPrivateResourceList(0);
};
//资源库搜索
$scope.goResourceSearch = function () {
resourceLibraryTempData.setCategoryIndex(chooseIndex);
resourceLibraryTempData.setChecked($scope.checked);
//1:需求,2:成果,6:企业,8:人才
var tabindex = 3;
if (libtype == 1) {
tabindex = 4;
} else if (libtype == 2) {
tabindex = 3;
} else if (libtype == 6) {
tabindex = 5;
} else if (libtype == 8) {
tabindex = 6;
}
$timeout(function () {
$scope.go('resourceSearch', {resourcetype: 1001, reclibid: $scope.reclibid, tabindex: tabindex});
}, 350);
};
$scope.shareflg = false;
$scope.openShare = function (tempobj, ind) {
$scope.go('chooseShareResource', {
chereslist: angular.toJson([tempobj.unique]),
folderid: $scope.reclibid,
isCloud: 1,
recourcetype: tempobj.type,
recourcecomefrom: tempobj.source
});
/*$scope.shareflg = true;
$(".resource_wrap").css("left", "0%");
$(".pay_list_c2").css("left", "-35px");
$("#collect-bottom").css("display", "none");
checkedresource = tempobj;
checkedindex = ind;*/
};
$scope.closeShare = function () {
$timeout(function () {
$ionicListDelegate.closeOptionButtons();
}, 10);
$scope.shareflg = false;
};
//选择排序
$scope.chooseSort = function (b) {
$scope.checked.SortType = b.type;
checkedsort = b.value;
};
//选择分类
/*$scope.chooseClassification = function (tempclass) {
$scope.checked.classificationType = tempclass.type;
};*/
//地区
/*$scope.chooseActionlocation = function (index) {
$(".locationclassfile ul li").eq(index).addClass("specialSpan").siblings().removeClass("specialSpan");
if (index != 0) {
$(".locationclassfile ul li:first-child").css({"color": "#000", "border": "none"});
} else {
$(".locationclassfile ul li:first-child").css({"color": "#3385ff", "border": "#3385ff .5px solid"});
$(".locationclassfile ul li").removeClass("specialSpan");
}
};*/
//选择成熟度
$scope.chooseActionMaturity = function (s) {
$scope.checked.MaturityType = s.type;
};
//选择知识产产权
$scope.chooseActionRight = function (r) {
$scope.checked.RightType = r.type;
};
//选择合作模式
$scope.chooseActionModel = function (m) {
$scope.checked.ModelType = m.type;
};
//选择投入预算
$scope.chooseInputBudget = function (budget) {
$scope.checked.BudgetType = budget.type;
};
//选择企业规模
$scope.chooseEenterpriseScale = function (scale) {
$scope.checked.ScaleType = scale.type;
};
//高企
$scope.chooseStarType = function (star) {
$scope.checked.starType = star.type;
};
//选择企业类型
$scope.chooseEnterpriseType = function (enterprise) {
$scope.checked.EnterpriseType = enterprise.type;
};
//选择学位
$scope.chooseAcademicDegree = function (degree) {
$scope.checked.DegreeType = degree.type;
};
//性别
$scope.chooseSexType = function (sex) {
$scope.checked.sexType = sex.type;
};
//选择职称
$scope.chooseOccupationalTitle = function (title) {
$scope.checked.TitleType = title.type;
};
//选择学校类别
$scope.chooseUniversityType = function (university) {
$scope.checked.UniversityType = university.type;
};
//展开/收起排序
$scope.toggleSort = function () {
$(".sort ul").toggle();
$(".sort h3 i").toggleClass("transformArrow");
};
//展开/收起分类
/*$scope.toggleClassification = function () {
$(".Classification ul").toggle();
$(".Classification h3 i").toggleClass("transformArrow");
};
//展开/收起地区
$scope.toggleClassfilelocation = function () {
$(".locationclassfile ul").toggle();
$(".locationclassfile h3 i").toggleClass("transformArrow");
};*/
//展开/收起成熟度
$scope.toggleClassfileMaturity = function () {
$(".Maturityclassfile ul").toggle();
$(".Maturityclassfile h3 i").toggleClass("transformArrow");
};
//展开/收起知识产权
$scope.toggleClassfileRight = function () {
$(".Rightclassfile ul").toggle();
$(".Rightclassfile h3 i").toggleClass("transformArrow");
};
//展开/收起合作模式
$scope.toggleClassfileModel = function () {
$(".Modelclassfile ul").toggle();
$(".Modelclassfile h3 i").toggleClass("transformArrow");
};
//展开/收起投入预算
$scope.toggleInputBudget = function () {
$(".InputBudget ul").toggle();
$(".InputBudget h3 i").toggleClass("transformArrow");
};
//展开/收起企业规模
$scope.toggleEenterpriseScale = function () {
$(".EenterpriseScale ul").toggle();
$(".EenterpriseScale h3 i").toggleClass("transformArrow");
};
//展开/收起高企
$scope.toggleStarType = function () {
$(".StarType ul").toggle();
$(".StarType h3 i").toggleClass("transformArrow");
};
//展开/收起企业类型
$scope.toggleEnterpriseType = function () {
$(".EnterpriseType ul").toggle();
$(".EnterpriseType h3 i").toggleClass("transformArrow");
};
//展开/收起学位
$scope.toggleAcademicDegree = function () {
$(".AcademicDegree ul").toggle();
$(".AcademicDegree h3 i").toggleClass("transformArrow");
};
//展开/收起性别
$scope.toggleSexType = function () {
$(".sexType ul").toggle();
$(".sexType h3 i").toggleClass("transformArrow");
};
//展开/收起职称
$scope.toggleOccupationalTitle = function () {
$(".OccupationalTitle ul").toggle();
$(".OccupationalTitle h3 i").toggleClass("transformArrow");
};
//展开/收起学校类别
$scope.toggleUniversityType = function () {
$(".UniversityType ul").toggle();
$(".UniversityType h3 i").toggleClass("transformArrow");
};
$scope.finishShow = false;
//展开筛选
$scope.menueFilter = function () {
$scope.finishShow = true;
};
//完成选择,刷新数据
$scope.finishDone = function () {
$scope.finishShow = false;
// 获取资源列表-全部企业
$scope.getAllPrivateResourceList(0);
// 获取资源列表-我的企业
//TODO
// userid = 859;
$scope.getPrivateResourceList(userid);
};
//重置选择数据
$scope.reseChecked = function () {
$scope.checked = {
SortType: 0,
classificationType: libtype,
starType: 0,
MaturityType: 0,
RightType: 0,
ModelType: 0,
BudgetType: 0,
ScaleType: 0,
EnterpriseType: 0,
DegreeType: 0,
sexType: 0,
TitleType: 0,
UniversityType: 0
};
checkedsort = $scope.sorts[0].value;
};
//点击空白灰色选择条件隐藏
$scope.hideSortDiv = function () {
$scope.finishShow = false;
// 获取资源列表-全部企业
$scope.getAllPrivateResourceList(0);
// 获取资源列表-我的企业
//TODO
// userid = 859;
$scope.getPrivateResourceList(userid);
};
//打开操作表
$scope.openActionSheet = function () {
$ionicActionSheet.show({
buttons: [
{text: '设置'}
],
cancelText: '取消',
buttonClicked: function (index) {
if (index == 0) {
$scope.go("authoritySet", {
reclibid: reclib.id,
authorityid: reclib.authorityid,
authoritycomefrom: reclib.authoritycomefrom,
name: reclib.name,
content: reclib.content,
sort: reclib.sort,
goflg: 1,
type: 1,
parentid: reclib.parentid
});
}
return true;
}
});
};
//分享选择操作表
var selectflg = false;//列表选择打开标志
$scope.openCollectShare = function () {
selectflg = true;
$scope.contentlist[$scope.index].reslist[checkedindex].value = true;
var tempres = {
infoid: checkedresource.unique,
infocomefrom: checkedresource.source,
infoType: checkedresource.type
};
$scope.checkedresourcelist.push(tempres);
$(".item-options").addClass("invisible");
$(".resource_wrap").css("left", "10%");
$(".pay_list_c2").css("left", "4%");
$(".item-content").css("transform", "translate3d(0px, 0px, 0px)");
$("#collect-bottom").css("display", "block");
$scope.closeShare();
};
//取消分享
$scope.cancelShare = function () {
angular.forEach($scope.contentlist[$scope.index].reslist, function (value, ind) {
$scope.contentlist[$scope.index].reslist[ind].value = false;
});
$scope.checkedresourcelist = [];
$(".resource_wrap").css("left", "0%");
$(".pay_list_c2").css("left", "-35px");
$("#collect-bottom").css("display", "none");
selectflg = false;
};
var selectResource = function (resource, ind) {
var tempres = {
infoid: resource.unique,
infocomefrom: resource.source,
infoType: resource.type
};
var chind = -1;
angular.forEach($scope.checkedresourcelist, function (value, index) {
if (value.infoid == resource.unique) {
chind = index;
}
});
if (chind == -1) {
$scope.contentlist[$scope.index].reslist[ind].value = true;
$scope.checkedresourcelist.unshift(tempres);
} else {
$scope.contentlist[$scope.index].reslist[ind].value = false;
$scope.checkedresourcelist.splice(chind, 1);
}
// console.log($scope.checkedresourcelist);
};
$scope.shareResourceToPrilib = function () {
$scope.go('chooseShareResource', {
chereslist: angular.toJson($scope.checkedresourcelist),
reclibid: $scope.reclibid
});
};
// 搜索各种资源信息
$scope.searchResourceList = function () {
$scope.showLoadingToast();
var activity = ['task', 'mytask'];
if ($scope.act == activity[1]) {
// 获取资源列表-全部企业
$scope.getAllPrivateResourceList(0);
} else if ($scope.act == activity[0]) {
// 获取资源列表-我的企业
$scope.getPrivateResourceList(userid);
}
}, function () {
$scope.hideLoadingToast();
};
//新建走访
$scope.goEnterCompanyInfo = function (moduleid) {
console.log(moduleid);
if (moduleid == 3 || moduleid == 30 || moduleid == 31 || moduleid == 32 || moduleid == 33 || moduleid == 34) {
if (!$scope.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$ionicPopup.alert({
title: '提示',
template: '请先关注微信公众号"' + title + '"!'
});
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.selCom.show();
return;
}
}
}
} else {
$scope.selCom.show();
return;
}
} else {
if (moduleid == 3) {
moduleid = 34;
$stateParams.libtype = 34;
}
if ($stateParams.libtype == 30 || $stateParams.libtype == 31 || $stateParams.libtype == 32 || $stateParams.libtype == 33 || $stateParams.libtype == 34) {
$scope.go('visitModularForm', {
companyid: 0,
pageid: moduleid,
orgtype: moduleid == 6 ? ConstantService.UNITTYPE_10104 : moduleid == 7 ? ConstantService.UNITTYPE_10105 : 0,
isedit: 0,// isedit:对应的是0新增/1编辑/2复制并新建
connid: 0,
pagecode: 1000030,
pageTitle: '新建' + $scope.privateName.slice(0, $scope.privateName.length - 1),
node: UserService.node,
comfrom: 'resource'
});
} else {
ResourceLibraryService.getPageId(moduleid).then(function (res) {
if (res.code == 3350) {
$scope.go('visitModularForm', {
companyid: 0,
pageid: res.data,
orgtype: moduleid == 6 || moduleid == 43 ? ConstantService.UNITTYPE_10104 : moduleid == 7 ? ConstantService.UNITTYPE_10105 : 0,
isedit: 0,// isedit:对应的是0新增/1编辑/2复制并新建
connid: 0,
pagecode: 1000030,
pageTitle: '新建' + $scope.privateName.slice(0, $scope.privateName.length),
node: UserService.node,
resourcetype: moduleid,
comfrom: 'privateResource'
});
}
})
}
}
}
if (moduleid == 44) {
$scope.go('visitModularForm', {
companyid: 0,
pageid: 44,
orgtype: 10104,
pagecode: 1000027,
isedit: 0,
node: UserService.node,
pageTitle: '新建导师'
});
}
if (moduleid == 39) {
$scope.go('visitModularForm', {
companyid: 0,
pageid: 39,
orgtype: 10104,
pagecode: 1000036,
isedit: 0,
node: UserService.node,
pageTitle: '新建金融信息',
innertype: 39
});
}
};
//假数据、添加星级、评分与评价数
// *******不能删,加载列表需要用到********
// 我的企业
$scope.contentlist = [
{
title: '企业A',
ishigh: 1,
industry: '化工',
starNum: 5,
commentListNum: 222,
},
{
title: '企业A',
ishigh: 1,
industry: '化工',
starNum: 4.5,
commentListNum: 102
},
{
title: '企业A',
ishigh: 1,
industry: '化工',
starNum: 4,
commentListNum: 82
},
{
title: '企业B',
ishigh: 1,
industry: '化工',
starNum: 3.5,
commentListNum: 62
},
{
title: '企业C',
ishigh: 1,
industry: '化工',
starNum: 3,
commentListNum: 42
},
{
title: '企业D',
ishigh: 0,
industry: '化工',
starNum: 2,
commentListNum: 32
},
{
title: '企业的名字好长好长好长好长好长好长好长好长好长好长好长好长好长好长好长',
ishigh: 0,
industry: '化工',
starNum: 1,
commentListNum: 22
},
{
title: '企业的名字好长好长好长好长好长好长好长好长好长好长好长好长好长好长好长',
ishigh: 0,
industry: '化工',
starNum: 0,
commentListNum: 12
}
];
// 全部企业
$scope.allcontentlist = [
{
title: '企业A',
ishigh: 1,
industry: '化工',
starNum: 5,
commentListNum: 222,
},
{
title: '企业A',
ishigh: 1,
industry: '化工',
starNum: 4.5,
commentListNum: 102
},
{
title: '企业A',
ishigh: 1,
industry: '化工',
starNum: 4,
commentListNum: 82
},
{
title: '企业B',
ishigh: 1,
industry: '化工',
starNum: 3.5,
commentListNum: 62
},
{
title: '企业C',
ishigh: 1,
industry: '化工',
starNum: 3,
commentListNum: 42
},
{
title: '企业D',
ishigh: 0,
industry: '化工',
starNum: 2,
commentListNum: 32
},
{
title: '企业的名字好长好长好长好长好长好长好长好长好长好长好长好长好长好长好长',
ishigh: 0,
industry: '化工',
starNum: 1,
commentListNum: 22
},
{
title: '企业的名字好长好长好长好长好长好长好长好长好长好长好长好长好长好长好长',
ishigh: 0,
industry: '化工',
starNum: 0,
commentListNum: 12
}
]
$scope.editItem = function () {
console.log(1);
}
$scope.deletItem = function (id, node, idx) {
console.log(2);
var data = {
data: {
id: id,
isenabled: 2,
comfrom: node
},
node: node
}
// confirm 对话框
var confirmPopup = $ionicPopup.confirm({
title: '删除确认',
template: '请确认是否要删除此项!',
cancelText: '取消',
okText: '确认',
});
confirmPopup.then(function (res) {
console.log(res);
if (res) {
dataToolsService.saveWebInfo(data).then(function (res) {
if (res.code == 3350) {
if ($scope.app) {
UtilService.showMess('删除成功');
} else {
CommonService.showMessage('删除成功', $scope);
}
if ($scope.act == activity[1]) {
// 获取资源列表-全部企业
$scope.getAllPrivateResourceList(0);
} else if ($scope.act == activity[0]) {
// 获取资源列表-我的企业
$scope.getPrivateResourceList(userid);
}
} else {
if ($scope.app) {
UtilService.showMess('删除失败');
} else {
CommonService.showMessage('删除失败', $scope);
}
}
})
} else {
// console.log('You are not sure');
}
});
}
// 筛选条件页面
$ionicModal.fromTemplateUrl('./modules/common/views/filterPage.html', {
scope: $scope,
animation: 'slide-in-left'
}).then(function (modal) {
$scope.filterPageModal = modal;
});
$scope.showSideBar = function () {
$scope.filterPageModal.show();
}
$scope.taskTypeList =
{
title: '需求类型',
items: [
{labelName: '全部', labelKey: 0, selected: true},
{labelName: '技术需求', labelKey: 5350, selected: false},
{labelName: '人才需求', labelKey: 5351, selected: false},
{labelName: '申报科技项目需求', labelKey: 5352, selected: false},
{labelName: '投融资需求', labelKey: 5353, selected: false},
{labelName: '其他', labelKey: 5354, selected: false},
]
}
$scope.filterList = [
// {
// title:'区域' ,
// items:[
// {labelName:'全部',labelKey:666},
// {labelName:'南京',labelKey:1},
// {labelName:'武进',labelKey:2},
// {labelName:'溧阳',labelKey:3},
// {labelName:'溧水',labelKey:4},
// ],
// },{
// title:'行业' ,
// items:[
// {labelName:'全部',labelKey:88s8},
// {labelName:'电子',labelKey:1},
// {labelName:'金融',labelKey:2},
// {labelName:'软件',labelKey:3},
// ],
// },
]
$scope.showFilter = false;
ResourceLibraryService.getFilterList(sessionStorage.moduleid).then(function (res) {
console.log(res);
if (res.code == 3350 && res.data.length > 0) {
$scope.showFilter = true;
$scope.filterList = res.data;
angular.forEach($scope.filterList, function (val) {
val.items.unshift({labelName: '全部', labelKey: 88888888});
angular.forEach(val.items, function (value, index) {
value.selected = index == 0;
})
})
}
})
$scope.changSelected = function (outerIndex, index) {
angular.forEach($scope.filterList[outerIndex].items, function (val) {
val.selected = false;
})
$scope.filterList[outerIndex].items[index].selected = true;
}
$scope.resetSelected = function () {
angular.forEach($scope.filterList, function (val) {
angular.forEach(val.items, function (value, index) {
value.selected = index == 0;
})
})
angular.forEach($scope.sortList.items, function (value, index) {
value.selected = index == 0;
})
$scope.labelKeys = '';
//重新加载全部企业
/*$scope.showLoadingToast();
$scope.repeatLoadAll();
$scope.repeatLoad();*/
$scope.selectBySort(0);
// $scope.filterList.key='';
// $scope.currentnode=UserService.node;
// if ($scope.act == 'task') {
// if(!$scope.islogin){
// }else{
// //TODO
// getMyData(0).then(function(data){
// $scope.reportCompanyList=data;
// })
// }
// } else if ($scope.act == 'mytask') {
// getData(1).then(function(data){
// $scope.reportCompanyList=data;
// });
// }
}
$scope.submitSelected = function () {
$scope.labelKeys = '';
angular.forEach($scope.filterList, function (val) {
angular.forEach(val.items, function (value, index) {
if (value.selected && value.labelName != '全部') {
$scope.labelKeys += value.labelKey + ',';
}
})
});
angular.forEach($scope.orgtypelist.items, function (value) {
if (value.selected && value.name != '全部') {
$scope.labelKeys += value.value + ',';
}
});
//重新加载全部企业
$scope.showLoadingToast();
$scope.repeatLoadAll();
$scope.filterPageModal.hide();
}
$scope.selectByOrgType = function (index) {
angular.forEach($scope.orgtypelist.items, function (val) {
val.selected = false;
})
$scope.orgtypelist.items[index].selected = true;
$scope.submitSelected();
}
$scope.selectByJob = function (index) {
angular.forEach($scope.joblist.items, function (val) {
val.selected = false;
})
$scope.joblist.items[index].selected = true;
}
$scope.selectByLabel = function (outerIndex, index) {
$scope.contentlist[chooseIndex].reslist = [];
$scope.allcontentlist[chooseIndex].reslist = [];
$scope.changSelected(outerIndex, index);
$scope.submitSelected();
}
$scope.changSelectedSort = function (index) {
angular.forEach($scope.sortList.items, function (val) {
val.selected = false;
})
$scope.sortList.items[index].selected = true;
}
$scope.changSelectedList = function (index) {
angular.forEach($scope.typeList, function (val) {
val.selected = false;
})
$scope.typeList[index].selected = true;
}
$scope.changSelectedTaskType = function (index) {
angular.forEach($scope.taskTypeList.items, function (val) {
val.selected = false;
})
$scope.taskTypeList.items[index].selected = true;
}
$scope.selectBySort = function (index) {
$scope.contentlist[chooseIndex].reslist = [];
$scope.allcontentlist[chooseIndex].reslist = [];
checkedsort = $scope.sortList.items[index].labelKey;
$scope.changSelectedSort(index);
$scope.submitSelected();
}
$scope.selectByList = function (index) {
$scope.contentlist[chooseIndex].reslist = [];
$scope.allcontentlist[chooseIndex].reslist = [];
$scope.changSelectedList(index);
$scope.submitSelected();
}
$scope.selectByTaskType = function (index) {
$scope.contentlist[chooseIndex].reslist = [];
$scope.allcontentlist[chooseIndex].reslist = [];
checkedsort = $scope.taskTypeList.items[index].labelKey;
$scope.changSelectedTaskType(index);
$scope.submitSelected();
}
// 设置置顶
$scope.changeStickTop = function (type, resid) {
console.log(resid);
if (type) {
ResourceLibraryService.cancelStickTop(resid).then(function (res) {
console.log(res);
if (res.code == 3350) {
$scope.contentlist[chooseIndex].reslist = [];
$scope.allcontentlist[chooseIndex].reslist = [];
$scope.submitSelected();
}
})
} else {
ResourceLibraryService.stickTop(resid).then(function (res) {
console.log(res);
if (res.code == 3350) {
$scope.contentlist[chooseIndex].reslist = [];
$scope.allcontentlist[chooseIndex].reslist = [];
$scope.submitSelected();
}
})
}
}
$scope.orgtypelist =
{
title: '企业资质',
items: [
{name: '全部', value: 0, selected: true},
{name: '国高', value: 8307, selected: false},
{name: '市高', value: 8308, selected: false},
{name: '省科技型中小企业', value: 8309, selected: false}
]
}
if ($scope.libtype == 6) {
$scope.joblist =
{
title: '职位',
items: [
{name: '全部', value: 0, selected: true},
{name: '科技联络人', value: 1, selected: false},
{name: '企业负责人', value: 2, selected: false},
{name: '研发总监', value: 3, selected: false}
]
}
} else {
$scope.joblist =
{
title: '职位',
items: [
{name: '联系人', value: 1, selected: true},
]
}
}
$scope.resourcelist = [];
$scope.residList = [];
$scope.selectResource = function (resource) {
resource.isSelected = !resource.isSelected;
angular.forEach($scope.allcontentlist[0].reslist, function (val) {
if (val.isSelected == true) {
$scope.resourcelist.push(val);
}
})
if ($scope.resourcelist.length > 0) {
document.getElementById("nextpage").style.backgroundColor = "#3b8bd0";
} else {
document.getElementById("nextpage").style.backgroundColor = "grey";
}
$scope.resourcelist = [];
}
$scope.choiceAllNum = 0;
$scope.choiceText = "全选";
$scope.choiceAll = function () {
$scope.choiceAllNum++;
if ($scope.choiceAllNum % 2 == 0) {
//偶数次点击,证明是全取消
angular.forEach($scope.allcontentlist[0].reslist, function (val) {
val.isSelected = false;
})
document.getElementById("nextpage").style.backgroundColor = "grey";
$scope.choiceText = "全选";
$scope.isChoiceAll = false;
} else {
//奇数次点击,证明是全选
angular.forEach($scope.allcontentlist[0].reslist, function (val) {
val.isSelected = true;
})
document.getElementById("nextpage").style.backgroundColor = "#3B8BD0";
$scope.choiceText = "全不选";
$scope.isChoiceAll = true;
}
}
$scope.goNextPage = function () {
console.log(222222222222222222)
$scope.showLoadingToastUtilEnd();
var jumptonextpage = false;
angular.forEach($scope.allcontentlist[0].reslist, function (val) {
if (val.isSelected == true) {
$scope.residList.push(val.unique);
$scope.resourcelist.push(val);
}
})
if ($scope.resourcelist.length == 0) {
return;
}
angular.forEach($scope.joblist.items, function (val) {
if (val.selected) {
$scope.roleValue = val.value;
}
})
ResourceLibraryService.getResourceListByESList($scope.residList, "资源库列表").then(function (res) {
$scope.hideLoadingToast()
if (res.code == 3350) {
var allRole = 0;//全部
var techRole = 0;//科技联络人
var orgRole = 0;//企业负责人
var devRole = 0;//研发总监
angular.forEach(res.data, function (val) {
if ($scope.roleValue == 0) {
//全部
if(val.tel!="" || val.legalrepresentativetel!="" || val.technologyContactphone!=""){
allRole++;
jumptonextpage =true;
}
}
if ($scope.roleValue == 1) {
//科技联络人
if(val.tel || val.legalrepresentativetel){
techRole++;
jumptonextpage =true;
}
}
if ($scope.roleValue == 2) {
//企业负责人
if(val.legalrepresentativetel){
orgRole++;
jumptonextpage =true;
}
}
if ($scope.roleValue == 3) {
//研发总监
if(val.technologyContactphone || val.legalrepresentativetel){
devRole++;
jumptonextpage =true;
}
}
})
if ($scope.roleValue == 0 && allRole == 0) {
$ionicPopup.alert({
title: '提示',
template: "没有可发送的收件号码"
})
return;
}
if ($scope.roleValue == 1 && techRole == 0) {
$ionicPopup.alert({
title: '提示',
template: "没有可发送的收件号码"
})
return;
}
if ($scope.roleValue == 2 && orgRole == 0) {
$ionicPopup.alert({
title: '提示',
template: "没有可发送的收件号码"
})
return;
}
if ($scope.roleValue == 3 && devRole == 0) {
$ionicPopup.alert({
title: '提示',
template: "没有可发送的收件号码"
})
return;
}
}
if (jumptonextpage ==true) {
angular.forEach($scope.orgtypelist.items, function(val){
if(val.selected){
$scope.resrole = val.name;
}
})
$scope.go("sendMessage", {resourcelist: $scope.resourcelist, job: $scope.joblist, resrole:$scope.resrole});
}
});
}
$scope.gobacktoselectlibrary = function () {
$scope.go('noticeHelper');
}
})
;