my-passbook.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. mui.init();
  2. var d = dialog({contentType:'load', skin:'bk-popup'});
  3. var pagetype=53;
  4. (function(mui) {
  5. checkUserAgent();
  6. var unUserPage=userPage=1;//初始化页数
  7. var loadMoreNumber=15;//一次加载几条
  8. var useAgent=JSON.parse(window.localStorage.getItem(agentName));
  9. var accountId=window.localStorage.getItem("accountId");
  10. findAccount();
  11. function initPage(){
  12. var deceleration = mui.os.ios?0.003:0.0009;
  13. mui('.mui-scroll-wrapper').scroll({
  14. bounce: false,
  15. indicators: false, //是否显示滚动条
  16. deceleration:deceleration
  17. });
  18. }
  19. function getIntegralList(index, isLoadMore){
  20. var self= this;
  21. var tradeDirection,__page;
  22. var useAgent=JSON.parse(window.localStorage.getItem(agentName));
  23. if(index===0){
  24. tradeDirection=1;
  25. unUserPage=__page=isLoadMore?unUserPage:1;
  26. }else{
  27. tradeDirection=-1;
  28. userPage=__page=isLoadMore?userPage:1;
  29. }
  30. var params={
  31. creditsLogDo : JSON.stringify({"accountId":accountId,"tradeDirection":tradeDirection}),
  32. // tradeDirection : tradeDirection,
  33. page : __page,
  34. size : loadMoreNumber
  35. };
  36. sendPost('healthBank/selectDetails', params, 'json', 'post',function(){
  37. if(isLoadMore){
  38. self.endPullupToRefresh();
  39. }else{
  40. self.endPulldownToRefresh();
  41. }
  42. airDialog('服务器繁忙,请稍后再试!')
  43. },function(res){
  44. html = template('li_tmpl',{list: res.data&&res.data.detailModelList});
  45. var ul=self.element.querySelector('.integral-list');
  46. var length=res.data && res.data.detailModelList && res.data.detailModelList.length || 0;
  47. if(isLoadMore){//是否是上拉加载
  48. ul.innerHTML+=html;
  49. //加载完新数据后,必须执行如下代码,true表示没有更多数据了:
  50. if((length==0&&unUserPage==1)||(length==0&&userPage==1)){
  51. $('.mui-pull-caption-refresh').hide();
  52. $(ul).hide();
  53. $(ul).parents(".mui-slider-item").find('.div-no-info').removeClass("c-hide");
  54. }else{
  55. if(index===0) unUserPage++;
  56. else userPage++;
  57. }
  58. //
  59. self.endPullupToRefresh(length<loadMoreNumber);
  60. }else{
  61. ul.innerHTML=html;
  62. self.endPulldownToRefresh();
  63. }
  64. })
  65. }
  66. function findAccount(){
  67. var params={
  68. creditsDetail:JSON.stringify({patientId:useAgent.uid,tradeDirection:-1}),
  69. };
  70. sendPost('patient/healthBank/selectAccount', params , 'json', 'post',function(){
  71. airDialog("系统繁忙,请稍后再试!");
  72. $('.div-no-info').removeClass('c-hide');
  73. },function(res){
  74. if(res.status==200){
  75. var accountId=res.data&&res.data.obj&&res.data.obj.id || "";
  76. if(accountId){
  77. window.localStorage.setItem("accountId",accountId);
  78. initPage();
  79. }else{
  80. $('.div-no-info').removeClass('c-hide');
  81. airDialog("获取用户账户信息失败")
  82. }
  83. var total=res.data && res.data.obj && res.data.obj.total || 0;
  84. var useTotal=res.data && res.data.obj && res.data.obj.usedTotal || 0;
  85. $(".totalable").text(total);
  86. $("#useTotal").text(useTotal);
  87. }else{
  88. airDialog(res.msg)
  89. }
  90. })
  91. }
  92. })(mui);
  93. function airDialog(content){
  94. dialog({contentType:'tipsbox',top:true, skin:'bk-popup' , content:content}).show();
  95. }
  96. function goUrl(url){
  97. if(url) location.href=url;
  98. else airDialog('功能开发中,敬请期待!')
  99. }