sign_info.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 == 1){
  20. fuwujilu.getInfo();
  21. }
  22. self.endPulldownToRefresh();
  23. }, 1000);
  24. }
  25. }
  26. });
  27. });
  28. });
  29. // var tab = localStorage.getItem("signInfo_tab");
  30. // if(tab){
  31. // index = tab;
  32. // clickTab(index, 100);
  33. // }
  34. getFirstTabValue();
  35. bindEvent();
  36. getWxSign();
  37. //判断前一个页面存储的支付信息
  38. var payParams = window.localStorage.getItem("payParams");
  39. if(payParams){
  40. window.localStorage.removeItem("payParams");
  41. }
  42. })(mui);
  43. function getWxSign(){
  44. //从后台那边获取签名等信息
  45. var params = {};
  46. var url1 = window.location.href;
  47. params.pageUrl = url1;
  48. $.ajax(server + "weixin/getSign", {
  49. data: params,
  50. dataType: "json",
  51. type: "post",
  52. success: function(res){
  53. if (res.status == 200) {
  54. var t = res.data.timestamp;
  55. var noncestr = res.data.noncestr;
  56. var signature = res.data.signature;
  57. wx.config({
  58. appId: appId, // 必填,公众号的唯一标识
  59. timestamp: t, // 必填,生成签名的时间戳
  60. nonceStr: noncestr, // 必填,生成签名的随机串
  61. signature: signature,// 必填,签名,见附录1
  62. jsApiList: [
  63. 'chooseImage',
  64. 'uploadImage',
  65. 'startRecord',
  66. 'stopRecord',
  67. 'onVoiceRecordEnd',
  68. 'playVoice',
  69. 'pauseVoice',
  70. 'stopVoice',
  71. 'translateVoice',
  72. 'onVoicePlayEnd',
  73. 'uploadVoice',
  74. 'getNetworkType'
  75. ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  76. });
  77. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  78. wx.ready(function(){
  79. wx.getNetworkType({
  80. success: function (res) {
  81. networkStatus = res.networkType; // 返回网络类型2g,3g,4g,wifi
  82. }
  83. });
  84. });
  85. }
  86. }
  87. });
  88. }
  89. function getFirstTabValue(){
  90. consulting.getWeixinSign();
  91. consulting.getInfo();
  92. consulting.bindEvents();
  93. }
  94. function clickTab(index){
  95. $(".mui-slider .mui-control-item").eq(index).addClass("mui-active");
  96. var slider = mui('.mui-slider').slider();
  97. slider.gotoPage(index,100);
  98. }
  99. function bindEvent(){
  100. document.querySelector('.mui-slider').addEventListener('slide', function(event) {
  101. var index = event.detail.slideNumber;
  102. localStorage.setItem("signInfo_tab", index);
  103. var item = "item"+(index+1);
  104. var activeItem = $(event.target).find(".mui-control-item:eq("+index+")");
  105. var options = [consulting, fuwujilu];
  106. if(!activeItem.attr("showed")){
  107. options[index].getInfo();
  108. options[index].bindEvents();
  109. activeItem.attr("showed", "1");
  110. }
  111. });
  112. }
  113. template.helper('getPhoto', function(str){
  114. return getImgUrl(str);
  115. })