123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- var index = 0;
- var request = GetRequest();
- (function($){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- $('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- $.ready(function() {
- //循环初始化所有下拉刷新,上拉加载。
- $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
- $(pullRefreshEl).pullRefresh({
- down: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- if(index == 0){
- fuwutuandui.getInfo();
- }
- if(index == 1){
- fuwujilu.getInfo();
- }
- self.endPulldownToRefresh();
- }, 1000);
- }
- }
- });
- });
- });
- var tab = localStorage.getItem("signInfo_tab");
- if(tab){
- index = tab;
- clickTab(index, 100);
- }
- getFirstTabValue();
- bindEvent();
- getWxSign();
-
- //判断前一个页面存储的支付信息
- var payParams = window.localStorage.getItem("payParams");
- if(payParams){
- window.localStorage.removeItem("payParams");
- }
- })(mui);
- function getWxSign(){
- //从后台那边获取签名等信息
- var params = {};
- var url1 = window.location.href;
- params.pageUrl = url1;
- $.ajax(server + "weixin/getSign", {
- data: params,
- dataType: "json",
- type: "post",
- success: function(res){
- if (res.status == 200) {
- var t = res.data.timestamp;
- var noncestr = res.data.noncestr;
- var signature = res.data.signature;
- wx.config({
- appId: appId, // 必填,公众号的唯一标识
- timestamp: t, // 必填,生成签名的时间戳
- nonceStr: noncestr, // 必填,生成签名的随机串
- signature: signature,// 必填,签名,见附录1
- jsApiList: [
- 'chooseImage',
- 'uploadImage',
- 'startRecord',
- 'stopRecord',
- 'onVoiceRecordEnd',
- 'playVoice',
- 'pauseVoice',
- 'stopVoice',
- 'translateVoice',
- 'onVoicePlayEnd',
- 'uploadVoice',
- 'getNetworkType'
- ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
- });
-
- // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
- wx.ready(function(){
- wx.getNetworkType({
- success: function (res) {
- networkStatus = res.networkType; // 返回网络类型2g,3g,4g,wifi
- }
- });
- });
- }
- }
- });
- }
- function getFirstTabValue(){
- fuwutuandui.getInfo();
- fuwutuandui.bindEvents();
- }
- function createIframe(objId,options) {
- var wrapper = document.createElement('div');
- wrapper.className = 'mui-iframe-wrapper';
- var styles = options.styles || {};
- if (typeof styles.top !== 'string') {
- styles.top = '0px';
- }
- if (typeof styles.bottom !== 'string') {
- styles.bottom = '0px';
- }
- wrapper.style.top = styles.top;
- wrapper.style.bottom = styles.bottom;
- var iframe = document.createElement('iframe');
- iframe.src = options.url+"?teamCode="+request.teamCode+"&type="+request.type+"&doctor="+request.doctor+"&status="+request.status;
- iframe.id = options.id || options.url;
- iframe.name = iframe.id;
- wrapper.appendChild(iframe);
- document.getElementById(objId).appendChild(wrapper);
- //目前仅处理微信
- handleScroll(wrapper, iframe);
- };
- function handleScroll(wrapper, iframe) {
- var key = 'MUI_SCROLL_POSITION_' + document.location.href + '_' + iframe.src;
- var scrollTop = (parseFloat(localStorage.getItem(key)) || 0);
- if (scrollTop) {
- (function(y) {
- iframe.onload = function() {
- window.scrollTo(0, y);
- };
- })(scrollTop);
- }
- setInterval(function() {
- var _scrollTop = window.scrollY;
- if (scrollTop !== _scrollTop) {
- localStorage.setItem(key, _scrollTop + '');
- scrollTop = _scrollTop;
- }
- }, 100);
- };
- function clickTab(index){
- // $(".mui-slider .mui-control-item").eq(index).trigger("click");
- var slider = mui('.mui-slider').slider();
- slider.gotoPage(index,100);
- }
- function bindEvent(){
- document.querySelector('.mui-slider').addEventListener('slide', function(event) {
- var index = event.detail.slideNumber;
- localStorage.setItem("signInfo_tab", index);
- var item = "item"+(index+1);
- var activeItem = $(event.target).find(".mui-control-item:eq("+index+")");
- // var options = {
- // url: activeItem.attr("data-href"),
- // id: activeItem.attr("href-id"),
- // styles:{}
- // };
- var options = [fuwutuandui, consulting, fuwujilu];
- if(!activeItem.attr("showed")){
- // createIframe(item, options);
- options[index].getInfo();
- options[index].bindEvents();
- activeItem.attr("showed", "1");
- }
- });
- }
- template.helper('getPhoto', function(str){
- return getImgUrl(str);
- })
|