Commit 83747aa26b16b7b1d8e6201ae76cd8aabd9ebd50

Authored by 后端研发-倪永富
1 parent 00c38f4a

优化商品分类&添加自定义底部导航

@@ -5,29 +5,86 @@ var api = require("./api/api.js") @@ -5,29 +5,86 @@ var api = require("./api/api.js")
5 5
6 //公共方法和变量 6 //公共方法和变量
7 App({ 7 App({
8 - globalData: {  
9 - setting: t,  
10 - wechatUser: null,  
11 - userInfo: null,  
12 - config: null, //门店参数  
13 - config2: null, //门店配置  
14 - code: null,  
15 - heigth:0,  
16 - user_id:null,// 3674923,// 4379287,// null,// 5682068,  
17 - buy_now:null,  
18 - picklist:null, //门店列表  
19 - wuliuprice: null, //物流价格表  
20 - wuliu: null, //物流公司  
21 - baddr:null,  
22 - mobile: null, //记录手机  
23 - getu:null, //记录会员信息  
24 - sessionKey: null,//记录会员信息  
25 - openid: null, //记录会员信息 8 + editTabBar: function () {
  9 + //使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组,数组最后一个就是当前页面。
26 10
27 - to_group:null, //参团传递的数据  
28 - wxapp_buy_obj:null, //微信小程序购买的Object  
29 - pk_store:null, //选择的门店 11 + var curPageArr = getCurrentPages(); //获取加载的页面
  12 + var curPage = curPageArr[curPageArr.length - 1]; //获取当前页面的对象
  13 + var pagePath = curPage.route; //当前页面url
  14 + if (pagePath.indexOf('/') != 0) {
  15 + pagePath = '/' + pagePath;
  16 + }
  17 + console.log("获取加载的页面:="+curPageArr)
  18 + console.log("获取当前页面的对象:="+curPage)
  19 + console.log("当前页面url:="+pagePath)
  20 + var tabBar = this.globalData.tabBar;
  21 + for (var i = 0; i < tabBar.list.length; i++) {
  22 + tabBar.list[i].active = false;
  23 + if (tabBar.list[i].weappurl == pagePath) {
  24 + tabBar.list[i].active = true; //根据页面地址设置当前页面状态
  25 + }
  26 + }
  27 + curPage.setData({
  28 + tabBar: tabBar
  29 + });
  30 + },
  31 +
  32 + globalData: {
  33 + tabBar: {
  34 + "color": "#6e6d6b",//文字未选择color
  35 + "selectedColor": "#f23030",//文字被选择后color
  36 + "borderStyle": "white",//
  37 + "backgroundColor": "#ffffff",//背景color
  38 + "list": [
  39 + {
  40 + "weappurl": "/pages/index/index/index",
  41 + "nav_name": "首页",
  42 + "src": "/images/bar/index.png",
  43 + "src_sele": "/images/bar/index_on.png"
  44 + },
  45 + {
  46 + "weappurl": "/pages/goods/categoryList/categoryList",
  47 + "nav_name": "分类",
  48 + "src": "/images/bar/fl.png",
  49 + "src_sele": "/images/bar/fl_on.png"
  50 + },
  51 + {
  52 + "weappurl": "/pages/cart/cart/cart",
  53 + "nav_name": "购物车",
  54 + "src": "/images/bar/car.png",
  55 + "src_sele": "/images/bar/car_on.png"
  56 + },
  57 + {
  58 + "weappurl": "/pages/user/index/index",
  59 + "nav_name": "我的",
  60 + "src": "/images/bar/user.png",
  61 + "src_sele": "/images/bar/user_on.png"
  62 + }
  63 + ]
30 }, 64 },
  65 + isTabBar:false,
  66 + setting: t,
  67 + wechatUser: null,
  68 + userInfo: null,
  69 + config: null, //门店参数
  70 + config2: null, //门店配置
  71 + code: null,
  72 + heigth:0,
  73 + user_id:null,// 3674923,// 4379287,// null,// 5682068,
  74 + buy_now:null,
  75 + picklist:null, //门店列表
  76 + wuliuprice: null, //物流价格表
  77 + wuliu: null, //物流公司
  78 + baddr:null,
  79 + mobile: null, //记录手机
  80 + getu:null, //记录会员信息
  81 + sessionKey: null,//记录会员信息
  82 + openid: null, //记录会员信息
  83 +
  84 + to_group:null, //参团传递的数据
  85 + wxapp_buy_obj:null, //微信小程序购买的Object
  86 + pk_store:null, //选择的门店
  87 + },
31 auth: o, 88 auth: o,
32 request: a, 89 request: a,
33 onLaunch: function() { 90 onLaunch: function() {
pages/cart/cart/cart.js
@@ -55,6 +55,11 @@ Page({ @@ -55,6 +55,11 @@ Page({
55 }, 55 },
56 onShow: function() { 56 onShow: function() {
57 var th = this; 57 var th = this;
  58 + th.setData({
  59 + isTabBar: getApp().globalData.isTabBar,
  60 + });
  61 +
  62 + t.editTabBar(); //显示自定义的底部导航
58 this.getCardList(); 63 this.getCardList();
59 if(getApp().globalData.user_id) getApp().requestCardNum(); 64 if(getApp().globalData.user_id) getApp().requestCardNum();
60 //--获取是否又秒杀活动-- 65 //--获取是否又秒杀活动--
@@ -73,6 +78,7 @@ Page({ @@ -73,6 +78,7 @@ Page({
73 }) 78 })
74 } 79 }
75 }); 80 });
  81 + isTabBar
76 82
77 }, 83 },
78 84
pages/cart/cart/cart.wxml
@@ -147,7 +147,7 @@ @@ -147,7 +147,7 @@
147 </view> 147 </view>
148 148
149 <!-- 好物推荐 --> 149 <!-- 好物推荐 -->
150 -<view class="title" style="margin-top: 60rpx" wx:if="{{(!requestData|| requestData.length==0) && is_load}}"> 150 +<view class="title" style="margin-top: 60rpx; margin-bottom:{{isTabBar == true ? '50px' : '0'}}" wx:if="{{(!requestData|| requestData.length==0) && is_load}}">
151 <!-- 标题 --> 151 <!-- 标题 -->
152 <view> 152 <view>
153 <!-- 中文名标题 --> 153 <!-- 中文名标题 -->
@@ -182,4 +182,8 @@ @@ -182,4 +182,8 @@
182 182
183 183
184 184
185 -<warn id="warn"></warn>  
186 \ No newline at end of file 185 \ No newline at end of file
  186 +<warn id="warn"></warn>
  187 +<view wx:if="{{isTabBar == true}}">
  188 + <import src="../../tabbar/tabbar.wxml" />
  189 + <template is="tabBar" data="{{tabBar}}" />
  190 +</view>
187 \ No newline at end of file 191 \ No newline at end of file
pages/goods/categoryList/categoryList.js
@@ -68,6 +68,8 @@ Page({ @@ -68,6 +68,8 @@ Page({
68 }, 68 },
69 onLoad: function(tt) { 69 onLoad: function(tt) {
70 var that = this; 70 var that = this;
  71 + that.get_brand();
  72 +
71 clearInterval(that.data.timer); 73 clearInterval(that.data.timer);
72 that.setData({ countDownNum: 3, stylePage: 1 }); 74 that.setData({ countDownNum: 3, stylePage: 1 });
73 75
@@ -151,6 +153,10 @@ Page({ @@ -151,6 +153,10 @@ Page({
151 153
152 onShow:function(){ 154 onShow:function(){
153 var that=this; 155 var that=this;
  156 + that.setData({
  157 + isTabBar: getApp().globalData.isTabBar,
  158 + });
  159 + t.editTabBar(); //显示自定义的底部导航
154 //this.requestFirstCategoris(); 160 //this.requestFirstCategoris();
155 if(getApp().globalData.user_id) getApp().requestCardNum(); 161 if(getApp().globalData.user_id) getApp().requestCardNum();
156 getApp().getConfig2(function (e) { 162 getApp().getConfig2(function (e) {
pages/goods/categoryList/categoryList.wxml
@@ -288,7 +288,7 @@ @@ -288,7 +288,7 @@
288 <view class="flex project_height" style="margin-left:-10rpx;"> 288 <view class="flex project_height" style="margin-left:-10rpx;">
289 <!-- 分类项目的类型 --> 289 <!-- 分类项目的类型 -->
290 <view class="project_type" style="height:88%;overflow-y:auto;position:fixed;left:0;z-index:999999;top:120rpx;"> 290 <view class="project_type" style="height:88%;overflow-y:auto;position:fixed;left:0;z-index:999999;top:120rpx;">
291 - <view class="project_type-frame"> 291 + <view class="project_type-frame" style="margin-bottom:50px;">
292 <view wx:if="{{is_show_gb}}"> 292 <view wx:if="{{is_show_gb}}">
293 <view bindtap="click_classify" class="share_type fs30 flex-space-between xc-letter-spacing {{select_classify_on==223?'select_classify':''}}"data-index="223"data-name="国家" wx:if="{{is_country}}"> 293 <view bindtap="click_classify" class="share_type fs30 flex-space-between xc-letter-spacing {{select_classify_on==223?'select_classify':''}}"data-index="223"data-name="国家" wx:if="{{is_country}}">
294 <text>国</text><text>家</text> 294 <text>国</text><text>家</text>
@@ -316,7 +316,7 @@ @@ -316,7 +316,7 @@
316 </view> 316 </view>
317 </view> 317 </view>
318 <!-- 分类项目的内容 --> 318 <!-- 分类项目的内容 -->
319 - <view class="classify_content" style="margin-left:26%;margin-top:51px"> 319 + <view class="classify_content" style="margin-left:26%;margin-top:60px">
320 <!-- 国家的样式 --> 320 <!-- 国家的样式 -->
321 <block wx:if="{{select_classify_on==223&&is_show_gb}}"> 321 <block wx:if="{{select_classify_on==223&&is_show_gb}}">
322 <view class="classify_name fs28 flex-space-between"> 322 <view class="classify_name fs28 flex-space-between">
@@ -365,7 +365,7 @@ @@ -365,7 +365,7 @@
365 <block wx:if="{{is_show_pl}}"> 365 <block wx:if="{{is_show_pl}}">
366 <block wx:if="{{select_classify_on!=220&&select_classify_on!=223&&is_level_three!=1}}"> 366 <block wx:if="{{select_classify_on!=220&&select_classify_on!=223&&is_level_three!=1}}">
367 <view style="width:100%;height:100%;"> 367 <view style="width:100%;height:100%;">
368 - <view class="classify_name fs28 flex-space-between" id="header" data-pid="0" data-cid="{{cat_id}}" bindtap='select_more' style="position:fixed;z-index:999999;top:120rpx;width:70%;background-color:#ffffff;left:26%;padding:0 10rpx;"> 368 + <view class="classify_name fs28 flex-space-between" id="header" data-pid="0" data-cid="{{cat_id}}" bindtap='select_more' style="position:fixed;z-index:999999;top:65px;width:70%;background-color:#ffffff;left:26%;padding:0 10rpx;">
369 <view class="classify_title ellipsis-1">{{classify_name}}</view> 369 <view class="classify_title ellipsis-1">{{classify_name}}</view>
370 <view class="flex select_more" > 370 <view class="flex select_more" >
371 <view class="red-co fs24" >更多</view> 371 <view class="red-co fs24" >更多</view>
@@ -376,13 +376,13 @@ @@ -376,13 +376,13 @@
376 <!-- <view class="classify_content-frame flex-wrap" style="width:100%;overflow:hidden;heigth:100%;"> --> 376 <!-- <view class="classify_content-frame flex-wrap" style="width:100%;overflow:hidden;heigth:100%;"> -->
377 377
378 <!-- <view class="null" style="width:100%;margin-top:70rpx;"></view> --> 378 <!-- <view class="null" style="width:100%;margin-top:70rpx;"></view> -->
379 - <scroll-view scroll-y scroll-top="{{scrollTop}}" bindscrolltolower='scrollLower' style="height:{{windowHeight}};position:absolute;margin-top:70rpx;top:120rpx;bottom:0;rigth:0;left:26%;width:73%;"> 379 + <scroll-view scroll-y scroll-top="{{scrollTop}}" bindscrolltolower='scrollLower' style="height:{{windowHeight}};position:absolute;margin-top:70rpx;top:120rpx;bottom:0;rigth:0;left:26%;width:73%;margin-bottom:50px;">
380 <view class="null" style="width:100%;height:1px;"></view> 380 <view class="null" style="width:100%;height:1px;"></view>
381 <!-- goodslist --> 381 <!-- goodslist -->
382 <view class="choice_list" style="height:{{msgStatus != true?'100%':''}}"> 382 <view class="choice_list" style="height:{{msgStatus != true?'100%':''}}">
383 <navigator class="choice_item" style="margin-bottom:{{dataLength -1 == index?'100px':'0'}}" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:for="{{requestData}}" data-id="{{index}}" wx:key="{{index}}"> 383 <navigator class="choice_item" style="margin-bottom:{{dataLength -1 == index?'100px':'0'}}" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:for="{{requestData}}" data-id="{{index}}" wx:key="{{index}}">
384 <view class="img-wrap"> 384 <view class="img-wrap">
385 - <image src="{{item.original_img}}" binderror="bind_bnerr2" data-url="{{url+item.original_img}}" lazy-load="true" data-errorimg="requestData[{{index}}].original_img"></image> 385 + <image src="{{url+item.original_img}}" binderror="bind_bnerr2" data-url="{{url+item.original_img}}" lazy-load="true" data-errorimg="requestData[{{index}}].original_img"></image>
386 </view> 386 </view>
387 <view class="item-cont"> 387 <view class="item-cont">
388 <view class="title">{{item.goods_name}}</view> 388 <view class="title">{{item.goods_name}}</view>
@@ -486,4 +486,8 @@ @@ -486,4 +486,8 @@
486 </view> 486 </view>
487 </block> 487 </block>
488 488
489 -</block>  
490 \ No newline at end of file 489 \ No newline at end of file
  490 +</block>
  491 +<view wx:if="{{isTabBar == true}}">
  492 + <import src="../../tabbar/tabbar.wxml" />
  493 + <template is="tabBar" data="{{tabBar}}" />
  494 +</view>
491 \ No newline at end of file 495 \ No newline at end of file
pages/index/index/index.js
@@ -77,7 +77,7 @@ Page({ @@ -77,7 +77,7 @@ Page({
77 77
78 onLoad: function() { 78 onLoad: function() {
79 var th = this; 79 var th = this;
80 - 80 +
81 //看一下商家是否开通了权益 81 //看一下商家是否开通了权益
82 //--初始化是否有打勾-- 82 //--初始化是否有打勾--
83 getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", { 83 getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
@@ -104,7 +104,37 @@ Page({ @@ -104,7 +104,37 @@ Page({
104 }, 104 },
105 async onShow() { 105 async onShow() {
106 var th = this; 106 var th = this;
107 - 107 + //获取底部导航
  108 + await getApp().request.promiseGet("/api/weshop/storeFooter/get/"+o.stoid, {
  109 +
  110 + }).then(res => {
  111 + var e = res;
  112 + console.log(e)
  113 + if(e.data.code != -1){
  114 + getApp().globalData.isTabBar = true
  115 + //console.log(JSON.parse(e))
  116 + var itemList = e.data.data.data;
  117 +
  118 + itemList = JSON.parse(itemList)
  119 + for(var i=0; i<itemList.length; i++){
  120 + itemList[i]['active'] = false
  121 + }
  122 + console.log(itemList)
  123 + getApp().globalData.tabBar.backgroundColor = e.data.data.bkcolor
  124 + getApp().globalData.tabBar.selectedColor = e.data.data.fontcolor_sele
  125 + getApp().globalData.tabBar.color = e.data.data.fontcolor
  126 + getApp().globalData.tabBar.list = itemList
  127 + wx.hideTabBar({})
  128 + }else{
  129 + getApp().globalData.isTabBar = true
  130 + }
  131 + th.setData({
  132 + isTabBar: getApp().globalData.isTabBar,
  133 + });
  134 + })
  135 + console.log("isTabBar:="+getApp().globalData.isTabBar)
  136 + t.editTabBar(); //显示自定义的底部导航
  137 +
108 if (getApp().globalData.user_id) getApp().requestCardNum(); 138 if (getApp().globalData.user_id) getApp().requestCardNum();
109 await this.init_load(); 139 await this.init_load();
110 //显示的时候要开启计时器 140 //显示的时候要开启计时器
pages/index/index/index.wxml
@@ -246,7 +246,7 @@ @@ -246,7 +246,7 @@
246 </view> 246 </view>
247 247
248 <!-- 好物推荐 --> 248 <!-- 好物推荐 -->
249 - <view class="title"> 249 + <view class="title" style="margin-bottom:{{isTabBar == true ? '50px' : '0'}}">
250 <!-- 标题 --> 250 <!-- 标题 -->
251 <view> 251 <view>
252 <!-- 中文名标题 --> 252 <!-- 中文名标题 -->
@@ -359,7 +359,9 @@ @@ -359,7 +359,9 @@
359 </view> 359 </view>
360 </view> 360 </view>
361 </block> 361 </block>
362 -  
363 - 362 +<!-- <view wx:if="{{isTabBar == true}}"> -->
  363 + <import src="../../tabbar/tabbar.wxml" />
  364 + <template is="tabBar" data="{{tabBar}}" />
  365 +<!-- </view> -->
364 366
365 367
pages/user/index/index.js
@@ -78,12 +78,18 @@ Page({ @@ -78,12 +78,18 @@ Page({
78 onShow: function() { 78 onShow: function() {
79 79
80 this.is_assistance(); 80 this.is_assistance();
  81 +
81 82
82 var stoid = app_d.setting.stoid; 83 var stoid = app_d.setting.stoid;
83 var s = this, 84 var s = this,
84 th = s, 85 th = s,
85 need_money = 0, 86 need_money = 0,
86 cur_g_num = 0; 87 cur_g_num = 0;
  88 + th.setData({
  89 + isTabBar: getApp().globalData.isTabBar,
  90 + });
  91 +
  92 + app.editTabBar(); //显示自定义的底部导航
87 getApp().get_isbuy(th.setappdata); 93 getApp().get_isbuy(th.setappdata);
88 if (getApp().globalData.user_id) getApp().requestCardNum(); 94 if (getApp().globalData.user_id) getApp().requestCardNum();
89 /*------会员登录------*/ 95 /*------会员登录------*/
pages/user/index/index.wxml
1 -<view class="xc-page"> 1 +<view class="xc-page" style="margin-bottom:{{isTabBar == true ? '50px' : '0'}}">
2 <view class="xc-user"> 2 <view class="xc-user">
3 <view class="xc-head rel"> 3 <view class="xc-head rel">
4 <image class="xc-background" src="{{iurl}}{{ad_img?ad_img:'/miniapp/images/user_index_powder.jpg'}}"> 4 <image class="xc-background" src="{{iurl}}{{ad_img?ad_img:'/miniapp/images/user_index_powder.jpg'}}">
@@ -297,3 +297,7 @@ @@ -297,3 +297,7 @@
297 </view> 297 </view>
298 298
299 <pop_txt id="pop_txt"></pop_txt> 299 <pop_txt id="pop_txt"></pop_txt>
  300 +<view wx:if="{{isTabBar == true}}">
  301 + <import src="../../tabbar/tabbar.wxml" />
  302 + <template is="tabBar" data="{{tabBar}}" />
  303 +</view>
300 \ No newline at end of file 304 \ No newline at end of file