Commit 2c080645b7925d8c3915b73b89f9d528a8fa714d
1 parent
a7eb046e
分销小店 分类图片
Showing
3 changed files
with
675 additions
and
673 deletions
packageA/pages/distribution/shop/shop.js
| 1 | // packageA//pages/distribution/commision/commision.js | 1 | // packageA//pages/distribution/commision/commision.js |
| 2 | -const app = getApp(); | 2 | +const app = getApp(); |
| 3 | let self = null; | 3 | let self = null; |
| 4 | -var os = app.globalData.setting, | ||
| 5 | - ut= require("../../../../utils/util.js"); | ||
| 6 | - | ||
| 7 | - | 4 | +var os = app.globalData.setting, |
| 5 | + ut = require("../../../../utils/util.js"); | ||
| 6 | + | ||
| 7 | + | ||
| 8 | Page({ | 8 | Page({ |
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * 页面的初始数据 | 11 | * 页面的初始数据 |
| 12 | */ | 12 | */ |
| 13 | data: { | 13 | data: { |
| 14 | - isInputFocus: false,//记录搜索输入框是否聚焦 | ||
| 15 | - inputVal: '',//记录搜索输入框的内容 | ||
| 16 | - isSort: false,//控制排序开关状态,true开启排序 | ||
| 17 | - isDescending: false, //isDescending降序,ascending升序 | ||
| 18 | - imghost: '', | ||
| 19 | - url: os.imghost, | ||
| 20 | - | ||
| 21 | - tabArr: ['最新','销量','评论','价格'], | ||
| 22 | - currentTabIndex: 0, | ||
| 23 | - isShowRow: false,//控制视图切换状态 | ||
| 24 | - isHiddenDropdown: true,//控制筛选下拉菜单显隐 | ||
| 25 | - | ||
| 26 | - list: null, | ||
| 27 | - isLoading: false, // 检测是否已经发送请求,防止重复发送请求 | ||
| 28 | - noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 | ||
| 29 | - pageNum: 1, // 当前页数 | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - rank_switch: false, | ||
| 33 | - card_field: "", | ||
| 34 | - card_name: "", | ||
| 35 | - max_card_field: "", | ||
| 36 | - card_list: null, | ||
| 37 | - | ||
| 38 | - isAll: true, | ||
| 39 | - | ||
| 40 | - default_img: '/miniapp/images/default_g_img.gif', | 14 | + isInputFocus: false,//记录搜索输入框是否聚焦 |
| 15 | + inputVal: '',//记录搜索输入框的内容 | ||
| 16 | + isSort: false,//控制排序开关状态,true开启排序 | ||
| 17 | + isDescending: false, //isDescending降序,ascending升序 | ||
| 18 | + imghost: '', | ||
| 19 | + url: os.imghost, | ||
| 20 | + | ||
| 21 | + tabArr: ['最新', '销量', '评论', '价格'], | ||
| 22 | + currentTabIndex: 0, | ||
| 23 | + isShowRow: false,//控制视图切换状态 | ||
| 24 | + isHiddenDropdown: true,//控制筛选下拉菜单显隐 | ||
| 25 | + | ||
| 26 | + list: null, | ||
| 27 | + isLoading: false, // 检测是否已经发送请求,防止重复发送请求 | ||
| 28 | + noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 | ||
| 29 | + pageNum: 1, // 当前页数 | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + rank_switch: false, | ||
| 33 | + card_field: "", | ||
| 34 | + card_name: "", | ||
| 35 | + max_card_field: "", | ||
| 36 | + card_list: null, | ||
| 37 | + | ||
| 38 | + isAll: true, | ||
| 39 | + | ||
| 40 | + default_img: '/miniapp/images/default_g_img.gif', | ||
| 41 | }, | 41 | }, |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | * 生命周期函数--监听页面加载 | 44 | * 生命周期函数--监听页面加载 |
| 45 | */ | 45 | */ |
| 46 | onLoad: function (options) { | 46 | onLoad: function (options) { |
| 47 | - | ||
| 48 | - wx.setNavigationBarTitle({ | ||
| 49 | - title: "我的小店", | ||
| 50 | - }); | ||
| 51 | - self = this;//保存全局指针 | ||
| 52 | - app.isLogin().then(function(data) {//进入页面前已经授权登录成功 | ||
| 53 | - self.setData({ | ||
| 54 | - userInfo: data, | ||
| 55 | - }); | ||
| 56 | - }); | ||
| 57 | - | ||
| 58 | - //从别人的分享的跳转过来 | ||
| 59 | - var first_leader = decodeURIComponent(options.scene); | ||
| 60 | - if(first_leader && first_leader!='undefined'){ | ||
| 61 | - getApp().globalData.first_leader=first_leader; | ||
| 62 | - this.data.first_leader=first_leader; | ||
| 63 | - | ||
| 64 | - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + first_leader, { | ||
| 65 | - isShowLoading:false, | ||
| 66 | - data:{r:Math.random()}, | ||
| 67 | - success: function (e) { | ||
| 68 | - if(e.data.code==0){ | ||
| 69 | - self.setData({ | ||
| 70 | - userInfo2:e.data.data, | ||
| 71 | - }); | ||
| 72 | - }; | ||
| 73 | - | ||
| 74 | - }, | ||
| 75 | - }); | ||
| 76 | - | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - // 判断会员是否授权登录, | ||
| 81 | - // 没有登录则跳转到登录页, | ||
| 82 | - // 已登录则设置已登录状态,请求加载签到数据 | ||
| 83 | - // isLogin记录登录状态 | ||
| 84 | - // app.isLogin().then(function(data) { | ||
| 85 | - // // 1.登录成功 | ||
| 86 | - // self.setData({ | ||
| 87 | - // isLogin: true, | ||
| 88 | - // userInfo: data, | ||
| 89 | - // currentQuery: { | ||
| 90 | - // store_id: app.globalData.setting.stoid, | ||
| 91 | - // user_id: app.globalData.user_id, | ||
| 92 | - // }, | ||
| 93 | - // }); | ||
| 94 | - // // 2.请求全部商品数据 | ||
| 95 | - // self.getData(true, '/api/weshop/users/distribut/pagemyshop', self.data.currentQuery); | ||
| 96 | - // // 3.请求新品 | ||
| 97 | - // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | ||
| 98 | - // data: self.data.currentQuery, | ||
| 99 | - // }).then(function(res) { | ||
| 100 | - // self.setData({ | ||
| 101 | - // newList: res.data.data, | ||
| 102 | - // }); | ||
| 103 | - // }) | ||
| 104 | - // }); | 47 | + console.log(options); |
| 48 | + wx.setNavigationBarTitle({ | ||
| 49 | + title: "我的小店", | ||
| 50 | + }); | ||
| 51 | + | ||
| 52 | + self = this;//保存全局指针 | ||
| 53 | + app.isLogin().then(function (data) {//进入页面前已经授权登录成功 | ||
| 54 | + self.setData({ | ||
| 55 | + userInfo: data, | ||
| 56 | + }); | ||
| 57 | + }); | ||
| 58 | + //从别人的分享的跳转过来 | ||
| 59 | + var first_leader = decodeURIComponent(options.scene); | ||
| 60 | + if (first_leader && first_leader != 'undefined') { | ||
| 61 | + getApp().globalData.first_leader = first_leader; | ||
| 62 | + this.data.first_leader = first_leader; | ||
| 63 | + | ||
| 64 | + getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + first_leader, { | ||
| 65 | + isShowLoading: false, | ||
| 66 | + data: { r: Math.random() }, | ||
| 67 | + success: function (e) { | ||
| 68 | + if (e.data.code == 0) { | ||
| 69 | + self.setData({ | ||
| 70 | + userInfo2: e.data.data, | ||
| 71 | + }); | ||
| 72 | + }; | ||
| 73 | + | ||
| 74 | + }, | ||
| 75 | + }); | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + | ||
| 80 | + // 判断会员是否授权登录, | ||
| 81 | + // 没有登录则跳转到登录页, | ||
| 82 | + // 已登录则设置已登录状态,请求加载签到数据 | ||
| 83 | + // isLogin记录登录状态 | ||
| 84 | + // app.isLogin().then(function(data) { | ||
| 85 | + // // 1.登录成功 | ||
| 86 | + // self.setData({ | ||
| 87 | + // isLogin: true, | ||
| 88 | + // userInfo: data, | ||
| 89 | + // currentQuery: { | ||
| 90 | + // store_id: app.globalData.setting.stoid, | ||
| 91 | + // user_id: app.globalData.user_id, | ||
| 92 | + // }, | ||
| 93 | + // }); | ||
| 94 | + // // 2.请求全部商品数据 | ||
| 95 | + // self.getData(true, '/api/weshop/users/distribut/pagemyshop', self.data.currentQuery); | ||
| 96 | + // // 3.请求新品 | ||
| 97 | + // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | ||
| 98 | + // data: self.data.currentQuery, | ||
| 99 | + // }).then(function(res) { | ||
| 100 | + // self.setData({ | ||
| 101 | + // newList: res.data.data, | ||
| 102 | + // }); | ||
| 103 | + // }) | ||
| 104 | + // }); | ||
| 105 | }, | 105 | }, |
| 106 | 106 | ||
| 107 | /** | 107 | /** |
| 108 | * 生命周期函数--监听页面初次渲染完成 | 108 | * 生命周期函数--监听页面初次渲染完成 |
| 109 | */ | 109 | */ |
| 110 | - onReady: function () {}, | 110 | + onReady: function () { }, |
| 111 | 111 | ||
| 112 | /** | 112 | /** |
| 113 | * 生命周期函数--监听页面显示 | 113 | * 生命周期函数--监听页面显示 |
| 114 | */ | 114 | */ |
| 115 | onShow: function () { | 115 | onShow: function () { |
| 116 | - //自己登录的 | ||
| 117 | - if(app.globalData.userInfo && !this.data.first_leader) { | ||
| 118 | - if(!this.data.isLogin) { | ||
| 119 | - this.setData({ | ||
| 120 | - userInfo: app.globalData.userInfo, | ||
| 121 | - imghost: app.globalData.setting.imghost, | ||
| 122 | - currentQuery: { | ||
| 123 | - store_id: app.globalData.setting.stoid, | ||
| 124 | - user_id: app.globalData.user_id, | ||
| 125 | - }, | ||
| 126 | - isLogin: true, | ||
| 127 | - }); | ||
| 128 | - | ||
| 129 | - // 请求数据 | ||
| 130 | - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?orderType=desc', { | ||
| 131 | - data: this.data.currentQuery, | ||
| 132 | - }).then(res => { | ||
| 133 | - self.setData({ | ||
| 134 | - list: res.data.data, | ||
| 135 | - total: res.data.data.total, | ||
| 136 | - }); | ||
| 137 | - }); | ||
| 138 | - | ||
| 139 | - // 新品 | ||
| 140 | - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', { | ||
| 141 | - data: self.data.currentQuery, | ||
| 142 | - }).then(res => { | ||
| 143 | - self.setData({ | ||
| 144 | - newList: res.data.data, | ||
| 145 | - }); | ||
| 146 | - }); | ||
| 147 | - // 广告banner | ||
| 148 | - app.request.promiseGet("/api/weshop/ad/page", { | ||
| 149 | - data: { | ||
| 150 | - pid: 401, | ||
| 151 | - enabled: 1, | ||
| 152 | - store_id: app.globalData.setting.stoid, | ||
| 153 | - } | ||
| 154 | - }).then(res => { | ||
| 155 | - if(res.data.code == 0 && res.data.data) { | ||
| 156 | - let item = res.data.data.pageData[0]; | ||
| 157 | - if(item && item.ad_code) { | ||
| 158 | - self.setData({ | ||
| 159 | - ad_img: item.ad_code, | ||
| 160 | - }); | ||
| 161 | - }; | ||
| 162 | - }; | ||
| 163 | - }); | ||
| 164 | - | ||
| 165 | - }; | ||
| 166 | - } | ||
| 167 | - //被人分享点击开的 | ||
| 168 | - else if(this.data.first_leader){ | ||
| 169 | - this.setData({ | ||
| 170 | - imghost: app.globalData.setting.imghost, | ||
| 171 | - currentQuery: { | ||
| 172 | - store_id: app.globalData.setting.stoid, | ||
| 173 | - user_id: this.data.first_leader, | ||
| 174 | - }, | ||
| 175 | - isLogin: true, | ||
| 176 | - }); | ||
| 177 | - | ||
| 178 | - // 请求数据 | ||
| 179 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); | ||
| 180 | - // 新品 | ||
| 181 | - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | ||
| 182 | - data: self.data.currentQuery, | ||
| 183 | - }).then(res => { | ||
| 184 | - self.setData({ | ||
| 185 | - newList: res.data.data, | ||
| 186 | - }); | ||
| 187 | - }); | ||
| 188 | - // 广告banner | ||
| 189 | - app.request.promiseGet("/api/weshop/ad/page", { | ||
| 190 | - data: { | ||
| 191 | - pid: 401, | ||
| 192 | - enabled: 1, | ||
| 193 | - store_id: app.globalData.setting.stoid, | ||
| 194 | - } | ||
| 195 | - }).then(res => { | ||
| 196 | - if(res.data.code == 0 && res.data.data) { | ||
| 197 | - let item = res.data.data.pageData[0]; | ||
| 198 | - if(item && item.ad_code) { | ||
| 199 | - self.setData({ | ||
| 200 | - ad_img: item.ad_code, | ||
| 201 | - }); | ||
| 202 | - }; | ||
| 203 | - }; | ||
| 204 | - }); | ||
| 205 | - } | ||
| 206 | - var th=this; | ||
| 207 | - //更新一下会员的信息 | ||
| 208 | - if(getApp().globalData.user_id) { | ||
| 209 | - if(!getApp().globalData.userInfo['is_distribut']){ | ||
| 210 | - th.setData({ishidden_comise:1}) | ||
| 211 | - } | ||
| 212 | - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { | ||
| 213 | - isShowLoading:false, | ||
| 214 | - success: function (e) { | ||
| 215 | - getApp().globalData.userInfo = e.data.data; | ||
| 216 | - getApp().getConfig2(function (e) { | ||
| 217 | - var swithc_list = e.switch_list; | ||
| 218 | - var sw_arr = JSON.parse(swithc_list); | ||
| 219 | - //---如果后台有开等级卡的开关--- | ||
| 220 | - if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { | ||
| 221 | - th.setData({ | ||
| 222 | - rank_switch: true | ||
| 223 | - }); | ||
| 224 | - //---回调卡的列表--- | ||
| 225 | - th.getPlusCardType(function (ob) { | ||
| 226 | - th.setData({ | ||
| 227 | - card_list: ob.card_list | ||
| 228 | - }); | ||
| 229 | - var ti = setInterval(function () { | ||
| 230 | - var user = getApp().globalData.userInfo; | ||
| 231 | - if (!user) return false; | ||
| 232 | - clearInterval(ti); | ||
| 233 | - if (user.card_field && user['card_expiredate']) { | ||
| 234 | - var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 235 | - var end = new Date(str); | ||
| 236 | - end = Date.parse(end) / 1000; | ||
| 237 | - var now = ut.gettimestamp(); | ||
| 238 | - //--- 判断是等级会员,且在有效期范围内 --- | ||
| 239 | - if (user.card_field && now < end) { | ||
| 240 | - var card_name = ob.name_map.get(user.card_field); | ||
| 241 | - if (card_name.length > 4) card_name = card_name.substring(0, 8); | ||
| 242 | - th.setData({ | ||
| 243 | - card_field: user.card_field, | ||
| 244 | - card_name: card_name, | ||
| 245 | - card_list: ob.card_list | ||
| 246 | - }); | ||
| 247 | - } | ||
| 248 | - } | ||
| 249 | - }, 500) | ||
| 250 | - }) | ||
| 251 | - } | ||
| 252 | - }) | ||
| 253 | - } | ||
| 254 | - }) | ||
| 255 | - } | ||
| 256 | - | ||
| 257 | - | 116 | + //自己登录的 |
| 117 | + if (app.globalData.userInfo && !this.data.first_leader) { | ||
| 118 | + if (!this.data.isLogin) { | ||
| 119 | + this.setData({ | ||
| 120 | + userInfo: app.globalData.userInfo, | ||
| 121 | + imghost: app.globalData.setting.imghost, | ||
| 122 | + isLogin: true, | ||
| 123 | + currentQuery: { | ||
| 124 | + store_id: app.globalData.setting.stoid, | ||
| 125 | + user_id: app.globalData.user_id, | ||
| 126 | + }, | ||
| 127 | + }); | ||
| 128 | + // 请求数据 | ||
| 129 | + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?orderType=desc', { | ||
| 130 | + data: this.data.currentQuery, | ||
| 131 | + }).then(res => { | ||
| 132 | + self.setData({ | ||
| 133 | + list: res.data.data, | ||
| 134 | + total: res.data.data.total, | ||
| 135 | + }); | ||
| 136 | + }); | ||
| 137 | + | ||
| 138 | + // 新品 | ||
| 139 | + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', { | ||
| 140 | + data: self.data.currentQuery, | ||
| 141 | + }).then(res => { | ||
| 142 | + self.setData({ | ||
| 143 | + newList: res.data.data, | ||
| 144 | + }); | ||
| 145 | + }); | ||
| 146 | + // 广告banner | ||
| 147 | + app.request.promiseGet("/api/weshop/ad/page", { | ||
| 148 | + data: { | ||
| 149 | + pid: 401, | ||
| 150 | + enabled: 1, | ||
| 151 | + store_id: app.globalData.setting.stoid, | ||
| 152 | + } | ||
| 153 | + }).then(res => { | ||
| 154 | + if (res.data.code == 0 && res.data.data) { | ||
| 155 | + let item = res.data.data.pageData[0]; | ||
| 156 | + if (item && item.ad_code) { | ||
| 157 | + self.setData({ | ||
| 158 | + ad_img: item.ad_code, | ||
| 159 | + }); | ||
| 160 | + }; | ||
| 161 | + }; | ||
| 162 | + }); | ||
| 163 | + | ||
| 164 | + }; | ||
| 165 | + } | ||
| 166 | + //被人分享点击开的 | ||
| 167 | + else if (this.data.first_leader) { | ||
| 168 | + console.log(11); | ||
| 169 | + this.setData({ | ||
| 170 | + imghost: app.globalData.setting.imghost, | ||
| 171 | + currentQuery: { | ||
| 172 | + store_id: app.globalData.setting.stoid, | ||
| 173 | + user_id: this.data.first_leader, | ||
| 174 | + }, | ||
| 175 | + isLogin: true, | ||
| 176 | + }); | ||
| 177 | + console.log('fenxiang'); | ||
| 178 | + // 请求数据 | ||
| 179 | + this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); | ||
| 180 | + // 新品 | ||
| 181 | + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | ||
| 182 | + data: self.data.currentQuery, | ||
| 183 | + }).then(res => { | ||
| 184 | + self.setData({ | ||
| 185 | + newList: res.data.data, | ||
| 186 | + }); | ||
| 187 | + }); | ||
| 188 | + // 广告banner | ||
| 189 | + app.request.promiseGet("/api/weshop/ad/page", { | ||
| 190 | + data: { | ||
| 191 | + pid: 401, | ||
| 192 | + enabled: 1, | ||
| 193 | + store_id: app.globalData.setting.stoid, | ||
| 194 | + } | ||
| 195 | + }).then(res => { | ||
| 196 | + if (res.data.code == 0 && res.data.data) { | ||
| 197 | + let item = res.data.data.pageData[0]; | ||
| 198 | + if (item && item.ad_code) { | ||
| 199 | + self.setData({ | ||
| 200 | + ad_img: item.ad_code, | ||
| 201 | + }); | ||
| 202 | + }; | ||
| 203 | + }; | ||
| 204 | + }); | ||
| 205 | + } | ||
| 206 | + var th = this; | ||
| 207 | + //更新一下会员的信息 | ||
| 208 | + if (getApp().globalData.user_id) { | ||
| 209 | + if (!getApp().globalData.userInfo['is_distribut']) { | ||
| 210 | + th.setData({ ishidden_comise: 1 }) | ||
| 211 | + } | ||
| 212 | + getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { | ||
| 213 | + isShowLoading: false, | ||
| 214 | + success: function (e) { | ||
| 215 | + getApp().globalData.userInfo = e.data.data; | ||
| 216 | + getApp().getConfig2(function (e) { | ||
| 217 | + var swithc_list = e.switch_list; | ||
| 218 | + var sw_arr = JSON.parse(swithc_list); | ||
| 219 | + //---如果后台有开等级卡的开关--- | ||
| 220 | + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { | ||
| 221 | + th.setData({ | ||
| 222 | + rank_switch: true | ||
| 223 | + }); | ||
| 224 | + //---回调卡的列表--- | ||
| 225 | + th.getPlusCardType(function (ob) { | ||
| 226 | + th.setData({ | ||
| 227 | + card_list: ob.card_list | ||
| 228 | + }); | ||
| 229 | + var ti = setInterval(function () { | ||
| 230 | + var user = getApp().globalData.userInfo; | ||
| 231 | + if (!user) return false; | ||
| 232 | + clearInterval(ti); | ||
| 233 | + if (user.card_field && user['card_expiredate']) { | ||
| 234 | + var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 235 | + var end = new Date(str); | ||
| 236 | + end = Date.parse(end) / 1000; | ||
| 237 | + var now = ut.gettimestamp(); | ||
| 238 | + //--- 判断是等级会员,且在有效期范围内 --- | ||
| 239 | + if (user.card_field && now < end) { | ||
| 240 | + var card_name = ob.name_map.get(user.card_field); | ||
| 241 | + if (card_name.length > 4) card_name = card_name.substring(0, 8); | ||
| 242 | + th.setData({ | ||
| 243 | + card_field: user.card_field, | ||
| 244 | + card_name: card_name, | ||
| 245 | + card_list: ob.card_list | ||
| 246 | + }); | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + }, 500) | ||
| 250 | + }) | ||
| 251 | + } | ||
| 252 | + }) | ||
| 253 | + } | ||
| 254 | + }) | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + if (app.globalData.key_word) { | ||
| 258 | + this.setData({ | ||
| 259 | + inputVal: app.globalData.key_word, | ||
| 260 | + }) | ||
| 261 | + this.search(); | ||
| 262 | + } | ||
| 258 | }, | 263 | }, |
| 259 | 264 | ||
| 260 | /** | 265 | /** |
| @@ -268,7 +273,7 @@ Page({ | @@ -268,7 +273,7 @@ Page({ | ||
| 268 | * 生命周期函数--监听页面卸载 | 273 | * 生命周期函数--监听页面卸载 |
| 269 | */ | 274 | */ |
| 270 | onUnload: function () { | 275 | onUnload: function () { |
| 271 | - | 276 | + app.globalData.key_word=null; |
| 272 | }, | 277 | }, |
| 273 | 278 | ||
| 274 | /** | 279 | /** |
| @@ -282,449 +287,449 @@ Page({ | @@ -282,449 +287,449 @@ Page({ | ||
| 282 | * 页面上拉触底事件的处理函数 | 287 | * 页面上拉触底事件的处理函数 |
| 283 | */ | 288 | */ |
| 284 | onReachBottom: function () { | 289 | onReachBottom: function () { |
| 285 | - let url = ''; | ||
| 286 | - if(this.data.isAll) { | ||
| 287 | - url = '/api/weshop/users/distribut/pagemyshop'; | ||
| 288 | - } else { | ||
| 289 | - url = '/api/weshop/users/distribut/pagemyshop?type=2'; | ||
| 290 | - }; | ||
| 291 | - this.scrollToLower(url, this.data.currentQuery); | 290 | + let url = ''; |
| 291 | + if (this.data.isAll) { | ||
| 292 | + url = '/api/weshop/users/distribut/pagemyshop'; | ||
| 293 | + } else { | ||
| 294 | + url = '/api/weshop/users/distribut/pagemyshop?type=2'; | ||
| 295 | + }; | ||
| 296 | + this.scrollToLower(url, this.data.currentQuery); | ||
| 292 | }, | 297 | }, |
| 293 | 298 | ||
| 294 | /** | 299 | /** |
| 295 | * 用户点击右上角分享 | 300 | * 用户点击右上角分享 |
| 296 | *--点击分享事件--分享我的小店 | 301 | *--点击分享事件--分享我的小店 |
| 297 | *--*/ | 302 | *--*/ |
| 298 | - onShareAppMessage: function(t) { | ||
| 299 | - | 303 | + onShareAppMessage: function (t) { |
| 304 | + | ||
| 300 | var th = this; | 305 | var th = this; |
| 301 | - var title= "我的小店"; | ||
| 302 | - var user_id=this.data.first_leader; | ||
| 303 | - if(!user_id){ | ||
| 304 | - user_id=getApp().globalData.user_id | ||
| 305 | - } | ||
| 306 | - var url="/packageA/pages/distribution/shop/shop?scene=" + user_id; | ||
| 307 | - if(getApp().globalData.user_id){ | ||
| 308 | - url+="&first_leader="+getApp().globalData.user_id; | 306 | + var title = "我的小店"; |
| 307 | + var user_id = this.data.first_leader; | ||
| 308 | + if (!user_id) { | ||
| 309 | + user_id = getApp().globalData.user_id | ||
| 309 | } | 310 | } |
| 310 | - | ||
| 311 | - var ob={ | 311 | + var url = "/packageA/pages/distribution/shop/shop?scene=" + user_id; |
| 312 | + if (getApp().globalData.user_id) { | ||
| 313 | + url += "&first_leader=" + getApp().globalData.user_id; | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + var ob = { | ||
| 312 | title: title, | 317 | title: title, |
| 313 | - path:url, | ||
| 314 | - }; | 318 | + path: url, |
| 319 | + }; | ||
| 315 | return ob; | 320 | return ob; |
| 316 | - | 321 | + |
| 322 | + }, | ||
| 323 | + | ||
| 324 | + /** | ||
| 325 | + * 点击下拉菜单 | ||
| 326 | + */ | ||
| 327 | + clickDropdown() { | ||
| 328 | + this.setData({ | ||
| 329 | + isHiddenDropdown: !this.data.isHiddenDropdown, | ||
| 330 | + }); | ||
| 331 | + }, | ||
| 332 | + | ||
| 333 | + /** | ||
| 334 | + * 点击遮罩层 | ||
| 335 | + */ | ||
| 336 | + clickMask() { | ||
| 337 | + this.setData({ | ||
| 338 | + isHiddenDropdown: true, | ||
| 339 | + }); | ||
| 340 | + }, | ||
| 341 | + | ||
| 342 | + /** | ||
| 343 | + * 选择下拉菜单项 | ||
| 344 | + */ | ||
| 345 | + selectDropdown(e) { | ||
| 346 | + let currentIndex = e.target.dataset.index; | ||
| 347 | + this.setData({ | ||
| 348 | + isHiddenDropdown: true, | ||
| 349 | + currentSelect: this.data.dropdownArr[currentIndex], | ||
| 350 | + }); | ||
| 351 | + }, | ||
| 352 | + | ||
| 353 | + /** | ||
| 354 | + * 搜索输入框聚焦 | ||
| 355 | + */ | ||
| 356 | + inputFocus() { | ||
| 357 | + this.setData({ | ||
| 358 | + isInputFocus: true, | ||
| 359 | + }); | ||
| 360 | + }, | ||
| 361 | + | ||
| 362 | + | ||
| 363 | + /** | ||
| 364 | + * 搜索输入框失焦 | ||
| 365 | + */ | ||
| 366 | + inputBlur() { | ||
| 367 | + this.setData({ | ||
| 368 | + isInputFocus: false, | ||
| 369 | + }); | ||
| 370 | + }, | ||
| 371 | + | ||
| 372 | + /** | ||
| 373 | + * 获取搜索输入框输入的内容 | ||
| 374 | + */ | ||
| 375 | + input(e) { | ||
| 376 | + this.data.inputVal = e.detail.value; | ||
| 377 | + }, | ||
| 378 | + | ||
| 379 | + /** | ||
| 380 | + * 搜索输入框清空内容 | ||
| 381 | + */ | ||
| 382 | + inputClear() { | ||
| 383 | + let inputVal = this.data.inputVal; | ||
| 384 | + console.log('input', inputVal); | ||
| 385 | + if (inputVal) { | ||
| 386 | + this.setData({ | ||
| 387 | + inputVal: '', | ||
| 388 | + }); | ||
| 389 | + }; | ||
| 390 | + }, | ||
| 391 | + | ||
| 392 | + /** | ||
| 393 | + * 搜索输入框聚焦 | ||
| 394 | + */ | ||
| 395 | + search() { | ||
| 396 | + let data = this.data.currentQuery; | ||
| 397 | + data.key = this.data.inputVal; | ||
| 398 | + if (data.orderField) { | ||
| 399 | + delete data.orderField; | ||
| 400 | + }; | ||
| 401 | + if (data.page) { | ||
| 402 | + delete data.page; | ||
| 403 | + }; | ||
| 404 | + this.setData({ | ||
| 405 | + currentTabIndex: 4, | ||
| 406 | + isSort: false, | ||
| 407 | + isDescending: false, | ||
| 408 | + currentQuery: data, | ||
| 409 | + pageNum: 1, | ||
| 410 | + }); | ||
| 411 | + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 412 | + }, | ||
| 413 | + | ||
| 414 | + /** | ||
| 415 | + * 点击排序 | ||
| 416 | + */ | ||
| 417 | + clickSort(e) { | ||
| 418 | + let data = this.data.currentQuery; | ||
| 419 | + // data.orderField = 'shop_price'; | ||
| 420 | + data.orderField = 'prom_price'; | ||
| 421 | + if (data.page) { | ||
| 422 | + delete data.page; | ||
| 423 | + }; | ||
| 424 | + if (!this.data.isSort) { | ||
| 425 | + this.setData({ | ||
| 426 | + isSort: true, | ||
| 427 | + }); | ||
| 428 | + data.orderType = 'asc'; | ||
| 429 | + } else { | ||
| 430 | + this.setData({ | ||
| 431 | + isDescending: !this.data.isDescending, | ||
| 432 | + }); | ||
| 433 | + | ||
| 434 | + if (this.data.isDescending) { | ||
| 435 | + data.orderType = 'desc'; | ||
| 436 | + } else { | ||
| 437 | + data.orderType = 'asc'; | ||
| 438 | + }; | ||
| 439 | + | ||
| 440 | + }; | ||
| 441 | + console.log('当前参数:', data); | ||
| 442 | + | ||
| 443 | + this.setData({ | ||
| 444 | + currentQuery: data, | ||
| 445 | + noMore: false, | ||
| 446 | + }); | ||
| 447 | + | ||
| 448 | + // 请求数据 | ||
| 449 | + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 450 | + }, | ||
| 451 | + | ||
| 452 | + /** | ||
| 453 | + * 点击视图切换按钮 | ||
| 454 | + */ | ||
| 455 | + change() { | ||
| 456 | + this.setData({ | ||
| 457 | + isShowRow: !this.data.isShowRow | ||
| 458 | + }); | ||
| 459 | + }, | ||
| 460 | + | ||
| 461 | + /** | ||
| 462 | + * 点击Tab | ||
| 463 | + */ | ||
| 464 | + clickTab(e) { | ||
| 465 | + let data = this.data.currentQuery; | ||
| 466 | + let isSort = this.data.isSort; | ||
| 467 | + let currentIndex = e.target.dataset.index; | ||
| 468 | + if (currentIndex != 3) { | ||
| 469 | + if (isSort) { | ||
| 470 | + isSort = false; | ||
| 471 | + }; | ||
| 472 | + if (data.orderType) {// 清除orderType | ||
| 473 | + delete data.orderType; | ||
| 474 | + }; | ||
| 475 | + }; | ||
| 476 | + this.setData({ | ||
| 477 | + list: null, | ||
| 478 | + isAll: true, | ||
| 479 | + currentTabIndex: currentIndex, | ||
| 480 | + isSort, | ||
| 481 | + pageNum: 1, | ||
| 482 | + noMore: false, | ||
| 483 | + }); | ||
| 484 | + if (data.page) {// 清除page | ||
| 485 | + delete data.page; | ||
| 486 | + }; | ||
| 487 | + | ||
| 488 | + | ||
| 489 | + | ||
| 490 | + if (currentIndex == 0) { | ||
| 491 | + if (data.orderField) {// 清除orderField | ||
| 492 | + delete data.orderField; | ||
| 493 | + }; | ||
| 494 | + }; | ||
| 495 | + if (currentIndex == 1) { | ||
| 496 | + data.orderField = 'sales_sum'; | ||
| 497 | + }; | ||
| 498 | + if (currentIndex == 2) { | ||
| 499 | + data.orderField = 'comment_count'; | ||
| 500 | + }; | ||
| 501 | + | ||
| 502 | + if (currentIndex == 3) { | ||
| 503 | + // console.log('点击价格'); | ||
| 504 | + if (data.orderType) {// 清除orderType | ||
| 505 | + delete data.orderType; | ||
| 506 | + }; | ||
| 507 | + return; | ||
| 508 | + }; | ||
| 509 | + data.orderType = 'desc'; | ||
| 510 | + this.data.currentQuery = data; | ||
| 511 | + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 512 | + }, | ||
| 513 | + | ||
| 514 | + /** | ||
| 515 | + * 点击筛选 | ||
| 516 | + */ | ||
| 517 | + clickFilter() { | ||
| 518 | + this.setData({ | ||
| 519 | + isHiddenDropdown: !this.data.isHiddenDropdown, | ||
| 520 | + }); | ||
| 521 | + }, | ||
| 522 | + | ||
| 523 | + /** | ||
| 524 | + * 点击遮罩层,关闭筛选下拉菜单 | ||
| 525 | + */ | ||
| 526 | + clickMask() { | ||
| 527 | + if (!this.data.isHiddenDropdown) { | ||
| 528 | + this.setData({ | ||
| 529 | + isHiddenDropdown: true, | ||
| 530 | + }); | ||
| 531 | + } | ||
| 532 | + }, | ||
| 533 | + | ||
| 534 | + /** | ||
| 535 | + * 请求数据 | ||
| 536 | + */ | ||
| 537 | + getData: function (isInit, url, data) { | ||
| 538 | + | ||
| 539 | + app.request.promiseGet(url, { | ||
| 540 | + data: data, | ||
| 541 | + isShowLoading: true, | ||
| 542 | + }) | ||
| 543 | + .then(function (res) { | ||
| 544 | + // console.log('1121', res.data.code); | ||
| 545 | + if (res.data.code == 0) { | ||
| 546 | + | ||
| 547 | + self.setData({ | ||
| 548 | + isLoading: false | ||
| 549 | + }); | ||
| 550 | + | ||
| 551 | + if (isInit) {// 第一次加载 | ||
| 552 | + self.setData({ | ||
| 553 | + list: res.data.data, | ||
| 554 | + }); | ||
| 555 | + } else { | ||
| 556 | + self.setData({ | ||
| 557 | + 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) | ||
| 558 | + }); | ||
| 559 | + }; | ||
| 560 | + | ||
| 561 | + if ((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { | ||
| 562 | + self.setData({ | ||
| 563 | + noMore: true | ||
| 564 | + }); | ||
| 565 | + }; | ||
| 566 | + | ||
| 567 | + } else { | ||
| 568 | + self.setData({ | ||
| 569 | + 'list.pageData': [] | ||
| 570 | + }); | ||
| 571 | + }; | ||
| 572 | + | ||
| 573 | + }) | ||
| 574 | + .catch(function (err) { | ||
| 575 | + console.log('出错拉!!!!', err); | ||
| 576 | + self.setData({ | ||
| 577 | + 'list.pageData': [] | ||
| 578 | + }); | ||
| 579 | + }); | ||
| 580 | + }, | ||
| 581 | + | ||
| 582 | + | ||
| 583 | + /** | ||
| 584 | + * 上拉加载 | ||
| 585 | + */ | ||
| 586 | + scrollToLower(url, requestData) { | ||
| 587 | + | ||
| 588 | + // 数据总量 | ||
| 589 | + let total = this.data.list.total; | ||
| 590 | + // 单页最大数据量 | ||
| 591 | + let pageSize = this.data.list.pageSize; | ||
| 592 | + // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ | ||
| 593 | + if ((total != 0) && (total <= pageSize)) { | ||
| 594 | + this.setData({ | ||
| 595 | + noMore: true | ||
| 596 | + }); | ||
| 597 | + }; | ||
| 598 | + | ||
| 599 | + if (!this.data.isLoading && !this.data.noMore) { | ||
| 600 | + this.setData({ | ||
| 601 | + isLoading: true, | ||
| 602 | + pageNum: this.data.pageNum + 1 | ||
| 603 | + }); | ||
| 604 | + requestData.page = this.data.pageNum; | ||
| 605 | + console.log('滚动data:', requestData); | ||
| 606 | + this.getData(false, url, requestData); | ||
| 607 | + }; | ||
| 608 | + }, | ||
| 609 | + | ||
| 610 | + /** | ||
| 611 | + * 点击跳转 | ||
| 612 | + */ | ||
| 613 | + goto(e) { | ||
| 614 | + let url = ''; | ||
| 615 | + if (e.target.dataset.url) { | ||
| 616 | + url = e.target.dataset.url; | ||
| 617 | + } else { | ||
| 618 | + url = e.currentTarget.dataset.url; | ||
| 619 | + } | ||
| 620 | + app.goto(url); | ||
| 621 | + }, | ||
| 622 | + | ||
| 623 | + | ||
| 624 | + //--- 获取卡类列表 --- | ||
| 625 | + getPlusCardType: function (func) { | ||
| 626 | + var storid = os.stoid; | ||
| 627 | + var th = this; | ||
| 628 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, | ||
| 629 | + {}).then(res => { | ||
| 630 | + | ||
| 631 | + if (res.data.code != 0 || !res.data.data) { | ||
| 632 | + var ob = { | ||
| 633 | + "card_list": [], | ||
| 634 | + "name_map": "" | ||
| 635 | + }; | ||
| 636 | + func(ob); | ||
| 637 | + return false; | ||
| 638 | + } | ||
| 639 | + | ||
| 640 | + var plusCard = res.data.data; | ||
| 641 | + var arr = [1219, 2089, 3031]; | ||
| 642 | + var new_arr = new Array(); | ||
| 643 | + var card_name_map = new Map(); | ||
| 644 | + | ||
| 645 | + var user = getApp().globalData.userInfo; | ||
| 646 | + if (plusCard) { | ||
| 647 | + for (var i = 0; i < plusCard.length; i++) { | ||
| 648 | + if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { | ||
| 649 | + continue; | ||
| 650 | + } | ||
| 651 | + var name = "card" + plusCard[i].CorrPrice.toLowerCase(); | ||
| 652 | + card_name_map.set(name, plusCard[i].CardName); | ||
| 653 | + new_arr.push(plusCard[i]); | ||
| 654 | + | ||
| 655 | + } | ||
| 656 | + } | ||
| 657 | + var ob = { | ||
| 658 | + "card_list": new_arr, | ||
| 659 | + "name_map": card_name_map | ||
| 660 | + }; | ||
| 661 | + func(ob); | ||
| 662 | + }) | ||
| 663 | + }, | ||
| 664 | + | ||
| 665 | + | ||
| 666 | + /** | ||
| 667 | + * 点击全部 | ||
| 668 | + */ | ||
| 669 | + clickAll() { | ||
| 670 | + let data = this.data.currentQuery; | ||
| 671 | + | ||
| 672 | + if (data.page) delete data.page; | ||
| 673 | + if (data.orderField) delete data.orderField; | ||
| 674 | + if (data.orderType) delete data.orderType; | ||
| 675 | + if (data.key) delete data.key; | ||
| 676 | + | ||
| 677 | + this.setData({ | ||
| 678 | + pageNum: 1, | ||
| 679 | + noMore: false, | ||
| 680 | + isAll: true, | ||
| 681 | + }); | ||
| 682 | + | ||
| 683 | + this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 684 | + }, | ||
| 685 | + | ||
| 686 | + /** | ||
| 687 | + * 点击新品 | ||
| 688 | + */ | ||
| 689 | + clickNew() { | ||
| 690 | + let data = this.data.currentQuery; | ||
| 691 | + | ||
| 692 | + if (data.page) delete data.page; | ||
| 693 | + if (data.orderField) delete data.orderField; | ||
| 694 | + if (data.orderType) delete data.orderType; | ||
| 695 | + if (data.key) delete data.key; | ||
| 696 | + | ||
| 697 | + this.setData({ | ||
| 698 | + pageNum: 1, | ||
| 699 | + noMore: false, | ||
| 700 | + isAll: false, | ||
| 701 | + }); | ||
| 702 | + | ||
| 703 | + this.getData(true, '/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', data); | ||
| 704 | + // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | ||
| 705 | + // data: data, | ||
| 706 | + // }).then(res => { | ||
| 707 | + // self.setData({ | ||
| 708 | + // list: res.data.data, | ||
| 709 | + // }); | ||
| 710 | + // }); | ||
| 711 | + }, | ||
| 712 | + | ||
| 713 | + | ||
| 714 | + /** | ||
| 715 | + * 点击新品 | ||
| 716 | + */ | ||
| 717 | + // imgError(e) { | ||
| 718 | + // this.setData({ | ||
| 719 | + // noImg: true, | ||
| 720 | + // }); | ||
| 721 | + // }, | ||
| 722 | + | ||
| 723 | + | ||
| 724 | + bind_bnerr2: function (e) { | ||
| 725 | + var _errImg = e.target.dataset.errorimg; | ||
| 726 | + var _errurl = e.target.dataset.url; | ||
| 727 | + var ii = _errurl.indexOf(oo.imghost); | ||
| 728 | + if (ii != -1) { | ||
| 729 | + var _errObj = {}; | ||
| 730 | + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 731 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 732 | + } | ||
| 317 | }, | 733 | }, |
| 318 | - | ||
| 319 | - /** | ||
| 320 | - * 点击下拉菜单 | ||
| 321 | - */ | ||
| 322 | - clickDropdown() { | ||
| 323 | - this.setData({ | ||
| 324 | - isHiddenDropdown: !this.data.isHiddenDropdown, | ||
| 325 | - }); | ||
| 326 | - }, | ||
| 327 | - | ||
| 328 | - /** | ||
| 329 | - * 点击遮罩层 | ||
| 330 | - */ | ||
| 331 | - clickMask() { | ||
| 332 | - this.setData({ | ||
| 333 | - isHiddenDropdown: true, | ||
| 334 | - }); | ||
| 335 | - }, | ||
| 336 | - | ||
| 337 | - /** | ||
| 338 | - * 选择下拉菜单项 | ||
| 339 | - */ | ||
| 340 | - selectDropdown(e) { | ||
| 341 | - let currentIndex = e.target.dataset.index; | ||
| 342 | - this.setData({ | ||
| 343 | - isHiddenDropdown: true, | ||
| 344 | - currentSelect: this.data.dropdownArr[currentIndex], | ||
| 345 | - }); | ||
| 346 | - }, | ||
| 347 | - | ||
| 348 | - /** | ||
| 349 | - * 搜索输入框聚焦 | ||
| 350 | - */ | ||
| 351 | - inputFocus() { | ||
| 352 | - this.setData({ | ||
| 353 | - isInputFocus: true, | ||
| 354 | - }); | ||
| 355 | - }, | ||
| 356 | - | ||
| 357 | - | ||
| 358 | - /** | ||
| 359 | - * 搜索输入框失焦 | ||
| 360 | - */ | ||
| 361 | - inputBlur() { | ||
| 362 | - this.setData({ | ||
| 363 | - isInputFocus: false, | ||
| 364 | - }); | ||
| 365 | - }, | ||
| 366 | - | ||
| 367 | - /** | ||
| 368 | - * 获取搜索输入框输入的内容 | ||
| 369 | - */ | ||
| 370 | - input(e) { | ||
| 371 | - this.data.inputVal = e.detail.value; | ||
| 372 | - }, | ||
| 373 | - | ||
| 374 | - /** | ||
| 375 | - * 搜索输入框清空内容 | ||
| 376 | - */ | ||
| 377 | - inputClear() { | ||
| 378 | - let inputVal = this.data.inputVal; | ||
| 379 | - console.log('input', inputVal); | ||
| 380 | - if(inputVal) { | ||
| 381 | - this.setData({ | ||
| 382 | - inputVal: '', | ||
| 383 | - }); | ||
| 384 | - }; | ||
| 385 | - }, | ||
| 386 | - | ||
| 387 | - /** | ||
| 388 | - * 搜索输入框聚焦 | ||
| 389 | - */ | ||
| 390 | - search() { | ||
| 391 | - let data = this.data.currentQuery; | ||
| 392 | - data.key = this.data.inputVal; | ||
| 393 | - if(data.orderField) { | ||
| 394 | - delete data.orderField; | ||
| 395 | - }; | ||
| 396 | - if(data.page) { | ||
| 397 | - delete data.page; | ||
| 398 | - }; | ||
| 399 | - this.setData({ | ||
| 400 | - currentTabIndex: 4, | ||
| 401 | - isSort: false, | ||
| 402 | - isDescending: false, | ||
| 403 | - currentQuery: data, | ||
| 404 | - pageNum: 1, | ||
| 405 | - }); | ||
| 406 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 407 | - }, | ||
| 408 | - | ||
| 409 | - /** | ||
| 410 | - * 点击排序 | ||
| 411 | - */ | ||
| 412 | - clickSort(e) { | ||
| 413 | - let data = this.data.currentQuery; | ||
| 414 | - // data.orderField = 'shop_price'; | ||
| 415 | - data.orderField = 'prom_price'; | ||
| 416 | - if(data.page) { | ||
| 417 | - delete data.page; | ||
| 418 | - }; | ||
| 419 | - if(!this.data.isSort) { | ||
| 420 | - this.setData({ | ||
| 421 | - isSort: true, | ||
| 422 | - }); | ||
| 423 | - data.orderType = 'asc'; | ||
| 424 | - } else { | ||
| 425 | - this.setData({ | ||
| 426 | - isDescending: !this.data.isDescending, | ||
| 427 | - }); | ||
| 428 | - | ||
| 429 | - if(this.data.isDescending) { | ||
| 430 | - data.orderType = 'desc'; | ||
| 431 | - } else { | ||
| 432 | - data.orderType = 'asc'; | ||
| 433 | - }; | ||
| 434 | - | ||
| 435 | - }; | ||
| 436 | - console.log('当前参数:', data); | ||
| 437 | - | ||
| 438 | - this.setData({ | ||
| 439 | - currentQuery: data, | ||
| 440 | - noMore: false, | ||
| 441 | - }); | ||
| 442 | - | ||
| 443 | - // 请求数据 | ||
| 444 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 445 | - }, | ||
| 446 | - | ||
| 447 | - /** | ||
| 448 | - * 点击视图切换按钮 | ||
| 449 | - */ | ||
| 450 | - change() { | ||
| 451 | - this.setData({ | ||
| 452 | - isShowRow: !this.data.isShowRow | ||
| 453 | - }); | ||
| 454 | - }, | ||
| 455 | - | ||
| 456 | - /** | ||
| 457 | - * 点击Tab | ||
| 458 | - */ | ||
| 459 | - clickTab(e) { | ||
| 460 | - let data = this.data.currentQuery; | ||
| 461 | - let isSort = this.data.isSort; | ||
| 462 | - let currentIndex = e.target.dataset.index; | ||
| 463 | - if(currentIndex != 3) { | ||
| 464 | - if(isSort) { | ||
| 465 | - isSort = false; | ||
| 466 | - }; | ||
| 467 | - if(data.orderType) {// 清除orderType | ||
| 468 | - delete data.orderType; | ||
| 469 | - }; | ||
| 470 | - }; | ||
| 471 | - this.setData({ | ||
| 472 | - list: null, | ||
| 473 | - isAll: true, | ||
| 474 | - currentTabIndex: currentIndex, | ||
| 475 | - isSort, | ||
| 476 | - pageNum: 1, | ||
| 477 | - noMore: false, | ||
| 478 | - }); | ||
| 479 | - if(data.page) {// 清除page | ||
| 480 | - delete data.page; | ||
| 481 | - }; | ||
| 482 | - | ||
| 483 | - | ||
| 484 | - | ||
| 485 | - if(currentIndex == 0) { | ||
| 486 | - if(data.orderField) {// 清除orderField | ||
| 487 | - delete data.orderField; | ||
| 488 | - }; | ||
| 489 | - }; | ||
| 490 | - if(currentIndex == 1) { | ||
| 491 | - data.orderField = 'sales_sum'; | ||
| 492 | - }; | ||
| 493 | - if(currentIndex == 2) { | ||
| 494 | - data.orderField = 'comment_count'; | ||
| 495 | - }; | ||
| 496 | - | ||
| 497 | - if(currentIndex == 3) { | ||
| 498 | - // console.log('点击价格'); | ||
| 499 | - if(data.orderType) {// 清除orderType | ||
| 500 | - delete data.orderType; | ||
| 501 | - }; | ||
| 502 | - return; | ||
| 503 | - }; | ||
| 504 | - data.orderType = 'desc'; | ||
| 505 | - this.data.currentQuery = data; | ||
| 506 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 507 | - }, | ||
| 508 | - | ||
| 509 | - /** | ||
| 510 | - * 点击筛选 | ||
| 511 | - */ | ||
| 512 | - clickFilter() { | ||
| 513 | - this.setData({ | ||
| 514 | - isHiddenDropdown: !this.data.isHiddenDropdown, | ||
| 515 | - }); | ||
| 516 | - }, | ||
| 517 | - | ||
| 518 | - /** | ||
| 519 | - * 点击遮罩层,关闭筛选下拉菜单 | ||
| 520 | - */ | ||
| 521 | - clickMask() { | ||
| 522 | - if(!this.data.isHiddenDropdown) { | ||
| 523 | - this.setData({ | ||
| 524 | - isHiddenDropdown: true, | ||
| 525 | - }); | ||
| 526 | - } | ||
| 527 | - }, | ||
| 528 | - | ||
| 529 | - /** | ||
| 530 | - * 请求数据 | ||
| 531 | - */ | ||
| 532 | - getData: function(isInit, url, data) { | ||
| 533 | - | ||
| 534 | - app.request.promiseGet(url, { | ||
| 535 | - data: data, | ||
| 536 | - isShowLoading: true, | ||
| 537 | - }) | ||
| 538 | - .then(function(res) { | ||
| 539 | - // console.log('1121', res.data.code); | ||
| 540 | - if(res.data.code == 0) { | ||
| 541 | - | ||
| 542 | - self.setData({ | ||
| 543 | - isLoading: false | ||
| 544 | - }); | ||
| 545 | - | ||
| 546 | - if(isInit) {// 第一次加载 | ||
| 547 | - self.setData({ | ||
| 548 | - list: res.data.data, | ||
| 549 | - }); | ||
| 550 | - } else { | ||
| 551 | - self.setData({ | ||
| 552 | - 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) | ||
| 553 | - }); | ||
| 554 | - }; | ||
| 555 | - | ||
| 556 | - if((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { | ||
| 557 | - self.setData({ | ||
| 558 | - noMore: true | ||
| 559 | - }); | ||
| 560 | - }; | ||
| 561 | - | ||
| 562 | - } else { | ||
| 563 | - self.setData({ | ||
| 564 | - 'list.pageData': [] | ||
| 565 | - }); | ||
| 566 | - }; | ||
| 567 | - | ||
| 568 | - }) | ||
| 569 | - .catch(function(err) { | ||
| 570 | - console.log('出错拉!!!!',err); | ||
| 571 | - self.setData({ | ||
| 572 | - 'list.pageData': [] | ||
| 573 | - }); | ||
| 574 | - }); | ||
| 575 | - }, | ||
| 576 | - | ||
| 577 | - | ||
| 578 | - /** | ||
| 579 | - * 上拉加载 | ||
| 580 | - */ | ||
| 581 | - scrollToLower(url, requestData) { | ||
| 582 | - | ||
| 583 | - // 数据总量 | ||
| 584 | - let total = this.data.list.total; | ||
| 585 | - // 单页最大数据量 | ||
| 586 | - let pageSize = this.data.list.pageSize; | ||
| 587 | - // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ | ||
| 588 | - if((total != 0)&&(total <= pageSize)) { | ||
| 589 | - this.setData({ | ||
| 590 | - noMore: true | ||
| 591 | - }); | ||
| 592 | - }; | ||
| 593 | - | ||
| 594 | - if(!this.data.isLoading && !this.data.noMore) { | ||
| 595 | - this.setData({ | ||
| 596 | - isLoading: true, | ||
| 597 | - pageNum: this.data.pageNum + 1 | ||
| 598 | - }); | ||
| 599 | - requestData.page = this.data.pageNum; | ||
| 600 | - console.log('滚动data:', requestData); | ||
| 601 | - this.getData(false, url, requestData); | ||
| 602 | - }; | ||
| 603 | - }, | ||
| 604 | - | ||
| 605 | - /** | ||
| 606 | - * 点击跳转 | ||
| 607 | - */ | ||
| 608 | - goto(e) { | ||
| 609 | - let url = ''; | ||
| 610 | - if(e.target.dataset.url) { | ||
| 611 | - url = e.target.dataset.url; | ||
| 612 | - } else { | ||
| 613 | - url = e.currentTarget.dataset.url; | ||
| 614 | - } | ||
| 615 | - app.goto(url); | ||
| 616 | - }, | ||
| 617 | - | ||
| 618 | - | ||
| 619 | - //--- 获取卡类列表 --- | ||
| 620 | - getPlusCardType: function (func) { | ||
| 621 | - var storid = os.stoid; | ||
| 622 | - var th = this; | ||
| 623 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, | ||
| 624 | - {}).then(res => { | ||
| 625 | - | ||
| 626 | - if(res.data.code!=0 || !res.data.data){ | ||
| 627 | - var ob = { | ||
| 628 | - "card_list": [], | ||
| 629 | - "name_map": "" | ||
| 630 | - }; | ||
| 631 | - func(ob); | ||
| 632 | - return false; | ||
| 633 | - } | ||
| 634 | - | ||
| 635 | - var plusCard = res.data.data; | ||
| 636 | - var arr = [1219, 2089, 3031]; | ||
| 637 | - var new_arr = new Array(); | ||
| 638 | - var card_name_map = new Map(); | ||
| 639 | - | ||
| 640 | - var user = getApp().globalData.userInfo; | ||
| 641 | - if(plusCard) { | ||
| 642 | - for (var i = 0; i < plusCard.length; i++) { | ||
| 643 | - if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { | ||
| 644 | - continue; | ||
| 645 | - } | ||
| 646 | - var name = "card" + plusCard[i].CorrPrice.toLowerCase(); | ||
| 647 | - card_name_map.set(name, plusCard[i].CardName); | ||
| 648 | - new_arr.push(plusCard[i]); | ||
| 649 | - | ||
| 650 | - } | ||
| 651 | - } | ||
| 652 | - var ob = { | ||
| 653 | - "card_list": new_arr, | ||
| 654 | - "name_map": card_name_map | ||
| 655 | - }; | ||
| 656 | - func(ob); | ||
| 657 | - }) | ||
| 658 | - }, | ||
| 659 | - | ||
| 660 | - | ||
| 661 | - /** | ||
| 662 | - * 点击全部 | ||
| 663 | - */ | ||
| 664 | - clickAll() { | ||
| 665 | - let data = this.data.currentQuery; | ||
| 666 | - | ||
| 667 | - if(data.page) delete data.page; | ||
| 668 | - if(data.orderField) delete data.orderField; | ||
| 669 | - if(data.orderType) delete data.orderType; | ||
| 670 | - if(data.key) delete data.key; | ||
| 671 | - | ||
| 672 | - this.setData({ | ||
| 673 | - pageNum: 1, | ||
| 674 | - noMore: false, | ||
| 675 | - isAll: true, | ||
| 676 | - }); | ||
| 677 | - | ||
| 678 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); | ||
| 679 | - }, | ||
| 680 | - | ||
| 681 | - /** | ||
| 682 | - * 点击新品 | ||
| 683 | - */ | ||
| 684 | - clickNew() { | ||
| 685 | - let data = this.data.currentQuery; | ||
| 686 | - | ||
| 687 | - if(data.page) delete data.page; | ||
| 688 | - if(data.orderField) delete data.orderField; | ||
| 689 | - if(data.orderType) delete data.orderType; | ||
| 690 | - if(data.key) delete data.key; | ||
| 691 | - | ||
| 692 | - this.setData({ | ||
| 693 | - pageNum: 1, | ||
| 694 | - noMore: false, | ||
| 695 | - isAll: false, | ||
| 696 | - }); | ||
| 697 | - | ||
| 698 | - this.getData(true, '/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', data); | ||
| 699 | - // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { | ||
| 700 | - // data: data, | ||
| 701 | - // }).then(res => { | ||
| 702 | - // self.setData({ | ||
| 703 | - // list: res.data.data, | ||
| 704 | - // }); | ||
| 705 | - // }); | ||
| 706 | - }, | ||
| 707 | - | ||
| 708 | - | ||
| 709 | - /** | ||
| 710 | - * 点击新品 | ||
| 711 | - */ | ||
| 712 | - // imgError(e) { | ||
| 713 | - // this.setData({ | ||
| 714 | - // noImg: true, | ||
| 715 | - // }); | ||
| 716 | - // }, | ||
| 717 | - | ||
| 718 | - | ||
| 719 | - bind_bnerr2: function (e) { | ||
| 720 | - var _errImg = e.target.dataset.errorimg; | ||
| 721 | - var _errurl = e.target.dataset.url; | ||
| 722 | - var ii = _errurl.indexOf(oo.imghost); | ||
| 723 | - if (ii != -1) { | ||
| 724 | - var _errObj = {}; | ||
| 725 | - _errObj[_errImg] = this.data.iurl+"/miniapp/images/default_g_img.gif"; | ||
| 726 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 727 | - } | ||
| 728 | - }, | ||
| 729 | 734 | ||
| 730 | }) | 735 | }) |
| 731 | \ No newline at end of file | 736 | \ No newline at end of file |
packageA/pages/distribution/shop/shop.wxml
| @@ -37,6 +37,7 @@ | @@ -37,6 +37,7 @@ | ||
| 37 | 37 | ||
| 38 | <!-- 搜索 --> | 38 | <!-- 搜索 --> |
| 39 | <view class="flex ai-center fs26 bg-white pd20"> | 39 | <view class="flex ai-center fs26 bg-white pd20"> |
| 40 | + <text class="pd20 c-9b iconfont icon-fenxiang" catch:tap="goto" data-url="/packageC/pages/goods/distributionCategoryList/index"></text> | ||
| 40 | <view class="input-container f1"> | 41 | <view class="input-container f1"> |
| 41 | <input class="input" type="text" value="{{inputVal}}" placeholder="请输入商品关键字" confirm-type="search" bindfocus="inputFocus" bindblur="inputBlur" bindinput="input" bindconfirm="search"/> | 42 | <input class="input" type="text" value="{{inputVal}}" placeholder="请输入商品关键字" confirm-type="search" bindfocus="inputFocus" bindblur="inputBlur" bindinput="input" bindconfirm="search"/> |
| 42 | <text class="iconfont icon-guanbi" hidden="{{!isInputFocus}}" catchtap="inputClear"></text> | 43 | <text class="iconfont icon-guanbi" hidden="{{!isInputFocus}}" catchtap="inputClear"></text> |
packageA/pages/distribution/shop/shop.wxss
| @@ -100,10 +100,6 @@ page { | @@ -100,10 +100,6 @@ page { | ||
| 100 | margin-top: 20rpx; | 100 | margin-top: 20rpx; |
| 101 | } */ | 101 | } */ |
| 102 | 102 | ||
| 103 | -.money { | ||
| 104 | - /* word-break: break-all; | ||
| 105 | - word-wrap: break-word; */ | ||
| 106 | -} | ||
| 107 | .money::before { | 103 | .money::before { |
| 108 | content: '¥'; | 104 | content: '¥'; |
| 109 | font-size: 22rpx; | 105 | font-size: 22rpx; |
| @@ -236,10 +232,10 @@ page { | @@ -236,10 +232,10 @@ page { | ||
| 236 | 232 | ||
| 237 | 233 | ||
| 238 | /*checkbox 整体大小 */ | 234 | /*checkbox 整体大小 */ |
| 239 | -checkbox { | 235 | +/* checkbox { */ |
| 240 | /* width: 240rpx; | 236 | /* width: 240rpx; |
| 241 | height: 90rpx; */ | 237 | height: 90rpx; */ |
| 242 | -} | 238 | +/* } */ |
| 243 | /*checkbox 选项框大小 */ | 239 | /*checkbox 选项框大小 */ |
| 244 | checkbox .wx-checkbox-input { | 240 | checkbox .wx-checkbox-input { |
| 245 | width: 34rpx; | 241 | width: 34rpx; |