From 2767e58717052718adde427ca5c80b397dd09c50 Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Tue, 2 Jun 2020 11:34:03 +0800 Subject: [PATCH] 1. 底部导航的优化 跳转函数,navigator的优化 2. 自定义模块 广告模块的滑块的时间,圆点的颜色 俩边间距, 图片间距功能 --- app.js | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- app.json | 32 -------------------------------- components/diy_advertising/diy_advertising.js | 3 ++- components/diy_advertising/diy_advertising.wxml | 43 ++++++++++++++++++++++++++++++------------- components/diy_advertising/diy_advertising.wxss | 15 +++++---------- pages/cart/cart/cart.js | 16 ++++++++++------ pages/cart/cart/cart.wxml | 8 ++------ pages/cart/cart/cart.wxss | 4 ++-- pages/cart/cart2/cart2.js | 2 +- pages/cart/cart2_pt/cart2_pt.js | 2 +- pages/cart/cart_wk/cart_wk.js | 2 +- pages/goods/categoryList/categoryList.js | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------ pages/goods/categoryList/categoryList.wxml | 43 +++++++++++++++++++++---------------------- pages/goods/categoryList/categoryList.wxss | 16 ++++++++++++---- pages/goods/goodsInfo/goodsInfo.js | 5 ++++- pages/goods/goodsInfo/goodsInfo.wxml | 2 +- pages/goods/goodsList/goodsList.wxml | 2 +- pages/goods/search/search.wxml | 2 +- pages/index/index/index.js | 55 +++++++++++++++---------------------------------------- pages/index/index/index.wxml | 12 ++++++------ pages/tabbar/tabbar.js | 67 ------------------------------------------------------------------- pages/tabbar/tabbar.wxml | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- pages/tabbar/tabbar.wxss | 1 - pages/team/team_show/team_show.js | 2 +- pages/user/binding_info/binding_info.js | 2 +- pages/user/collect_list/collect_list.js | 2 +- pages/user/comment/comment.js | 2 +- pages/user/coupon/coupon.wxml | 4 ++-- pages/user/deposit/prepaid/msg/msg.js | 2 +- pages/user/get_user_info/get_user_info.wxml | 2 +- pages/user/index/index.js | 36 ++++++++++-------------------------- pages/user/index/index.wxml | 10 ++-------- pages/user/integral/msg/msg.js | 2 +- pages/user/member/bring/msg/msg.js | 2 +- pages/user/my_service/tment_details.js | 2 +- pages/user/order_list/order_list.js | 3 ++- pages/user/return_goods_list/return_goods_list.wxml | 2 +- utils/auth.js | 2 +- utils/request.js | 4 ++-- 39 files changed, 471 insertions(+), 387 deletions(-) diff --git a/app.js b/app.js index 0df5ad2..35768ac 100644 --- a/app.js +++ b/app.js @@ -5,66 +5,112 @@ 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,12 +132,14 @@ App({ to_group:null, //参团传递的数据 wxapp_buy_obj:null, //微信小程序购买的Object pk_store:null, //选择的门店 + }, 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; @@ -106,6 +154,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(){} + }) + + }, //---初始化第三方---- @@ -333,6 +419,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 +427,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成功 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/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 + +