my.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. (function (app) {
  2. app.controller('myCtrl', ["$scope","$ionicTabsDelegate", "$state", "$http", "storage", "myService", "common", "config", "msg"
  3. , function ($scope,$ionicTabsDelegate, $state, $http, storage, myService, common, 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. });
  10. $scope.setAvator = function () {
  11. common.setAvator().then(function (result) {
  12. var response = JSON.parse(result.response);
  13. console.log(response.data.file);
  14. $scope.user.avatar = config.imgServer + response.data.file;
  15. });
  16. };
  17. }]);
  18. app.controller('profileCtrl', ["$scope","$ionicTabsDelegate","$state","$filter", "storage", "myService", "msg", "config", "common"
  19. , function ($scope, $ionicTabsDelegate, $state, $filter, storage, myService, msg, config, common) {
  20. $scope.$on('$ionicView.beforeEnter', function () {
  21. $ionicTabsDelegate.showBar(false);
  22. msg.loading();
  23. myService.myInfo().then(function(result){
  24. // alert(JSON.stringify(result.data.data));
  25. $scope.vm = result.data.data;
  26. console.log($scope.vm.avatar);
  27. $scope.vm.sex = $scope.vm.sex+'';
  28. $scope.vm.emotion = $scope.vm.emotion+'';
  29. if($scope.vm.birthday){
  30. var arr1 = $scope.vm.birthday.split("-");
  31. $scope.vm.birthday1 = new Date(arr1[0],parseInt(arr1[1])-1,arr1[2]);
  32. }
  33. msg.hide();
  34. },function(error){
  35. msg.hide();
  36. // msg.error(error.data.message);
  37. })
  38. });
  39. $scope.setAvator = function () {
  40. common.setAvator().then(function (result) {
  41. var response = JSON.parse(result.response);
  42. $scope.vm.avatar = config.imgServer + response.data.file;
  43. });
  44. };
  45. //保存个人信息
  46. $scope.vm={
  47. pic:"",
  48. sex:"",
  49. signture:"",
  50. emotion:"",
  51. job:"",
  52. tall:"",
  53. nickname:"",
  54. birthday1:""
  55. };
  56. $scope.saveMaterial = function(){
  57. var data = {
  58. sex:$scope.vm.sex,
  59. signture:$scope.vm.signture,
  60. emotion:$scope.vm.emotion,
  61. work:$scope.vm.work,
  62. height:$scope.vm.height,
  63. city:$scope.vm.city,
  64. nickname:$scope.vm.nickname,
  65. birthday:$scope.vm.birthday1
  66. };
  67. if($scope.vm.birthday1){
  68. data.birthday = $filter('date')($scope.vm.birthday1, "yyyy-MM-dd");
  69. }
  70. if($scope.vm.avatar){
  71. data.pic = $scope.vm.avatar;
  72. }
  73. //msg.loading('提交中...');
  74. msg.loading();
  75. myService.saveMaterial(data).then(function(result){
  76. msg.hide();
  77. msg.success("保存成功!");
  78. $state.go('app.my');
  79. myService.myInfo();
  80. },function(error){
  81. msg.hide();
  82. msg.error(error.data.message);
  83. })
  84. }
  85. }]);
  86. app.controller('settingCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  87. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  88. $scope.$on('$ionicView.beforeEnter', function () {
  89. $ionicTabsDelegate.showBar(false);
  90. });
  91. //退出登陆
  92. $scope.logout = function(){
  93. storage.remove("token");
  94. storage.remove("user");
  95. $state.go("login");
  96. }
  97. }]);
  98. app.controller('aboutMiaoCtrl', ["$scope","$ionicTabsDelegate","$timeout", "$state", "myService", "msg","storage"
  99. , function ($scope,$ionicTabsDelegate,$timeout, $state,myService, msg, storage) {
  100. $scope.$on('$ionicView.beforeEnter', function () {
  101. $scope.aboutMiao();
  102. });
  103. $scope.aboutMiao = function(){
  104. myService.aboutMiao().then(function(result){
  105. $scope.items = result.data.data;
  106. },function(error){
  107. msg.error(error.data.message)
  108. })
  109. };
  110. }]);
  111. app.controller('withdrawCtrl', ["$scope","$ionicTabsDelegate","$ionicHistory","$timeout", "$state", "myService", "msg","storage"
  112. , function ($scope,$ionicTabsDelegate, $ionicHistory,$timeout,$state,myService, msg, storage) {
  113. $scope.vm={
  114. pay:"",
  115. cash:""
  116. };
  117. $scope.$on("$ionicView.enter",function(){
  118. myService.showAccount().then(function(result){
  119. $scope.accountId = result.data.data;
  120. var items = result.data.data;
  121. if(items.length==0){
  122. msg.text("请先添加账户");
  123. $state.go("app.my_account_add");
  124. return
  125. }
  126. $scope.pays=[];
  127. angular.forEach(items,function(item){
  128. if(item.bank_name!=null) {
  129. var value=item.bank_name+"(";
  130. var len=item.bank_number.length;
  131. var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
  132. var txt2=item.bank_number.substr(len-4,4);
  133. value=value+txt1+txt2+")";
  134. }
  135. else {
  136. value=item.type;
  137. }
  138. $scope.pays.push({id:item.id,value:value});
  139. });
  140. $scope.vm.pay = $scope.pays[0]
  141. },function(error){
  142. msg.error(error.data.message)
  143. })
  144. });
  145. $scope.withdraw = function(){
  146. var data = {
  147. data:{
  148. bank_id:$scope.vm.pay.id,
  149. cash:$scope.vm.cash
  150. }
  151. };
  152. myService.withdraw(data).then(function(result){
  153. msg.text("提现申请已提交");
  154. $timeout(function () {
  155. $ionicHistory.goBack();
  156. },1000);
  157. },function(error){
  158. })
  159. }
  160. }]);
  161. app.controller('payoutCtrl', ["$scope","$ionicTabsDelegate","$timeout","$ionicHistory", "$state", "myService", "msg","storage"
  162. , function ($scope,$ionicTabsDelegate, $timeout, $ionicHistory,$state,myService, msg, storage) {
  163. $scope.vm={
  164. pay:"",
  165. cash:""
  166. };
  167. $scope.$on("$ionicView.enter",function(){
  168. myService.showAccount().then(function(result){
  169. $scope.accountId = result.data.data;
  170. var items = result.data.data;
  171. $scope.pays=[];
  172. angular.forEach(items,function(item){
  173. if(item.bank_name!=null) {
  174. var value=item.bank_name+"(";
  175. var len=item.bank_number.length;
  176. var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
  177. var txt2=item.bank_number.substr(len-4,4);
  178. value=value+txt1+txt2+")";
  179. }
  180. else {
  181. value=item.type;
  182. }
  183. $scope.pays.push({id:item.id,value:value});
  184. })
  185. },function(error){
  186. msg.error(error.data.message)
  187. })
  188. });
  189. $scope.withdraw = function(){
  190. var data = {
  191. data:{
  192. bank_id:$scope.vm.pay.id,
  193. cash:$scope.vm.cash
  194. }
  195. };
  196. myService.withdraw(data).then(function(result){
  197. msg.text("提现申请已提交");
  198. $timeout(function () {
  199. $ionicHistory.goBack();
  200. },1000);
  201. },function(error){
  202. })
  203. }
  204. }]);
  205. app.controller('payExplainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  206. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  207. $scope.$on('$ionicView.beforeEnter', function () {
  208. $scope.payExplain();
  209. });
  210. $scope.payExplain = function(){
  211. myService.payExplain().then(function(result){
  212. $scope.items = result.data.data;
  213. },function(error){
  214. msg.error(error.data.message)
  215. })
  216. };
  217. }]);
  218. app.controller('explainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  219. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  220. }]);
  221. app.controller('contactCtrl', ["$scope","$ionicTabsDelegate", "$timeout","$state", "myService", "msg","storage"
  222. , function ($scope,$ionicTabsDelegate, $timeout,$state,myService, msg, storage) {
  223. $scope.vm={
  224. content:"",
  225. email:""
  226. };
  227. $scope.contact = function(){
  228. var data={
  229. data:{
  230. content:$scope.vm.content,
  231. email:$scope.vm.email
  232. }
  233. };
  234. myService.contact(data).then(function(result){
  235. msg.text("发送成功");
  236. $timeout(function(){
  237. $state.go("app.my");
  238. },1000);
  239. },function(error){
  240. msg.error(error.data.message);
  241. })
  242. }
  243. }]);
  244. app.controller('attentionCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  245. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  246. $scope.$on('$ionicView.beforeEnter', function () {
  247. myService.attention().then(function(result){
  248. $scope.users = result.data.data;
  249. },function(error){
  250. })
  251. });
  252. $scope.toMyUserDetail = function (id) {
  253. myService.toMyUserDetail(id).then(function(result){
  254. $scope.items = result.data.data;
  255. $state.go('app.attention_Detail',{id:id,items:$scope.items});
  256. },function(error){
  257. //msg.error(msg.data.error)
  258. })
  259. };
  260. }]);
  261. app.controller('mySupportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  262. , function ($scope,homeService,$stateParams, $state, msg) {
  263. var user_id = $stateParams.user_id;
  264. $scope.$on('$ionicView.beforeEnter',function(){
  265. $scope.toUserDetail(user_id);
  266. });
  267. $scope.toUserDetail = function(user_id){
  268. homeService.toUserDetail(user_id).then(function(result){
  269. $scope.items = result.data.data;
  270. $scope.user = result.data.data.user;
  271. $scope.dreams = $scope.user.sup_dream;
  272. },function(error){
  273. })
  274. };
  275. $scope.toDetail = function(){
  276. $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  277. }
  278. }]);
  279. app.controller('myOldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  280. , function ($scope,homeService,$stateParams, $state, msg) {
  281. var user_id = $stateParams.user_id;
  282. $scope.$on('$ionicView.beforeEnter',function(){
  283. $scope.toUserDetail(user_id);
  284. });
  285. $scope.toUserDetail = function(user_id){
  286. homeService.toUserDetail(user_id).then(function(result){
  287. $scope.items = result.data.data;
  288. $scope.user = result.data.data.user;
  289. $scope.dreams = $scope.user.dreams;
  290. },function(error){
  291. })
  292. };
  293. $scope.toDetail = function(){
  294. $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  295. };
  296. }]);
  297. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  298. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  299. }]);
  300. app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  301. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  302. $scope.$on('$ionicView.beforeEnter', function () {
  303. myService.letter().then(function(result){
  304. $scope.comments = result.data.data;
  305. },function(error){
  306. });
  307. });
  308. }]);
  309. app.controller('rechargeCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService", "msg"
  310. , function ($scope,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService, msg) {
  311. $scope.$on('$ionicView.beforeEnter', function () {
  312. $ionicTabsDelegate.showBar(false);
  313. myService.myInfo().then(function(result){
  314. $scope.vm = result.data.data;
  315. $scope.vm.number = '';
  316. $scope.vm.payType = 2;
  317. })
  318. });
  319. $scope.payExplain = function(){
  320. $state.go("app.payExplain")
  321. };
  322. $scope.withdraw = function(){
  323. $state.go("app.withdraw")
  324. };
  325. $scope.testcharge = function(number){
  326. if (!number) {
  327. msg.text('请输入充值金额');
  328. return;
  329. }
  330. myService.testcharge(number,2).then(function (result) {
  331. msg.text("充值成功");
  332. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  333. // $timeout(function(){
  334. // $ionicHistory.goBack();
  335. // },500)
  336. });
  337. }
  338. //充值
  339. $scope.charge = function(number){
  340. if (!number) {
  341. msg.text('请输入充值金额');
  342. return;
  343. }
  344. myService.charge(number,2).then(function (result) {
  345. //todo:result需要返回支付宝或者微信的签名信息
  346. console.log("result: " + JSON.stringify(result));
  347. var payInfo = result.data;
  348. if ($scope.vm.payType == 1) { //支付宝
  349. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  350. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  351. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  352. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  353. //当e.resultStatus为9000时,请去服务端验证支付结果
  354. $scope.clicksub = false;
  355. if (e.resultStatus == '9000') {
  356. alert(orderID);
  357. //支付成功
  358. // $state.go('app.my');
  359. } else {
  360. msg.error("支付失败");
  361. // msg.error("支付失败:" + JSON.stringify(e));
  362. }
  363. }, function error(e) {
  364. $scope.clicksub = false;
  365. // msg.error("支付失败:" + JSON.stringify(e));
  366. msg.error("支付失败");
  367. });
  368. }
  369. if ($scope.vm.payType == 2) { //微信
  370. var obj = JSON.parse(payInfo);
  371. var params = {
  372. partnerid: obj.partnerid, // merchant id
  373. prepayid: obj.prepayid, // prepay id
  374. noncestr: obj.noncestr, // nonce
  375. timestamp: obj.timestamp, // timestamp
  376. sign: obj.sign, // signed string
  377. };
  378. Wechat.sendPaymentRequest(params, function (r) {
  379. $scope.clicksub = false;
  380. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  381. // alert(result);
  382. //支付成功
  383. // $state.go('app.my');
  384. }, function (erro) {
  385. msg.alert("支付反馈失败:" + JSON.stringify(erro));
  386. });
  387. }, function (reason) {
  388. $scope.clicksub = false;
  389. msg.alert("支付失败:" + JSON.stringify(reason));
  390. });
  391. }
  392. // msg.text("充值成功");
  393. // $state.go('app.my');
  394. });
  395. }
  396. }]);
  397. app.controller('payCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$timeout","$ionicHistory","$state", "myService", "msg"
  398. , function ($scope,$timeout,$ionicHistory,$ionicTabsDelegate, $timeout,$ionicHistory,$state, myService, msg) {
  399. $scope.$on('$ionicView.beforeEnter', function () {
  400. myService.myInfo().then(function(result){
  401. $scope.vm = result.data.data;
  402. $scope.vm.money = '';
  403. $scope.vm.payType = 2;
  404. })
  405. });
  406. $scope.payExplain = function(){
  407. $state.go("app.explain")
  408. };
  409. $scope.withdraw = function(){
  410. $state.go("app.payout")
  411. };
  412. //充值
  413. $scope.testcharge = function(number){
  414. if (!number) {
  415. msg.text('请输入充值金额');
  416. return;
  417. }
  418. myService.testcharge(number,2).then(function (result) {
  419. msg.text("充值成功");
  420. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  421. $timeout(function(){
  422. $ionicHistory.goBack();
  423. },500)
  424. });
  425. }
  426. //充值
  427. $scope.charge = function(number){
  428. if (!number) {
  429. msg.text('请输入充值金额');
  430. return;
  431. }
  432. myService.charge(number,2).then(function (result) {
  433. //todo:result需要返回支付宝或者微信的签名信息
  434. console.log("result: " + JSON.stringify(result));
  435. var payInfo = result.data;
  436. if ($scope.vm.payType == 1) { //支付宝
  437. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  438. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  439. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  440. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  441. //当e.resultStatus为9000时,请去服务端验证支付结果
  442. $scope.clicksub = false;
  443. if (e.resultStatus == '9000') {
  444. alert(orderID);
  445. //支付成功
  446. // $state.go('app.my');
  447. } else {
  448. msg.error("支付失败");
  449. // msg.error("支付失败:" + JSON.stringify(e));
  450. }
  451. }, function error(e) {
  452. $scope.clicksub = false;
  453. // msg.error("支付失败:" + JSON.stringify(e));
  454. msg.error("支付失败");
  455. });
  456. }
  457. if ($scope.vm.payType == 2) { //微信
  458. var obj = JSON.parse(payInfo);
  459. var params = {
  460. partnerid: obj.partnerid, // merchant id
  461. prepayid: obj.prepayid, // prepay id
  462. noncestr: obj.noncestr, // nonce
  463. timestamp: obj.timestamp, // timestamp
  464. sign: obj.sign, // signed string
  465. };
  466. Wechat.sendPaymentRequest(params, function (r) {
  467. $scope.clicksub = false;
  468. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  469. // alert(result);
  470. //支付成功
  471. // $state.go('app.my');
  472. }, function (erro) {
  473. msg.alert("支付反馈失败:" + JSON.stringify(erro));
  474. });
  475. }, function (reason) {
  476. $scope.clicksub = false;
  477. msg.alert("支付失败:" + JSON.stringify(reason));
  478. });
  479. }
  480. // msg.text("充值成功");
  481. // $state.go('app.my');
  482. });
  483. }
  484. }]);
  485. app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  486. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  487. $scope.$on('$ionicView.beforeEnter', function () {
  488. $ionicTabsDelegate.showBar(false);
  489. $scope.showAccount();
  490. });
  491. $scope.showAccount = function(){
  492. myService.showAccount().then(function(result){
  493. $scope.items = result.data.data;
  494. },function(error){
  495. msg.error(error.data.message);
  496. })
  497. };
  498. $scope.destroyAccount = function(id){
  499. myService.destroyAccount(id).then(function(result){
  500. msg.text("删除成功");
  501. $scope.showAccount();
  502. },function(error){
  503. msg.error(error.data.message);
  504. })
  505. }
  506. }]);
  507. app.controller('my_account_addCtrl', ["$scope","config","common","$timeout","$ionicTabsDelegate", "$state", "myService", "msg"
  508. , function ($scope,config,common,$timeout,$ionicTabsDelegate, $state, myService, msg) {
  509. $scope.addpict = function () {
  510. common.chooseImage().then(function (qrcode) {
  511. common.uploadFiles(qrcode,1).then(function (result) {
  512. var response = JSON.parse(result.response);
  513. var file = config.imgServer+response.data.file;
  514. $scope.vm.file = file;
  515. $scope.qrcode.push(file);
  516. }, function (error) {
  517. msg.error('图片上传失败');
  518. });
  519. }, function (error) {
  520. console.log('图片选择失败');
  521. });
  522. };
  523. $scope.qrcode=[];
  524. $scope.deletefile = function (file) {
  525. var index = $scope.qrcode.indexOf(file);
  526. $scope.qrcode.splice(index, 1);
  527. common.deletefile(file).then(function () {
  528. })
  529. };
  530. $scope.vm={
  531. bank_name:'',
  532. bank_number:'',
  533. bank_phone:'',
  534. bank_user:'',
  535. type:""
  536. };
  537. $scope.addAccount = function () {
  538. var data = {
  539. data:{
  540. bank_name:$scope.vm.bank_name,
  541. bank_number:$scope.vm.bank_number,
  542. bank_phone:$scope.vm.bank_phone,
  543. bank_user:$scope.vm.bank_user
  544. }
  545. };
  546. //msg.loading('保存中...');
  547. msg.loading();
  548. myService.addAccount(data).then(function (result) {
  549. msg.hide();
  550. $state.go('app.my_account');
  551. }, function (error) {
  552. msg.hide();
  553. msg.error(error.data.message);
  554. });
  555. };
  556. $scope.addQrcode = function(){
  557. var data = {
  558. data:{
  559. type:$scope.vm.type,
  560. qrcode:$scope.vm.file
  561. //qrcode:"https://www.baidu.com/img/bd_logo1.png"
  562. }
  563. };
  564. myService.addQrcode(data).then(function(result){
  565. msg.text("添加成功",true);
  566. $state.go("app.my_account");
  567. },function(error){
  568. msg.error(error.data.message);
  569. })
  570. }
  571. }]);
  572. app.controller('messageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  573. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  574. $scope.$on('$ionicView.beforeEnter', function () {
  575. $ionicTabsDelegate.showBar(false);
  576. myService.messageInfo().then(function(result){
  577. $scope.infos = result.data.data;
  578. },function(error){
  579. });
  580. });
  581. //系统消息
  582. $scope.systemInfo = function(){
  583. $state.go("app.my_message_sys");
  584. };
  585. $scope.notRead = function(){
  586. myService.notRead().then(function(result){
  587. myService.messageInfo().then(function(result){
  588. $scope.infos = result.data.data;
  589. },function(error){
  590. });
  591. },function(error){
  592. })
  593. };
  594. //回复我的
  595. $scope.replyMy = function(){
  596. $state.go("app.my_message_reply");
  597. };
  598. $scope.personalLetter = function(){
  599. $state.go("app.personalLetter");
  600. }
  601. }]);
  602. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  603. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  604. $scope.$on('$ionicView.beforeEnter', function () {
  605. $ionicTabsDelegate.showBar(false);
  606. myService.myDream().then(function(result){
  607. $scope.dreams = result.data.data;
  608. });
  609. myService.myInfo().then(function(result){
  610. $scope.user = result.data.data
  611. });
  612. });
  613. $scope.toDetail = function (id) {
  614. $state.go('app.my_dreamdetail',{id:id});
  615. };
  616. }]);
  617. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  618. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  619. $scope.$on('$ionicView.beforeEnter', function () {
  620. $ionicTabsDelegate.showBar(false);
  621. myService.collect().then(function(result){
  622. $scope.dreams = result.data.data.dreams;
  623. });
  624. });
  625. $scope.toDetail = function (id) {
  626. $state.go('app.my_dreamdetail',{id:id});
  627. };
  628. }]);
  629. app.controller('messageSysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  630. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  631. $scope.$on('$ionicView.beforeEnter', function () {
  632. myService.systemInfo().then(function(result){
  633. $scope.sysInfos = result.data.data;
  634. },function(error){
  635. });
  636. });
  637. }]);
  638. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  639. , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  640. $scope.$on('$ionicView.beforeEnter', function () {
  641. myService.replyMy().then(function(result){
  642. $scope.comments = result.data.data;
  643. },function(error){
  644. });
  645. });
  646. $ionicModal.fromTemplateUrl('my-modal.html', {
  647. scope: $scope,
  648. animation: 'slide-in-up'
  649. }).then(function (modal) {
  650. $scope.modal = modal;
  651. });
  652. $scope.openModal = function () {
  653. $scope.modal.show();
  654. };
  655. $scope.closeModal = function () {
  656. $scope.modal.hide();
  657. };
  658. //我的回复
  659. $scope.vm={
  660. content:"",
  661. comment_id:""
  662. };
  663. $scope.myReplay = function(){
  664. var data = {
  665. content:$scope.vm.content,
  666. comment_id:$scope.vm.id
  667. };
  668. myService.myReplay(data).then(function(result){
  669. },function(error){
  670. });
  671. $scope.modal.hide();
  672. }
  673. }]);
  674. })(angular.module('app.controllers'));