technicalBrokerAddDemandInfoCtrl.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. angular.module('push')
  2. .controller('technicalBrokerAddDemandInfoCtrl', function ($scope,$ionicActionSheet,UtilService,AccountService,UserService,$ionicScrollDelegate) {
  3. $scope.enterCompanyInfo={
  4. deldemandInfo: "",// 删除的需求信息
  5. demandInfoimagelist:[]// app端图片插件进行传递的变量(需求图片)
  6. };
  7. $scope.delproductInfo = "";
  8. $scope.deldemandInfo = "";
  9. //产品信息
  10. $scope.produceInfoList = [{
  11. id: 0,
  12. stype: 2,
  13. produceInfoAddname: ""
  14. }];
  15. //需求信息
  16. $scope.demandInfoList=[{
  17. id: 0,
  18. stype: 2,
  19. demandInfoAddname: ""
  20. }];
  21. //产品图片
  22. $scope.productInfoimagelist = [];
  23. //需求图片
  24. $scope.demandInfoimagelist = [];
  25. //切换到对应页面
  26. var activity=['baseInfo','productInfo','demandInfo'];
  27. $scope.act = activity[0];
  28. $scope.changeAct = function (num) {
  29. if (num == 0) {
  30. $scope.act = activity[num];
  31. } else if (num == 1) {
  32. $scope.act = activity[num];
  33. }else if (num == 2) {
  34. $scope.act = activity[num];
  35. }
  36. };
  37. $scope.companyListInfo ={
  38. isactive:true,
  39. isactiveInfo:"是"
  40. };
  41. $scope.watchIsChange=function () {
  42. if($scope.companyListInfo.isactive==true){
  43. $scope.companyListInfo.isactiveInfo="是"
  44. }else{
  45. $scope.companyListInfo.isactiveInfo="否"
  46. }
  47. };
  48. // 弹出获取企业logo
  49. $scope.show_logo = function () {
  50. $ionicActionSheet.show({
  51. cancelOnStateChange: true,
  52. cssClass: 'action_s',
  53. cancelText: '取消',
  54. buttons: [
  55. {text: "拍照"},
  56. {text: "从相册上传"}
  57. ],
  58. buttonClicked: function (index) {
  59. if (index == 0) {
  60. openCamera(1);
  61. } else {
  62. openCamera(0);
  63. }
  64. return true;
  65. },
  66. destructiveButtonClicked: function () {
  67. return true;
  68. }
  69. });
  70. };
  71. // 弹出获取产品图片
  72. $scope.showProductImage = function () {
  73. $ionicActionSheet.show({
  74. cancelOnStateChange: true,
  75. cssClass: 'action_s',
  76. cancelText: '取消',
  77. buttons: [
  78. {text: "拍照"},
  79. {text: "从相册上传"}
  80. ],
  81. buttonClicked: function (index) {
  82. if (index == 0) {
  83. openCamera(1);
  84. } else {
  85. openCamera(0);
  86. }
  87. return true;
  88. },
  89. destructiveButtonClicked: function () {
  90. return true;
  91. }
  92. });
  93. };
  94. // 弹出获取需求图片
  95. $scope.showDemandImage = function () {
  96. $ionicActionSheet.show({
  97. cancelOnStateChange: true,
  98. cssClass: 'action_s',
  99. cancelText: '取消',
  100. buttons: [
  101. {text: "拍照"},
  102. {text: "从相册上传"}
  103. ],
  104. buttonClicked: function (index) {
  105. if (index == 0) {
  106. openCamera(1);
  107. } else {
  108. openCamera(0);
  109. }
  110. return true;
  111. },
  112. destructiveButtonClicked: function () {
  113. return true;
  114. }
  115. });
  116. };
  117. var openCamera = function (srcType) {
  118. var options = {
  119. // Some common settings are 20, 50, and 100
  120. quality: 50,
  121. destinationType: Camera.DestinationType.FILE_URI,
  122. // In this app, dynamically set the picture source, Camera or photo gallery
  123. sourceType: srcType,
  124. encodingType: Camera.EncodingType.JPEG,
  125. mediaType: Camera.MediaType.PICTURE,
  126. allowEdit: false,
  127. correctOrientation: true //Corrects Android orientation quirks
  128. };
  129. navigator.camera.getPicture(function (imageData) {
  130. $scope.imgurl = imageData;
  131. $scope.showLoadingToast();
  132. UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
  133. AccountService.setuserName(response[0].userPhoto, 3).then(function (res) {
  134. $scope.userInfo.photo = res.photo;
  135. UserService.user.user.photo = res.photo;
  136. }, function () {
  137. });
  138. $scope.hideLoadingToast();
  139. }, function () {
  140. $scope.hideLoadingToast();
  141. });
  142. }, function (message) {
  143. }, options);
  144. };
  145. var verifyStorage = function () {
  146. window.imagePicker.verifyStorage(
  147. function (results) {
  148. if (results == "1") {
  149. getPic();
  150. }
  151. }, function (error) {
  152. }
  153. );
  154. };
  155. var getPic = function () {
  156. //产品图片
  157. if ($scope.productInfoimagelist.length >= 9) {
  158. UtilService.showMess("最多选取9张图片");
  159. return;
  160. }
  161. UtilService.getPictureList(9 - $scope.productInfoimagelist.length).then(function (results) {
  162. // console.log(results);
  163. angular.forEach(results, function (value, index) {
  164. $scope.productInfoimagelist.push({photo_name: value, original_name: value})
  165. });
  166. $scope.totalImglength = 600 * $scope.productInfoimagelist.length;
  167. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  168. }, function (err) {
  169. });
  170. //需求图片
  171. if ($scope.demandInfoimagelist.length >= 9) {
  172. UtilService.showMess("最多选取9张图片");
  173. return;
  174. }
  175. UtilService.getPictureList(9 - $scope.demandInfoimagelist.length).then(function (results) {
  176. // console.log(results);
  177. angular.forEach(results, function (value, index) {
  178. $scope.demandInfoimagelist.push({photo_name: value, original_name: value})
  179. });
  180. $scope.totalImglength = 600 * $scope.demandInfoimagelist.length;
  181. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  182. }, function (err) {
  183. });
  184. };
  185. //点击产品图片放大
  186. $scope.bigImageProduct=false; //初始默认大图是隐藏的
  187. $scope.hideBigImageProduct = function () {
  188. if($scope.app){
  189. $scope.setStatusBar(0);
  190. }
  191. $timeout(function () {
  192. $scope.bigImageProduct = false;
  193. }, 400);
  194. };
  195. //点击需求图片放大
  196. $scope.bigImageDemand=false; //初始默认大图是隐藏的
  197. $scope.hideBigImageProduct = function () {
  198. if($scope.app){
  199. $scope.setStatusBar(0);
  200. }
  201. $timeout(function () {
  202. $scope.bigImageDemand = false;
  203. }, 400);
  204. };
  205. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  206. if($scope.app){
  207. $scope.setStatusBar(1);
  208. }
  209. $(function () {
  210. $('div.pinch-zoom').each(function () {
  211. new RTP.PinchZoom($(this), {});
  212. });
  213. });
  214. $scope.bigImage = true;//显示大图
  215. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  216. //图片总数量
  217. setTimeout(function () {
  218. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
  219. //获取图片
  220. var imgObj = document.getElementsByClassName('bigimage');
  221. var n;
  222. for (n = 0; n < imgObj.length; n++) {
  223. // 获取图片的原始高度和宽度
  224. var oldWid = imgObj[n].naturalWidth;
  225. var oldHei = imgObj[n].naturalHeight;
  226. var screen = document.body.offsetWidth;
  227. var screenH = window.innerHeight;
  228. // console.log(oldWid / oldHei);
  229. // console.log(screen);
  230. var cc = screen / (oldWid / oldHei);
  231. imgObj[n].style.height = cc + 'px';
  232. if (cc < screenH) {
  233. imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
  234. // console.log("e:"+imgObj[n].style.marginTop);
  235. } else {
  236. imgObj[n].style.marginTop = 0 + 'px';
  237. // console.log((cc-screenH) +'px')
  238. }
  239. }
  240. }, 10);
  241. };
  242. //删除产品图片
  243. $scope.deleteProductPhoto = function (index) {
  244. $scope.productInfoInfoimagelist.splice(index, 1);
  245. };
  246. //删除需求图片
  247. $scope.deleteDemandPhoto = function (index) {
  248. $scope.demandInfoimagelist.splice(index, 1);
  249. };
  250. //选择企业产业领域
  251. var buttonsIndustryStatus = [
  252. {text: "专业A",
  253. stausName:"专业A",
  254. stausId: "1"
  255. },
  256. {text: "专业B",
  257. stausName:"专业B",
  258. stausId: "2"
  259. }
  260. ];
  261. $scope.showIndustryStatus=function () {
  262. $ionicActionSheet.show({
  263. cancelOnStateChange: true,
  264. cssClass: 'action_s',
  265. cancelText: '取消',
  266. buttons: buttonsIndustryStatus,
  267. buttonClicked: function (index) {
  268. $scope.companyListInfo.stausId = buttonsIndustryStatus[index].stausId;
  269. $scope.companyListInfo.stausName = buttonsIndustryStatus[index].stausName;
  270. return true;
  271. },
  272. destructiveButtonClicked: function () {
  273. return true;
  274. }
  275. });
  276. };
  277. //选择研发机构等级
  278. var buttonsResearchStatus = [
  279. { text: "区级",
  280. ResearchStatusName:"区级",
  281. ResearchStatusId: "0"
  282. },
  283. { text: "市级",
  284. ResearchStatusName:"市级",
  285. ResearchStatusId: "1"
  286. },
  287. { text: "省级",
  288. ResearchStatusName:"省级",
  289. ResearchStatusId: "2"
  290. },
  291. { text: "国家级",
  292. ResearchStatusName:"国家级",
  293. ResearchStatusId: "3"
  294. }
  295. ];
  296. $scope.showResearchStatus=function () {
  297. $ionicActionSheet.show({
  298. cancelOnStateChange: true,
  299. cssClass: 'action_s',
  300. cancelText: '取消',
  301. buttons: buttonsResearchStatus,
  302. buttonClicked: function (index) {
  303. $scope.companyListInfo.ResearchStatusId = buttonsResearchStatus[index].ResearchStatusId;
  304. $scope.companyListInfo.ResearchStatusName = buttonsResearchStatus[index].ResearchStatusName;
  305. return true;
  306. },
  307. destructiveButtonClicked: function () {
  308. return true;
  309. }
  310. });
  311. };
  312. //选择需求标签
  313. var demandLabels = [
  314. { text: "标签A",
  315. demandLabelName:"标签A",
  316. demandLabelId: "0"
  317. },
  318. { text: "标签B",
  319. demandLabelName:"标签B",
  320. demandLabelId: "1"
  321. },
  322. { text: "标签C",
  323. demandLabelName:"标签C",
  324. demandLabelId: "2"
  325. },
  326. { text: "标签D",
  327. demandLabelName:"标签D",
  328. demandLabelId: "3"
  329. }
  330. ];
  331. $scope.showDemandLabelName=function () {
  332. $ionicActionSheet.show({
  333. cancelOnStateChange: true,
  334. cssClass: 'action_s',
  335. cancelText: '取消',
  336. buttons: demandLabels,
  337. buttonClicked: function (index) {
  338. $scope.demandInfoList.demandLabelId = demandLabels[index].demandLabelId;
  339. $scope.demandInfoList.demandLabelName = demandLabels[index].demandLabelName;
  340. return true;
  341. },
  342. destructiveButtonClicked: function () {
  343. return true;
  344. }
  345. });
  346. };
  347. //添加、删除更多产品
  348. $scope.AddOrDelProductInfo = function (ind) {
  349. if (ind == 0) {
  350. $scope.produceInfoList.push({
  351. id: 0,
  352. stype: 2,
  353. produceInfoAddname: ""
  354. });
  355. } else {
  356. if ($scope.produceInfoList[ind].id != 0) {
  357. delproductInfo.push($scope.produceInfoList[ind].id);
  358. }
  359. $scope.produceInfoList.splice(ind, 1);
  360. }
  361. };
  362. //添加、删除更多需求
  363. $scope.AddOrDelDemandInfo = function (ind) {
  364. if (ind == 0) {
  365. $scope.demandInfoList.push({
  366. id: 0,
  367. stype: 2,
  368. demandInfoAddname: ""
  369. });
  370. } else {
  371. if ($scope.demandInfoList[ind].id != 0) {
  372. deldemandInfo.push($scope.demandInfoList[ind].id);
  373. }
  374. $scope.demandInfoList.splice(ind, 1);
  375. }
  376. };
  377. });