diff --git a/app.js b/app.js index 0df5ad2..4437718 100644 --- a/app.js +++ b/app.js @@ -5,66 +5,111 @@ var api = require("./api/api.js") //公共方法和变量 App({ - editTabBar: function () { + editTabBar: function (taht,stoid,url) { + var that=this; + var th = taht //使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组,数组最后一个就是当前页面。 - - var curPageArr = getCurrentPages(); //获取加载的页面 - var curPage = curPageArr[curPageArr.length - 1]; //获取当前页面的对象 + var custum_data=this.globalData.custum_data; + var isIpx=this.globalData.isIpx; + //var curPageArr = getCurrentPages(); //获取加载的页面 + //var curPage = curPageArr[curPageArr.length - 1]; //获取当前页面的对象 + var curPage=th; var pagePath = curPage.route; //当前页面url if (pagePath.indexOf('/') != 0) { - pagePath = '/' + pagePath; + pagePath = '/' + pagePath; } - console.log("获取加载的页面:="+curPageArr) - console.log("获取当前页面的对象:="+curPage) - console.log("当前页面url:="+pagePath) - var tabBar = this.globalData.tabBar; - for (var i = 0; i < tabBar.list.length; i++) { - tabBar.list[i].active = false; - if (tabBar.list[i].weappurl == pagePath) { - tabBar.list[i].active = true; //根据页面地址设置当前页面状态 - } + if(isIpx){ + if(custum_data){ + that.set_custom_nav(custum_data,isIpx,pagePath,url,curPage); + }else{ + var tabBar = { + 'iscustom':2, + 'url':url, + 'active':pagePath, + 'isIpx':isIpx, + cartGoodsNum:this.globalData.cartGoodsNum + } + curPage.setData({ + tabBar:tabBar, + isIpx:isIpx, + cartGoodsNum:this.globalData.cartGoodsNum + }) + } + + }else{ + var isIpx = false; + wx.getSystemInfo({ + success: (res) => { + // console.log(res) + let modelmes = res.model; //手机品牌 + if (modelmes.indexOf('iPhone X') != -1) {  //XS,XR,XS MAX均可以适配,因为indexOf()会将包含'iPhone X'的字段都查出来 + isIpx = true + } + //缓存住,下次就不调用接口了 + that.globalData.isIpx=isIpx; + getApp().request.promiseGet("/api/weshop/storeFooter/get/"+stoid, { + }).then(res => { + var e = res; + if(e.data.code != -1){ + that.globalData.custum_data=e.data.data; + that.set_custom_nav(e.data.data,isIpx,pagePath,url,curPage); + }else{ + var tabBar = { + 'iscustom':2, + 'url':url, + 'active':pagePath, + 'isIpx':isIpx, + cartGoodsNum:this.globalData.cartGoodsNum + } + curPage.setData({ + tabBar:tabBar, + isIpx:isIpx, + cartGoodsNum:this.globalData.cartGoodsNum + }) + } + + }) + }, + }) } - curPage.setData({ - tabBar: tabBar - }); }, + set_custom_nav(data,isIpx,pagePath,url,curPage){ + //缓存住,下次就不调用接口了 + var itemList = data.data; + itemList = JSON.parse(itemList) + //使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组,数组最后一个就是当前页面。 + for (var i = 0; i < itemList.length; i++) { + itemList[i].active = false; + if (itemList[i].weappurl == pagePath) { + itemList[i].active = true; //根据页面地址设置当前页面状态 + } + } + //如果当服务端返回的值有数据就渲染数据到页面 + var tabBar = { + 'iscustom':1, + 'url':url, + 'active':pagePath, + 'list':itemList, + 'backgroundColor': data.bkcolor, + 'selectedColor' : data.fontcolor_sele, + 'color':data.fontcolor, + 'length':itemList.length, + 'isIpx':isIpx, + cartGoodsNum:this.globalData.cartGoodsNum + } + curPage.setData({ + tabBar:tabBar, + isIpx:isIpx, + cartGoodsNum:this.globalData.cartGoodsNum + }) + }, + globalData: { - tabBar: { - "color": "#6e6d6b",//文字未选择color - "selectedColor": "#f23030",//文字被选择后color - "borderStyle": "white",// - "backgroundColor": "#ffffff",//背景color - "iscustom":'', - "url":"", - "list": [ - { - "weappurl": "/pages/index/index/index", - "nav_name": "首页", - "src": "/miniapp/images/bar/index.png", - "src_sele": "/miniapp/images/bar/index_on.png" - }, - { - "weappurl": "/pages/goods/categoryList/categoryList", - "nav_name": "分类", - "src": "/miniapp/images/bar/fl.png", - "src_sele": "/miniapp/images/bar/fl_on.png" - }, - { - "weappurl": "/pages/cart/cart/cart", - "nav_name": "购物车", - "src": "/miniapp/images/bar/car.png", - "src_sele": "/miniapp/images/bar/car_on.png" - }, - { - "weappurl": "/pages/user/index/index", - "nav_name": "我的", - "src": "/miniapp/images/bar/user.png", - "src_sele": "/miniapp/images/bar/user_on.png" - } - ] - }, - isTabBar:false, + cartGoodsNum:0, //购物车总数量 + isTabBar :false, + isIpx: false, //适配IPhoneX + url:"", setting: t, wechatUser: null, userInfo: null, @@ -86,17 +131,23 @@ App({ to_group:null, //参团传递的数据 wxapp_buy_obj:null, //微信小程序购买的Object pk_store:null, //选择的门店 + first_leader:null, //分享会员ID + guide_id:null, //分享导购ID + + windowWidth:0, //整个窗体的宽度 }, auth: o, request: a, onLaunch: function() { this.initExt(); var t = this.globalData.setting; + //console.log(t) t.resourceUrl = t.url + "/template/mobile/rainbow"; var clientWidth = wx.getSystemInfoSync().windowWidth; var rpxR = 750 / clientWidth; var calc = wx.getSystemInfoSync().windowHeight * rpxR; this.globalData.heigth=calc; + this.globalData.windowWidth=clientWidth; var app=this; if(!app.globalData.userInfo){ @@ -106,6 +157,44 @@ App({ app.globalData.user_id= app.globalData.userInfo.user_id; } } + + wx.getSystemInfo({ + success: (res) => { + // console.log(res) + let modelmes = res.model; //手机品牌 + console.log('手机品牌', modelmes) + if (modelmes.indexOf('iPhone X') != -1) {  //XS,XR,XS MAX均可以适配,因为indexOf()会将包含'iPhone X'的字段都查出来 + this.globalData.isIpx = true + } + }, + }) + console.log(t.stoid,this.globalData.user_id) + var tha = this + wx.request({ + url: t.url+'/api/weshop/cart/page', + data: { +         store_id:t.stoid, +         user_id:tha.globalData.user_id, +         state:0, +         is_gift:0 +       }, + methods:'GET', + header: { + 'content-type': 'json' + }, + success: function(e){ + + var num = 0; +         for (var i = 0; i < e.data.data.pageData.length; i++) { +           num += e.data.data.pageData[i].goods_num; +         } +         console.log("购物车数量:=",num) +        tha.globalData.cartGoodsNum=num + }, + fail: function(){} + }) + + }, //---初始化第三方---- @@ -294,7 +383,6 @@ App({ //同步化,在调用的时候要await async get_isbuy() { - var th=this; await api.check_isbuy({ store_id: t.stoid, type: 5 }).then(res=>{ var o=res; @@ -333,6 +421,7 @@ App({ //----智能跳转,判断 非tabBar,tabBar页面的跳转---- goto:function (url) { + var arr_tabbar=["/pages/index/index/index","/pages/goods/categoryList/categoryList", "/pages/goods/categoryList/categoryList?type=2", "/pages/goods/categoryList/categoryList?type=1", @@ -340,10 +429,12 @@ App({ if(arr_tabbar.indexOf(url)!=-1){ if(url.indexOf("categoryList?type=1")!=-1) this.globalData.cat_type=1; if(url.indexOf("categoryList?type=2")!=-1) this.globalData.cat_type=2; - wx.switchTab({ url: url, }) //跳到tabbar页 + wx.navigateTo({ url: url, }) //跳到tabbar页 + }else{ wx.navigateTo({ url: url, }) //跳到非tabbar页 } + //wx.navigateTo({ url: url, }) //跳到非tabbar页 }, //显示提示,word提示内容,type 0失败,提示 1成功 @@ -473,7 +564,14 @@ App({ } },1000); } - } + }, + + //清空登录时候缓存的值 + onHide:function () { + this.globalData.is_test=0; + this.globalData.guide_id=null; //导购清空 + this.globalData.first_leader=null; //分享的会员清空 + } }); diff --git a/app.json b/app.json index 80c7662..83e2937 100644 --- a/app.json +++ b/app.json @@ -117,38 +117,6 @@ "backgroundColor": "#ffffff", "enablePullDownRefresh": true }, - "tabBar": { - "color": "#6e6d6b", - "selectedColor": "#f23030", - "borderStyle": "white", - "backgroundColor": "#ffffff", - "list": [ - { - "pagePath": "pages/index/index/index", - "text": "首页", - "iconPath": "packageA/images/bar/index.png", - "selectedIconPath": "packageA/images/bar/index_on.png" - }, - { - "pagePath": "pages/goods/categoryList/categoryList", - "text": "分类", - "iconPath": "packageA/images/bar/fl.png", - "selectedIconPath": "packageA/images/bar/fl_on.png" - }, - { - "pagePath": "pages/cart/cart/cart", - "text": "购物车", - "iconPath": "packageA/images/bar/car.png", - "selectedIconPath": "packageA/images/bar/car_on.png" - }, - { - "pagePath": "pages/user/index/index", - "text": "我的", - "iconPath": "packageA/images/bar/user.png", - "selectedIconPath": "packageA/images/bar/user_on.png" - } - ] - }, "debug": false, "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/components/diy_advertising/diy_advertising.js b/components/diy_advertising/diy_advertising.js index a2f3aa1..6f66ec4 100644 --- a/components/diy_advertising/diy_advertising.js +++ b/components/diy_advertising/diy_advertising.js @@ -16,9 +16,10 @@ Component({ interval:3000, duration:1000, someData: {}, - max_sw_height:null, + max_sw_height:getApp().globalData.windowWidth, }, methods: { + customMethod: function () { }, //---智能跳转--- go_url:function(e){ diff --git a/components/diy_advertising/diy_advertising.wxml b/components/diy_advertising/diy_advertising.wxml index 08f65c4..fe1a1ae 100644 --- a/components/diy_advertising/diy_advertising.wxml +++ b/components/diy_advertising/diy_advertising.wxml @@ -1,9 +1,9 @@ - + - + 建议宽度640 @@ -80,19 +80,31 @@ - + - + 200*200 - - + + + + + + 200*200 + + + + + + + @@ -137,10 +149,10 @@ 300*150 - + - + @@ -388,9 +400,14 @@ - + + - @@ -400,10 +417,10 @@ - - - + + + diff --git a/components/diy_advertising/diy_advertising.wxss b/components/diy_advertising/diy_advertising.wxss index 60f24cc..72e1551 100644 --- a/components/diy_advertising/diy_advertising.wxss +++ b/components/diy_advertising/diy_advertising.wxss @@ -17,7 +17,6 @@ } .s1 { - width: 100%; display: flex; } @@ -152,14 +151,10 @@ .s4_gk { /* background-color: rgb(129, 213, 249); */ - width: 32%; color: #fff; font-size: 32rpx; - height: 240rpx; text-align: center; - margin-left: 1%; float: left; - margin-bottom: 8rpx; } .s4_gk1 { @@ -331,8 +326,8 @@ width: 100%; margin: 0; } - - -.zwp_s1{ - margin-bottom: 8rpx; -} \ No newline at end of file +.sw_con{ + position: relative; +} +.clicle{ width: 20rpx; height: 20rpx} +.dots{ position: absolute; bottom: 10rpx; width: 100%; display: flex; justify-content: center} diff --git a/packageA/images/share/ct_num.png b/images/share/ct_num.png index c6e1ac3..c6e1ac3 100644 --- a/packageA/images/share/ct_num.png +++ b/images/share/ct_num.png diff --git a/packageA/images/share/default_g_img.gif b/images/share/default_g_img.gif index a5369e2..a5369e2 100644 --- a/packageA/images/share/default_g_img.gif +++ b/images/share/default_g_img.gif diff --git a/packageA/images/share/hui_hear_pic.png b/images/share/hui_hear_pic.png index 91144c7..91144c7 100644 --- a/packageA/images/share/hui_hear_pic.png +++ b/images/share/hui_hear_pic.png diff --git a/packageA/images/share/mackground.png b/images/share/mackground.png index 6bcf62e..6bcf62e 100644 --- a/packageA/images/share/mackground.png +++ b/images/share/mackground.png diff --git a/packageA/images/share/miao_share.png b/images/share/miao_share.png index f788197..f788197 100644 --- a/packageA/images/share/miao_share.png +++ b/images/share/miao_share.png diff --git a/packageA/images/share/q_tj.png b/images/share/q_tj.png index 56136e5..56136e5 100644 --- a/packageA/images/share/q_tj.png +++ b/images/share/q_tj.png diff --git a/packageA/images/share/s_gou.png b/images/share/s_gou.png index 5e4e765..5e4e765 100644 --- a/packageA/images/share/s_gou.png +++ b/images/share/s_gou.png diff --git a/packageA/images/share/share_bg.png b/images/share/share_bg.png index a3177c6..a3177c6 100644 --- a/packageA/images/share/share_bg.png +++ b/images/share/share_bg.png diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 81a9eea..05f1aae 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -55,11 +55,9 @@ Page({ }, onShow: function() { var th = this; - //th.setData({ - // isTabBar: getApp().globalData.isTabBar, - //}); - - t.editTabBar(); //显示自定义的底部导航 + //调用底部导航 + t.editTabBar(th,getApp().globalData.setting.stoid,getApp().globalData.url); + this.getCardList(); if(getApp().globalData.user_id) getApp().requestCardNum(); //--获取是否又秒杀活动-- @@ -81,6 +79,12 @@ Page({ }, + onHide(){ + for(var i = 1; i < 100; i++) { + clearInterval(i); + } + }, + //-------------获取购物车列表,要安装门店进行分类订单----------- getCardList: function() { var th = this; @@ -1102,7 +1106,7 @@ Page({ }, //跳到首页 goto: function(e) { - wx.switchTab({ + navigateTo({ url: '/pages/index/index/index', }) }, diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml index 725c2da..8744b68 100644 --- a/pages/cart/cart/cart.wxml +++ b/pages/cart/cart/cart.wxml @@ -180,10 +180,6 @@ - - - \ No newline at end of file + +