my.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  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.server = response.data.file;
  845. var file = config.imgServer+response.data.file;
  846. $scope.video.isOK = true;
  847. $scope.video.file = file;
  848. $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
  849. }, function (error) {
  850. //msg.error('视频上传失败');
  851. msg.hide();
  852. msg.error(JSON.stringify(error));
  853. });
  854. }, function (erro) {
  855. console.log('选择视频失败');
  856. });
  857. };
  858. $scope.deletevideo = function (file) {
  859. $scope.video = {};
  860. common.deletefile(file).then(function (res) {
  861. },function(erro){
  862. //alert(JSON.stringify(erro));
  863. })
  864. };
  865. $scope.goMes = function(is_reply,is_url,dream_id,is_end,message,user_id,info,attr_id){
  866. //发送私信
  867. if(is_reply==1){
  868. $scope.vm.content='';
  869. $scope.imgs=[];
  870. $scope.video = {};
  871. var myPopup = $ionicPopup.show({
  872. template : '<div>' +
  873. '<textarea autofocus style="border: 1px solid #D0D0D0" name="" id="" cols="30" rows="8" ng-model="vm.content" placeholder="对他的好意给予感谢的回复"></textarea onf>' +
  874. '<a ng-if="!video.isOK&&imgs.length==0" class="btn-file-up" ng-click="addpict()">' +
  875. '<img src="img/icon_photo.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  876. '<em style="font-size: 16px">添加图片</em>' +
  877. '</a>' +
  878. '<a ng-if="imgs.length==0&&!video.isOK" class="btn-file-up" ng-click="addvideo()">' +
  879. '<img src="img/icon_video.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  880. '<em style="font-size: 16px">添加视频</em>' +
  881. '</a>' +
  882. '<a ng-repeat="item in imgs" ng-click="showImages(item)" class="img-file-up">' +
  883. '<b style="background-image:url({{item}});"><em ng-click="deletefile(item)" class="ion-ios-close-outline"></em></b>' +
  884. '</a>' +
  885. '<div class="img-file-up" ng-if="video.isOK">' +
  886. '<div style="position:relative;">' +
  887. '<em ng-click="deletevideo(video.file)" class="ion-ios-close-outline"></em>' +
  888. '<video ng-src="{{video.file | trustUrl}}" style="width: 100px; height: 100px; border: 1px solid #D0D0D0" poster="{{video.vpic}}" controls="controls"></video>' +
  889. '</div>' +
  890. '</div>' +
  891. '</div>',
  892. title: message,
  893. scope: $scope,
  894. buttons: [
  895. { text: '取消' },
  896. {
  897. text: '<b>确定</b>',
  898. type: 'button-positive',
  899. onTap: function(e) {
  900. var data = {
  901. to_user_id:user_id,
  902. content:$scope.vm.content,
  903. video:$scope.video.file,
  904. image:$scope.imgs,
  905. //image:['http://img0.imgtn.bdimg.com/it/u=2398075737,160631337&fm=214&gp=0.jpg'],
  906. };
  907. myService.sendLetter(data).then(function(result){
  908. if(result.data.status_code==0){
  909. msg.success('发送成功');
  910. }
  911. })
  912. }
  913. }
  914. ]
  915. });
  916. }
  917. //跳转
  918. else if(is_url==1){
  919. if($location.path()=="/app/home/message/sys"){
  920. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  921. }
  922. else {
  923. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  924. }
  925. }
  926. //梦想结束
  927. else if(is_end==1&&attr_id==6){
  928. var endTemplate = '<div style="text-align: center"><p>恭喜你成功地你的梦想迈出最大的一步,</p>' +
  929. '<p>要取出全部梦想资金,</p>' +
  930. '<p>你需要亲自问候你的梦主</p>' +
  931. '<p>致出最诚挚的感谢</p>' +
  932. '<p>点击《确定》我们会提供</p>' +
  933. '<p>《梦主》的资料</p>' +
  934. '<p>如果你觉得不合适,你可以点击《取消》,但是《梦主》的资金会被退还给他</p>' +
  935. '<p>你以后创建梦想也会比较难</p>' +
  936. '</div>';
  937. msg.confirm('恭喜你!',endTemplate,'拒绝').then(function(result){
  938. if(result==true){
  939. myService.sure_meet(dream_id,1).then(function(res){
  940. if(res.data.status_code==0){
  941. if(res.data.data==0){
  942. msg.success('该梦想暂无梦主!');
  943. }
  944. else {
  945. msg.success('确定见面,期待相见吧!');
  946. }
  947. }
  948. })
  949. }
  950. else {
  951. myService.sure_meet(dream_id,0).then(function(res){
  952. if(res.data.status_code==0){
  953. msg.success('已拒绝见面!');
  954. }
  955. })
  956. }
  957. })
  958. }
  959. }
  960. }]);
  961. app.controller('messageReplyCtrl', ["$scope","$location","$ionicPopup","$ionicTabsDelegate", "$state","config", "myService", "msg", "$ionicModal"
  962. , function ($scope,$location,$ionicPopup,$ionicTabsDelegate, $state,config, myService, msg, $ionicModal) {
  963. $scope.$on('$ionicView.beforeEnter', function () {
  964. $scope.load(true);
  965. });
  966. $scope.load = function (init) {
  967. myService.replyMy().then(function (result) {
  968. $scope.comments = result.data.data;
  969. if (init) {
  970. $scope.$broadcast('scroll.refreshComplete');
  971. } else {
  972. $scope.$broadcast('scroll.infiniteScrollComplete');
  973. }
  974. }, function (error) {
  975. });
  976. };
  977. $scope.goMes = function(info,img,is_max,mes,video,attr_id,dream_id,to_user_id,is_end,is_url){
  978. //收到私信
  979. if(attr_id==7){
  980. if(video!=null){
  981. var letterTemplate = '<div style="text-align: center">' +
  982. '<video ng-src=" ' +config.imgServer+video+' " width="100%" style="height: 350px;" class="centerme" controls="controls" ></video>' +
  983. '<p>'+info+'</p>' +
  984. '</div>';
  985. }
  986. else if(img!='') {
  987. var letterTemplate = '<div style="text-align: center;">' +
  988. '<img src="'+img+'" style="width:100%; height: 100%;">' +
  989. '<p>'+info+'</p>' +
  990. '</div>';
  991. }
  992. else {
  993. var letterTemplate = '<div style="text-align: center">' +
  994. '<p>'+info+'</p>' +
  995. '</div>';
  996. }
  997. msg.confirm('私信',letterTemplate,'','梦想页').then(function(result){
  998. if(result==true){
  999. if($location.path()=="/app/home/message/reply"){
  1000. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  1001. }
  1002. else {
  1003. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  1004. }
  1005. }
  1006. })
  1007. }
  1008. //成为梦主
  1009. else if(is_max==1&&is_end==1){
  1010. var maxTemplate = '<div style="text-align: center"><p>'+ mes +'</p>' +
  1011. '<p>'+ info +'</p>' +
  1012. '</div>';
  1013. msg.confirm('恭喜你!',maxTemplate).then(function(result){
  1014. if(result==true){
  1015. myService.sure_meet2(to_user_id,1).then(function(res){
  1016. if(res.data.status_code==0) {
  1017. msg.success('确定见面,期待相见吧!');
  1018. }
  1019. })
  1020. }
  1021. else {
  1022. myService.sure_meet2(to_user_id,0).then(function(res){
  1023. if(res.data.status_code==0){
  1024. msg.success('已取消见面!');
  1025. }
  1026. })
  1027. }
  1028. })
  1029. }//确认见面/扫一扫
  1030. else if(is_max==0&&is_url==0){
  1031. var maxTemplate = '<div style="text-align: center"><p>'+ mes +'</p>' +
  1032. '</div>';
  1033. msg.alert('恭喜你!',maxTemplate).then(function(result){
  1034. })
  1035. }
  1036. else if(is_end==0&&is_url==0){
  1037. }
  1038. else {
  1039. if($location.path()=="/app/home/message/reply"){
  1040. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  1041. }
  1042. else {
  1043. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  1044. }
  1045. }
  1046. };
  1047. //我的回复
  1048. $scope.vm = {
  1049. content: ""
  1050. };
  1051. $ionicModal.fromTemplateUrl('my-modal.html', {
  1052. scope: $scope,
  1053. animation: 'slide-in-up'
  1054. }).then(function (modal) {
  1055. $scope.modal = modal;
  1056. });
  1057. //$ionicModal.fromTemplateUrl('my-modal.html', {
  1058. // scope: $scope,
  1059. // animation: 'slide-in-up'
  1060. //}).then(function (modal) {
  1061. // $scope.modal = modal;
  1062. //});
  1063. //$scope.openModal = function () {
  1064. // $scope.modal.show();
  1065. //};
  1066. //$scope.closeModal = function () {
  1067. // $scope.modal.hide();
  1068. //
  1069. //};
  1070. $scope.goDetail = function (id,interaction_id){
  1071. $state.go('app.home_dreamdetail',{id:id,interaction_id:interaction_id,type:2});
  1072. };
  1073. //我的回复
  1074. //$scope.vm={
  1075. // content:"",
  1076. // comment_id:""
  1077. //};
  1078. //$scope.closeModal = function () {
  1079. // var data = {
  1080. // content: $scope.vm.content,
  1081. // comment_id: $scope.item.id,
  1082. // interaction_id: $scope.item.interaction_id
  1083. // };
  1084. // myService.myReplay(data).then(function (result) {
  1085. // msg.success('回复成功');
  1086. // $scope.load();
  1087. // }, function (error) {
  1088. // msg.error('回复失败');
  1089. // });
  1090. // $scope.vm.content = '';
  1091. // $scope.item = null;
  1092. // $scope.modal.hide();
  1093. //};
  1094. //
  1095. //$scope.reply = function (item) {
  1096. // $scope.item = item;
  1097. // $scope.modal.show();
  1098. //}
  1099. }]);
  1100. })(angular.module('app.controllers'));