my.js 35 KB

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