sign_info.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. var index = 0;
  2. var request = GetRequest();
  3. (function($){
  4. //阻尼系数
  5. var deceleration = mui.os.ios?0.003:0.0009;
  6. $('.mui-scroll-wrapper').scroll({
  7. bounce: false,
  8. indicators: true, //是否显示滚动条
  9. deceleration:deceleration
  10. });
  11. $.ready(function() {
  12. //循环初始化所有下拉刷新,上拉加载。
  13. $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
  14. $(pullRefreshEl).pullRefresh({
  15. down: {
  16. callback: function() {
  17. var self = this;
  18. setTimeout(function() {
  19. if(index == 0){
  20. fuwutuandui.getInfo();
  21. }
  22. if(index == 1){
  23. fuwujilu.getInfo();
  24. }
  25. self.endPulldownToRefresh();
  26. }, 1000);
  27. }
  28. }
  29. });
  30. });
  31. });
  32. var tab = localStorage.getItem("signInfo_tab");
  33. if(tab){
  34. index = tab;
  35. clickTab(index, 100);
  36. }
  37. getFirstTabValue();
  38. bindEvent();
  39. getWxSign();
  40. //判断前一个页面存储的支付信息
  41. var payParams = window.localStorage.getItem("payParams");
  42. if(payParams){
  43. window.localStorage.removeItem("payParams");
  44. }
  45. })(mui);
  46. function getWxSign(){
  47. //从后台那边获取签名等信息
  48. var params = {};
  49. var url1 = window.location.href;
  50. params.pageUrl = url1;
  51. $.ajax(server + "weixin/getSign", {
  52. data: params,
  53. dataType: "json",
  54. type: "post",
  55. success: function(res){
  56. if (res.status == 200) {
  57. var t = res.data.timestamp;
  58. var noncestr = res.data.noncestr;
  59. var signature = res.data.signature;
  60. wx.config({
  61. appId: appId, // 必填,公众号的唯一标识
  62. timestamp: t, // 必填,生成签名的时间戳
  63. nonceStr: noncestr, // 必填,生成签名的随机串
  64. signature: signature,// 必填,签名,见附录1
  65. jsApiList: [
  66. 'chooseImage',
  67. 'uploadImage',
  68. 'startRecord',
  69. 'stopRecord',
  70. 'onVoiceRecordEnd',
  71. 'playVoice',
  72. 'pauseVoice',
  73. 'stopVoice',
  74. 'translateVoice',
  75. 'onVoicePlayEnd',
  76. 'uploadVoice',
  77. 'getNetworkType'
  78. ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  79. });
  80. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  81. wx.ready(function(){
  82. wx.getNetworkType({
  83. success: function (res) {
  84. networkStatus = res.networkType; // 返回网络类型2g,3g,4g,wifi
  85. }
  86. });
  87. });
  88. }
  89. }
  90. });
  91. }
  92. function getFirstTabValue(){
  93. fuwutuandui.getInfo();
  94. fuwutuandui.bindEvents();
  95. }
  96. function createIframe(objId,options) {
  97. var wrapper = document.createElement('div');
  98. wrapper.className = 'mui-iframe-wrapper';
  99. var styles = options.styles || {};
  100. if (typeof styles.top !== 'string') {
  101. styles.top = '0px';
  102. }
  103. if (typeof styles.bottom !== 'string') {
  104. styles.bottom = '0px';
  105. }
  106. wrapper.style.top = styles.top;
  107. wrapper.style.bottom = styles.bottom;
  108. var iframe = document.createElement('iframe');
  109. iframe.src = options.url+"?teamCode="+request.teamCode+"&type="+request.type+"&doctor="+request.doctor+"&status="+request.status;
  110. iframe.id = options.id || options.url;
  111. iframe.name = iframe.id;
  112. wrapper.appendChild(iframe);
  113. document.getElementById(objId).appendChild(wrapper);
  114. //目前仅处理微信
  115. handleScroll(wrapper, iframe);
  116. };
  117. function handleScroll(wrapper, iframe) {
  118. var key = 'MUI_SCROLL_POSITION_' + document.location.href + '_' + iframe.src;
  119. var scrollTop = (parseFloat(localStorage.getItem(key)) || 0);
  120. if (scrollTop) {
  121. (function(y) {
  122. iframe.onload = function() {
  123. window.scrollTo(0, y);
  124. };
  125. })(scrollTop);
  126. }
  127. setInterval(function() {
  128. var _scrollTop = window.scrollY;
  129. if (scrollTop !== _scrollTop) {
  130. localStorage.setItem(key, _scrollTop + '');
  131. scrollTop = _scrollTop;
  132. }
  133. }, 100);
  134. };
  135. function clickTab(index){
  136. // $(".mui-slider .mui-control-item").eq(index).trigger("click");
  137. var slider = mui('.mui-slider').slider();
  138. slider.gotoPage(index,100);
  139. }
  140. function bindEvent(){
  141. document.querySelector('.mui-slider').addEventListener('slide', function(event) {
  142. var index = event.detail.slideNumber;
  143. localStorage.setItem("signInfo_tab", index);
  144. var item = "item"+(index+1);
  145. var activeItem = $(event.target).find(".mui-control-item:eq("+index+")");
  146. // var options = {
  147. // url: activeItem.attr("data-href"),
  148. // id: activeItem.attr("href-id"),
  149. // styles:{}
  150. // };
  151. var options = [fuwutuandui, consulting, fuwujilu];
  152. if(!activeItem.attr("showed")){
  153. // createIframe(item, options);
  154. options[index].getInfo();
  155. options[index].bindEvents();
  156. activeItem.attr("showed", "1");
  157. }
  158. });
  159. }
  160. template.helper('getPhoto', function(str){
  161. return getImgUrl(str);
  162. })