my.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  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. myService.saveMaterial(data).then(function(result){
  75. msg.hide();
  76. msg.success("保存成功!");
  77. $state.go('app.my');
  78. myService.myInfo();
  79. },function(error){
  80. msg.hide();
  81. msg.error(error.data.message);
  82. })
  83. }
  84. }]);
  85. app.controller('settingCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  86. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  87. $scope.$on('$ionicView.beforeEnter', function () {
  88. $ionicTabsDelegate.showBar(false);
  89. });
  90. //退出登陆
  91. $scope.logout = function(){
  92. storage.remove("token");
  93. storage.remove("user");
  94. $state.go("login");
  95. }
  96. }]);
  97. app.controller('aboutMiaoCtrl', ["$scope","$ionicTabsDelegate","$timeout", "$state", "myService", "msg","storage"
  98. , function ($scope,$ionicTabsDelegate,$timeout, $state,myService, msg, storage) {
  99. $scope.$on('$ionicView.beforeEnter', function () {
  100. $scope.aboutMiao();
  101. });
  102. $scope.aboutMiao = function(){
  103. myService.aboutMiao().then(function(result){
  104. $scope.items = result.data.data;
  105. },function(error){
  106. msg.error(error.data.message)
  107. })
  108. };
  109. }]);
  110. app.controller('withdrawCtrl', ["$scope","$ionicTabsDelegate","$ionicHistory","$timeout", "$state", "myService", "msg","storage"
  111. , function ($scope,$ionicTabsDelegate, $ionicHistory,$timeout,$state,myService, msg, storage) {
  112. $scope.vm={
  113. pay:"",
  114. cash:""
  115. };
  116. $scope.$on("$ionicView.enter",function(){
  117. myService.showAccount().then(function(result){
  118. $scope.accountId = result.data.data;
  119. var items = result.data.data;
  120. if(items.length==0){
  121. msg.text("请先添加账户");
  122. $state.go("app.my_account_add");
  123. return
  124. }
  125. $scope.pays=[];
  126. angular.forEach(items,function(item){
  127. if(item.bank_name!=null) {
  128. var value=item.bank_name+"(";
  129. var len=item.bank_number.length;
  130. var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
  131. var txt2=item.bank_number.substr(len-4,4);
  132. value=value+txt1+txt2+")";
  133. }
  134. else {
  135. value=item.type;
  136. }
  137. $scope.pays.push({id:item.id,value:value});
  138. });
  139. $scope.vm.pay = $scope.pays[0]
  140. },function(error){
  141. msg.error(error.data.message)
  142. })
  143. });
  144. $scope.withdraw = function(){
  145. var data = {
  146. data:{
  147. bank_id:$scope.vm.pay.id,
  148. cash:$scope.vm.cash
  149. }
  150. };
  151. myService.withdraw(data).then(function(result){
  152. msg.text("提现申请已提交");
  153. $timeout(function () {
  154. $ionicHistory.goBack();
  155. },1000);
  156. },function(error){
  157. })
  158. }
  159. }]);
  160. app.controller('payoutCtrl', ["$scope","$ionicTabsDelegate","$timeout","$ionicHistory", "$state", "myService", "msg","storage"
  161. , function ($scope,$ionicTabsDelegate, $timeout, $ionicHistory,$state,myService, msg, storage) {
  162. $scope.vm={
  163. pay:"",
  164. cash:""
  165. };
  166. $scope.$on("$ionicView.enter",function(){
  167. myService.showAccount().then(function(result){
  168. $scope.accountId = result.data.data;
  169. var items = result.data.data;
  170. $scope.pays=[];
  171. angular.forEach(items,function(item){
  172. if(item.bank_name!=null) {
  173. var value=item.bank_name+"(";
  174. var len=item.bank_number.length;
  175. var txt1=item.bank_number.substr(0,len-4).replace(/\d+/g,'**');
  176. var txt2=item.bank_number.substr(len-4,4);
  177. value=value+txt1+txt2+")";
  178. }
  179. else {
  180. value=item.type;
  181. }
  182. $scope.pays.push({id:item.id,value:value});
  183. })
  184. },function(error){
  185. msg.error(error.data.message)
  186. })
  187. });
  188. $scope.withdraw = function(){
  189. var data = {
  190. data:{
  191. bank_id:$scope.vm.pay.id,
  192. cash:$scope.vm.cash
  193. }
  194. };
  195. myService.withdraw(data).then(function(result){
  196. msg.text("提现申请已提交");
  197. $timeout(function () {
  198. $ionicHistory.goBack();
  199. },1000);
  200. },function(error){
  201. })
  202. }
  203. }]);
  204. app.controller('payExplainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  205. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  206. $scope.$on('$ionicView.beforeEnter', function () {
  207. $scope.payExplain();
  208. });
  209. $scope.payExplain = function(){
  210. myService.payExplain().then(function(result){
  211. $scope.items = result.data.data;
  212. },function(error){
  213. msg.error(error.data.message)
  214. })
  215. };
  216. }]);
  217. app.controller('explainCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  218. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  219. }]);
  220. app.controller('contactCtrl', ["$scope","$ionicTabsDelegate", "$timeout","$state", "myService", "msg","storage"
  221. , function ($scope,$ionicTabsDelegate, $timeout,$state,myService, msg, storage) {
  222. $scope.vm={
  223. content:"",
  224. email:""
  225. };
  226. $scope.contact = function(){
  227. var data={
  228. data:{
  229. content:$scope.vm.content,
  230. email:$scope.vm.email
  231. }
  232. };
  233. myService.contact(data).then(function(result){
  234. msg.text("发送成功");
  235. $timeout(function(){
  236. $state.go("app.my");
  237. },1000);
  238. },function(error){
  239. msg.error(error.data.message);
  240. })
  241. }
  242. }]);
  243. app.controller('attentionCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  244. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  245. $scope.$on('$ionicView.beforeEnter', function () {
  246. myService.attention().then(function(result){
  247. $scope.users = result.data.data;
  248. },function(error){
  249. })
  250. });
  251. $scope.toMyUserDetail = function (id) {
  252. myService.toMyUserDetail(id).then(function(result){
  253. $scope.items = result.data.data;
  254. $state.go('app.attention_Detail',{id:id,items:$scope.items});
  255. },function(error){
  256. //msg.error(msg.data.error)
  257. })
  258. };
  259. }]);
  260. app.controller('attention_DetailCtrl', ["$scope", "$state", "$ionicModal","storage","msg", "common", "config", "homeService", "$ionicTabsDelegate", "$stateParams", "$ionicModal", "$timeout", "$ionicScrollDelegate", "$interval"
  261. , function ($scope, $state,$ionicModal, storage , msg, common, config, homeService, $ionicTabsDelegate, $stateParams, $ionicModal, $timeout, $ionicScrollDelegate, $interval) {
  262. var id = $stateParams.id;
  263. $scope.items = $stateParams.items;
  264. $scope.$on('$ionicView.beforeEnter', function () {
  265. $ionicTabsDelegate.showBar(false);
  266. });
  267. $scope.attentionUser = function(is_care){
  268. homeService.attentionUser(id,is_care).then(function(result){
  269. $scope.items.is_care=result.data.data;
  270. })
  271. };
  272. $scope.next = function (type) {
  273. //type:1 前一个,type:2 后一个
  274. if($scope.items.imgs.length>0){
  275. if(type==1)
  276. {
  277. var temp= $scope.items.imgs.splice(0,1);
  278. $scope.items.imgs.push(temp[0]);
  279. }
  280. if (type==2){
  281. var temp= $scope.items.imgs.splice($scope.items.imgs.length-1,1);
  282. $scope.items.imgs.unshift(temp[0]);
  283. }
  284. }
  285. };
  286. $scope.bigImage = false;
  287. $scope.showBigImage = function(imageName){
  288. $scope.url = imageName;
  289. $scope.bigImage = true;
  290. };
  291. $scope.hideBigImage = function(){
  292. $scope.bigImage = false;
  293. };
  294. $scope.cancelSupport = function () {
  295. $scope.tosupport = false;
  296. $scope.toshare = false;
  297. };
  298. $scope.toshare = false;
  299. $scope.toshare = false;
  300. $scope.toRecharge = function(){
  301. $state.go("app.recharge")
  302. };
  303. $scope.share = function (type,$event) {
  304. $scope.toshare = true;
  305. if (type==0) {//分享给朋友
  306. /* Wechat.share({
  307. text: "分享的文字",
  308. scene: Wechat.Scene.SESSION // share to 好友
  309. }, function () {
  310. alert("Success");
  311. }, function (reason) {
  312. alert("Failed: " + reason);
  313. });*/
  314. Wechat.share({
  315. message: {
  316. title:"瞄瞄",
  317. description:"HELLO,这是我的个人资料,快来围观吧!",
  318. thumb:"img/icon_cat_h.png",
  319. media: {
  320. type: Wechat.Type.WEBPAGE,
  321. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  322. }
  323. },
  324. scene: Wechat.Scene.SESSION
  325. }, function () {
  326. alert("Success");
  327. }, function (reason) {
  328. alert("Failed: " + reason);
  329. });
  330. }
  331. if(type==1){
  332. Wechat.share({
  333. message: {
  334. title:"瞄瞄",
  335. description:"HELLO,这是我的个人资料,快来围观吧!",
  336. thumb:"img/icon_cat_h.png",
  337. media: {
  338. type: Wechat.Type.WEBPAGE,
  339. webpageUrl: "q8.9026.com//admin/share/view?id=" + id
  340. }
  341. },
  342. scene: Wechat.Scene.TIMELINE
  343. }, function () {
  344. alert("Success");
  345. }, function (reason) {
  346. alert("Failed: " + reason);
  347. });
  348. }
  349. // $state.go("app.shareDream",{item:$scope.dream});
  350. };
  351. $scope.toDetail = function (dream_id) {
  352. if($scope.items.near_dream==null){
  353. msg.alert("当前梦想","该用户没有当前梦想");
  354. }
  355. if($scope.items.near_dream!=null){
  356. var dream_id = $scope.items.near_dream.id;
  357. $state.go('app.my_dreamdetail',{id:dream_id});
  358. }
  359. };
  360. $scope.toOldDream = function(){
  361. if($scope.items.dreams.length<2){
  362. msg.alert("曾经的梦想","该用户没有曾经的梦想");
  363. }
  364. if($scope.items.dreams.length>1){
  365. $state.go("app.myOldDream",{user_id:$scope.items.user.id});
  366. }
  367. };
  368. $scope.toSupportDream = function(){
  369. if($scope.items.sup_dreams.length==0){
  370. msg.alert("支持的梦想","该用户没有支持的梦想");
  371. }
  372. if($scope.items.sup_dreams.length!=0){
  373. $state.go("app.mySupportDream",{user_id:$scope.items.user.id});
  374. }
  375. };
  376. $scope.collectionDream = function(is_collection){
  377. homeService.collectionDream(id,is_collection).then(function(result){
  378. $scope.user.is_collection=result.data.data;
  379. })
  380. };
  381. }]);
  382. app.controller('mySupportDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  383. , function ($scope,homeService,$stateParams, $state, msg) {
  384. var user_id = $stateParams.user_id;
  385. $scope.$on('$ionicView.beforeEnter',function(){
  386. $scope.toUserDetail(user_id);
  387. });
  388. $scope.toUserDetail = function(user_id){
  389. homeService.toUserDetail(user_id).then(function(result){
  390. $scope.items = result.data.data;
  391. $scope.user = result.data.data.user;
  392. $scope.dreams = $scope.user.sup_dream;
  393. },function(error){
  394. })
  395. };
  396. $scope.toDetail = function(){
  397. $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  398. }
  399. }]);
  400. app.controller('myOldDreamCtrl', ["$scope","homeService", "$stateParams","$state", "msg"
  401. , function ($scope,homeService,$stateParams, $state, msg) {
  402. var user_id = $stateParams.user_id;
  403. $scope.$on('$ionicView.beforeEnter',function(){
  404. $scope.toUserDetail(user_id);
  405. });
  406. $scope.toUserDetail = function(user_id){
  407. homeService.toUserDetail(user_id).then(function(result){
  408. $scope.items = result.data.data;
  409. $scope.user = result.data.data.user;
  410. $scope.dreams = $scope.user.dreams;
  411. },function(error){
  412. })
  413. };
  414. $scope.toDetail = function(){
  415. $state.go("app.attention_Detail",{user_id:user_id,items:$scope.items})
  416. };
  417. }]);
  418. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  419. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  420. }]);
  421. app.controller('personalLetterCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg","storage"
  422. , function ($scope,$ionicTabsDelegate, $state,myService, msg, storage) {
  423. $scope.$on('$ionicView.beforeEnter', function () {
  424. myService.letter().then(function(result){
  425. $scope.comments = result.data.data;
  426. },function(error){
  427. });
  428. });
  429. }]);
  430. app.controller('rechargeCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$state", "myService", "msg"
  431. , function ($scope,$timeout, $ionicHistory,$ionicTabsDelegate,$state, myService, msg) {
  432. $scope.$on('$ionicView.beforeEnter', function () {
  433. $ionicTabsDelegate.showBar(false);
  434. myService.myInfo().then(function(result){
  435. $scope.vm = result.data.data;
  436. $scope.vm.number = '';
  437. $scope.vm.payType = 2;
  438. })
  439. });
  440. $scope.payExplain = function(){
  441. $state.go("app.payExplain")
  442. };
  443. $scope.withdraw = function(){
  444. $state.go("app.withdraw")
  445. };
  446. $scope.testcharge = function(number){
  447. if (!number) {
  448. msg.text('请输入充值金额');
  449. return;
  450. }
  451. myService.testcharge(number,2).then(function (result) {
  452. msg.text("充值成功");
  453. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  454. // $timeout(function(){
  455. // $ionicHistory.goBack();
  456. // },500)
  457. });
  458. }
  459. //充值
  460. $scope.charge = function(number){
  461. if (!number) {
  462. msg.text('请输入充值金额');
  463. return;
  464. }
  465. myService.charge(number,2).then(function (result) {
  466. //todo:result需要返回支付宝或者微信的签名信息
  467. console.log("result: " + JSON.stringify(result));
  468. var payInfo = result.data;
  469. if ($scope.vm.payType == 1) { //支付宝
  470. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  471. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  472. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  473. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  474. //当e.resultStatus为9000时,请去服务端验证支付结果
  475. $scope.clicksub = false;
  476. if (e.resultStatus == '9000') {
  477. alert(orderID);
  478. //支付成功
  479. // $state.go('app.my');
  480. } else {
  481. msg.error("支付失败");
  482. // msg.error("支付失败:" + JSON.stringify(e));
  483. }
  484. }, function error(e) {
  485. $scope.clicksub = false;
  486. // msg.error("支付失败:" + JSON.stringify(e));
  487. msg.error("支付失败");
  488. });
  489. }
  490. if ($scope.vm.payType == 2) { //微信
  491. var obj = JSON.parse(payInfo);
  492. var params = {
  493. partnerid: obj.partnerid, // merchant id
  494. prepayid: obj.prepayid, // prepay id
  495. noncestr: obj.noncestr, // nonce
  496. timestamp: obj.timestamp, // timestamp
  497. sign: obj.sign, // signed string
  498. };
  499. Wechat.sendPaymentRequest(params, function (r) {
  500. $scope.clicksub = false;
  501. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  502. // alert(result);
  503. //支付成功
  504. // $state.go('app.my');
  505. }, function (erro) {
  506. msg.alert("支付反馈失败:" + JSON.stringify(erro));
  507. });
  508. }, function (reason) {
  509. $scope.clicksub = false;
  510. msg.alert("支付失败:" + JSON.stringify(reason));
  511. });
  512. }
  513. // msg.text("充值成功");
  514. // $state.go('app.my');
  515. });
  516. }
  517. }]);
  518. app.controller('payCtrl', ["$scope","$timeout","$ionicHistory","$ionicTabsDelegate", "$timeout","$ionicHistory","$state", "myService", "msg"
  519. , function ($scope,$timeout,$ionicHistory,$ionicTabsDelegate, $timeout,$ionicHistory,$state, myService, msg) {
  520. $scope.$on('$ionicView.beforeEnter', function () {
  521. myService.myInfo().then(function(result){
  522. $scope.vm = result.data.data;
  523. $scope.vm.money = '';
  524. $scope.vm.payType = 2;
  525. })
  526. });
  527. $scope.payExplain = function(){
  528. $state.go("app.explain")
  529. };
  530. $scope.withdraw = function(){
  531. $state.go("app.payout")
  532. };
  533. //充值
  534. $scope.testcharge = function(number){
  535. if (!number) {
  536. msg.text('请输入充值金额');
  537. return;
  538. }
  539. myService.testcharge(number,2).then(function (result) {
  540. msg.text("充值成功");
  541. $scope.vm.coin = parseInt($scope.vm.coin) + parseInt(number);
  542. $timeout(function(){
  543. $ionicHistory.goBack();
  544. },500)
  545. });
  546. }
  547. //充值
  548. $scope.charge = function(number){
  549. if (!number) {
  550. msg.text('请输入充值金额');
  551. return;
  552. }
  553. myService.charge(number,2).then(function (result) {
  554. //todo:result需要返回支付宝或者微信的签名信息
  555. console.log("result: " + JSON.stringify(result));
  556. var payInfo = result.data;
  557. if ($scope.vm.payType == 1) { //支付宝
  558. cordova.plugins.AliPay.pay(payInfo, function success(e) {
  559. //e.resultStatus 状态代码 e.result 本次操作返回的结果数据 e.memo 提示信息
  560. //e.resultStatus 9000 订单支付成功 ;8000 正在处理中 调用function success
  561. //e.resultStatus 4000 订单支付失败 ;6001 用户中途取消 ;6002 网络连接出错 调用function error
  562. //当e.resultStatus为9000时,请去服务端验证支付结果
  563. $scope.clicksub = false;
  564. if (e.resultStatus == '9000') {
  565. alert(orderID);
  566. //支付成功
  567. // $state.go('app.my');
  568. } else {
  569. msg.error("支付失败");
  570. // msg.error("支付失败:" + JSON.stringify(e));
  571. }
  572. }, function error(e) {
  573. $scope.clicksub = false;
  574. // msg.error("支付失败:" + JSON.stringify(e));
  575. msg.error("支付失败");
  576. });
  577. }
  578. if ($scope.vm.payType == 2) { //微信
  579. var obj = JSON.parse(payInfo);
  580. var params = {
  581. partnerid: obj.partnerid, // merchant id
  582. prepayid: obj.prepayid, // prepay id
  583. noncestr: obj.noncestr, // nonce
  584. timestamp: obj.timestamp, // timestamp
  585. sign: obj.sign, // signed string
  586. };
  587. Wechat.sendPaymentRequest(params, function (r) {
  588. $scope.clicksub = false;
  589. courseService.orderStatus(orderID, $scope.paytype).then(function (result) {
  590. // alert(result);
  591. //支付成功
  592. // $state.go('app.my');
  593. }, function (erro) {
  594. msg.alert("支付反馈失败:" + JSON.stringify(erro));
  595. });
  596. }, function (reason) {
  597. $scope.clicksub = false;
  598. msg.alert("支付失败:" + JSON.stringify(reason));
  599. });
  600. }
  601. // msg.text("充值成功");
  602. // $state.go('app.my');
  603. });
  604. }
  605. }]);
  606. app.controller('accountCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  607. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  608. $scope.$on('$ionicView.beforeEnter', function () {
  609. $ionicTabsDelegate.showBar(false);
  610. $scope.showAccount();
  611. });
  612. $scope.showAccount = function(){
  613. myService.showAccount().then(function(result){
  614. $scope.items = result.data.data;
  615. },function(error){
  616. msg.error(error.data.message);
  617. })
  618. };
  619. $scope.destroyAccount = function(id){
  620. myService.destroyAccount(id).then(function(result){
  621. msg.text("删除成功");
  622. $scope.showAccount();
  623. },function(error){
  624. msg.error(error.data.message);
  625. })
  626. }
  627. }]);
  628. app.controller('my_account_addCtrl', ["$scope","config","common","$timeout","$ionicTabsDelegate", "$state", "myService", "msg"
  629. , function ($scope,config,common,$timeout,$ionicTabsDelegate, $state, myService, msg) {
  630. $scope.addpict = function () {
  631. common.chooseImage().then(function (qrcode) {
  632. common.uploadFiles(qrcode,1).then(function (result) {
  633. var response = JSON.parse(result.response);
  634. var file = config.imgServer+response.data.file;
  635. $scope.vm.file = file;
  636. $scope.qrcode.push(file);
  637. }, function (error) {
  638. msg.error('图片上传失败');
  639. });
  640. }, function (error) {
  641. console.log('图片选择失败');
  642. });
  643. };
  644. $scope.qrcode=[];
  645. $scope.deletefile = function (file) {
  646. var index = $scope.qrcode.indexOf(file);
  647. $scope.qrcode.splice(index, 1);
  648. common.deletefile(file).then(function () {
  649. })
  650. };
  651. $scope.vm={
  652. bank_name:'',
  653. bank_number:'',
  654. bank_phone:'',
  655. bank_user:'',
  656. type:""
  657. };
  658. $scope.addAccount = function () {
  659. var data = {
  660. data:{
  661. bank_name:$scope.vm.bank_name,
  662. bank_number:$scope.vm.bank_number,
  663. bank_phone:$scope.vm.bank_phone,
  664. bank_user:$scope.vm.bank_user
  665. }
  666. };
  667. msg.loading('保存中...');
  668. myService.addAccount(data).then(function (result) {
  669. msg.hide();
  670. $state.go('app.my_account');
  671. }, function (error) {
  672. msg.hide();
  673. msg.error(error.data.message);
  674. });
  675. };
  676. $scope.addQrcode = function(){
  677. var data = {
  678. data:{
  679. type:$scope.vm.type,
  680. qrcode:$scope.vm.file
  681. //qrcode:"https://www.baidu.com/img/bd_logo1.png"
  682. }
  683. };
  684. myService.addQrcode(data).then(function(result){
  685. msg.text("添加成功",true);
  686. $state.go("app.my_account");
  687. },function(error){
  688. msg.error(error.data.message);
  689. })
  690. }
  691. }]);
  692. app.controller('messageCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  693. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  694. $scope.$on('$ionicView.beforeEnter', function () {
  695. $ionicTabsDelegate.showBar(false);
  696. myService.messageInfo().then(function(result){
  697. $scope.infos = result.data.data;
  698. },function(error){
  699. });
  700. });
  701. //系统消息
  702. $scope.systemInfo = function(){
  703. $state.go("app.my_message_sys");
  704. };
  705. $scope.notRead = function(){
  706. myService.notRead().then(function(result){
  707. myService.messageInfo().then(function(result){
  708. $scope.infos = result.data.data;
  709. },function(error){
  710. });
  711. },function(error){
  712. })
  713. };
  714. //回复我的
  715. $scope.replyMy = function(){
  716. $state.go("app.my_message_reply");
  717. };
  718. $scope.personalLetter = function(){
  719. $state.go("app.personalLetter");
  720. }
  721. }]);
  722. app.controller('dreamCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  723. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  724. $scope.$on('$ionicView.beforeEnter', function () {
  725. $ionicTabsDelegate.showBar(false);
  726. myService.myDream().then(function(result){
  727. $scope.dreams = result.data.data;
  728. });
  729. myService.myInfo().then(function(result){
  730. $scope.user = result.data.data
  731. });
  732. });
  733. $scope.toDetail = function (id) {
  734. $state.go('app.my_dreamdetail',{id:id});
  735. };
  736. }]);
  737. app.controller('collectCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg"
  738. , function ($scope, $ionicTabsDelegate,$state, myService, msg) {
  739. $scope.$on('$ionicView.beforeEnter', function () {
  740. $ionicTabsDelegate.showBar(false);
  741. myService.collect().then(function(result){
  742. $scope.dreams = result.data.data.dreams;
  743. });
  744. });
  745. $scope.toDetail = function (id) {
  746. $state.go('app.my_dreamdetail',{id:id});
  747. };
  748. }]);
  749. app.controller('messageSysCtrl', ["$scope", "$ionicTabsDelegate","$state", "myService", "msg"
  750. , function ($scope,$ionicTabsDelegate, $state, myService, msg) {
  751. $scope.$on('$ionicView.beforeEnter', function () {
  752. myService.systemInfo().then(function(result){
  753. $scope.sysInfos = result.data.data;
  754. },function(error){
  755. });
  756. });
  757. }]);
  758. app.controller('messageReplyCtrl', ["$scope","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  759. , function ($scope,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  760. $scope.$on('$ionicView.beforeEnter', function () {
  761. myService.replyMy().then(function(result){
  762. $scope.comments = result.data.data;
  763. },function(error){
  764. });
  765. });
  766. $ionicModal.fromTemplateUrl('my-modal.html', {
  767. scope: $scope,
  768. animation: 'slide-in-up'
  769. }).then(function (modal) {
  770. $scope.modal = modal;
  771. });
  772. $scope.openModal = function () {
  773. $scope.modal.show();
  774. };
  775. $scope.closeModal = function () {
  776. $scope.modal.hide();
  777. };
  778. //我的回复
  779. $scope.vm={
  780. content:"",
  781. comment_id:""
  782. };
  783. $scope.myReplay = function(){
  784. var data = {
  785. content:$scope.vm.content,
  786. comment_id:$scope.vm.id
  787. };
  788. myService.myReplay(data).then(function(result){
  789. },function(error){
  790. });
  791. $scope.modal.hide();
  792. }
  793. }]);
  794. })(angular.module('app.controllers'));