diff --git a/packageC/pages/goods/distributionCategoryList/index.js b/packageC/pages/goods/distributionCategoryList/index.js index 13d5628..a00415d 100644 --- a/packageC/pages/goods/distributionCategoryList/index.js +++ b/packageC/pages/goods/distributionCategoryList/index.js @@ -1,7 +1,7 @@ const { app } = require("../../../../utils/common"); let startY = 0; let endY = 0; -let scrolltop = 0; +let isReachBt = 0; let moveDistance = 0; const t = getApp(), e = t.request, oo = t.globalData.setting; var i = function (i) { @@ -449,6 +449,9 @@ Page({ }, async click_classify(e) { + + clearInterval(this.data.timer); + let { cid, current } = e.currentTarget.dataset; this.setData({ select_classify_on: current, @@ -495,71 +498,87 @@ Page({ }) } }, */ - async requestGoodsList() { - console.log('hanshu'); - if (this.data.isLoading) return false; - // if(this.data.is_no_more)return - if (this.data.is_no_more && this.data.is_up) return false; + + requestGoodsList() { + if(this.data.isLoading) return false; + if(this.data.is_no_more) return false this.data.isLoading = 1; + var th=this; + let { currentData } = this.data; currentData.cat_id = this.data.cat_id; currentData.page = this.data.stylePage; - // console.log(data); - let url = `/api/weshop/users/distribut/pagemyshop`; - const { data: res } = await e.promiseGet(url, { + + let url = '/api/weshop/users/distribut/pagemyshop'; + getApp().promiseGet(url, { isShowLoading: true, data: currentData, - }); - console.log(res); - - let index = this.getCurrentIndex(); - let next_classify_name = this.data.catelist[index].name; - this.setData({ - isLoading: 0, - is_no_more: 0, - is_get: 1, - select_classify_on: index, - classify_name: next_classify_name, - next_classify_name, - }); - if (res.code == 0 && res.data.pageData.length > 0) { - // if(res.data.pageData.length 1) { - this.setData({ - requestData: this.data.requestData.concat(res.data.pageData), + }).then(res=>{ + var res=res.data; + let index = this.getCurrentIndex(); + let next_classify_name = this.data.catelist[index].name; + th.setData({ + isLoading: 0, + is_get: 1, + select_classify_on: index, + classify_name: next_classify_name, + next_classify_name, }); - } else { - this.setData({ - requestData: res.data.pageData, - }); - } - } else { - //上拉加载 - if (res.data.page > 1) { - this.setData({ - is_no_more: 1, - }) - } else { - this.setData({ - requestData: [], - }); - //如果类目为空则3秒后加载下一类目 - this.data.timer = setInterval(() => { - this.setData({ - countDownNum: this.data.countDownNum - 1, - }); - if (this.data.countDownNum == 0) { - clearInterval(this.data.timer); - this.get_next_cate(index); - } - }, 1000); - } - } + if (res.code == 0 && res.data.pageData.length > 0) { + if (res.data.page > 1) { + th.setData({ + requestData: th.data.requestData.concat(res.data.pageData), + }); + } else { + th.setData({ + requestData: res.data.pageData, + }); + } + isReachBt = 0; + + if(res.data.pageData.length<10){ + this.setData({ + is_no_more: 1, + }) + } + + } else { + //上拉加载 + if (res.data.page > 1) { + th.setData({ + is_no_more: 1, + }) + } else { + th.setData({ + requestData: [], + }); + + //如果类目为空则3秒后加载下一类目 + if(th.data.timer) { + th.data.timer=clearInterval(th.data.timer); + th.data.timer=0; + } + th.data.timer = setInterval(() => { + if(th.data.countDownNum<0){ + clearInterval(th.data.timer); + return false; + } + + th.setData({ + countDownNum: this.data.countDownNum - 1, + }); + if (th.data.countDownNum <= 0) { + clearInterval(th.data.timer); + th.get_next_cate(index); + return false; + } + }, 1000); + } + } + }) + + }, //查找当前类目在 catelist的下标 为后面下一个类目使用 @@ -577,23 +596,22 @@ Page({ return index; }, - get_next_cate(index) { - console.log('get_next_cate'); + if(this.data.isLoading) return false; index = index + 1; let nex_cat_id = this.data.catelist[index].id; this.setData({ cat_id: nex_cat_id, stylePage: 1, is_get: 0, + is_no_more:0, next_classify_name: this.data.catelist[index].name, }); - this.data.is_up = 0; + this.data.car_scroll=0; + isReachBt = 0; this.requestGoodsList(); }, - onReachBottom: function () { - }, //选择更多 select_more: function (e) { var cid = e.currentTarget.dataset.cid; @@ -624,41 +642,45 @@ Page({ }, touchstart(e) { - // if (!this.data.is_no_more) return false; - // if(this.data.is_next){ - // this.setData({ - // is_no_more:0, - // }) - // } - // this.data.is_next=0; + startY=0; + if (!this.data.is_no_more) return false; + if(isReachBt<=0) return false; startY = e.changedTouches[0].clientY; - console.log('gdsg'); + }, touchend(e) { + var th=this; + setTimeout(function () { + if(!th.data.car_scroll){ + clearInterval(th.data.timer); + th.get_next_cate(th.data.select_classify_on); + return false; + } - endY = e.changedTouches[0].clientY; - moveDistance = startY - endY; - if(moveDistance<0){ - scrolltop=0 - } - console.log(scrolltop); - if (this.data.is_no_more && !this.data.is_up) { - this.data.is_up = 1; - return false; - } + if(!startY) return false; + endY = e.changedTouches[0].clientY; + moveDistance = startY - endY; + if(moveDistance<0){ + isReachBt=0; + return false; + } + if (th.data.is_no_more && moveDistance >= 10 && isReachBt > 0) { + clearInterval(th.data.timer); + th.get_next_cate(th.data.select_classify_on); + } + },50) - if (this.data.is_no_more && moveDistance >= 300 && scrolltop > 0) { - this.data.is_up = 0; - this.get_next_cate(this.data.select_classify_on); - } }, // 左侧更新 scrollLower: function () { - scrolltop = 1; - if (this.data.isLoading) return false; - if (this.data.is_no_more) return false; + console.log("low111"); + if (this.data.isLoading) return false; + if (this.data.is_no_more) { + isReachBt = 1; + return false; + } this.setData({ stylePage: this.data.stylePage + 1, @@ -666,7 +688,6 @@ Page({ }); !this.data.is_none && this.requestGoodsList(); - }, //--- 获取卡类列表 --- @@ -693,4 +714,8 @@ Page({ }) }, + bd_scroll:function (e) { + this.data.car_scroll=1; + } + }); \ No newline at end of file diff --git a/packageC/pages/goods/distributionCategoryList/index.wxml b/packageC/pages/goods/distributionCategoryList/index.wxml index 84b9936..77ab9f5 100644 --- a/packageC/pages/goods/distributionCategoryList/index.wxml +++ b/packageC/pages/goods/distributionCategoryList/index.wxml @@ -95,8 +95,10 @@ - - + + @@ -204,9 +206,9 @@ - + - 向上拉继续浏览{{next_classify_name}} + 向上拉继续浏览下一个类别