dyy_history.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. var page = 10,
  2. pagesize = 10,
  3. patiCode = "",
  4. teamCode;
  5. var noResultWrap = '<div id="no_result_wrap">'+
  6. '<img class="no-result-img" style="margin-top: 60px; widht:100%;height:auto;" src="../../../images/shujuweikong_img.png" />'+
  7. // '<div class="f-fs14 c-323232 c-t-center">暂无医学知识记录~</div>'+
  8. '</div>';
  9. mui.init();
  10. mui.plusReady(function(){
  11. var self = plus.webview.currentWebview();
  12. patiCode = self.patientCode;
  13. initScroll();
  14. initTemplateHelper();
  15. getTeamInfo();
  16. bindEvents();
  17. });
  18. function initScroll(){
  19. //阻尼系数
  20. var deceleration = mui.os.ios?0.003:0.0009;
  21. mui('.mui-scroll-wrapper').scroll({
  22. bounce: false,
  23. indicators: true, //是否显示滚动条
  24. deceleration:deceleration
  25. });
  26. mui('.mui-scroll-wrapper').pullRefresh({
  27. down: {
  28. callback: function() {
  29. var self = this;
  30. setTimeout(function() {
  31. getList(true);
  32. self.endPulldownToRefresh();
  33. }, 1000);
  34. }
  35. },
  36. up: {
  37. callback: function() {
  38. var self = this;
  39. setTimeout(function() {
  40. getList(false);
  41. self.endPullupToRefresh();
  42. }, 1000);
  43. }
  44. }
  45. });
  46. }
  47. function getTeamInfo(){
  48. plus.nativeUI.showWaiting();
  49. // TODO 团队选择
  50. return getReqPromise("doctor/family_contract/patient_doctor_teams",{
  51. patient: patiCode
  52. }).then(function(res) {
  53. if(res.status == 200) {
  54. var data = res.data,teams = [];
  55. // 是否有签约关系 1:有 0:无,此时jtTeam与ssTeam都没有
  56. if(data.hasSign=="1") {
  57. data.ssTeam && (function() {
  58. var team = data.ssTeam.team;
  59. team.hasSign = data.ssTeam.hasSign; // 医生与患者是否有签约关系
  60. team.isLeader = data.ssTeam.isLeader; // 是否是团队长
  61. teams.push(team)
  62. })();
  63. data.jtTeam && (function() {
  64. var team = data.jtTeam.team;
  65. team.hasSign = data.jtTeam.hasSign; // 医生与患者是否有签约关系
  66. team.isLeader = data.jtTeam.isLeader; // 是否是团队长
  67. teams.push(team)
  68. })();
  69. }
  70. }
  71. $('.lin-sel-group').html(template('teams_tmpl', {data:teams}));
  72. //初始默认选中第一个团队信息
  73. var $select = $(".lin-sel-group li").eq(0);
  74. var code = parseInt($select.attr("data-code"));
  75. $(".lin-sel-group li").removeClass("checked");
  76. $select.addClass("checked");
  77. teamCode = code;
  78. $("#Dtitle").html($select.find("label").html()).attr("data-index",code);
  79. }).then(function(){
  80. getList(true);
  81. });
  82. }
  83. function getList(isInit){
  84. page = isInit? 1: page;
  85. var url = "third/guahao/GetPatientReservationList",
  86. params = {
  87. patient: patiCode,
  88. teamCode: teamCode || "",
  89. pageIndex: page,
  90. pageSize: pagesize,
  91. };
  92. plus.nativeUI.showWaiting();
  93. sendPost(url, params, null, function(res){
  94. if(res.status == 200){
  95. var list = res.list || res.data;
  96. if(list.length > 0){
  97. $(".mui-scroll-wrapper").show();
  98. $("#no_result_wrap").hide();
  99. page++;
  100. var html = template('daiyuyue_tmpl', {list: list});
  101. if(isInit){
  102. $(".mui-scroll").empty().append(html);
  103. }else{
  104. $(".mui-scroll").append(html);
  105. }
  106. if(list.length < pagesize){
  107. mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(true);
  108. }
  109. }else{
  110. //无数据
  111. if(isInit){
  112. $(".mui-scroll-wrapper").hide();
  113. $("#no_result_wrap").show();
  114. }
  115. }
  116. }else{
  117. mui.toast(res.msg);
  118. }
  119. plus.nativeUI.closeWaiting();
  120. }, 'POST', '', true);
  121. }
  122. function bindEvents(){
  123. $('body').on("tap", ".dyy_detail", function(){
  124. chooseItem(this)
  125. });
  126. $(".demo-comtop").on("click","h1",function(){
  127. $(".lin-mask").show();
  128. $(".lin-sel-group").show();
  129. });
  130. $(".lin-mask").on("click",function(){
  131. $(".lin-mask").hide();
  132. $(".lin-sel-group").hide();
  133. });
  134. $(".lin-sel-group").on("click","li",function(){
  135. var index = parseInt($(this).attr("data-index"));
  136. $(".lin-sel-group li").removeClass("checked");
  137. $(this).addClass("checked");
  138. $(".lin-mask").trigger("click");
  139. $("#Dtitle").html($(this).find("label").html()).attr("data-index",index);
  140. teamCode = $(this).attr("data-code");
  141. //重新加载数据
  142. getList(true);
  143. });
  144. }
  145. function chooseItem(ele){
  146. var info = $(ele).closest(".n-list").attr("data-info"),
  147. self = plus.webview.currentWebview();
  148. var questionaires = plus.webview.getWebviewById("questionaires");
  149. mui.fire(questionaires, "filldyy", {info: info});
  150. questionaires.show();
  151. mui.later(function(){
  152. self.close();
  153. }, 300);
  154. }
  155. function initTemplateHelper(){
  156. template.helper('toInfo', function(v){
  157. return JSON.stringify(v);
  158. });
  159. template.helper("setSex", function(s) {
  160. if(s == 1) {
  161. return "男"
  162. } else if(s == 2) {
  163. return "女"
  164. }
  165. });
  166. template.helper("setPhoto", function(p) {
  167. if(!p || p.length == 0) {
  168. return "../../../images/p-default.png";
  169. } else {
  170. return getImgUrl(p);
  171. }
  172. });
  173. template.helper("setTime", function(p) {
  174. // 为了防止类似“2016-12-21 14:08:10.0”在IOS上无法识别问题
  175. if(p){
  176. p = p.split('.')[0];
  177. return new Date(Date.parse(p.replace(/-/g, "/"))).format("yyyy-MM-dd hh:mm:ss")
  178. }else{
  179. return "";
  180. }
  181. });
  182. }