my.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  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. // }]);
  351. app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", '$location',"$state", "myService", "msg","storage"
  352. , function ($scope,$ionicTabsDelegate,$location, $state,myService, msg, storage) {
  353. $scope.$on('$ionicView.beforeEnter', function () {
  354. myService.letter().then(function(result){
  355. $scope.items = result.data.data;
  356. },function(error){
  357. });
  358. });
  359. $scope.toLetter = function(id){
  360. if($location.path()=="/app/home/message/letter"){
  361. console.log($location.path());
  362. $state.go('app.letterDetail')
  363. }
  364. else {
  365. $state.go('app.myLetterDetail')
  366. }
  367. }
  368. }]);
  369. app.controller('letterDetailCtrl', ["$scope","$ionicTabsDelegate",'$stateParams',"$state", "myService", "msg","storage"
  370. , function ($scope,$ionicTabsDelegate,$stateParams, $state,myService, msg, storage) {
  371. var id = $stateParams.id;
  372. $scope.$on('$ionicView.beforeEnter', function () {
  373. myService.letter().then(function(result){
  374. $scope.items = result.data.data;
  375. },function(error){
  376. });
  377. });
  378. }]);
  379. app.controller('rechargeCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService", "msg"
  380. , function ($scope,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService, msg) {
  381. $scope.$on('$ionicView.beforeEnter', function () {
  382. $ionicTabsDelegate.showBar(false);
  383. myService.myInfo().then(function(result){
  384. $scope.vm = result.data.data;
  385. $scope.vm.number = '';
  386. $scope.vm.payType = 2;
  387. })
  388. });
  389. $scope.payExplain = function(){
  390. $state.go("app.payExplain")
  391. };
  392. $scope.withdraw = function(){
  393. $state.go("app.withdraw")
  394. };
  395. $scope.testcharge = function(number){
  396. if (!number) {
  397. msg.text('请输入充值金额');
  398. return;
  399. }
  400. myService.testcharge(number,2).then(function (result) {
  401. msg.text("充值成功");
  402. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  403. // $timeout(function(){
  404. // $ionicHistory.goBack();
  405. // },500)
  406. });
  407. };
  408. //充值
  409. $scope.charge = function(number){
  410. if (!number) {
  411. msg.text('请输入充值金额');
  412. return;
  413. }
  414. myService.charge(number,2).then(function (result) {
  415. //todo:result需要返回支付宝或者微信的签名信息
  416. console.log("result: " + JSON.stringify(result));
  417. var payInfo = result.data.data;
  418. if ($scope.vm.payType == 1) { //支付宝
  419. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  420. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  421. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  422. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  423. //当e.resultStatus为9000时,请去服务端验证支付结果
  424. $scope.clicksub = false;
  425. if (e.resultStatus == '9000') {
  426. alert(orderID);
  427. //支付成功
  428. // $state.go('app.my');
  429. } else {
  430. msg.error("支付失败");
  431. // msg.error("支付失败:" + JSON.stringify(e));
  432. }
  433. }, function error(e) {
  434. $scope.clicksub = false;
  435. // msg.error("支付失败:" + JSON.stringify(e));
  436. msg.error("支付失败");
  437. });
  438. }
  439. if ($scope.vm.payType == 2) { //微信
  440. // var obj = JSON.parse(payInfo);
  441. var obj = payInfo.orderString;
  442. // console.log("obj: " + JSON.stringify(obj));
  443. var params = {
  444. partnerid: obj.partnerid, // merchant id
  445. prepayid: obj.prepayid, // prepay id
  446. noncestr: obj.noncestr, // nonce
  447. timestamp: obj.timestamp, // timestamp
  448. sign: obj.sign, // signed string
  449. };
  450. // console.log("result: " + JSON.stringify(params));
  451. Wechat.sendPaymentRequest(params, function (r) {
  452. $scope.clicksub = false;
  453. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  454. // alert(result);
  455. //支付成功
  456. // $state.go('app.my');
  457. }, function (erro) {
  458. // msg.alert("支付反馈失败:" + JSON.stringify(erro));
  459. });
  460. }, function (reason) {
  461. $scope.clicksub = false;
  462. // msg.alert("支付失败:" + JSON.stringify(reason));
  463. });
  464. }
  465. // msg.text("充值成功");
  466. // $state.go('app.my');
  467. });
  468. }
  469. }]);
  470. app.controller('payCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$timeout","$ionicHistory","$state", "myService", "msg"
  471. , function ($scope,$timeout,$ionicHistory,$ionicTabsDelegate, $timeout,$ionicHistory,$state, myService, msg) {
  472. $scope.$on('$ionicView.beforeEnter', function () {
  473. myService.myInfo().then(function(result){
  474. $scope.vm = result.data.data;
  475. $scope.vm.money = '';
  476. $scope.vm.payType = 2;
  477. })
  478. });
  479. $scope.payExplain = function(){
  480. $state.go("app.explain")
  481. };
  482. $scope.withdraw = function(){
  483. $state.go("app.payout")
  484. };
  485. //充值
  486. $scope.testcharge = function(number){
  487. if (!number) {
  488. msg.text('请输入充值金额');
  489. return;
  490. }
  491. myService.testcharge(number,2).then(function (result) {
  492. msg.text("充值成功");
  493. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  494. $timeout(function(){
  495. $ionicHistory.goBack();
  496. },500)
  497. });
  498. }
  499. //充值
  500. $scope.charge = function(number){
  501. if (!number) {
  502. msg.text('请输入充值金额');
  503. return;
  504. }
  505. myService.charge(number,2).then(function (result) {
  506. //todo:result需要返回支付宝或者微信的签名信息
  507. console.log("result: " + JSON.stringify(result));
  508. var payInfo = result.data;
  509. if ($scope.vm.payType == 1) { //支付宝
  510. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  511. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  512. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  513. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  514. //当e.resultStatus为9000时,请去服务端验证支付结果
  515. $scope.clicksub = false;
  516. if (e.resultStatus == '9000') {
  517. alert(orderID);
  518. //支付成功
  519. // $state.go('app.my');
  520. } else {
  521. msg.error("支付失败");
  522. // msg.error("支付失败:" + JSON.stringify(e));
  523. }
  524. }, function error(e) {
  525. $scope.clicksub = false;
  526. // msg.error("支付失败:" + JSON.stringify(e));
  527. msg.error("支付失败");
  528. });
  529. }
  530. if ($scope.vm.payType == 2) { //微信
  531. var obj = JSON.parse(payInfo);
  532. var params = {
  533. partnerid: obj.partnerid, // merchant id
  534. prepayid: obj.prepayid, // prepay id
  535. noncestr: obj.noncestr, // nonce
  536. timestamp: obj.timestamp, // timestamp
  537. sign: obj.sign, // signed string
  538. };
  539. Wechat.sendPaymentRequest(params, function (r) {
  540. $scope.clicksub = false;
  541. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  542. // alert(result);
  543. //支付成功
  544. // $state.go('app.my');
  545. }, function (erro) {
  546. msg.alert("支付反馈失败:" + JSON.stringify(erro));
  547. });
  548. }, function (reason) {
  549. $scope.clicksub = false;
  550. msg.alert("支付失败:" + JSON.stringify(reason));
  551. });
  552. }
  553. // msg.text("充值成功");
  554. // $state.go('app.my');
  555. });
  556. }
  557. }]);
  558. app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  559. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  560. $scope.$on('$ionicView.beforeEnter', function () {
  561. $ionicTabsDelegate.showBar(false);
  562. $scope.showAccount();
  563. });
  564. $scope.showAccount = function(){
  565. myService.showAccount().then(function(result){
  566. $scope.items = result.data.data;
  567. },function(error){
  568. msg.error(error.data.message);
  569. })
  570. };
  571. $scope.destroyAccount = function(id){
  572. myService.destroyAccount(id).then(function(result){
  573. msg.text("删除成功");
  574. $scope.showAccount();
  575. },function(error){
  576. msg.error(error.data.message);
  577. })
  578. }
  579. }]);
  580. app.controller('my_account_addCtrl', ["$scope","config","common","$timeout","$ionicTabsDelegate", "$state", "myService", "msg"
  581. , function ($scope,config,common,$timeout,$ionicTabsDelegate, $state, myService, msg) {
  582. $scope.addpict = function () {
  583. common.chooseImage().then(function (qrcode) {
  584. common.uploadFiles(qrcode,1).then(function (result) {
  585. var response = JSON.parse(result.response);
  586. var file = config.imgServer+response.data.file;
  587. $scope.vm.file = file;
  588. $scope.qrcode.push(file);
  589. }, function (error) {
  590. msg.error('图片上传失败');
  591. });
  592. }, function (error) {
  593. console.log('图片选择失败');
  594. });
  595. };
  596. $scope.qrcode=[];
  597. $scope.deletefile = function (file) {
  598. var index = $scope.qrcode.indexOf(file);
  599. $scope.qrcode.splice(index, 1);
  600. common.deletefile(file).then(function () {
  601. })
  602. };
  603. $scope.vm={
  604. bank_name:'',
  605. bank_number:'',
  606. bank_phone:'',
  607. bank_user:'',
  608. type:""
  609. };
  610. $scope.addAccount = function () {
  611. var data = {
  612. data:{
  613. bank_name:$scope.vm.bank_name,
  614. bank_number:$scope.vm.bank_number,
  615. bank_phone:$scope.vm.bank_phone,
  616. bank_user:$scope.vm.bank_user
  617. }
  618. };
  619. //msg.loading('保存中...');
  620. msg.loading();
  621. myService.addAccount(data).then(function (result) {
  622. msg.hide();
  623. $state.go('app.my_account');
  624. }, function (error) {
  625. msg.hide();
  626. msg.error(error.data.message);
  627. });
  628. };
  629. $scope.addQrcode = function(){
  630. var data = {
  631. data:{
  632. type:$scope.vm.type,
  633. qrcode:$scope.vm.file
  634. //qrcode:"https://www.baidu.com/img/bd_logo1.png"
  635. }
  636. };
  637. myService.addQrcode(data).then(function(result){
  638. msg.text("添加成功",true);
  639. $state.go("app.my_account");
  640. },function(error){
  641. msg.error(error.data.message);
  642. })
  643. }
  644. }]);
  645. app.controller('messageCtrl', ["$scope", "$location","$ionicTabsDelegate","$state", "myService", "msg"
  646. , function ($scope,$location,$ionicTabsDelegate, $state, myService, msg) {
  647. $scope.$on('$ionicView.beforeEnter', function () {
  648. $ionicTabsDelegate.showBar(false);
  649. myService.messageInfo().then(function(result){
  650. $scope.infos = result.data.data;
  651. },function(error){
  652. });
  653. });
  654. $scope.notRead = function(){
  655. myService.notRead().then(function(result){
  656. myService.messageInfo().then(function(result){
  657. $scope.infos = result.data.data;
  658. },function(error){
  659. });
  660. },function(error){
  661. })
  662. };
  663. //梦想消息
  664. $scope.systemInfo = function(){
  665. if($location.path()=='/app/my/message'){
  666. $state.go("app.my_message_sys");
  667. }
  668. else {
  669. $state.go("app.message_sys");
  670. //myService.systemInfo().then(function(result){
  671. //},function(error){
  672. //
  673. //});
  674. }
  675. };
  676. //支持消息
  677. $scope.replyMy = function(){
  678. if($location.path()=='/app/my/message'){
  679. $state.go("app.my_message_reply");
  680. }
  681. else {
  682. $state.go("app.message_reply");
  683. }
  684. };
  685. //通知
  686. $scope.personalLetter = function(){
  687. if($location.path()=='/app/my/message'){
  688. $state.go("app.personalLetter");
  689. }
  690. else {
  691. $state.go("app.letter");
  692. }
  693. };
  694. }]);
  695. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  696. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  697. $scope.$on('$ionicView.beforeEnter', function () {
  698. $ionicTabsDelegate.showBar(false);
  699. $scope.load(true);
  700. myService.myInfo().then(function(result){
  701. $scope.user = result.data.data
  702. });
  703. });
  704. $scope.filter = {
  705. hasMore: false,
  706. pageIndex: 1,
  707. pageSize: 25
  708. };
  709. $scope.load = function (init) {
  710. if (init) {
  711. $scope.filter.pageIndex = 1;
  712. $scope.dreams = [];
  713. }
  714. msg.loading();
  715. myService.myDream($scope.filter.pageIndex).then(function(result){
  716. msg.hide();
  717. $scope.filter.pageIndex++;
  718. var more = (result.data.data.data.length >= $scope.filter.pageSize);
  719. $scope.filter.hasMore = more;
  720. $scope.dreams = $scope.dreams.concat(result.data.data.data);
  721. if (init) {
  722. $scope.$broadcast('scroll.refreshComplete');
  723. } else {
  724. $scope.$broadcast('scroll.infiniteScrollComplete');
  725. }
  726. },function(error){
  727. msg.hide();
  728. });
  729. };
  730. $scope.toDetail = function (id) {
  731. $state.go('app.my_dreamdetail',{id:id});
  732. };
  733. }]);
  734. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  735. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  736. $scope.$on('$ionicView.beforeEnter', function () {
  737. $ionicTabsDelegate.showBar(false);
  738. myService.collect().then(function(result){
  739. $scope.dreams = result.data.data.dreams;
  740. });
  741. });
  742. $scope.toDetail = function (id) {
  743. $state.go('app.my_dreamdetail',{id:id});
  744. };
  745. }]);
  746. app.controller('messageSysCtrl', ["$scope","$location", "$ionicTabsDelegate","$state", "myService", "msg"
  747. , function ($scope,$location,$ionicTabsDelegate, $state, myService, msg) {
  748. $scope.$on('$ionicView.beforeEnter', function () {
  749. myService.systemInfo().then(function(result){
  750. $scope.sysInfos = result.data.data;
  751. },function(error){
  752. });
  753. });
  754. var template = '<div>' +
  755. '<textarea name="" id="" cols="30" rows="8" placeholder="对他的好意给予感谢的回复"></textarea>' +
  756. '<a class="btn-file-up" ng-click="addpict()">' +
  757. '<img src="img/icon_photo.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  758. '<em style="font-size: 16px">添加图片</em>' +
  759. '</a>' +
  760. '<a class="btn-file-up" ng-click="addvideo()">' +
  761. '<img src="img/icon_video.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  762. '<em style="font-size: 16px">添加视频</em>' +
  763. '</a>' +
  764. '<a ng-repeat="item in imgs" ng-click="showImages(item)" class="img-file-up">' +
  765. '<b style="background-image:url({{item}});"><em ng-click="deletefile(item)" class="ion-ios-close-outline"></em></b>' +
  766. '</a>' +
  767. '<div class="img-file-up" ng-if="video.isOK">' +
  768. '<div style="position:relative;">' +
  769. '<em ng-click="deletevideo(video.file)" class="ion-ios-close-outline"></em>' +
  770. '<video ng-src="{{video.file | trustUrl}}" poster="{{video.vpic}}" controls="controls"></video>' +
  771. '</div>' +
  772. '</div>' +
  773. '</div>';
  774. $scope.goMes = function(is_reply,is_url,dream_id){
  775. if(is_reply==1){
  776. msg.confirm('Brian向你的梦想支持了300梦想币!',template)
  777. }
  778. if(is_url==1){
  779. if($location.path()=="/app/home/message/sys"){
  780. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  781. }
  782. else {
  783. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  784. }
  785. }
  786. }
  787. }]);
  788. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  789. , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  790. $scope.$on('$ionicView.beforeEnter', function () {
  791. $scope.load();
  792. });
  793. $scope.load = function () {
  794. myService.replyMy().then(function (result) {
  795. $scope.comments = result.data.data;
  796. }, function (error) {
  797. });
  798. };
  799. //我的回复
  800. $scope.vm = {
  801. content: ""
  802. };
  803. $ionicModal.fromTemplateUrl('my-modal.html', {
  804. scope: $scope,
  805. animation: 'slide-in-up'
  806. }).then(function (modal) {
  807. $scope.modal = modal;
  808. });
  809. //$ionicModal.fromTemplateUrl('my-modal.html', {
  810. // scope: $scope,
  811. // animation: 'slide-in-up'
  812. //}).then(function (modal) {
  813. // $scope.modal = modal;
  814. //});
  815. //$scope.openModal = function () {
  816. // $scope.modal.show();
  817. //};
  818. //$scope.closeModal = function () {
  819. // $scope.modal.hide();
  820. //
  821. //};
  822. $scope.goDetail = function (id,interaction_id){
  823. $state.go('app.home_dreamdetail',{id:id,interaction_id:interaction_id,type:2});
  824. };
  825. //我的回复
  826. //$scope.vm={
  827. // content:"",
  828. // comment_id:""
  829. //};
  830. //$scope.closeModal = function () {
  831. // var data = {
  832. // content: $scope.vm.content,
  833. // comment_id: $scope.item.id,
  834. // interaction_id: $scope.item.interaction_id
  835. // };
  836. // myService.myReplay(data).then(function (result) {
  837. // msg.success('回复成功');
  838. // $scope.load();
  839. // }, function (error) {
  840. // msg.error('回复失败');
  841. // });
  842. // $scope.vm.content = '';
  843. // $scope.item = null;
  844. // $scope.modal.hide();
  845. //};
  846. //
  847. //$scope.reply = function (item) {
  848. // $scope.item = item;
  849. // $scope.modal.show();
  850. //}
  851. }]);
  852. })(angular.module('app.controllers'));