my.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  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.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 obj = payInfo.orderString;
  372. // console.log("obj: " + JSON.stringify(obj));
  373. var params = {
  374. partnerid: obj.partnerid, // merchant id
  375. prepayid: obj.prepayid, // prepay id
  376. noncestr: obj.noncestr, // nonce
  377. timestamp: obj.timestamp, // timestamp
  378. sign: obj.sign, // signed string
  379. };
  380. // console.log("result: " + JSON.stringify(params));
  381. Wechat.sendPaymentRequest(params, function (r) {
  382. $scope.clicksub = false;
  383. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  384. // alert(result);
  385. //支付成功
  386. // $state.go('app.my');
  387. }, function (erro) {
  388. // msg.alert("支付反馈失败:" + JSON.stringify(erro));
  389. });
  390. }, function (reason) {
  391. $scope.clicksub = false;
  392. // msg.alert("支付失败:" + JSON.stringify(reason));
  393. });
  394. }
  395. // msg.text("充值成功");
  396. // $state.go('app.my');
  397. });
  398. }
  399. }]);
  400. app.controller('payCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$timeout","$ionicHistory","$state", "myService", "msg"
  401. , function ($scope,$timeout,$ionicHistory,$ionicTabsDelegate, $timeout,$ionicHistory,$state, myService, msg) {
  402. $scope.$on('$ionicView.beforeEnter', function () {
  403. myService.myInfo().then(function(result){
  404. $scope.vm = result.data.data;
  405. $scope.vm.money = '';
  406. $scope.vm.payType = 2;
  407. })
  408. });
  409. $scope.payExplain = function(){
  410. $state.go("app.explain")
  411. };
  412. $scope.withdraw = function(){
  413. $state.go("app.payout")
  414. };
  415. //充值
  416. $scope.testcharge = function(number){
  417. if (!number) {
  418. msg.text('请输入充值金额');
  419. return;
  420. }
  421. myService.testcharge(number,2).then(function (result) {
  422. msg.text("充值成功");
  423. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  424. $timeout(function(){
  425. $ionicHistory.goBack();
  426. },500)
  427. });
  428. }
  429. //充值
  430. $scope.charge = function(number){
  431. if (!number) {
  432. msg.text('请输入充值金额');
  433. return;
  434. }
  435. myService.charge(number,2).then(function (result) {
  436. //todo:result需要返回支付宝或者微信的签名信息
  437. console.log("result: " + JSON.stringify(result));
  438. var payInfo = result.data;
  439. if ($scope.vm.payType == 1) { //支付宝
  440. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  441. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  442. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  443. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  444. //当e.resultStatus为9000时,请去服务端验证支付结果
  445. $scope.clicksub = false;
  446. if (e.resultStatus == '9000') {
  447. alert(orderID);
  448. //支付成功
  449. // $state.go('app.my');
  450. } else {
  451. msg.error("支付失败");
  452. // msg.error("支付失败:" + JSON.stringify(e));
  453. }
  454. }, function error(e) {
  455. $scope.clicksub = false;
  456. // msg.error("支付失败:" + JSON.stringify(e));
  457. msg.error("支付失败");
  458. });
  459. }
  460. if ($scope.vm.payType == 2) { //微信
  461. var obj = JSON.parse(payInfo);
  462. var params = {
  463. partnerid: obj.partnerid, // merchant id
  464. prepayid: obj.prepayid, // prepay id
  465. noncestr: obj.noncestr, // nonce
  466. timestamp: obj.timestamp, // timestamp
  467. sign: obj.sign, // signed string
  468. };
  469. Wechat.sendPaymentRequest(params, function (r) {
  470. $scope.clicksub = false;
  471. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  472. // alert(result);
  473. //支付成功
  474. // $state.go('app.my');
  475. }, function (erro) {
  476. msg.alert("支付反馈失败:" + JSON.stringify(erro));
  477. });
  478. }, function (reason) {
  479. $scope.clicksub = false;
  480. msg.alert("支付失败:" + JSON.stringify(reason));
  481. });
  482. }
  483. // msg.text("充值成功");
  484. // $state.go('app.my');
  485. });
  486. }
  487. }]);
  488. app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  489. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  490. $scope.$on('$ionicView.beforeEnter', function () {
  491. $ionicTabsDelegate.showBar(false);
  492. $scope.showAccount();
  493. });
  494. $scope.showAccount = function(){
  495. myService.showAccount().then(function(result){
  496. $scope.items = result.data.data;
  497. },function(error){
  498. msg.error(error.data.message);
  499. })
  500. };
  501. $scope.destroyAccount = function(id){
  502. myService.destroyAccount(id).then(function(result){
  503. msg.text("删除成功");
  504. $scope.showAccount();
  505. },function(error){
  506. msg.error(error.data.message);
  507. })
  508. }
  509. }]);
  510. app.controller('my_account_addCtrl', ["$scope","config","common","$timeout","$ionicTabsDelegate", "$state", "myService", "msg"
  511. , function ($scope,config,common,$timeout,$ionicTabsDelegate, $state, myService, msg) {
  512. $scope.addpict = function () {
  513. common.chooseImage().then(function (qrcode) {
  514. common.uploadFiles(qrcode,1).then(function (result) {
  515. var response = JSON.parse(result.response);
  516. var file = config.imgServer+response.data.file;
  517. $scope.vm.file = file;
  518. $scope.qrcode.push(file);
  519. }, function (error) {
  520. msg.error('图片上传失败');
  521. });
  522. }, function (error) {
  523. console.log('图片选择失败');
  524. });
  525. };
  526. $scope.qrcode=[];
  527. $scope.deletefile = function (file) {
  528. var index = $scope.qrcode.indexOf(file);
  529. $scope.qrcode.splice(index, 1);
  530. common.deletefile(file).then(function () {
  531. })
  532. };
  533. $scope.vm={
  534. bank_name:'',
  535. bank_number:'',
  536. bank_phone:'',
  537. bank_user:'',
  538. type:""
  539. };
  540. $scope.addAccount = function () {
  541. var data = {
  542. data:{
  543. bank_name:$scope.vm.bank_name,
  544. bank_number:$scope.vm.bank_number,
  545. bank_phone:$scope.vm.bank_phone,
  546. bank_user:$scope.vm.bank_user
  547. }
  548. };
  549. //msg.loading('保存中...');
  550. msg.loading();
  551. myService.addAccount(data).then(function (result) {
  552. msg.hide();
  553. $state.go('app.my_account');
  554. }, function (error) {
  555. msg.hide();
  556. msg.error(error.data.message);
  557. });
  558. };
  559. $scope.addQrcode = function(){
  560. var data = {
  561. data:{
  562. type:$scope.vm.type,
  563. qrcode:$scope.vm.file
  564. //qrcode:"https://www.baidu.com/img/bd_logo1.png"
  565. }
  566. };
  567. myService.addQrcode(data).then(function(result){
  568. msg.text("添加成功",true);
  569. $state.go("app.my_account");
  570. },function(error){
  571. msg.error(error.data.message);
  572. })
  573. }
  574. }]);
  575. app.controller('messageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  576. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  577. $scope.$on('$ionicView.beforeEnter', function () {
  578. $ionicTabsDelegate.showBar(false);
  579. myService.messageInfo().then(function(result){
  580. $scope.infos = result.data.data;
  581. },function(error){
  582. });
  583. });
  584. //系统消息
  585. $scope.systemInfo = function(){
  586. $state.go("app.my_message_sys");
  587. };
  588. $scope.notRead = function(){
  589. myService.notRead().then(function(result){
  590. myService.messageInfo().then(function(result){
  591. $scope.infos = result.data.data;
  592. },function(error){
  593. });
  594. },function(error){
  595. })
  596. };
  597. //回复我的
  598. $scope.replyMy = function(){
  599. $state.go("app.my_message_reply");
  600. };
  601. $scope.personalLetter = function(){
  602. $state.go("app.personalLetter");
  603. }
  604. }]);
  605. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  606. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  607. $scope.$on('$ionicView.beforeEnter', function () {
  608. $ionicTabsDelegate.showBar(false);
  609. $scope.load(true);
  610. myService.myInfo().then(function(result){
  611. $scope.user = result.data.data
  612. });
  613. });
  614. $scope.filter = {
  615. hasMore: false,
  616. pageIndex: 1,
  617. pageSize: 25
  618. };
  619. $scope.load = function (init) {
  620. if (init) {
  621. $scope.filter.pageIndex = 1;
  622. $scope.dreams = [];
  623. }
  624. msg.loading();
  625. myService.myDream($scope.filter.pageIndex).then(function(result){
  626. msg.hide();
  627. $scope.filter.pageIndex++;
  628. var more = (result.data.data.data.length >= $scope.filter.pageSize);
  629. $scope.filter.hasMore = more;
  630. $scope.dreams = $scope.dreams.concat(result.data.data.data);
  631. if (init) {
  632. $scope.$broadcast('scroll.refreshComplete');
  633. } else {
  634. $scope.$broadcast('scroll.infiniteScrollComplete');
  635. }
  636. },function(error){
  637. msg.hide();
  638. });
  639. };
  640. $scope.toDetail = function (id) {
  641. $state.go('app.my_dreamdetail',{id:id});
  642. };
  643. }]);
  644. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  645. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  646. $scope.$on('$ionicView.beforeEnter', function () {
  647. $ionicTabsDelegate.showBar(false);
  648. myService.collect().then(function(result){
  649. $scope.dreams = result.data.data.dreams;
  650. });
  651. });
  652. $scope.toDetail = function (id) {
  653. $state.go('app.my_dreamdetail',{id:id});
  654. };
  655. }]);
  656. app.controller('messageSysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  657. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  658. $scope.$on('$ionicView.beforeEnter', function () {
  659. myService.systemInfo().then(function(result){
  660. $scope.sysInfos = result.data.data;
  661. },function(error){
  662. });
  663. });
  664. }]);
  665. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  666. , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  667. $scope.$on('$ionicView.beforeEnter', function () {
  668. myService.replyMy().then(function(result){
  669. $scope.comments = result.data.data;
  670. },function(error){
  671. });
  672. });
  673. $ionicModal.fromTemplateUrl('my-modal.html', {
  674. scope: $scope,
  675. animation: 'slide-in-up'
  676. }).then(function (modal) {
  677. $scope.modal = modal;
  678. });
  679. $scope.openModal = function () {
  680. $scope.modal.show();
  681. };
  682. $scope.closeModal = function () {
  683. $scope.modal.hide();
  684. };
  685. //我的回复
  686. $scope.vm={
  687. content:"",
  688. comment_id:""
  689. };
  690. $scope.myReplay = function(){
  691. var data = {
  692. content:$scope.vm.content,
  693. comment_id:$scope.vm.id
  694. };
  695. myService.myReplay(data).then(function(result){
  696. },function(error){
  697. });
  698. $scope.modal.hide();
  699. }
  700. }]);
  701. })(angular.module('app.controllers'));