Commit 72137b2cfb4e677060e9afe7129d60828bede76b
1 parent
b1e1b58d
我的小店点击全部商品和新品
Showing
4 changed files
with
64 additions
and
74 deletions
packageA/pages/distribution/main/main.js
| @@ -15,12 +15,14 @@ Page({ | @@ -15,12 +15,14 @@ Page({ | ||
| 15 | * 生命周期函数--监听页面加载 | 15 | * 生命周期函数--监听页面加载 |
| 16 | */ | 16 | */ |
| 17 | onLoad: function (options) { | 17 | onLoad: function (options) { |
| 18 | - self = this;//保存全局指针 | 18 | + self = this;//保存全局指针 |
| 19 | + | ||
| 19 | app.isLogin().then(function(data) {//进入页面前已经授权登录成功 | 20 | app.isLogin().then(function(data) {//进入页面前已经授权登录成功 |
| 20 | self.setData({ | 21 | self.setData({ |
| 21 | userInfo: data, | 22 | userInfo: data, |
| 22 | }); | 23 | }); |
| 23 | }); | 24 | }); |
| 25 | + | ||
| 24 | }, | 26 | }, |
| 25 | 27 | ||
| 26 | /** | 28 | /** |
| @@ -34,8 +36,8 @@ Page({ | @@ -34,8 +36,8 @@ Page({ | ||
| 34 | * 生命周期函数--监听页面显示 | 36 | * 生命周期函数--监听页面显示 |
| 35 | */ | 37 | */ |
| 36 | onShow: function () { | 38 | onShow: function () { |
| 39 | + console.log('onshow'); | ||
| 37 | let url = '/api/weshop/users/distribut/getMoney'; | 40 | let url = '/api/weshop/users/distribut/getMoney'; |
| 38 | - | ||
| 39 | if(app.globalData.userInfo) { | 41 | if(app.globalData.userInfo) { |
| 40 | if(!this.data.isLogin) { | 42 | if(!this.data.isLogin) { |
| 41 | this.setData({ | 43 | this.setData({ |
| @@ -43,10 +45,11 @@ Page({ | @@ -43,10 +45,11 @@ Page({ | ||
| 43 | imghost: app.globalData.setting.imghost, | 45 | imghost: app.globalData.setting.imghost, |
| 44 | isLogin: true, | 46 | isLogin: true, |
| 45 | }); | 47 | }); |
| 46 | - console.log('userinfo', this.data.userInfo); | 48 | + |
| 47 | // 请求数据 | 49 | // 请求数据 |
| 48 | app.request.get(url + '/' + this.data.userInfo.store_id + '/' + this.data.userInfo.user_id, { | 50 | app.request.get(url + '/' + this.data.userInfo.store_id + '/' + this.data.userInfo.user_id, { |
| 49 | success: function(res) { | 51 | success: function(res) { |
| 52 | + console.log('success~~`', self.data.userInfo); | ||
| 50 | if(res.data.code == 0){ | 53 | if(res.data.code == 0){ |
| 51 | 54 | ||
| 52 | self.setData({ | 55 | self.setData({ |
| @@ -61,7 +64,6 @@ Page({ | @@ -61,7 +64,6 @@ Page({ | ||
| 61 | storeId: self.data.userInfo.store_id, | 64 | storeId: self.data.userInfo.store_id, |
| 62 | userId: self.data.userInfo.user_id, | 65 | userId: self.data.userInfo.user_id, |
| 63 | first_leader: self.data.userInfo.first_leader, | 66 | first_leader: self.data.userInfo.first_leader, |
| 64 | - // first_leader: '', | ||
| 65 | }, | 67 | }, |
| 66 | isShowLoading: true, | 68 | isShowLoading: true, |
| 67 | }).then(function(res) { | 69 | }).then(function(res) { |
| @@ -74,19 +76,14 @@ Page({ | @@ -74,19 +76,14 @@ Page({ | ||
| 74 | // }; | 76 | // }; |
| 75 | }; | 77 | }; |
| 76 | }, | 78 | }, |
| 77 | - fail: function() { | ||
| 78 | - | ||
| 79 | - }, | 79 | + |
| 80 | }); | 80 | }); |
| 81 | 81 | ||
| 82 | - // this.getData('/api/weshop/users/distribut/getMoney', { | ||
| 83 | - // store_id: app.globalData.setting.stoid, | ||
| 84 | - // user_id: app.globalData.user_id, | ||
| 85 | - // }); | ||
| 86 | 82 | ||
| 87 | }; | 83 | }; |
| 88 | }; | 84 | }; |
| 89 | 85 | ||
| 86 | + | ||
| 90 | }, | 87 | }, |
| 91 | 88 | ||
| 92 | /** | 89 | /** |
| @@ -138,34 +135,7 @@ Page({ | @@ -138,34 +135,7 @@ Page({ | ||
| 138 | app.goto(url); | 135 | app.goto(url); |
| 139 | }, | 136 | }, |
| 140 | 137 | ||
| 141 | - /** | ||
| 142 | - * 请求数据 | ||
| 143 | - */ | ||
| 144 | - // getData(url, data) { | ||
| 145 | - | ||
| 146 | - // app.request.get(url + '/' + data.store_id + '/' + data.user_id, { | ||
| 147 | - // success: function(res) { | ||
| 148 | - // if(res.data.code == 0){ | ||
| 149 | - // // console.log('success',res.data.data.is_distribut); | ||
| 150 | - // if(res.data.data.is_distribut) {//如果是分销商 | ||
| 151 | - // self.setData({ | ||
| 152 | - // data: res.data.data, | ||
| 153 | - // }); | ||
| 154 | - // } else {//如果不是分销商 | ||
| 155 | - | ||
| 156 | - // }; | ||
| 157 | - // }else{ | ||
| 158 | - // wx.showToast({ | ||
| 159 | - // title: "网络繁忙,请重试", | ||
| 160 | - // icon: 'none', | ||
| 161 | - // duration: 2000 | ||
| 162 | - // }) | ||
| 163 | - // } | ||
| 164 | - // }, | ||
| 165 | - // fail: function() {}, | ||
| 166 | - // }); | ||
| 167 | - | ||
| 168 | - // }, | 138 | + |
| 169 | 139 | ||
| 170 | /** | 140 | /** |
| 171 | * 获取输入框 | 141 | * 获取输入框 |
| @@ -221,19 +191,6 @@ Page({ | @@ -221,19 +191,6 @@ Page({ | ||
| 221 | } | 191 | } |
| 222 | }); | 192 | }); |
| 223 | 193 | ||
| 224 | - // app.request.promisePost('/api/weshop/users/distribut/updateUserRecommender', { | ||
| 225 | - // data: { | ||
| 226 | - // storeId: self.data.userInfo.store_id, | ||
| 227 | - // userId: self.data.userInfo.user_id, | ||
| 228 | - // mobile: mobile, | ||
| 229 | - // }, | ||
| 230 | - // isShowLoading: true, | ||
| 231 | - // }).then(function(res) { | ||
| 232 | - // console.log('!!!===>', res); | ||
| 233 | - // self.setData({ | ||
| 234 | - // fenxiao: res.data.data, | ||
| 235 | - // }); | ||
| 236 | - // }); | ||
| 237 | } | 194 | } |
| 238 | } else { | 195 | } else { |
| 239 | wx.showToast({ | 196 | wx.showToast({ |
packageA/pages/distribution/shop/shop.js
| @@ -24,6 +24,8 @@ Page({ | @@ -24,6 +24,8 @@ Page({ | ||
| 24 | isLoading: false, // 检测是否已经发送请求,防止重复发送请求 | 24 | isLoading: false, // 检测是否已经发送请求,防止重复发送请求 |
| 25 | noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 | 25 | noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 |
| 26 | pageNum: 1, // 当前页数 | 26 | pageNum: 1, // 当前页数 |
| 27 | + | ||
| 28 | + isAll: true, | ||
| 27 | }, | 29 | }, |
| 28 | 30 | ||
| 29 | /** | 31 | /** |
| @@ -109,7 +111,15 @@ Page({ | @@ -109,7 +111,15 @@ Page({ | ||
| 109 | }); | 111 | }); |
| 110 | 112 | ||
| 111 | // 请求数据 | 113 | // 请求数据 |
| 112 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); | 114 | + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop', { |
| 115 | + data: this.data.currentQuery, | ||
| 116 | + }).then(res => { | ||
| 117 | + self.setData({ | ||
| 118 | + list: res.data.data, | ||
| 119 | + total: res.data.data.total, | ||
| 120 | + }); | ||
| 121 | + }); | ||
| 122 | + | ||
| 113 | // 新品 | 123 | // 新品 |
| 114 | app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | 124 | app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { |
| 115 | data: self.data.currentQuery, | 125 | data: self.data.currentQuery, |
| @@ -205,7 +215,13 @@ Page({ | @@ -205,7 +215,13 @@ Page({ | ||
| 205 | * 页面上拉触底事件的处理函数 | 215 | * 页面上拉触底事件的处理函数 |
| 206 | */ | 216 | */ |
| 207 | onReachBottom: function () { | 217 | onReachBottom: function () { |
| 208 | - this.scrollToLower('/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); | 218 | + let url = ''; |
| 219 | + if(this.data.isAll) { | ||
| 220 | + url = '/api/weshop/users/distribut/pagemyshop'; | ||
| 221 | + } else { | ||
| 222 | + url = '/api/weshop/users/distribut/pagemyshop?type=2'; | ||
| 223 | + }; | ||
| 224 | + this.scrollToLower(url, this.data.currentQuery); | ||
| 209 | }, | 225 | }, |
| 210 | 226 | ||
| 211 | /** | 227 | /** |
| @@ -457,7 +473,7 @@ Page({ | @@ -457,7 +473,7 @@ Page({ | ||
| 457 | 473 | ||
| 458 | if(isInit) {// 第一次加载 | 474 | if(isInit) {// 第一次加载 |
| 459 | self.setData({ | 475 | self.setData({ |
| 460 | - list: res.data.data | 476 | + list: res.data.data, |
| 461 | }); | 477 | }); |
| 462 | } else { | 478 | } else { |
| 463 | self.setData({ | 479 | self.setData({ |
| @@ -524,7 +540,6 @@ Page({ | @@ -524,7 +540,6 @@ Page({ | ||
| 524 | } else { | 540 | } else { |
| 525 | url = e.currentTarget.dataset.url; | 541 | url = e.currentTarget.dataset.url; |
| 526 | } | 542 | } |
| 527 | - console.log(url); | ||
| 528 | app.goto(url); | 543 | app.goto(url); |
| 529 | }, | 544 | }, |
| 530 | 545 | ||
| @@ -533,10 +548,18 @@ Page({ | @@ -533,10 +548,18 @@ Page({ | ||
| 533 | */ | 548 | */ |
| 534 | clickAll() { | 549 | clickAll() { |
| 535 | let data = this.data.currentQuery; | 550 | let data = this.data.currentQuery; |
| 551 | + | ||
| 536 | if(data.page) delete data.page; | 552 | if(data.page) delete data.page; |
| 537 | if(data.orderField) delete data.orderField; | 553 | if(data.orderField) delete data.orderField; |
| 538 | if(data.orderType) delete data.orderType; | 554 | if(data.orderType) delete data.orderType; |
| 539 | if(data.key) delete data.key; | 555 | if(data.key) delete data.key; |
| 556 | + | ||
| 557 | + this.setData({ | ||
| 558 | + pageNum: 1, | ||
| 559 | + noMore: false, | ||
| 560 | + isAll: true, | ||
| 561 | + }); | ||
| 562 | + | ||
| 540 | this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | 563 | this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); |
| 541 | }, | 564 | }, |
| 542 | 565 | ||
| @@ -545,10 +568,25 @@ Page({ | @@ -545,10 +568,25 @@ Page({ | ||
| 545 | */ | 568 | */ |
| 546 | clickNew() { | 569 | clickNew() { |
| 547 | let data = this.data.currentQuery; | 570 | let data = this.data.currentQuery; |
| 571 | + | ||
| 548 | if(data.page) delete data.page; | 572 | if(data.page) delete data.page; |
| 549 | if(data.orderField) delete data.orderField; | 573 | if(data.orderField) delete data.orderField; |
| 550 | if(data.orderType) delete data.orderType; | 574 | if(data.orderType) delete data.orderType; |
| 551 | if(data.key) delete data.key; | 575 | if(data.key) delete data.key; |
| 552 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop?type=2', data); | 576 | + |
| 577 | + this.setData({ | ||
| 578 | + pageNum: 1, | ||
| 579 | + noMore: false, | ||
| 580 | + isAll: false, | ||
| 581 | + }); | ||
| 582 | + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | ||
| 583 | + data: data, | ||
| 584 | + }).then(res => { | ||
| 585 | + self.setData({ | ||
| 586 | + list: res.data.data, | ||
| 587 | + }); | ||
| 588 | + }); | ||
| 553 | }, | 589 | }, |
| 590 | + | ||
| 591 | + | ||
| 554 | }) | 592 | }) |
| 555 | \ No newline at end of file | 593 | \ No newline at end of file |
packageA/pages/distribution/shop/shop.wxml
| @@ -18,11 +18,11 @@ | @@ -18,11 +18,11 @@ | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | <view class="flex t-c fs24 f1 jc_fe"> | 20 | <view class="flex t-c fs24 f1 jc_fe"> |
| 21 | - <view class="pdv20 pdh40" bindtap="clickAll"> | ||
| 22 | - <view class="fs30">{{filter.show_default(list.total)}}</view> | 21 | + <view class="pdv20 pdh40 {{isAll ? 'selected':''}}" bindtap="clickAll"> |
| 22 | + <view class="fs30">{{filter.show_default(total)}}</view> | ||
| 23 | <view>全部商品</view> | 23 | <view>全部商品</view> |
| 24 | </view> | 24 | </view> |
| 25 | - <view class="pdv20 pdh40" bindtap="clickNew"> | 25 | + <view class="pdv20 pdh40 {{!isAll ? 'selected':''}}" bindtap="clickNew"> |
| 26 | <view class="fs30">{{filter.show_default(newList.total)}}</view> | 26 | <view class="fs30">{{filter.show_default(newList.total)}}</view> |
| 27 | <view>新品</view> | 27 | <view>新品</view> |
| 28 | </view> | 28 | </view> |
| @@ -113,19 +113,10 @@ | @@ -113,19 +113,10 @@ | ||
| 113 | </view> | 113 | </view> |
| 114 | 114 | ||
| 115 | 115 | ||
| 116 | - | ||
| 117 | - | ||
| 118 | - | ||
| 119 | - <!-- <view class="bottomBar flex pd20 jc_sb fs26 ai-center"> | ||
| 120 | - <view> | ||
| 121 | - <label class="flex ai-center"> | ||
| 122 | - <checkbox/>全选 | ||
| 123 | - </label> | ||
| 124 | - </view> | ||
| 125 | - <view class="pd20 btn" wx:if="{{options.index == 0}}">一键上架</view> | ||
| 126 | - <view class="pd20 btn" wx:else>一键下架</view> | ||
| 127 | - </view> --> | ||
| 128 | - | ||
| 129 | - | ||
| 130 | 116 | ||
| 131 | </view> | 117 | </view> |
| 118 | + | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + |