Commit 1bfa12ed by zujiaozhang

'修改链接无法点击问题'

parent ce61e7bc
......@@ -44,107 +44,22 @@ define([ 'zepto', 'medtap','mui'], function($, medtap,mui) {
chat.talkRelation();
chat.getWechatTicket();
chat.getAttention();
// var getTalk = setInterval(function() {
// chat.getTalkRecord();
// window.scrollTo(0, document.documentElement.clientHeight);
// }, 10000)
// $('input').on('focus',function(){
// //$('body').scrollTop(0);
// clearInterval(getTalk);
// });
// $('input').on('blur',function(){
// //$('body').scrollTop(0);
// var getTalk = setInterval(function() {
// chat.getTalkRecord();
// window.scrollTo(0, document.documentElement.clientHeight);
// }, 5000)
// });
// 监听页面滚动到底部的方法
// document.querySelector('body').addEventListener('touchmove', function (e) {
// if (!document.querySelector('#content').contains(e.target)) {
// e.preventDefault();
// }
// }, {passive: false});
// 新方法
var overscroll = function(el) {
  el.addEventListener('touchstart', function() {    var top = el.scrollTop
      , totalScroll = el.scrollHeight
      , currentScroll = top + el.offsetHeight;    
    if(top === 0) {
      el.scrollTop = 1;
    } else if(currentScroll === totalScroll) {
      el.scrollTop = top - 1;
    }
  });
  el.addEventListener('touchmove', function(evt) {   
    if(el.offsetHeight < el.scrollHeight)
      evt._isScroller = true;
  });
}
overscroll(document.querySelector('.chat_list'));
document.body.addEventListener('touchmove', function(evt) {  
  if(!evt._isScroller) {
    evt.preventDefault();
  }
var getTalk = setInterval(function() {
chat.getTalkRecord();
window.scrollTo(0, document.documentElement.clientHeight);
}, 10000)
$('input').on('focus',function(){
$('body').scrollTop(0);
clearInterval(getTalk);
});
//1.获取到列表的dom,刷新显示部分的dom,列表父容器的dom
var container = document.querySelector('.chat_list');
var refreshText = document.querySelector('.refreshText');
var parent = document.querySelector('.container');
//2.定义一些需要常用的变量
var startY = 0;//手指触摸最开始的Y坐标
var endY = 0;//手指结束触摸时的Y坐标
//3.给列表dom监听touchstart事件,得到起始位置的Y坐标
parent.addEventListener('touchstart',function(e){
startY = e.touches[0].pageY;
container.style.position = 'relative';
container.style.transition = 'transform 0s';
$('input').on('blur',function(){
$('body').scrollTop(0);
var getTalk = setInterval(function() {
chat.getTalkRecord();
window.scrollTo(0, document.documentElement.clientHeight);
}, 5000)
});
// container.ontouchmove = function (e) {
// var point = e.touches[0],
// eleTop = container.scrollTop,
// eleScrollHeight = container.scrollHeight,
// eleOffsetHeight = container.offsetHeight,
// eleTouchBottom = eleScrollHeight - eleOffsetHeight;
// if (eleTop === 0) {
// if (point.clientY > startY) {
// e.preventDefault();
// }
// }
// else if (eleTop === eleTouchBottom) {
// if (point.clientY < startY) {
// e.preventDefault()
// }
// }
// };
//4.给列表dom监听touchmove事件,当移动到一定程度需要显示上面的文字
parent.addEventListener('touchmove',function (e) {
if(isTop() && (e.touches[0].pageY-startY) > 0){
refreshText.style.height = "50px";
parent.style.transform = "translateY(50px)";
parent.style.transition = "all ease 0.3s";
refreshText.innerHTML = "获取更多聊天记录...";
}
});
//5.给列表dom监听touchend事件,此时说明用户已经松开了手指,应该进行异步操作了
parent.addEventListener('touchend',function (e) {
if(isTop()){
refreshText.innerHTML = "正在刷新...";
setTimeout(function(){
parent.style.transform = "translateY(0)";
console.log('成功刷新');
},800)
}
medtap.loading(1);
chat.refreshRecord(1)
return;
})
function isTop(){
var t = document.documentElement.scrollTop||document.body.scrollTop;
return t === 0 ? true : false;
}
},
bindEve: function() {
$('.close_info_btn').unbind().bind('click', function() {
......@@ -619,7 +534,6 @@ define([ 'zepto', 'medtap','mui'], function($, medtap,mui) {
startId: id
},
success: function(res) {
$('.refreshText').html('')
console.log('刷新的消息',res)
medtap.loading(0);
chat.offsetRefresh += 1;
......@@ -628,9 +542,9 @@ define([ 'zepto', 'medtap','mui'], function($, medtap,mui) {
var html = '';
if (record.length == 0) {
chat.hasMore = false;
medtap.toast({
message: '没有更多了'
})
// medtap.toast({
// message: '没有更多了'
// })
} else {
chat.hasMore = true;
if (operateType == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment