From f2daf8fd91ce1e59ad249df177a79e9d9ade781b Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Fri, 16 Apr 2021 09:16:44 +0800 Subject: [PATCH] 分销测试返回的bug修复 --- components/goods_list/goods_list.js | 85 ++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- custom-tab-bar/index.js | 27 ++++++++++++++++++++++++++- custom-tab-bar/index.wxml | 39 +++++++++++++++++++++++++-------------- custom-tab-bar/index.wxss | 1 + pages/distribution/distribution.js | 322 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------- pages/distribution/distribution.wxml | 56 +++++++++++++++++++++++++++++++++++--------------------- pages/distribution/distribution.wxss | 1 + pages/goods/goodsInfo/goodsInfo.js | 4 ++-- pages/user/index/index.js | 30 +++++++++++++++++++++--------- utils/auth.js | 16 ++++++++++++---- 10 files changed, 360 insertions(+), 221 deletions(-) diff --git a/components/goods_list/goods_list.js b/components/goods_list/goods_list.js index 5284d4c..79830f6 100644 --- a/components/goods_list/goods_list.js +++ b/components/goods_list/goods_list.js @@ -33,48 +33,55 @@ Component({ methods: { init: function () { var th = this; + if(!getApp().globalData.user_id) return false; getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { isShowLoading:false, success: function (e) { - getApp().globalData.userInfo = e.data.data; - getApp().getConfig2(function (e) { - var swithc_list = e.switch_list; - var sw_arr = JSON.parse(swithc_list); - //---如果后台有开等级卡的开关--- - if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { - th.setData({ - rank_switch: true - }); - //---回调卡的列表--- - th.getPlusCardType(function (ob) { - th.setData({ - card_list: ob.card_list - }); - var ti = setInterval(function () { - var user = getApp().globalData.userInfo; - if (!user) return false; - clearInterval(ti); - if (user.card_field && user['card_expiredate']) { - var str = user['card_expiredate'].replace(/-/g, '/'); - var end = new Date(str); - end = Date.parse(end) / 1000; - var now = ut.gettimestamp(); - //--- 判断是等级会员,且在有效期范围内 --- - if (user.card_field && now < end) { - var card_name = ob.name_map.get(user.card_field); - if (card_name.length > 4) card_name = card_name.substring(0, 8); - th.setData({ - card_field: user.card_field, - card_name: card_name, - card_list: ob.card_list - }); - } - } - }, 500) - }) - } - }) - } + if(e.code==0 && e.data && e.data.data){ + getApp().globalData.userInfo = e.data.data; + getApp().getConfig2(function (e) { + var swithc_list = e.switch_list; + var sw_arr = JSON.parse(swithc_list); + //---如果后台有开等级卡的开关--- + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { + th.setData({ + rank_switch: true + }); + //---回调卡的列表--- + th.getPlusCardType(function (ob) { + th.setData({ + card_list: ob.card_list + }); + var ti = setInterval(function () { + var user = getApp().globalData.userInfo; + if (!user) return false; + clearInterval(ti); + if (user.card_field && user['card_expiredate']) { + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + //--- 判断是等级会员,且在有效期范围内 --- + if (user.card_field && now < end) { + var card_name = ob.name_map.get(user.card_field); + if (card_name.length > 4) card_name = card_name.substring(0, 8); + th.setData({ + card_field: user.card_field, + card_name: card_name, + card_list: ob.card_list + }); + } + } + }, 500) + }) + } + }) + + } + + + + } }) }, // get_list: function () { diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index ee0f199..c6984e1 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -12,7 +12,31 @@ Component({ lifetimes: { - attached: function() { + attached: function() { + var th=this; + + getApp().getConfig2(function(){ + var e = getApp().globalData.config2; + var json_d = JSON.parse(e.switch_list); + if(!json_d.distribut_switch){ + th.setData({is_no_distri:1}) + } + }) + + + getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=5",{}).then(res=>{ + if(res.data.code==0){ + var arr = res.data.data.pageData; + if (arr.length > 0) { + var item=arr[0]; + if(item.is_sy==0){ + var now = Date.parse(new Date());now = now / 1000; + if(item.end_time - - - {{cartGoodsNum}} - - - - - {{item.nav_name}} - - + + + + {{cartGoodsNum}} + + + + + {{item.nav_name}} + + + + + + + + + + + {{item.nav_name}} + + + - - - \ No newline at end of file diff --git a/custom-tab-bar/index.wxss b/custom-tab-bar/index.wxss index 571e147..9d5b4b3 100644 --- a/custom-tab-bar/index.wxss +++ b/custom-tab-bar/index.wxss @@ -1,5 +1,6 @@ .main_bar{ width:100%; border-top: 1rpx solid #ebebeb; position: fixed; bottom: 0; left: 0; z-index: 10000; + display: flex; justify-content: space-around; } .tabbar_item{ position:relative;height:100%;float:left;text-align:center;padding:0px 0; diff --git a/pages/distribution/distribution.js b/pages/distribution/distribution.js index e210a4d..ece6c31 100644 --- a/pages/distribution/distribution.js +++ b/pages/distribution/distribution.js @@ -1,6 +1,7 @@ // packageA//pages/distribution/main/main.js const app = getApp(); -let self = null; +let self = null, os = app.globalData.setting; +var regeneratorRuntime = require('../../utils/runtime.js'); Page({ @@ -8,124 +9,186 @@ Page({ * 页面的初始数据 */ data: { - + buy_goods:null, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - self = this;//保存全局指针 - - app.isLogin().then(function(data) {//进入页面前已经授权登录成功 + self = this;//保存全局指针 + if(app.globalData.userInfo) { self.setData({ - userInfo: data, + userInfo: app.globalData.userInfo, }); - }); - + }else{ + getApp().goto("/pages/togoin/togoin") //跳到非tabbar页 + } + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + var self=this; + // 广告banner + app.request.promiseGet("/api/weshop/ad/page", { + data: { + pid: 401, + enabled: 1, + store_id: app.globalData.setting.stoid, + } + }).then(res => { + if(res.data.code == 0 && res.data.data) { + let item = res.data.data.pageData[0]; + if(item && item.ad_code) { + self.setData({ + ad_img: item.ad_code, + }); + }; + }; + }); }, /** * 生命周期函数--监听页面显示 */ - onShow: function () { - console.log('onshow'); - let url = '/api/weshop/users/distribut/getMoney'; - if(app.globalData.userInfo) { - if(!this.data.isLogin) { - this.setData({ - userInfo: app.globalData.userInfo, - imghost: app.globalData.setting.imghost, - isLogin: true, - }); - - // 请求数据 - 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) { + onShow: function () { + var self=this,userinfo=app.globalData.userInfo; + if(!app.globalData.userInfo){ + return false; + } + //-- 会员实时的信息获取 -- + getApp().promiseGet("/api/weshop/users/get/" + userinfo.store_id + "/" + userinfo.user_id,{}).then(res=>{ + if(res.data.code!=0){ + wx.showToast({ + title: "获取会员失败", + icon: 'none', + duration: 2000 + }); + return false; + } - self.setData({ - data: res.data.data, - }); - - // 广告banner - app.request.promiseGet("/api/weshop/ad/page", { - data: { - pid: 401, - enabled: 1, - store_id: app.globalData.setting.stoid, - } - }).then(res => { - if(res.data.code == 0 && res.data.data) { - let item = res.data.data.pageData[0]; - if(item && item.ad_code) { - self.setData({ - ad_img: item.ad_code, - }); - }; - }; - }); - - } else { - // if(!res.data.data.is_distribut) {//如果不是分销商:0不是,1是 - - app.request.promiseGet('/api/weshop/users/distribut/getIsDistribut', { - data: { - storeId: self.data.userInfo.store_id, - userId: self.data.userInfo.user_id, - first_leader: self.data.userInfo.first_leader, - }, - isShowLoading: true, - }).then(function(res) { - console.log('!!!===>', res); - if(res.data.code == 0) { - self.setData({ - fenxiao: res.data.data, - }); - } else { - self.setData({ - msg: res.data.msg, - }); - } - - }); - - - - }; - }, - - }); - + userinfo=res.data.data; + self.setData({ + userInfo: userinfo, + imghost: app.globalData.setting.imghost, + }); + app.globalData.userInfo=userinfo; + wx.setStorageSync("userinfo",userinfo); + //-- 获取分销的内容 -- + self.show_dis(); + }) - }; - }; - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - + + //-- 优化小程序没有开启或者过期没有必要再调用程序 --- + show_dis:async function(){ + var isok=1,self=this; + await getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{ + var dis=rs.data.data; + if( dis && dis.switch==0){ + self.setData({err_word:"商家暂时未开启分享,敬请期待"}); + isok=0; + } + + }) + + if(!isok) return false; + await getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=2",{}).then(rs=>{ + if(rs.data.code==0){ + var arr = rs.data.data.pageData; + if (arr.length > 0) { + var item=arr[0]; + if(item.is_sy==0){ + var now = Date.parse(new Date());now = now / 1000; + if(item.end_time', res); + if(res.data.code == 0) { + var data={ + fenxiao: res.data.data, + }; + var goods=null; + var isall_pass=1; + for(var i in res.data.data){ + if(!res.data.data[i].pass){ isall_pass=0; } + if(res.data.data[i].type==3 && res.data.data[i].conditonRemark){ + goods={is_buy:1,url:'/pages/index/index/index'}; + if(res.data.data[i].goods_id){ + goods.url='/pages/goods/goodsInfo/goodsInfo?goods_id='+res.data.data[i].goods_id; + } + break; + } + } + if(goods){ + data.buy_goods=goods; + } + self.setData(data); + //如果全部都更新了通过的话 + if(isall_pass){ + wx.showToast({ + title: "全部满足成为分销商", + icon: 'none', + duration: 2000 + }); + //-- 会员的分销的内容要进行存储 -- + app.globalData.userInfo.is_distribut=1; + wx.setStorageSync("userinfo",app.globalData.userInfo); + setTimeout(function(){ + self.getDis_data(); + self.setData({ + userInfo: app.globalData.userInfo, + }); + },2000) + } + } + + }); + }else{ + self.getDis_data() + } + }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - + + //-- 获取会员分销的金额的内容 -- + getDis_data:function(){ + var self=this; + let url = '/api/weshop/users/distribut/getMoney'; + // 请求数据 + app.request.get(url + '/' + this.data.userInfo.store_id + '/' + this.data.userInfo.user_id, { + success: function(res) { + if(res.data.code == 0) { + self.setData({ + data: res.data.data, + }); + } + }, + }); }, + /** * 页面相关事件处理函数--监听用户下拉动作 */ @@ -134,13 +197,6 @@ Page({ }, /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** * 用户点击右上角分享 */ onShareAppMessage: function () { @@ -160,9 +216,7 @@ Page({ console.log(url); app.goto(url); }, - - /** * 获取输入框 */ @@ -171,14 +225,15 @@ Page({ inputValue: e.detail.value, }); }, - - + /** * 验证 */ verify(e) { let pass = e.target.dataset.pass; + let index = e.target.dataset.index; let mobile = 0; + var th=this; if(this.data.inputValue) { mobile = this.data.inputValue; if(!pass) { @@ -188,32 +243,33 @@ Page({ userId: self.data.userInfo.user_id, mobile: mobile, }, - success: function (res) { - if(res.code = -1) { - wx.showToast({ - title: res.data.msg, - icon: 'none', - duration: 2000 - }); - }; - console.log('!!!===>', res); - - if(res.data.msg == '绑定上下级关系成功!') { - app.request.promiseGet('/api/weshop/users/distribut/getIsDistribut', { - data: { - storeId: self.data.userInfo.store_id, - userId: self.data.userInfo.user_id, - first_leader: self.data.userInfo.first_leader, - }, - isShowLoading: true, - }).then(function(res) { - console.log('!!!===>', res); - self.setData({ - fenxiao: res.data.data, - }); - }); - }; - + success: function (res) { + var showtxt=res.data.msg; + if(res.data.data.indexOf('已成为分销商')!=-1){ + showtxt="成功成为分销商"; + var txt="fenxiao["+index+"].pass"; + var txt2="data.is_distribut"; + setTimeout(function(){ + th.setData({[txt]:1,[txt2]:1}) + th.getDis_data(); + },1500) + + } + if(res.data.data.indexOf('验证成功')!=-1){ + var txt="fenxiao["+index+"].pass"; + th.setData({[txt]:1}) + } + if(res.data.data.indexOf('绑定上下级关系成功')!=-1){ + var txt="fenxiao["+index+"].pass"; + th.setData({[txt]:1}) + } + + wx.showToast({ + title: showtxt, + icon: 'none', + duration: 1500 + }); + } }); @@ -227,4 +283,8 @@ Page({ }; }, + + go_login(){ + getApp().goto("/pages/togoin/togoin") //跳到非tabbar页 + } }) \ No newline at end of file diff --git a/pages/distribution/distribution.wxml b/pages/distribution/distribution.wxml index 58ae2f8..806ba11 100644 --- a/pages/distribution/distribution.wxml +++ b/pages/distribution/distribution.wxml @@ -1,4 +1,6 @@ + + @@ -70,24 +72,30 @@ 新手必看 + + + + 提示 + + + {{err_word}} + + + + - - - - 提示 - - - {{msg}} - - - + + 分销规则说明 - 仅限PLUS卡({{item.conditonRemark}})的会员, 立即升级 + 仅限PLUS卡({{item.conditonRemark}})的会员, + PLUS详情 + 立即升级 + @@ -96,7 +104,7 @@ - 验证 + 验证 @@ -104,7 +112,7 @@ - {{item.conditonRemark}} + {{item.conditonRemark==null?'直接成为分销商':item.conditonRemark}} @@ -116,15 +124,21 @@ - 去购买 - - - - - + 去购买 + - - + + + + + + + + 您还未登录,请先授权登录! + 去授权 + + + \ No newline at end of file diff --git a/pages/distribution/distribution.wxss b/pages/distribution/distribution.wxss index f4c75c3..343b3f2 100644 --- a/pages/distribution/distribution.wxss +++ b/pages/distribution/distribution.wxss @@ -236,5 +236,6 @@ checkbox .wx-checkbox-input.wx-checkbox-input-checked::before { width: 400rpx; height: 400rpx; } +.btn{ background-color: #57b837; padding: 15rpx 20rpx; border-radius: 10rpx; color: #fff;} diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index bd18414..2495fe8 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -309,8 +309,7 @@ Page({ } ee.setData({ gid: gid}); if(first_leader){ - console.log("log---".first_leader); - + console.log("log---".first_leader); getApp().globalData.first_leader=first_leader; //调用接口判断是不是会员 getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{ @@ -2420,6 +2419,7 @@ Page({ if(pkno.indexOf(item.pickup_no)<0) pkno.push(item.pickup_no); } + pkno.sort(); var pkno_str=pkno.join(","); var o_plist=e.data.data.pageData; var new_list=[]; diff --git a/pages/user/index/index.js b/pages/user/index/index.js index ea6caa5..0b6baa6 100644 --- a/pages/user/index/index.js +++ b/pages/user/index/index.js @@ -63,8 +63,16 @@ Page({ getApp().request.promiseGet("/api/weshop/userTool/page?pageSize=100", { }).then(res => { if(res.data.code==0 ){ - var d_list=res.data.data.pageData; - th.setData({user_tool:d_list}); + var d_list=res.data.data.pageData; + getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{ + var dis=rs.data.data; + for(var i in d_list){ + if(d_list[i].name=='我的分销' && dis && dis.switch==0){ + d_list.splice(i,1); + } + } + th.setData({user_tool:d_list}); + }) } }) this.birthday(); @@ -307,10 +315,8 @@ Page({ getApp().getConfig2(function(e) { var t_swi = e.switch_list; if (t_swi) t_swi = JSON.parse(t_swi) - if(t_swi){ - var user_tool=[]; - if(t_swi.usertool) user_tool=JSON.parse(t_swi.usertool); - th.setData({sys_switch:t_swi,c_list:user_tool}); + if(t_swi){ + th.setData({sys_switch:t_swi}); } @@ -338,11 +344,17 @@ Page({ } } }) - - //th.requestRecommend(); - } + + var t_swi= getApp().globalData.config2.switch_list + if (t_swi){ + t_swi = JSON.parse(t_swi); + var user_tool=[]; + if(t_swi.usertool) user_tool=JSON.parse(t_swi.usertool); + th.setData({c_list:user_tool}) + } + var goods_list = this.selectComponent("#goods_recommend"); //组件的id goods_list.init(); diff --git a/utils/auth.js b/utils/auth.js index be2a77c..0765c10 100644 --- a/utils/auth.js +++ b/utils/auth.js @@ -32,12 +32,20 @@ module.exports = { login_fir: function (e, o, n) { var a = this.app(), app = a, i = this; - var userinfo= wx.getStorageSync("userinfo"); if(userinfo){ - a.globalData.userInfo=userinfo; - a.globalData.user_id=userinfo.user_id; - "function" == typeof n && n(a.globalData.userInfo, a.globalData.wechatUser); + //--生成会员 -- + getApp().promiseGet("/api/weshop/users/get/" + userinfo.store_id + "/" + userinfo.user_id,{}).then(res=>{ + if(res.data.code==0){ + //更新会员 + userinfo= e.data.data; + a.globalData.userInfo=userinfo; + a.globalData.user_id=userinfo.user_id; + wx.setStorageSync("userinfo",userinfo); + + "function" == typeof n && n(a.globalData.userInfo, a.globalData.wechatUser); + } + }) return true; } -- libgit2 0.21.4