my.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  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","$ionicPopup","$location", "$ionicTabsDelegate","$state", "myService", "msg"
  747. , function ($scope,$ionicPopup,$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. $scope.vm = {
  755. content:""
  756. };
  757. $scope.imgs = [];
  758. $scope.video = {};
  759. $scope.addpict = function () {
  760. common.chooseImage().then(function (img) {
  761. common.uploadFiles(img,1).then(function (result) {
  762. var response = JSON.parse(result.response);
  763. var file = config.imgServer + response.data.file;
  764. $scope.imgs.push(file);
  765. }, function (error) {
  766. msg.error('图片上传失败');
  767. });
  768. }, function (error) {
  769. console.log('图片选择失败');
  770. });
  771. };
  772. $scope.deletefile = function (file) {
  773. var index = $scope.imgs.indexOf(file);
  774. $scope.imgs.splice(index, 1);
  775. common.deletefile(file).then(function () {
  776. })
  777. };
  778. $scope.addvideo = function () {
  779. common.chooseVideo().then(function (file) {
  780. common.uploadFiles(file, 2).then(function (result) {
  781. var response = JSON.parse(result.response);
  782. var file = config.imgServer+response.data.file;
  783. $scope.video.isOK = true;
  784. $scope.video.file = response.data.file;
  785. $scope.video.vpic = config.server+'upload/vpic/'+response.data.file+'.jpg';
  786. }, function (error) {
  787. msg.error('视频上传失败');
  788. });
  789. }, function (erro) {
  790. console.log('选择视频失败');
  791. });
  792. };
  793. $scope.deletevideo = function (file) {
  794. common.deletefile(file).then(function (res) {
  795. },function(erro){
  796. alert(JSON.stringify(erro));
  797. })
  798. };
  799. $scope.goMes = function(is_reply,is_url,dream_id,is_end,message,user_id){
  800. //发送私信
  801. if(is_reply==1){
  802. var myPopup = $ionicPopup.show({
  803. template : '<div>' +
  804. '<textarea autofocus style="border: 1px solid #D0D0D0" name="" id="" cols="30" rows="8" ng-model="vm.content" placeholder="对他的好意给予感谢的回复"></textarea onf>' +
  805. '<a class="btn-file-up" ng-click="addpict()">' +
  806. '<img src="img/icon_photo.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  807. '<em style="font-size: 16px">添加图片</em>' +
  808. '</a>' +
  809. '<a class="btn-file-up" ng-click="addvideo()">' +
  810. '<img src="img/icon_video.svg" style="height: 40px; width: 40px; text-align: center; line-height: 40px" /><br>' +
  811. '<em style="font-size: 16px">添加视频</em>' +
  812. '</a>' +
  813. '<a ng-repeat="item in imgs" ng-click="showImages(item)" class="img-file-up">' +
  814. '<b style="background-image:url({{item}});"><em ng-click="deletefile(item)" class="ion-ios-close-outline"></em></b>' +
  815. '</a>' +
  816. '<div class="img-file-up" ng-if="video.isOK">' +
  817. '<div style="position:relative;">' +
  818. '<em ng-click="deletevideo(video.file)" class="ion-ios-close-outline"></em>' +
  819. '<video ng-src="{{video.file | trustUrl}}" poster="{{video.vpic}}" controls="controls"></video>' +
  820. '</div>' +
  821. '</div>' +
  822. '</div>',
  823. title: message,
  824. //subTitle: 'Please use normal things',
  825. scope: $scope,
  826. buttons: [
  827. { text: '取消' },
  828. {
  829. text: '<b>确定</b>',
  830. type: 'button-positive',
  831. onTap: function(e) {
  832. var data = {
  833. to_user_id:user_id,
  834. content:$scope.vm.content,
  835. image:$scope.imgs,
  836. video:$scope.video.file,
  837. //image:['http://img0.imgtn.bdimg.com/it/u=2398075737,160631337&fm=214&gp=0.jpg']
  838. };
  839. myService.sendLetter(data).then(function(result){
  840. if(result.data.status_code==0){
  841. msg.success('发送成功');
  842. }
  843. })
  844. }
  845. }
  846. ]
  847. });
  848. }
  849. //跳转
  850. else if(is_url==1){
  851. if($location.path()=="/app/home/message/sys"){
  852. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  853. }
  854. else {
  855. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  856. }
  857. }
  858. //梦想结束
  859. else if(is_end==1){
  860. var endTemplate = '<div style="text-align: center"><p>恭喜你成功地向你的梦想迈出最大的一步,照接下来的步骤做就可以领取你的梦想资金啦!</p>' +
  861. '<p>要取出全部梦想资金,</p>' +
  862. '<p>你需要亲自问候你的梦主</p>' +
  863. '<p>致出最诚挚的感谢</p>' +
  864. '<p>点击《确定》我们会提供</p>' +
  865. '<p>《梦主》的资料</p>' +
  866. '<p>如果你觉得不合适,你可以点击《取消》,但是《梦主》的资金会被退还给他</p>' +
  867. '<p>你以后创建梦想也会比较难</p>' +
  868. '</div>';
  869. msg.confirm('恭喜你!',endTemplate).then(function(result){
  870. if(result==true){
  871. myService.sure_meet(dream_id,1).then(function(res){
  872. if(res.data.status_code==0){
  873. if(res.data.data==0){
  874. msg.success('该梦想暂无梦主!');
  875. }
  876. else {
  877. msg.success('确定见面,期待与梦主的相见吧!');
  878. }
  879. }
  880. })
  881. }
  882. else {
  883. myService.sure_meet(dream_id,0).then(function(res){
  884. if(res.data.status_code==0){
  885. msg.success('已取消见面!');
  886. }
  887. })
  888. }
  889. })
  890. }
  891. }
  892. }]);
  893. app.controller('messageReplyCtrl', ["$scope","$location","$ionicPopup","$ionicTabsDelegate", "$state", "myService", "msg", "$ionicModal"
  894. , function ($scope,$location,$ionicPopup,$ionicTabsDelegate, $state, myService, msg, $ionicModal) {
  895. $scope.$on('$ionicView.beforeEnter', function () {
  896. $scope.load();
  897. });
  898. $scope.load = function () {
  899. myService.replyMy().then(function (result) {
  900. $scope.comments = result.data.data;
  901. }, function (error) {
  902. });
  903. };
  904. $scope.goMes = function(info,img,is_max,mes,video,attr_id,dream_id){
  905. //收到私信
  906. if(attr_id==7){
  907. if(video!=null){
  908. var letterTemplate = '<div style="text-align: center">' +
  909. '<img src="'+img+'" style="border-radius: 100%">' +
  910. '<video src="'+video+'"></video>' +
  911. '<p>'+info+'</p>' +
  912. '</div>';
  913. }
  914. else {
  915. var letterTemplate = '<div style="text-align: center">' +
  916. '<img src="'+img+'" style="border-radius: 100%">' +
  917. '<p>'+info+'</p>' +
  918. '</div>';
  919. }
  920. msg.confirm('私信',letterTemplate);
  921. }
  922. //成为梦主
  923. else if(is_max==1){
  924. var maxTemplate = '<div style="text-align: center"><p>'+ mes +'</p>' +
  925. '<p>'+ info +'</p>' +
  926. //'<p>小蝶将以你提供的微信/电话联系你,并到你越好的地点亲自感谢你给予的支持和鼓励。</p>' +
  927. //'<p>如果你不希望见面或者不想要梦想者拥有你的联系方式,请按《不要见面的按钮或者联系客服》</p>' +
  928. //'<p>请按《不要见面的按钮或者联系客服》</p>' +
  929. '</div>';
  930. msg.confirm('恭喜你!',maxTemplate);
  931. }
  932. else {
  933. if($location.path()=="/app/home/message/reply"){
  934. $state.go('app.home_dreamdetail',{id:dream_id,type:2});
  935. }
  936. else {
  937. $state.go('app.my_dreamdetail',{id:dream_id,type:2});
  938. }
  939. }
  940. };
  941. //我的回复
  942. $scope.vm = {
  943. content: ""
  944. };
  945. $ionicModal.fromTemplateUrl('my-modal.html', {
  946. scope: $scope,
  947. animation: 'slide-in-up'
  948. }).then(function (modal) {
  949. $scope.modal = modal;
  950. });
  951. //$ionicModal.fromTemplateUrl('my-modal.html', {
  952. // scope: $scope,
  953. // animation: 'slide-in-up'
  954. //}).then(function (modal) {
  955. // $scope.modal = modal;
  956. //});
  957. //$scope.openModal = function () {
  958. // $scope.modal.show();
  959. //};
  960. //$scope.closeModal = function () {
  961. // $scope.modal.hide();
  962. //
  963. //};
  964. $scope.goDetail = function (id,interaction_id){
  965. $state.go('app.home_dreamdetail',{id:id,interaction_id:interaction_id,type:2});
  966. };
  967. //我的回复
  968. //$scope.vm={
  969. // content:"",
  970. // comment_id:""
  971. //};
  972. //$scope.closeModal = function () {
  973. // var data = {
  974. // content: $scope.vm.content,
  975. // comment_id: $scope.item.id,
  976. // interaction_id: $scope.item.interaction_id
  977. // };
  978. // myService.myReplay(data).then(function (result) {
  979. // msg.success('回复成功');
  980. // $scope.load();
  981. // }, function (error) {
  982. // msg.error('回复失败');
  983. // });
  984. // $scope.vm.content = '';
  985. // $scope.item = null;
  986. // $scope.modal.hide();
  987. //};
  988. //
  989. //$scope.reply = function (item) {
  990. // $scope.item = item;
  991. // $scope.modal.show();
  992. //}
  993. }]);
  994. })(angular.module('app.controllers'));