my.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. (function (app) {
  2. app.controller('myCtrl', ["$scope","$ionicTabsDelegate", "$state", "$http", "storage", "myService", "common","userService", "config", "msg"
  3. , function ($scope,$ionicTabsDelegate, $state, $http, storage, myService, common,userService, config, msg) {
  4. $scope.$on('$ionicView.beforeEnter', function (viewResult) {
  5. $ionicTabsDelegate.showBar(true);
  6. myService.myInfo().then(function(result){
  7. $scope.user = result.data.data
  8. });
  9. $scope.showWithdraw = true;
  10. userService.isTest().then(function(res){
  11. if(res.data.data){
  12. $scope.showWithdraw = true;
  13. }
  14. else{
  15. $scope.showWithdraw = false;
  16. }
  17. })
  18. });
  19. $scope.setAvator = function () {
  20. common.setAvator().then(function (result) {
  21. var response = JSON.parse(result.response);
  22. console.log(response.data.file);
  23. $scope.user.avatar = config.imgServer + response.data.file;
  24. });
  25. };
  26. }]);
  27. app.controller('profileCtrl', ["$scope","$ionicTabsDelegate","$state","$filter", "storage", "myService", "msg", "config", "common"
  28. , function ($scope, $ionicTabsDelegate, $state, $filter, storage, myService, msg, config, common) {
  29. $scope.$on('$ionicView.beforeEnter', function () {
  30. $ionicTabsDelegate.showBar(false);
  31. msg.loading();
  32. myService.myInfo().then(function(result){
  33. $scope.vm = result.data.data;
  34. console.log($scope.vm.avatar);
  35. $scope.vm.sex = $scope.vm.sex+'';
  36. $scope.vm.emotion = $scope.vm.emotion+'';
  37. if($scope.vm.birthday){
  38. var arr1 = $scope.vm.birthday.split("-");
  39. $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]);
  40. }
  41. msg.hide();
  42. },function(error){
  43. msg.hide();
  44. // msg.error(error.data.message);
  45. })
  46. });
  47. $scope.setAvator = function () {
  48. common.setAvator().then(function (result) {
  49. var response = JSON.parse(result.response);
  50. $scope.vm.avatar = config.imgServer + response.data.file;
  51. });
  52. };
  53. //保存个人信息
  54. $scope.vm={
  55. pic:"",
  56. sex:"",
  57. signture:"",
  58. emotion:"",
  59. job:"",
  60. tall:"",
  61. nickname:"",
  62. birthday1:""
  63. };
  64. $scope.saveMaterial = function(){
  65. var data = {
  66. sex:$scope.vm.sex,
  67. signture:$scope.vm.signture,
  68. emotion:$scope.vm.emotion,
  69. work:$scope.vm.work,
  70. height:$scope.vm.height,
  71. city:$scope.vm.city,
  72. nickname:$scope.vm.nickname,
  73. birthday:$scope.vm.birthday1
  74. };
  75. if($scope.vm.birthday1){
  76. data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd");
  77. }
  78. if($scope.vm.avatar){
  79. data.pic = $scope.vm.avatar;
  80. }
  81. //msg.loading('提交中...');
  82. msg.loading();
  83. myService.saveMaterial(data).then(function(result){
  84. msg.hide();
  85. msg.success("保存成功!");
  86. $state.go('app.my');
  87. myService.myInfo();
  88. },function(error){
  89. msg.hide();
  90. msg.error(error.data.message);
  91. })
  92. }
  93. }]);
  94. app.controller('settingCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  95. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  96. $scope.$on('$ionicView.beforeEnter', function () {
  97. $ionicTabsDelegate.showBar(false);
  98. });
  99. //退出登陆
  100. $scope.logout = function(){
  101. storage.remove("token");
  102. storage.remove("user");
  103. $state.go("login");
  104. }
  105. }]);
  106. app.controller('aboutMiaoCtrl', ["$scope","$ionicTabsDelegate","$timeout", "$state", "myService", "msg","storage"
  107. , function ($scope,$ionicTabsDelegate,$timeout, $state,myService, msg, storage) {
  108. $scope.$on('$ionicView.beforeEnter', function () {
  109. $scope.aboutMiao();
  110. });
  111. $scope.aboutMiao = function(){
  112. myService.aboutMiao().then(function(result){
  113. $scope.items = result.data.data;
  114. },function(error){
  115. msg.error(error.data.message)
  116. })
  117. };
  118. }]);
  119. app.controller('withdrawCtrl', ["$scope","$ionicTabsDelegate","$ionicHistory","$timeout", "$state", "myService", "msg","storage"
  120. , function ($scope,$ionicTabsDelegate, $ionicHistory,$timeout,$state,myService, msg, storage) {
  121. $scope.vm={
  122. pay:"",
  123. cash:""
  124. };
  125. $scope.$on("$ionicView.enter",function(){
  126. myService.showAccount().then(function(result){
  127. $scope.accountId = result.data.data;
  128. var items = result.data.data;
  129. //if(items.length==0){
  130. // msg.text("请先添加账户");
  131. // $state.go("app.my_account_add");
  132. // return
  133. //}
  134. $scope.pays=[];
  135. angular.forEach(items,function(item){
  136. if(item.bank_name!=null) {
  137. var value=item.bank_name+"(";
  138. var len=item.bank_number.length;
  139. var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
  140. var txt2=item.bank_number.substr(len-4,4);
  141. value=value+txt1+txt2+")";
  142. }
  143. else {
  144. value=item.type;
  145. }
  146. $scope.pays.push({id:item.id,value:value});
  147. });
  148. $scope.vm.pay = $scope.pays[0]
  149. },function(error){
  150. msg.error(error.data.message)
  151. })
  152. });
  153. $scope.withdraw = function(){
  154. var data = {
  155. data:{
  156. bank_id:$scope.vm.pay.id,
  157. cash:$scope.vm.cash
  158. }
  159. };
  160. myService.withdraw(data).then(function(result){
  161. msg.text("提现申请已提交");
  162. $timeout(function () {
  163. $ionicHistory.goBack();
  164. },1000);
  165. },function(error){
  166. })
  167. }
  168. }]);
  169. app.controller('payoutCtrl', ["$scope","$ionicTabsDelegate","$timeout","$ionicHistory", "$state", "myService", "msg","storage"
  170. , function ($scope,$ionicTabsDelegate, $timeout, $ionicHistory,$state,myService, msg, storage) {
  171. $scope.vm={
  172. pay:"",
  173. cash:""
  174. };
  175. $scope.$on("$ionicView.enter",function(){
  176. myService.showAccount().then(function(result){
  177. $scope.accountId = result.data.data;
  178. var items = result.data.data;
  179. $scope.pays=[];
  180. angular.forEach(items,function(item){
  181. if(item.bank_name!=null) {
  182. var value=item.bank_name+"(";
  183. var len=item.bank_number.length;
  184. var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
  185. var txt2=item.bank_number.substr(len-4,4);
  186. value=value+txt1+txt2+")";
  187. }
  188. else {
  189. value=item.type;
  190. }
  191. $scope.pays.push({id:item.id,value:value});
  192. })
  193. },function(error){
  194. msg.error(error.data.message)
  195. })
  196. });
  197. $scope.withdraw = function(){
  198. var data = {
  199. data:{
  200. bank_id:$scope.vm.pay.id,
  201. cash:$scope.vm.cash
  202. }
  203. };
  204. myService.withdraw(data).then(function(result){
  205. msg.text("提现申请已提交");
  206. $timeout(function () {
  207. $ionicHistory.goBack();
  208. },1000);
  209. },function(error){
  210. })
  211. }
  212. }]);
  213. app.controller('payExplainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  214. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  215. $scope.$on('$ionicView.beforeEnter', function () {
  216. $scope.payExplain();
  217. });
  218. $scope.payExplain = function(){
  219. myService.payExplain().then(function(result){
  220. $scope.items = result.data.data;
  221. },function(error){
  222. msg.error(error.data.message)
  223. })
  224. };
  225. }]);
  226. app.controller('paySuccessCtrl', ["$scope","$stateParams","$ionicTabsDelegate","$ionicHistory", "$state", "myService", "msg","storage"
  227. , function ($scope,$stateParams,$ionicTabsDelegate,$ionicHistory, $state,myService, msg, storage) {
  228. var item = $stateParams.item;
  229. alert(item.out_trade_no);
  230. $scope.goBack = function(){
  231. $ionicHistory.goBack();
  232. }
  233. }]);
  234. app.controller('contactCtrl', ["$scope","$ionicTabsDelegate","$location", "$ionicHistory","$timeout","$state", "myService", "msg","storage"
  235. , function ($scope,$ionicTabsDelegate,$location,$ionicHistory, $timeout,$state,myService, msg, storage) {
  236. $scope.vm={
  237. content:"",
  238. email:""
  239. };
  240. $scope.contact = function(){
  241. var data={
  242. data:{
  243. content:$scope.vm.content,
  244. email:$scope.vm.email
  245. }
  246. };
  247. myService.contact(data).then(function(result){
  248. msg.text("发送成功");
  249. $timeout(function(){
  250. if($location.path()=='/app/home/contact'){
  251. $ionicHistory.goBack();
  252. }
  253. else{
  254. $state.go("app.my");
  255. }
  256. },1000);
  257. $scope.vm={
  258. content:"",
  259. email:""
  260. }
  261. },function(error){
  262. msg.error(error.data.message);
  263. })
  264. }
  265. }]);
  266. app.controller('attentionCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  267. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  268. $scope.$on('$ionicView.beforeEnter', function () {
  269. $ionicTabsDelegate.showBar(false);
  270. myService.attention().then(function(result){
  271. $scope.users = result.data.data;
  272. },function(error){
  273. })
  274. });
  275. $scope.toMyUserDetail = function (id) {
  276. myService.toMyUserDetail(id).then(function(result){
  277. $scope.items = result.data.data;
  278. $state.go('app.attention_Detail',{id:id,items:$scope.items});
  279. },function(error){
  280. //msg.error(msg.data.error)
  281. })
  282. };
  283. }]);
  284. app.controller('careCtrl', ["$scope","$ionicTabsDelegate",'$ionicModal',"$state", "myService", "msg","storage"
  285. , function ($scope,$ionicTabsDelegate,$ionicModal, $state,myService, msg, storage) {
  286. $scope.$on('$ionicView.beforeEnter', function () {
  287. $ionicTabsDelegate.showBar(false);
  288. myService.careMe().then(function(result){
  289. $scope.users = result.data.data;
  290. },function(error){
  291. })
  292. });
  293. $scope.toMyUserDetail = function (id) {
  294. myService.toMyUserDetail(id).then(function(result){
  295. $scope.items = result.data.data;
  296. $state.go('app.attention_Detail',{id:id,items:$scope.items});
  297. },function(error){
  298. //msg.error(msg.data.error)
  299. })
  300. };
  301. $ionicModal.fromTemplateUrl('my-modal.html', {
  302. scope: $scope,
  303. animation: 'slide-in-up'
  304. }).then(function (modal) {
  305. $scope.modal = modal;
  306. });
  307. //发私信
  308. $scope.vm={
  309. content:"",
  310. comment_id:""
  311. };
  312. $scope.closeModal = function () {
  313. var data = {
  314. content: $scope.vm.content,
  315. to_user_id: $scope.item.id
  316. };
  317. myService.sendLetter(data).then(function (result) {
  318. msg.success('发送成功');
  319. $scope.vm.content = '';
  320. $scope.item = null;
  321. $scope.modal.hide();
  322. }, function (error) {
  323. msg.error('发送失败');
  324. });
  325. };
  326. $scope.hideModal = function(){
  327. $scope.modal.hide();
  328. };
  329. $scope.reply = function (user) {
  330. event.stopPropagation();
  331. $scope.item = user;
  332. $scope.modal.show();
  333. }
  334. }]);
  335. app.controller('blacklistCtrl', ["$scope","$ionicTabsDelegate",'$ionicModal',"$state", "myService", "msg","storage"
  336. , function ($scope,$ionicTabsDelegate,$ionicModal, $state,myService, msg, storage) {
  337. $scope.$on('$ionicView.beforeEnter', function () {
  338. $ionicTabsDelegate.showBar(false);
  339. $scope.users = storage.getObject("blackUsers");
  340. // $scope.reportUser = storage.getObject("reportUser");
  341. });
  342. $scope.cancelReport = function(id){
  343. var reportUser = storage.getObject("reportUser");
  344. var blackUsers = storage.getObject("blackUsers");
  345. for(var i = 0; i < reportUser.length; i++){
  346. if(reportUser[i] == id){
  347. reportUser.splice(i,1);
  348. }
  349. }
  350. for(var j = 0; j < blackUsers.length; j++){
  351. if(blackUsers[j].id == id){
  352. blackUsers.splice(j,1);
  353. }
  354. }
  355. msg.text('已取消');
  356. $scope.users = blackUsers;
  357. storage.setObject('reportUser',reportUser);
  358. storage.setObject('blackUsers',blackUsers);
  359. }
  360. }]);
  361. app.controller('mySupportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  362. , function ($scope,homeService,$stateParams, $state, msg) {
  363. var user_id = $stateParams.user_id;
  364. $scope.$on('$ionicView.beforeEnter',function(){
  365. $scope.toUserDetail(user_id);
  366. });
  367. $scope.toUserDetail = function(user_id){
  368. homeService.toUserDetail(user_id).then(function(result){
  369. $scope.items = result.data.data;
  370. $scope.user = result.data.data.user;
  371. $scope.dreams = $scope.user.sup_dream;
  372. },function(error){
  373. })
  374. };
  375. $scope.toDetail = function(id){
  376. $state.go('app.my_dreamdetail',{id:id});
  377. // $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  378. }
  379. }]);
  380. app.controller('myOldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  381. , function ($scope,homeService,$stateParams, $state, msg) {
  382. var user_id = $stateParams.user_id;
  383. $scope.$on('$ionicView.beforeEnter',function(){
  384. $scope.toUserDetail(user_id);
  385. });
  386. $scope.toUserDetail = function(user_id){
  387. homeService.toUserDetail(user_id).then(function(result){
  388. $scope.items = result.data.data;
  389. $scope.user = result.data.data.user;
  390. $scope.dreams = $scope.user.dreams;
  391. },function(error){
  392. })
  393. };
  394. $scope.toDetail = function(id){
  395. $state.go('app.my_dreamdetail',{id:id});
  396. // $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  397. };
  398. }]);
  399. app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", '$location',"$state", "myService", "msg","storage"
  400. , function ($scope,$ionicTabsDelegate,$location, $state,myService, msg, storage) {
  401. $scope.$on('$ionicView.beforeEnter', function () {
  402. $scope.loaddata(true);
  403. });
  404. $scope.loaddata = function(init){
  405. myService.letter().then(function(result){
  406. $scope.items = result.data.data;
  407. if (init) {
  408. $scope.$broadcast('scroll.refreshComplete');
  409. } else {
  410. $scope.$broadcast('scroll.infiniteScrollComplete');
  411. }
  412. },function(error){
  413. });
  414. }
  415. $scope.toLetter = function(id){
  416. if($location.path()=="/app/home/message/letter"){
  417. console.log($location.path());
  418. $state.go('app.letterDetail')
  419. }
  420. else {
  421. $state.go('app.myLetterDetail')
  422. }
  423. }
  424. }]);
  425. app.controller('letterDetailCtrl', ["$scope","$ionicTabsDelegate",'$stateParams',"$state", "myService", "msg","storage"
  426. , function ($scope,$ionicTabsDelegate,$stateParams, $state,myService, msg, storage) {
  427. var id = $stateParams.id;
  428. $scope.$on('$ionicView.beforeEnter', function () {
  429. myService.letter().then(function(result){
  430. $scope.items = result.data.data;
  431. },function(error){
  432. });
  433. });
  434. }]);
  435. app.controller('rechargeCtrl', ["$scope","$ionicModal","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService","userService", "msg"
  436. , function ($scope,$ionicModal,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService,userService, msg) {
  437. $scope.$on('$ionicView.beforeEnter', function () {
  438. $scope.showWithdraw = true;
  439. $ionicTabsDelegate.showBar(false);
  440. $scope.vm = {
  441. }
  442. myService.myInfo().then(function(result){
  443. $scope.vm = result.data.data;
  444. $scope.vm.number = '';
  445. $scope.vm.payType = 2;
  446. });
  447. userService.isTest().then(function(res){
  448. if(res.data.data){
  449. $scope.showWithdraw = true;
  450. }
  451. else{
  452. $scope.showWithdraw = false;
  453. }
  454. })
  455. if($scope.ios.isIOS){
  456. var productIds = ['apple10001','apple102','apple103','apple104']; // <- Add your product Ids here
  457. msg.loading();
  458. inAppPurchase
  459. .getProducts(productIds)
  460. .then(function (products) {
  461. msg.hide();
  462. $scope.products = products;
  463. console.log('products:'+JSON.stringify(products));
  464. })
  465. .catch(function (err) {
  466. msg.hide();
  467. console.log(err);
  468. });
  469. }
  470. });
  471. $scope.payExplain = function(){
  472. $state.go("app.payExplain")
  473. };
  474. $scope.withdraw = function(){
  475. $state.go("app.withdraw")
  476. };
  477. $scope.testcharge = function(number){
  478. if (!number) {
  479. msg.text('请输入充值金额');
  480. return;
  481. }
  482. myService.testcharge(number,2).then(function (result) {
  483. msg.text("充值成功");
  484. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  485. // $timeout(function(){
  486. // $ionicHistory.goBack();
  487. // },500)
  488. });
  489. };
  490. $ionicModal.fromTemplateUrl('paysuccess-modal.html', {
  491. scope: $scope,
  492. animation: 'slide-in-up'
  493. }).then(function(modal) {
  494. $scope.modal = modal;
  495. });
  496. $scope.openModal = function() {
  497. $scope.modal.show();
  498. };
  499. $scope.closeModal = function() {
  500. $scope.modal.hide();
  501. };
  502. //当我们用到模型时,清除它!
  503. $scope.$on('$destroy', function() {
  504. $scope.modal.remove();
  505. });
  506. $scope.ios={
  507. isIOS:ionic.Platform.isIOS(),
  508. productid:'apple100001'
  509. }
  510. //充值
  511. $scope.charge = function(number){
  512. if($scope.ios.isIOS){
  513. if (number<2){
  514. msg.text('请选择充值金额');
  515. return;
  516. }
  517. console.log('购买productid:'+number);
  518. msg.loading();
  519. inAppPurchase
  520. .buy(number)
  521. .then(function (data) {
  522. msg.hide();
  523. console.log('购买then:'+JSON.stringify(data));
  524. return inAppPurchase.consume(data.productType, data.receipt, data.signature);
  525. })
  526. .then(function (data) {
  527. msg.hide();
  528. myService.orderIos(number).then(function (result) {
  529. console.log('服务器端购买成功:'+number);
  530. }, function (erro) {
  531. });
  532. console.log('购买成功:'+number);
  533. msg.success('购买成功');
  534. $ionicHistory.goBack();
  535. })
  536. .catch(function (err) {
  537. msg.hide();
  538. console.log('购买失败:'+JSON.stringify(err));
  539. // alert('购买失败:'+JSON.stringify(err));
  540. });
  541. }else{
  542. if (!number) {
  543. msg.text('请输入充值金额');
  544. return;
  545. }
  546. myService.charge(number,2).then(function (result) {
  547. //todo:result需要返回支付宝或者微信的签名信息
  548. console.log("result: " + JSON.stringify(result));
  549. var payInfo = result.data.data;
  550. var orderID = payInfo.transaction_id
  551. $scope.vm.transaction_id = payInfo.transaction_id;
  552. $scope.vm.price = payInfo.price;
  553. if ($scope.vm.payType == 1) { //支付宝
  554. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  555. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  556. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  557. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  558. //当e.resultStatus为9000时,请去服务端验证支付结果
  559. $scope.clicksub = false;
  560. if (e.resultStatus == '9000') {
  561. alert(orderID);
  562. //支付成功
  563. // $state.go('app.my');
  564. } else {
  565. msg.error("支付失败");
  566. // msg.error("支付失败:" + JSON.stringify(e));
  567. }
  568. }, function error(e) {
  569. $scope.clicksub = false;
  570. // msg.error("支付失败:" + JSON.stringify(e));
  571. msg.error("支付失败");
  572. });
  573. }
  574. if ($scope.vm.payType == 2) { //微信
  575. // var obj = JSON.parse(payInfo);
  576. var obj = payInfo.orderString;
  577. // console.log("obj: " + JSON.stringify(obj));
  578. var params = {
  579. partnerid: obj.partnerid, // merchant id
  580. prepayid: obj.prepayid, // prepay id
  581. noncestr: obj.noncestr, // nonce
  582. timestamp: obj.timestamp, // timestamp
  583. sign: obj.sign, // signed string
  584. };
  585. // console.log("result: " + JSON.stringify(params));
  586. Wechat.sendPaymentRequest(params, function (r) {
  587. $scope.clicksub = false;
  588. // $state.go("app.paySuccess")
  589. // $state.go('app.paySuccess',{item:payInfo})
  590. $scope.openModal();
  591. // alert(orderID);
  592. myService.orderStatus(orderID).then(function (result) {
  593. // alert(result);
  594. //支付成功
  595. // $state.go('app.my');
  596. }, function (erro) {
  597. // msg.alert("支付反馈失败:" + JSON.stringify(erro));
  598. });
  599. }, function (reason) {
  600. $scope.clicksub = false;
  601. // msg.alert("支付失败:" + JSON.stringify(reason));
  602. });
  603. }
  604. // msg.text("充值成功");
  605. // $state.go('app.my');
  606. });
  607. }
  608. }
  609. }]);
  610. app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  611. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  612. $scope.$on('$ionicView.beforeEnter', function () {
  613. $ionicTabsDelegate.showBar(false);
  614. $scope.showAccount();
  615. });
  616. $scope.showAccount = function(){
  617. myService.showAccount().then(function(result){
  618. $scope.items = result.data.data;
  619. },function(error){
  620. msg.error(error.data.message);
  621. })
  622. };
  623. $scope.destroyAccount = function(id){
  624. myService.destroyAccount(id).then(function(result){
  625. msg.text("删除成功");
  626. $scope.showAccount();
  627. },function(error){
  628. msg.error(error.data.message);
  629. })
  630. }
  631. }]);
  632. app.controller('my_account_addCtrl', ["$scope","config","common","$timeout","$ionicTabsDelegate", "$state", "myService", "msg"
  633. , function ($scope,config,common,$timeout,$ionicTabsDelegate, $state, myService, msg) {
  634. $scope.addpict = function () {
  635. common.chooseImage().then(function (qrcode) {
  636. common.uploadFiles(qrcode,1).then(function (result) {
  637. var response = JSON.parse(result.response);
  638. var file = config.imgServer+response.data.file;
  639. $scope.vm.file = file;
  640. $scope.qrcode.push(file);
  641. }, function (error) {
  642. msg.error('图片上传失败');
  643. });
  644. }, function (error) {
  645. console.log('图片选择失败');
  646. });
  647. };
  648. $scope.qrcode=[];
  649. $scope.deletefile = function (file) {
  650. var index = $scope.qrcode.indexOf(file);
  651. $scope.qrcode.splice(index, 1);
  652. common.deletefile(file).then(function () {
  653. })
  654. };
  655. $scope.vm={
  656. bank_name:'',
  657. bank_number:'',
  658. bank_phone:'',
  659. bank_user:'',
  660. type:""
  661. };
  662. $scope.addAccount = function () {
  663. var data = {
  664. data:{
  665. bank_name:$scope.vm.bank_name,
  666. bank_number:$scope.vm.bank_number,
  667. bank_phone:$scope.vm.bank_phone,
  668. bank_user:$scope.vm.bank_user
  669. }
  670. };
  671. //msg.loading('保存中...');
  672. msg.loading();
  673. myService.addAccount(data).then(function (result) {
  674. msg.hide();
  675. $state.go('app.my_account');
  676. }, function (error) {
  677. msg.hide();
  678. msg.error(error.data.message);
  679. });
  680. };
  681. $scope.addQrcode = function(){
  682. var data = {
  683. data:{
  684. type:$scope.vm.type,
  685. qrcode:$scope.vm.file
  686. //qrcode:"https://www.baidu.com/img/bd_logo1.png"
  687. }
  688. };
  689. myService.addQrcode(data).then(function(result){
  690. msg.text("添加成功",true);
  691. $state.go("app.my_account");
  692. },function(error){
  693. msg.error(error.data.message);
  694. })
  695. }
  696. }]);
  697. app.controller('messageCtrl', ["$scope", "$location","$ionicTabsDelegate","$state", "myService", "msg"
  698. , function ($scope,$location,$ionicTabsDelegate, $state, myService, msg) {
  699. $scope.$on('$ionicView.beforeEnter', function () {
  700. $ionicTabsDelegate.showBar(false);
  701. myService.messageInfo().then(function(result){
  702. $scope.infos = result.data.data;
  703. },function(error){
  704. });
  705. });
  706. $scope.notRead = function(){
  707. myService.notRead().then(function(result){
  708. myService.messageInfo().then(function(result){
  709. $scope.infos = result.data.data;
  710. },function(error){
  711. });
  712. },function(error){
  713. })
  714. };
  715. //梦想消息
  716. $scope.systemInfo = function(){
  717. if($location.path()=='/app/my/message'){
  718. $state.go("app.my_message_sys");
  719. }
  720. else {
  721. $state.go("app.message_sys");
  722. }
  723. };
  724. //支持消息
  725. $scope.replyMy = function(){
  726. if($location.path()=='/app/my/message'){
  727. $state.go("app.my_message_reply");
  728. }
  729. else {
  730. $state.go("app.message_reply");
  731. }
  732. };
  733. //通知
  734. $scope.personalLetter = function(){
  735. if($location.path()=='/app/my/message'){
  736. $state.go("app.personalLetter");
  737. }
  738. else {
  739. $state.go("app.letter");
  740. }
  741. };
  742. }]);
  743. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  744. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  745. $scope.$on('$ionicView.beforeEnter', function () {
  746. $ionicTabsDelegate.showBar(false);
  747. $scope.load(true);
  748. myService.myInfo().then(function(result){
  749. $scope.user = result.data.data
  750. });
  751. });
  752. $scope.filter = {
  753. hasMore: false,
  754. pageIndex: 1,
  755. pageSize: 25
  756. };
  757. $scope.load = function (init) {
  758. if (init) {
  759. $scope.filter.pageIndex = 1;
  760. $scope.dreams = [];
  761. }
  762. msg.loading();
  763. myService.myDream($scope.filter.pageIndex).then(function(result){
  764. msg.hide();
  765. $scope.filter.pageIndex++;
  766. var more = (result.data.data.data.length >= $scope.filter.pageSize);
  767. $scope.filter.hasMore = more;
  768. $scope.dreams = $scope.dreams.concat(result.data.data.data);
  769. if (init) {
  770. $scope.$broadcast('scroll.refreshComplete');
  771. } else {
  772. $scope.$broadcast('scroll.infiniteScrollComplete');
  773. }
  774. },function(error){
  775. msg.hide();
  776. });
  777. };
  778. $scope.toDetail = function (id) {
  779. $state.go('app.my_dreamdetail',{id:id});
  780. };
  781. $scope.time = function(){
  782. }
  783. }]);
  784. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  785. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  786. $scope.$on('$ionicView.beforeEnter', function () {
  787. $ionicTabsDelegate.showBar(false);
  788. myService.collect().then(function(result){
  789. $scope.dreams = result.data.data.dreams;
  790. });
  791. });
  792. $scope.toDetail = function (id) {
  793. $state.go('app.my_dreamdetail',{id:id});
  794. };
  795. }]);
  796. app.controller('messageSysCtrl', ["$scope","common","config","$ionicPopup","$location", "$ionicTabsDelegate","$state", "myService", "msg"
  797. , function ($scope,common,config,$ionicPopup,$location,$ionicTabsDelegate, $state, myService, msg) {
  798. $scope.$on('$ionicView.beforeEnter', function () {
  799. $scope.loaddata(true);
  800. });
  801. $scope.vm = {
  802. content:""
  803. };
  804. $scope.imgs = [];
  805. $scope.video = {};
  806. $scope.loaddata = function(init){
  807. myService.systemInfo().then(function(result){
  808. $scope.sysInfos = result.data.data;
  809. if (init) {
  810. $scope.$broadcast('scroll.refreshComplete');
  811. } else {
  812. $scope.$broadcast('scroll.infiniteScrollComplete');
  813. }
  814. },function(error){
  815. });
  816. }
  817. $scope.addpict = function () {
  818. common.chooseImage().then(function (img) {
  819. common.uploadFiles(img,1).then(function (result) {
  820. var response = JSON.parse(result.response);
  821. var file = config.imgServer + response.data.file;
  822. $scope.imgs.push(file);
  823. }, function (error) {
  824. msg.error('图片上传失败');
  825. });
  826. }, function (error) {
  827. console.log('图片选择失败');
  828. });
  829. };
  830. $scope.deletefile = function (file) {
  831. var index = $scope.imgs.indexOf(file);
  832. $scope.imgs.splice(index, 1);
  833. common.deletefile(file).then(function () {
  834. })
  835. };
  836. $scope.addvideo = function () {
  837. common.chooseVideo().then(function (file) {
  838. msg.loading();
  839. common.uploadFiles(file, 2).then(function (result) {
  840. msg.hide();
  841. var response = JSON.parse(result.response);
  842. //var file = config.imgServer+response.data.file;
  843. //$scope.video.file = response.data.file;
  844. $scope.video.isOK = true;
  845. $scope.video.file = file;
  846. $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
  847. }, function (error) {
  848. //msg.error('视频上传失败');
  849. msg.hide();
  850. msg.error(JSON.stringify(error));
  851. });
  852. }, function (erro) {
  853. console.log('选择视频失败');
  854. });
  855. };
  856. $scope.deletevideo = function (file) {
  857. $scope.video = {};
  858. common.deletefile(file).then(function (res) {
  859. },function(erro){
  860. //alert(JSON.stringify(erro));
  861. })
  862. };
  863. $scope.goMes = function(is_reply,is_url,dream_id,is_end,message,user_id,info,attr_id){
  864. //发送私信
  865. if(is_reply==1){
  866. $scope.vm.content='';
  867. $scope.imgs=[];
  868. $scope.video = {};
  869. var myPopup = $ionicPopup.show({
  870. template : '<div>' +
  871. '<textarea autofocus style="border: 1px solid #D0D0D0" name="" id="" cols="30" rows="8" ng-model="vm.content" placeholder="对他的好意给予感谢的回复"></textarea onf>' +
  872. '<a ng-if="!video.isOK&&imgs.length==0" class="btn-file-up" ng-click="addpict()">' +
  873. '<img src="img/icon_photo.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  874. '<em style="font-size: 16px">添加图片</em>' +
  875. '</a>' +
  876. '<a ng-if="imgs.length==0&&!video.isOK" class="btn-file-up" ng-click="addvideo()">' +
  877. '<img src="img/icon_video.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  878. '<em style="font-size: 16px">添加视频</em>' +
  879. '</a>' +
  880. '<a ng-repeat="item in imgs" ng-click="showImages(item)" class="img-file-up">' +
  881. '<b style="background-image:url({{item}});"><em ng-click="deletefile(item)" class="ion-ios-close-outline"></em></b>' +
  882. '</a>' +
  883. '<div class="img-file-up" ng-if="video.isOK">' +
  884. '<div style="position:relative;">' +
  885. '<em ng-click="deletevideo(video.file)" class="ion-ios-close-outline"></em>' +
  886. '<video ng-src="{{video.file | trustUrl}}" style="width: 100px; height: 100px; border: 1px solid #D0D0D0" poster="{{video.vpic}}" controls="controls"></video>' +
  887. '</div>' +
  888. '</div>' +
  889. '</div>',
  890. title: message,
  891. scope: $scope,
  892. buttons: [
  893. { text: '取消' },
  894. {
  895. text: '<b>确定</b>',
  896. type: 'button-positive',
  897. onTap: function(e) {
  898. var data = {
  899. to_user_id:user_id,
  900. content:$scope.vm.content,
  901. video:$scope.video.file,
  902. image:$scope.imgs,
  903. //image:['http://img0.imgtn.bdimg.com/it/u=2398075737,160631337&fm=214&gp=0.jpg'],
  904. };
  905. myService.sendLetter(data).then(function(result){
  906. if(result.data.status_code==0){
  907. msg.success('发送成功');
  908. }
  909. })
  910. }
  911. }
  912. ]
  913. });
  914. }
  915. //跳转
  916. else if(is_url==1){
  917. if($location.path()=="/app/home/message/sys"){
  918. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  919. }
  920. else {
  921. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  922. }
  923. }
  924. //梦想结束
  925. else if(is_end==1&&attr_id==6){
  926. var endTemplate = '<div style="text-align: center"><p>恭喜你成功地你的梦想迈出最大的一步,</p>' +
  927. '<p>要取出全部梦想资金,</p>' +
  928. '<p>你需要亲自问候你的梦主</p>' +
  929. '<p>致出最诚挚的感谢</p>' +
  930. '<p>点击《确定》我们会提供</p>' +
  931. '<p>《梦主》的资料</p>' +
  932. '<p>如果你觉得不合适,你可以点击《取消》,但是《梦主》的资金会被退还给他</p>' +
  933. '<p>你以后创建梦想也会比较难</p>' +
  934. '</div>';
  935. msg.confirm('恭喜你!',endTemplate,'拒绝').then(function(result){
  936. if(result==true){
  937. myService.sure_meet(dream_id,1).then(function(res){
  938. if(res.data.status_code==0){
  939. if(res.data.data==0){
  940. msg.success('该梦想暂无梦主!');
  941. }
  942. else {
  943. msg.success('确定见面,期待相见吧!');
  944. }
  945. }
  946. })
  947. }
  948. else {
  949. myService.sure_meet(dream_id,0).then(function(res){
  950. if(res.data.status_code==0){
  951. msg.success('已拒绝见面!');
  952. }
  953. })
  954. }
  955. })
  956. }
  957. }
  958. }]);
  959. app.controller('messageReplyCtrl', ["$scope","$location","$ionicPopup","$ionicTabsDelegate", "$state","config", "myService", "msg", "$ionicModal"
  960. , function ($scope,$location,$ionicPopup,$ionicTabsDelegate, $state,config, myService, msg, $ionicModal) {
  961. $scope.$on('$ionicView.beforeEnter', function () {
  962. $scope.load(true);
  963. });
  964. $scope.load = function (init) {
  965. myService.replyMy().then(function (result) {
  966. $scope.comments = result.data.data;
  967. if (init) {
  968. $scope.$broadcast('scroll.refreshComplete');
  969. } else {
  970. $scope.$broadcast('scroll.infiniteScrollComplete');
  971. }
  972. }, function (error) {
  973. });
  974. };
  975. $scope.goMes = function(info,img,is_max,mes,video,attr_id,dream_id,to_user_id,is_end,is_url){
  976. //收到私信
  977. if(attr_id==7){
  978. if(video!=null){
  979. var letterTemplate = '<div style="text-align: center">' +
  980. '<video ng-src=" ' +config.imgServer+video+' " width="100%" style="height: 350px;" class="centerme" controls="controls" ></video>' +
  981. '<p>'+info+'</p>' +
  982. '</div>';
  983. }
  984. else if(img!='') {
  985. var letterTemplate = '<div style="text-align: center;">' +
  986. '<img src="'+img+'" style="width:100%; height: 100%;">' +
  987. '<p>'+info+'</p>' +
  988. '</div>';
  989. }
  990. else {
  991. var letterTemplate = '<div style="text-align: center">' +
  992. '<p>'+info+'</p>' +
  993. '</div>';
  994. }
  995. msg.confirm('私信',letterTemplate,'','梦想页').then(function(result){
  996. if(result==true){
  997. if($location.path()=="/app/home/message/reply"){
  998. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  999. }
  1000. else {
  1001. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  1002. }
  1003. }
  1004. })
  1005. }
  1006. //成为梦主
  1007. else if(is_max==1&&is_end==1){
  1008. var maxTemplate = '<div style="text-align: center"><p>'+ mes +'</p>' +
  1009. '<p>'+ info +'</p>' +
  1010. '</div>';
  1011. msg.confirm('恭喜你!',maxTemplate).then(function(result){
  1012. if(result==true){
  1013. myService.sure_meet2(to_user_id,1).then(function(res){
  1014. if(res.data.status_code==0) {
  1015. msg.success('确定见面,期待相见吧!');
  1016. }
  1017. })
  1018. }
  1019. else {
  1020. myService.sure_meet2(to_user_id,0).then(function(res){
  1021. if(res.data.status_code==0){
  1022. msg.success('已取消见面!');
  1023. }
  1024. })
  1025. }
  1026. })
  1027. }//确认见面/扫一扫
  1028. else if(is_max==0&&is_url==0){
  1029. var maxTemplate = '<div style="text-align: center"><p>'+ mes +'</p>' +
  1030. '</div>';
  1031. msg.alert('恭喜你!',maxTemplate).then(function(result){
  1032. })
  1033. }
  1034. else if(is_end==0&&is_url==0){
  1035. }
  1036. else {
  1037. if($location.path()=="/app/home/message/reply"){
  1038. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  1039. }
  1040. else {
  1041. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  1042. }
  1043. }
  1044. };
  1045. //我的回复
  1046. $scope.vm = {
  1047. content: ""
  1048. };
  1049. $ionicModal.fromTemplateUrl('my-modal.html', {
  1050. scope: $scope,
  1051. animation: 'slide-in-up'
  1052. }).then(function (modal) {
  1053. $scope.modal = modal;
  1054. });
  1055. //$ionicModal.fromTemplateUrl('my-modal.html', {
  1056. // scope: $scope,
  1057. // animation: 'slide-in-up'
  1058. //}).then(function (modal) {
  1059. // $scope.modal = modal;
  1060. //});
  1061. //$scope.openModal = function () {
  1062. // $scope.modal.show();
  1063. //};
  1064. //$scope.closeModal = function () {
  1065. // $scope.modal.hide();
  1066. //
  1067. //};
  1068. $scope.goDetail = function (id,interaction_id){
  1069. $state.go('app.home_dreamdetail',{id:id,interaction_id:interaction_id,type:2});
  1070. };
  1071. //我的回复
  1072. //$scope.vm={
  1073. // content:"",
  1074. // comment_id:""
  1075. //};
  1076. //$scope.closeModal = function () {
  1077. // var data = {
  1078. // content: $scope.vm.content,
  1079. // comment_id: $scope.item.id,
  1080. // interaction_id: $scope.item.interaction_id
  1081. // };
  1082. // myService.myReplay(data).then(function (result) {
  1083. // msg.success('回复成功');
  1084. // $scope.load();
  1085. // }, function (error) {
  1086. // msg.error('回复失败');
  1087. // });
  1088. // $scope.vm.content = '';
  1089. // $scope.item = null;
  1090. // $scope.modal.hide();
  1091. //};
  1092. //
  1093. //$scope.reply = function (item) {
  1094. // $scope.item = item;
  1095. // $scope.modal.show();
  1096. //}
  1097. }]);
  1098. })(angular.module('app.controllers'));