my.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  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('careCtrl', ["$scope","$ionicTabsDelegate",'$ionicModal',"$state", "myService", "msg","storage"
  262. , function ($scope,$ionicTabsDelegate,$ionicModal, $state,myService, msg, storage) {
  263. $scope.$on('$ionicView.beforeEnter', function () {
  264. myService.careMe().then(function(result){
  265. $scope.users = result.data.data;
  266. },function(error){
  267. })
  268. });
  269. $scope.toMyUserDetail = function (id) {
  270. myService.toMyUserDetail(id).then(function(result){
  271. $scope.items = result.data.data;
  272. $state.go('app.attention_Detail',{id:id,items:$scope.items});
  273. },function(error){
  274. //msg.error(msg.data.error)
  275. })
  276. };
  277. $ionicModal.fromTemplateUrl('my-modal.html', {
  278. scope: $scope,
  279. animation: 'slide-in-up'
  280. }).then(function (modal) {
  281. $scope.modal = modal;
  282. });
  283. //发私信
  284. $scope.vm={
  285. content:"",
  286. comment_id:""
  287. };
  288. $scope.closeModal = function () {
  289. var data = {
  290. content: $scope.vm.content,
  291. to_user_id: $scope.item.id
  292. };
  293. myService.sendLetter(data).then(function (result) {
  294. msg.success('回复成功');
  295. $scope.vm.content = '';
  296. $scope.item = null;
  297. $scope.modal.hide();
  298. }, function (error) {
  299. msg.error('回复失败');
  300. });
  301. };
  302. $scope.hideModal = function(){
  303. $scope.modal.hide();
  304. };
  305. $scope.reply = function (user) {
  306. event.stopPropagation();
  307. $scope.item = user;
  308. $scope.modal.show();
  309. }
  310. }]);
  311. app.controller('mySupportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  312. , function ($scope,homeService,$stateParams, $state, msg) {
  313. var user_id = $stateParams.user_id;
  314. $scope.$on('$ionicView.beforeEnter',function(){
  315. $scope.toUserDetail(user_id);
  316. });
  317. $scope.toUserDetail = function(user_id){
  318. homeService.toUserDetail(user_id).then(function(result){
  319. $scope.items = result.data.data;
  320. $scope.user = result.data.data.user;
  321. $scope.dreams = $scope.user.sup_dream;
  322. },function(error){
  323. })
  324. };
  325. $scope.toDetail = function(){
  326. $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  327. }
  328. }]);
  329. app.controller('myOldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  330. , function ($scope,homeService,$stateParams, $state, msg) {
  331. var user_id = $stateParams.user_id;
  332. $scope.$on('$ionicView.beforeEnter',function(){
  333. $scope.toUserDetail(user_id);
  334. });
  335. $scope.toUserDetail = function(user_id){
  336. homeService.toUserDetail(user_id).then(function(result){
  337. $scope.items = result.data.data;
  338. $scope.user = result.data.data.user;
  339. $scope.dreams = $scope.user.dreams;
  340. },function(error){
  341. })
  342. };
  343. $scope.toDetail = function(){
  344. $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  345. };
  346. }]);
  347. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  348. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  349. }]);
  350. app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", '$location',"$state", "myService", "msg","storage"
  351. , function ($scope,$ionicTabsDelegate,$location, $state,myService, msg, storage) {
  352. $scope.$on('$ionicView.beforeEnter', function () {
  353. myService.letter().then(function(result){
  354. $scope.items = result.data.data;
  355. },function(error){
  356. });
  357. });
  358. $scope.toLetter = function(id){
  359. if($location.path()=="/app/home/message/letter"){
  360. console.log($location.path());
  361. $state.go('app.letterDetail')
  362. }
  363. else {
  364. $state.go('app.myLetterDetail')
  365. }
  366. }
  367. }]);
  368. app.controller('letterDetailCtrl', ["$scope","$ionicTabsDelegate",'$stateParams',"$state", "myService", "msg","storage"
  369. , function ($scope,$ionicTabsDelegate,$stateParams, $state,myService, msg, storage) {
  370. var id = $stateParams.id;
  371. $scope.$on('$ionicView.beforeEnter', function () {
  372. myService.letter().then(function(result){
  373. $scope.items = result.data.data;
  374. },function(error){
  375. });
  376. });
  377. }]);
  378. app.controller('rechargeCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService", "msg"
  379. , function ($scope,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService, msg) {
  380. $scope.$on('$ionicView.beforeEnter', function () {
  381. $ionicTabsDelegate.showBar(false);
  382. myService.myInfo().then(function(result){
  383. $scope.vm = result.data.data;
  384. $scope.vm.number = '';
  385. $scope.vm.payType = 2;
  386. })
  387. });
  388. $scope.payExplain = function(){
  389. $state.go("app.payExplain")
  390. };
  391. $scope.withdraw = function(){
  392. $state.go("app.withdraw")
  393. };
  394. $scope.testcharge = function(number){
  395. if (!number) {
  396. msg.text('请输入充值金额');
  397. return;
  398. }
  399. myService.testcharge(number,2).then(function (result) {
  400. msg.text("充值成功");
  401. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  402. // $timeout(function(){
  403. // $ionicHistory.goBack();
  404. // },500)
  405. });
  406. };
  407. //充值
  408. $scope.charge = function(number){
  409. if (!number) {
  410. msg.text('请输入充值金额');
  411. return;
  412. }
  413. myService.charge(number,2).then(function (result) {
  414. //todo:result需要返回支付宝或者微信的签名信息
  415. console.log("result: " + JSON.stringify(result));
  416. var payInfo = result.data.data;
  417. if ($scope.vm.payType == 1) { //支付宝
  418. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  419. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  420. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  421. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  422. //当e.resultStatus为9000时,请去服务端验证支付结果
  423. $scope.clicksub = false;
  424. if (e.resultStatus == '9000') {
  425. alert(orderID);
  426. //支付成功
  427. // $state.go('app.my');
  428. } else {
  429. msg.error("支付失败");
  430. // msg.error("支付失败:" + JSON.stringify(e));
  431. }
  432. }, function error(e) {
  433. $scope.clicksub = false;
  434. // msg.error("支付失败:" + JSON.stringify(e));
  435. msg.error("支付失败");
  436. });
  437. }
  438. if ($scope.vm.payType == 2) { //微信
  439. // var obj = JSON.parse(payInfo);
  440. var obj = payInfo.orderString;
  441. // console.log("obj: " + JSON.stringify(obj));
  442. var params = {
  443. partnerid: obj.partnerid, // merchant id
  444. prepayid: obj.prepayid, // prepay id
  445. noncestr: obj.noncestr, // nonce
  446. timestamp: obj.timestamp, // timestamp
  447. sign: obj.sign, // signed string
  448. };
  449. // console.log("result: " + JSON.stringify(params));
  450. Wechat.sendPaymentRequest(params, function (r) {
  451. $scope.clicksub = false;
  452. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  453. // alert(result);
  454. //支付成功
  455. // $state.go('app.my');
  456. }, function (erro) {
  457. // msg.alert("支付反馈失败:" + JSON.stringify(erro));
  458. });
  459. }, function (reason) {
  460. $scope.clicksub = false;
  461. // msg.alert("支付失败:" + JSON.stringify(reason));
  462. });
  463. }
  464. // msg.text("充值成功");
  465. // $state.go('app.my');
  466. });
  467. }
  468. }]);
  469. app.controller('payCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$timeout","$ionicHistory","$state", "myService", "msg"
  470. , function ($scope,$timeout,$ionicHistory,$ionicTabsDelegate, $timeout,$ionicHistory,$state, myService, msg) {
  471. $scope.$on('$ionicView.beforeEnter', function () {
  472. myService.myInfo().then(function(result){
  473. $scope.vm = result.data.data;
  474. $scope.vm.money = '';
  475. $scope.vm.payType = 2;
  476. })
  477. });
  478. $scope.payExplain = function(){
  479. $state.go("app.explain")
  480. };
  481. $scope.withdraw = function(){
  482. $state.go("app.payout")
  483. };
  484. //充值
  485. $scope.testcharge = function(number){
  486. if (!number) {
  487. msg.text('请输入充值金额');
  488. return;
  489. }
  490. myService.testcharge(number,2).then(function (result) {
  491. msg.text("充值成功");
  492. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  493. $timeout(function(){
  494. $ionicHistory.goBack();
  495. },500)
  496. });
  497. }
  498. //充值
  499. $scope.charge = function(number){
  500. if (!number) {
  501. msg.text('请输入充值金额');
  502. return;
  503. }
  504. myService.charge(number,2).then(function (result) {
  505. //todo:result需要返回支付宝或者微信的签名信息
  506. console.log("result: " + JSON.stringify(result));
  507. var payInfo = result.data;
  508. if ($scope.vm.payType == 1) { //支付宝
  509. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  510. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  511. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  512. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  513. //当e.resultStatus为9000时,请去服务端验证支付结果
  514. $scope.clicksub = false;
  515. if (e.resultStatus == '9000') {
  516. alert(orderID);
  517. //支付成功
  518. // $state.go('app.my');
  519. } else {
  520. msg.error("支付失败");
  521. // msg.error("支付失败:" + JSON.stringify(e));
  522. }
  523. }, function error(e) {
  524. $scope.clicksub = false;
  525. // msg.error("支付失败:" + JSON.stringify(e));
  526. msg.error("支付失败");
  527. });
  528. }
  529. if ($scope.vm.payType == 2) { //微信
  530. var obj = JSON.parse(payInfo);
  531. var params = {
  532. partnerid: obj.partnerid, // merchant id
  533. prepayid: obj.prepayid, // prepay id
  534. noncestr: obj.noncestr, // nonce
  535. timestamp: obj.timestamp, // timestamp
  536. sign: obj.sign, // signed string
  537. };
  538. Wechat.sendPaymentRequest(params, function (r) {
  539. $scope.clicksub = false;
  540. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  541. // alert(result);
  542. //支付成功
  543. // $state.go('app.my');
  544. }, function (erro) {
  545. msg.alert("支付反馈失败:" + JSON.stringify(erro));
  546. });
  547. }, function (reason) {
  548. $scope.clicksub = false;
  549. msg.alert("支付失败:" + JSON.stringify(reason));
  550. });
  551. }
  552. // msg.text("充值成功");
  553. // $state.go('app.my');
  554. });
  555. }
  556. }]);
  557. app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  558. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  559. $scope.$on('$ionicView.beforeEnter', function () {
  560. $ionicTabsDelegate.showBar(false);
  561. $scope.showAccount();
  562. });
  563. $scope.showAccount = function(){
  564. myService.showAccount().then(function(result){
  565. $scope.items = result.data.data;
  566. },function(error){
  567. msg.error(error.data.message);
  568. })
  569. };
  570. $scope.destroyAccount = function(id){
  571. myService.destroyAccount(id).then(function(result){
  572. msg.text("删除成功");
  573. $scope.showAccount();
  574. },function(error){
  575. msg.error(error.data.message);
  576. })
  577. }
  578. }]);
  579. app.controller('my_account_addCtrl', ["$scope","config","common","$timeout","$ionicTabsDelegate", "$state", "myService", "msg"
  580. , function ($scope,config,common,$timeout,$ionicTabsDelegate, $state, myService, msg) {
  581. $scope.addpict = function () {
  582. common.chooseImage().then(function (qrcode) {
  583. common.uploadFiles(qrcode,1).then(function (result) {
  584. var response = JSON.parse(result.response);
  585. var file = config.imgServer+response.data.file;
  586. $scope.vm.file = file;
  587. $scope.qrcode.push(file);
  588. }, function (error) {
  589. msg.error('图片上传失败');
  590. });
  591. }, function (error) {
  592. console.log('图片选择失败');
  593. });
  594. };
  595. $scope.qrcode=[];
  596. $scope.deletefile = function (file) {
  597. var index = $scope.qrcode.indexOf(file);
  598. $scope.qrcode.splice(index, 1);
  599. common.deletefile(file).then(function () {
  600. })
  601. };
  602. $scope.vm={
  603. bank_name:'',
  604. bank_number:'',
  605. bank_phone:'',
  606. bank_user:'',
  607. type:""
  608. };
  609. $scope.addAccount = function () {
  610. var data = {
  611. data:{
  612. bank_name:$scope.vm.bank_name,
  613. bank_number:$scope.vm.bank_number,
  614. bank_phone:$scope.vm.bank_phone,
  615. bank_user:$scope.vm.bank_user
  616. }
  617. };
  618. //msg.loading('保存中...');
  619. msg.loading();
  620. myService.addAccount(data).then(function (result) {
  621. msg.hide();
  622. $state.go('app.my_account');
  623. }, function (error) {
  624. msg.hide();
  625. msg.error(error.data.message);
  626. });
  627. };
  628. $scope.addQrcode = function(){
  629. var data = {
  630. data:{
  631. type:$scope.vm.type,
  632. qrcode:$scope.vm.file
  633. //qrcode:"https://www.baidu.com/img/bd_logo1.png"
  634. }
  635. };
  636. myService.addQrcode(data).then(function(result){
  637. msg.text("添加成功",true);
  638. $state.go("app.my_account");
  639. },function(error){
  640. msg.error(error.data.message);
  641. })
  642. }
  643. }]);
  644. app.controller('messageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  645. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  646. $scope.$on('$ionicView.beforeEnter', function () {
  647. $ionicTabsDelegate.showBar(false);
  648. myService.messageInfo().then(function(result){
  649. $scope.infos = result.data.data;
  650. },function(error){
  651. });
  652. });
  653. //系统消息
  654. $scope.systemInfo = function(){
  655. $state.go("app.my_message_sys");
  656. };
  657. $scope.notRead = function(){
  658. myService.notRead().then(function(result){
  659. myService.messageInfo().then(function(result){
  660. $scope.infos = result.data.data;
  661. },function(error){
  662. });
  663. },function(error){
  664. })
  665. };
  666. //回复我的
  667. $scope.replyMy = function(){
  668. $state.go("app.my_message_reply");
  669. };
  670. $scope.personalLetter = function(){
  671. $state.go("app.personalLetter");
  672. }
  673. }]);
  674. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  675. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  676. $scope.$on('$ionicView.beforeEnter', function () {
  677. $ionicTabsDelegate.showBar(false);
  678. $scope.load(true);
  679. myService.myInfo().then(function(result){
  680. $scope.user = result.data.data
  681. });
  682. });
  683. $scope.filter = {
  684. hasMore: false,
  685. pageIndex: 1,
  686. pageSize: 25
  687. };
  688. $scope.load = function (init) {
  689. if (init) {
  690. $scope.filter.pageIndex = 1;
  691. $scope.dreams = [];
  692. }
  693. msg.loading();
  694. myService.myDream($scope.filter.pageIndex).then(function(result){
  695. msg.hide();
  696. $scope.filter.pageIndex++;
  697. var more = (result.data.data.data.length >= $scope.filter.pageSize);
  698. $scope.filter.hasMore = more;
  699. $scope.dreams = $scope.dreams.concat(result.data.data.data);
  700. if (init) {
  701. $scope.$broadcast('scroll.refreshComplete');
  702. } else {
  703. $scope.$broadcast('scroll.infiniteScrollComplete');
  704. }
  705. },function(error){
  706. msg.hide();
  707. });
  708. };
  709. $scope.toDetail = function (id) {
  710. $state.go('app.my_dreamdetail',{id:id});
  711. };
  712. }]);
  713. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  714. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  715. $scope.$on('$ionicView.beforeEnter', function () {
  716. $ionicTabsDelegate.showBar(false);
  717. myService.collect().then(function(result){
  718. $scope.dreams = result.data.data.dreams;
  719. });
  720. });
  721. $scope.toDetail = function (id) {
  722. $state.go('app.my_dreamdetail',{id:id});
  723. };
  724. }]);
  725. app.controller('messageSysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  726. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  727. $scope.$on('$ionicView.beforeEnter', function () {
  728. myService.systemInfo().then(function(result){
  729. $scope.sysInfos = result.data.data;
  730. },function(error){
  731. });
  732. });
  733. }]);
  734. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  735. , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  736. $scope.$on('$ionicView.beforeEnter', function () {
  737. $scope.load();
  738. });
  739. $scope.load = function () {
  740. myService.replyMy().then(function (result) {
  741. $scope.comments = result.data.data;
  742. }, function (error) {
  743. });
  744. };
  745. //我的回复
  746. $scope.vm = {
  747. content: ""
  748. };
  749. $ionicModal.fromTemplateUrl('my-modal.html', {
  750. scope: $scope,
  751. animation: 'slide-in-up'
  752. }).then(function (modal) {
  753. $scope.modal = modal;
  754. });
  755. //$ionicModal.fromTemplateUrl('my-modal.html', {
  756. // scope: $scope,
  757. // animation: 'slide-in-up'
  758. //}).then(function (modal) {
  759. // $scope.modal = modal;
  760. //});
  761. //$scope.openModal = function () {
  762. // $scope.modal.show();
  763. //};
  764. //$scope.closeModal = function () {
  765. // $scope.modal.hide();
  766. //
  767. //};
  768. $scope.goDetail = function (id,interaction_id){
  769. $state.go('app.home_dreamdetail',{id:id,interaction_id:interaction_id,type:2});
  770. };
  771. //我的回复
  772. //$scope.vm={
  773. // content:"",
  774. // comment_id:""
  775. //};
  776. //$scope.closeModal = function () {
  777. // var data = {
  778. // content: $scope.vm.content,
  779. // comment_id: $scope.item.id,
  780. // interaction_id: $scope.item.interaction_id
  781. // };
  782. // myService.myReplay(data).then(function (result) {
  783. // msg.success('回复成功');
  784. // $scope.load();
  785. // }, function (error) {
  786. // msg.error('回复失败');
  787. // });
  788. // $scope.vm.content = '';
  789. // $scope.item = null;
  790. // $scope.modal.hide();
  791. //};
  792. //
  793. //$scope.reply = function (item) {
  794. // $scope.item = item;
  795. // $scope.modal.show();
  796. //}
  797. }]);
  798. })(angular.module('app.controllers'));