diff --git a/packageA/pages/distribution/main/main.js b/packageA/pages/distribution/main/main.js index 95beb46..d39f078 100644 --- a/packageA/pages/distribution/main/main.js +++ b/packageA/pages/distribution/main/main.js @@ -15,12 +15,14 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - self = this;//保存全局指针 + self = this;//保存全局指针 + app.isLogin().then(function(data) {//进入页面前已经授权登录成功 self.setData({ userInfo: data, }); }); + }, /** @@ -34,8 +36,8 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { + console.log('onshow'); let url = '/api/weshop/users/distribut/getMoney'; - if(app.globalData.userInfo) { if(!this.data.isLogin) { this.setData({ @@ -43,10 +45,11 @@ Page({ imghost: app.globalData.setting.imghost, isLogin: true, }); - console.log('userinfo', this.data.userInfo); + // 请求数据 app.request.get(url + '/' + this.data.userInfo.store_id + '/' + this.data.userInfo.user_id, { success: function(res) { + console.log('success~~`', self.data.userInfo); if(res.data.code == 0){ self.setData({ @@ -61,7 +64,6 @@ Page({ storeId: self.data.userInfo.store_id, userId: self.data.userInfo.user_id, first_leader: self.data.userInfo.first_leader, - // first_leader: '', }, isShowLoading: true, }).then(function(res) { @@ -74,19 +76,14 @@ Page({ // }; }; }, - fail: function() { - - }, + }); - // this.getData('/api/weshop/users/distribut/getMoney', { - // store_id: app.globalData.setting.stoid, - // user_id: app.globalData.user_id, - // }); }; }; + }, /** @@ -138,34 +135,7 @@ Page({ app.goto(url); }, - /** - * 请求数据 - */ - // getData(url, data) { - - // app.request.get(url + '/' + data.store_id + '/' + data.user_id, { - // success: function(res) { - // if(res.data.code == 0){ - // // console.log('success',res.data.data.is_distribut); - // if(res.data.data.is_distribut) {//如果是分销商 - // self.setData({ - // data: res.data.data, - // }); - // } else {//如果不是分销商 - - // }; - // }else{ - // wx.showToast({ - // title: "网络繁忙,请重试", - // icon: 'none', - // duration: 2000 - // }) - // } - // }, - // fail: function() {}, - // }); - - // }, + /** * 获取输入框 @@ -221,19 +191,6 @@ Page({ } }); - // app.request.promisePost('/api/weshop/users/distribut/updateUserRecommender', { - // data: { - // storeId: self.data.userInfo.store_id, - // userId: self.data.userInfo.user_id, - // mobile: mobile, - // }, - // isShowLoading: true, - // }).then(function(res) { - // console.log('!!!===>', res); - // self.setData({ - // fenxiao: res.data.data, - // }); - // }); } } else { wx.showToast({ diff --git a/packageA/pages/distribution/shop/shop.js b/packageA/pages/distribution/shop/shop.js index 54e6afd..472d912 100644 --- a/packageA/pages/distribution/shop/shop.js +++ b/packageA/pages/distribution/shop/shop.js @@ -24,6 +24,8 @@ Page({ isLoading: false, // 检测是否已经发送请求,防止重复发送请求 noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 pageNum: 1, // 当前页数 + + isAll: true, }, /** @@ -109,7 +111,15 @@ Page({ }); // 请求数据 - this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop', { + data: this.data.currentQuery, + }).then(res => { + self.setData({ + list: res.data.data, + total: res.data.data.total, + }); + }); + // 新品 app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { data: self.data.currentQuery, @@ -205,7 +215,13 @@ Page({ * 页面上拉触底事件的处理函数 */ onReachBottom: function () { - this.scrollToLower('/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); + let url = ''; + if(this.data.isAll) { + url = '/api/weshop/users/distribut/pagemyshop'; + } else { + url = '/api/weshop/users/distribut/pagemyshop?type=2'; + }; + this.scrollToLower(url, this.data.currentQuery); }, /** @@ -457,7 +473,7 @@ Page({ if(isInit) {// 第一次加载 self.setData({ - list: res.data.data + list: res.data.data, }); } else { self.setData({ @@ -524,7 +540,6 @@ Page({ } else { url = e.currentTarget.dataset.url; } - console.log(url); app.goto(url); }, @@ -533,10 +548,18 @@ Page({ */ clickAll() { let data = this.data.currentQuery; + if(data.page) delete data.page; if(data.orderField) delete data.orderField; if(data.orderType) delete data.orderType; if(data.key) delete data.key; + + this.setData({ + pageNum: 1, + noMore: false, + isAll: true, + }); + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); }, @@ -545,10 +568,25 @@ Page({ */ clickNew() { let data = this.data.currentQuery; + if(data.page) delete data.page; if(data.orderField) delete data.orderField; if(data.orderType) delete data.orderType; if(data.key) delete data.key; - this.getData(true, '/api/weshop/users/distribut/pagemyshop?type=2', data); + + this.setData({ + pageNum: 1, + noMore: false, + isAll: false, + }); + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { + data: data, + }).then(res => { + self.setData({ + list: res.data.data, + }); + }); }, + + }) \ No newline at end of file diff --git a/packageA/pages/distribution/shop/shop.wxml b/packageA/pages/distribution/shop/shop.wxml index 035befd..5035d34 100644 --- a/packageA/pages/distribution/shop/shop.wxml +++ b/packageA/pages/distribution/shop/shop.wxml @@ -18,11 +18,11 @@ - - {{filter.show_default(list.total)}} + + {{filter.show_default(total)}} 全部商品 - + {{filter.show_default(newList.total)}} 新品 @@ -113,19 +113,10 @@ - - - - - - + + + + + diff --git a/packageA/pages/distribution/shop/shop.wxss b/packageA/pages/distribution/shop/shop.wxss index c9b3f78..8889551 100644 --- a/packageA/pages/distribution/shop/shop.wxss +++ b/packageA/pages/distribution/shop/shop.wxss @@ -154,6 +154,10 @@ page { z-index: 1; } +.selected { + color: #FF6768; +} + .active { color: #FF6768;