123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- angular.module('push')
- .controller('technicalBrokerAddDemandInfoCtrl', function ($scope,$ionicActionSheet,UtilService,AccountService,UserService,$ionicScrollDelegate) {
- $scope.enterCompanyInfo={
- deldemandInfo: "",// 删除的需求信息
- demandInfoimagelist:[]// app端图片插件进行传递的变量(需求图片)
- };
- $scope.delproductInfo = "";
- $scope.deldemandInfo = "";
- //产品信息
- $scope.produceInfoList = [{
- id: 0,
- stype: 2,
- produceInfoAddname: ""
- }];
- //需求信息
- $scope.demandInfoList=[{
- id: 0,
- stype: 2,
- demandInfoAddname: ""
- }];
- //产品图片
- $scope.productInfoimagelist = [];
- //需求图片
- $scope.demandInfoimagelist = [];
- //切换到对应页面
- var activity=['baseInfo','productInfo','demandInfo'];
- $scope.act = activity[0];
- $scope.changeAct = function (num) {
- if (num == 0) {
- $scope.act = activity[num];
- } else if (num == 1) {
- $scope.act = activity[num];
- }else if (num == 2) {
- $scope.act = activity[num];
- }
- };
- $scope.companyListInfo ={
- isactive:true,
- isactiveInfo:"是"
- };
- $scope.watchIsChange=function () {
- if($scope.companyListInfo.isactive==true){
- $scope.companyListInfo.isactiveInfo="是"
- }else{
- $scope.companyListInfo.isactiveInfo="否"
- }
- };
- // 弹出获取企业logo
- $scope.show_logo = function () {
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: [
- {text: "拍照"},
- {text: "从相册上传"}
- ],
- buttonClicked: function (index) {
- if (index == 0) {
- openCamera(1);
- } else {
- openCamera(0);
- }
- return true;
- },
- destructiveButtonClicked: function () {
- return true;
- }
- });
- };
- // 弹出获取产品图片
- $scope.showProductImage = function () {
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: [
- {text: "拍照"},
- {text: "从相册上传"}
- ],
- buttonClicked: function (index) {
- if (index == 0) {
- openCamera(1);
- } else {
- openCamera(0);
- }
- return true;
- },
- destructiveButtonClicked: function () {
- return true;
- }
- });
- };
- // 弹出获取需求图片
- $scope.showDemandImage = function () {
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: [
- {text: "拍照"},
- {text: "从相册上传"}
- ],
- buttonClicked: function (index) {
- if (index == 0) {
- openCamera(1);
- } else {
- openCamera(0);
- }
- return true;
- },
- destructiveButtonClicked: function () {
- return true;
- }
- });
- };
- var openCamera = function (srcType) {
- var options = {
- // Some common settings are 20, 50, and 100
- quality: 50,
- destinationType: Camera.DestinationType.FILE_URI,
- // In this app, dynamically set the picture source, Camera or photo gallery
- sourceType: srcType,
- encodingType: Camera.EncodingType.JPEG,
- mediaType: Camera.MediaType.PICTURE,
- allowEdit: false,
- correctOrientation: true //Corrects Android orientation quirks
- };
- navigator.camera.getPicture(function (imageData) {
- $scope.imgurl = imageData;
- $scope.showLoadingToast();
- UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
- AccountService.setuserName(response[0].userPhoto, 3).then(function (res) {
- $scope.userInfo.photo = res.photo;
- UserService.user.user.photo = res.photo;
- }, function () {
- });
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- });
- }, function (message) {
- }, options);
- };
- var verifyStorage = function () {
- window.imagePicker.verifyStorage(
- function (results) {
- if (results == "1") {
- getPic();
- }
- }, function (error) {
- }
- );
- };
- var getPic = function () {
- //产品图片
- if ($scope.productInfoimagelist.length >= 9) {
- UtilService.showMess("最多选取9张图片");
- return;
- }
- UtilService.getPictureList(9 - $scope.productInfoimagelist.length).then(function (results) {
- // console.log(results);
- angular.forEach(results, function (value, index) {
- $scope.productInfoimagelist.push({photo_name: value, original_name: value})
- });
- $scope.totalImglength = 600 * $scope.productInfoimagelist.length;
- $ionicScrollDelegate.$getByHandle("scrollimage").resize();
- }, function (err) {
- });
- //需求图片
- if ($scope.demandInfoimagelist.length >= 9) {
- UtilService.showMess("最多选取9张图片");
- return;
- }
- UtilService.getPictureList(9 - $scope.demandInfoimagelist.length).then(function (results) {
- // console.log(results);
- angular.forEach(results, function (value, index) {
- $scope.demandInfoimagelist.push({photo_name: value, original_name: value})
- });
- $scope.totalImglength = 600 * $scope.demandInfoimagelist.length;
- $ionicScrollDelegate.$getByHandle("scrollimage").resize();
- }, function (err) {
- });
- };
- //点击产品图片放大
- $scope.bigImageProduct=false; //初始默认大图是隐藏的
- $scope.hideBigImageProduct = function () {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- $timeout(function () {
- $scope.bigImageProduct = false;
- }, 400);
- };
- //点击需求图片放大
- $scope.bigImageDemand=false; //初始默认大图是隐藏的
- $scope.hideBigImageProduct = function () {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- $timeout(function () {
- $scope.bigImageDemand = false;
- }, 400);
- };
- $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
- if($scope.app){
- $scope.setStatusBar(1);
- }
- $(function () {
- $('div.pinch-zoom').each(function () {
- new RTP.PinchZoom($(this), {});
- });
- });
- $scope.bigImage = true;//显示大图
- $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
- //图片总数量
- setTimeout(function () {
- $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
- //获取图片
- var imgObj = document.getElementsByClassName('bigimage');
- var n;
- for (n = 0; n < imgObj.length; n++) {
- // 获取图片的原始高度和宽度
- var oldWid = imgObj[n].naturalWidth;
- var oldHei = imgObj[n].naturalHeight;
- var screen = document.body.offsetWidth;
- var screenH = window.innerHeight;
- // console.log(oldWid / oldHei);
- // console.log(screen);
- var cc = screen / (oldWid / oldHei);
- imgObj[n].style.height = cc + 'px';
- if (cc < screenH) {
- imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
- // console.log("e:"+imgObj[n].style.marginTop);
- } else {
- imgObj[n].style.marginTop = 0 + 'px';
- // console.log((cc-screenH) +'px')
- }
- }
- }, 10);
- };
- //删除产品图片
- $scope.deleteProductPhoto = function (index) {
- $scope.productInfoInfoimagelist.splice(index, 1);
- };
- //删除需求图片
- $scope.deleteDemandPhoto = function (index) {
- $scope.demandInfoimagelist.splice(index, 1);
- };
- //选择企业产业领域
- var buttonsIndustryStatus = [
- {text: "专业A",
- stausName:"专业A",
- stausId: "1"
- },
- {text: "专业B",
- stausName:"专业B",
- stausId: "2"
- }
- ];
- $scope.showIndustryStatus=function () {
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: buttonsIndustryStatus,
- buttonClicked: function (index) {
- $scope.companyListInfo.stausId = buttonsIndustryStatus[index].stausId;
- $scope.companyListInfo.stausName = buttonsIndustryStatus[index].stausName;
- return true;
- },
- destructiveButtonClicked: function () {
- return true;
- }
- });
- };
- //选择研发机构等级
- var buttonsResearchStatus = [
- { text: "区级",
- ResearchStatusName:"区级",
- ResearchStatusId: "0"
- },
- { text: "市级",
- ResearchStatusName:"市级",
- ResearchStatusId: "1"
- },
- { text: "省级",
- ResearchStatusName:"省级",
- ResearchStatusId: "2"
- },
- { text: "国家级",
- ResearchStatusName:"国家级",
- ResearchStatusId: "3"
- }
- ];
- $scope.showResearchStatus=function () {
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: buttonsResearchStatus,
- buttonClicked: function (index) {
- $scope.companyListInfo.ResearchStatusId = buttonsResearchStatus[index].ResearchStatusId;
- $scope.companyListInfo.ResearchStatusName = buttonsResearchStatus[index].ResearchStatusName;
- return true;
- },
- destructiveButtonClicked: function () {
- return true;
- }
- });
- };
- //选择需求标签
- var demandLabels = [
- { text: "标签A",
- demandLabelName:"标签A",
- demandLabelId: "0"
- },
- { text: "标签B",
- demandLabelName:"标签B",
- demandLabelId: "1"
- },
- { text: "标签C",
- demandLabelName:"标签C",
- demandLabelId: "2"
- },
- { text: "标签D",
- demandLabelName:"标签D",
- demandLabelId: "3"
- }
- ];
- $scope.showDemandLabelName=function () {
- $ionicActionSheet.show({
- cancelOnStateChange: true,
- cssClass: 'action_s',
- cancelText: '取消',
- buttons: demandLabels,
- buttonClicked: function (index) {
- $scope.demandInfoList.demandLabelId = demandLabels[index].demandLabelId;
- $scope.demandInfoList.demandLabelName = demandLabels[index].demandLabelName;
- return true;
- },
- destructiveButtonClicked: function () {
- return true;
- }
- });
- };
- //添加、删除更多产品
- $scope.AddOrDelProductInfo = function (ind) {
- if (ind == 0) {
- $scope.produceInfoList.push({
- id: 0,
- stype: 2,
- produceInfoAddname: ""
- });
- } else {
- if ($scope.produceInfoList[ind].id != 0) {
- delproductInfo.push($scope.produceInfoList[ind].id);
- }
- $scope.produceInfoList.splice(ind, 1);
- }
- };
- //添加、删除更多需求
- $scope.AddOrDelDemandInfo = function (ind) {
- if (ind == 0) {
- $scope.demandInfoList.push({
- id: 0,
- stype: 2,
- demandInfoAddname: ""
- });
- } else {
- if ($scope.demandInfoList[ind].id != 0) {
- deldemandInfo.push($scope.demandInfoList[ind].id);
- }
- $scope.demandInfoList.splice(ind, 1);
- }
- };
- });
|