From 666cc4ff237dd654bb6ad118f520d7c9813d5c5b Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Wed, 16 Oct 2024 19:45:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=80=E9=94=AE=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=8E=9F=E7=94=9F=E5=BA=95=E9=83=A8=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 120 ++++++++++++++++++++---- components/cart/cart.vue | 15 ++- components/common/common.vue | 6 +- components/popup/popup.vue | 2 +- pages/goods-category/goods-category.vue | 24 +++-- 5 files changed, 135 insertions(+), 32 deletions(-) diff --git a/App.vue b/App.vue index 8ffd52d3..0cbb6325 100644 --- a/App.vue +++ b/App.vue @@ -7,12 +7,12 @@ data: { // 基础配置 // 数据接口请求地址 - request_url: 'http://shopxo.com/', - // request_url:'https://new.shopxo.vip/', + // request_url: 'http://shopxo.com/', + request_url:'https://new.shopxo.vip/', // 静态资源地址(如系统根目录不在public目录下面请在静态地址后面加public目录、如:https://d1.shopxo.vip/public/) - static_url: 'http://shopxo.com/', - // static_url:'https://new.shopxo.vip/', + // static_url: 'http://shopxo.com/', + static_url:'https://new.shopxo.vip/', // 系统类型(默认default、如额外独立小程序、可与程序分身插件实现不同主体小程序及支付独立) system_type: 'default', @@ -59,6 +59,9 @@ ], // 公共配置 + // 是否使用原生菜单(0否, 1是) + is_use_native_tabbar: 0, + // 分享及转发使用页面设置的默认图片及系统默认图片(0否, 1是) is_share_use_image: 1, @@ -942,7 +945,8 @@ * 当前地址是否存在底部菜单tabbar中 */ is_tabbar_pages(url = null) { - return this.is_tabbar_pages_handle(this.app_tabbar_pages(), url); + var pages = (this.data.is_use_native_tabbar == 1) ? this.data.system_tabbar : this.app_tabbar_pages(); + return this.is_tabbar_pages_handle(pages, url); }, /** @@ -970,7 +974,9 @@ // 系统底部菜单隐藏 system_hide_tabbar() { - uni.hideTabBar(); + if(this.data.is_use_native_tabbar != 1) { + uni.hideTabBar(); + } }, /** @@ -1177,20 +1183,35 @@ * value 显示的文本,超过 4 个字符则显示成 ...(type参数为1的情况下有效) */ set_tab_bar_badge(type, value = 0) { - // 数据处理 - if ((type || null) != null) { - var key = this.data.cache_tabbar_badge_key+'-'+type; - if ((value || null) == null) { - uni.removeStorageSync(key); - } else { - uni.setStorageSync(key, value); + // 是否使用原生菜单 + if(this.data.is_use_native_tabbar == 1) { + if(type == 'cart') { + if ((value || 0) == 0) { + uni.removeTabBarBadge({ + index: 2 + }); + } else { + uni.setTabBarBadge({ + index: 2, + text: value.toString() + }); + } + } + } else { + // 数据处理 + if ((type || null) != null) { + var key = this.data.cache_tabbar_badge_key+'-'+type; + if ((value || null) == null) { + uni.removeStorageSync(key); + } else { + uni.setStorageSync(key, value); + } + } + // 更新底部菜单数据 + var obj = this.get_page_object() || null; + if(obj != null && (obj.$vm || null) != null && (obj.$vm.$refs || null) != null && (obj.$vm.$refs.common || null) != null) { + obj.$vm.$refs.common.footer_init(); } - } - - // 更新底部菜单数据 - var obj = this.get_page_object() || null; - if(obj != null && (obj.$vm || null) != null && (obj.$vm.$refs || null) != null && (obj.$vm.$refs.common || null) != null) { - obj.$vm.$refs.common.footer_init(); } }, @@ -1452,6 +1473,9 @@ // 主题设置 self.set_theme_value(data.plugins_themestyle_data); + // 设置底部菜单 + self.set_tabbar(data.plugins_themestyle_data); + // 用户自动登录处理 self.user_auto_login_handle(); }, @@ -2496,6 +2520,64 @@ uni.setStorageSync('theme', value || this.data.default_theme); }, + // 底部菜单设置 + set_tabbar(theme) { + if(this.data.is_use_native_tabbar == 1) { + // 当前主题 + if ((theme || null) == null) { + theme = this.get_theme_value(); + } + + // 整体样式 + uni.setTabBarStyle({ + selectedColor: this.get_theme_color(theme), + color: '#333', + backgroundColor: '#fff', + borderStyle: 'black' + }); + + // 菜单 + uni.setTabBarItem({ + index: 0, + iconPath: 'static/images/common/tabbar/home.png', + selectedIconPath: 'static/images/' + theme + '/tabbar/home.png', + text: i18n.t('common.home'), + }); + uni.setTabBarItem({ + index: 1, + iconPath: 'static/images/common/tabbar/category.png', + selectedIconPath: 'static/images/' + theme + '/tabbar/category.png', + text: i18n.t('common.category'), + }); + uni.setTabBarItem({ + index: 2, + iconPath: 'static/images/common/tabbar/cart.png', + selectedIconPath: 'static/images/' + theme + '/tabbar/cart.png', + text: i18n.t('common.cart'), + }); + uni.setTabBarItem({ + index: 3, + iconPath: 'static/images/common/tabbar/user.png', + selectedIconPath: 'static/images/' + theme + '/tabbar/user.png', + text: i18n.t('common.my'), + }); + } + }, + + // 数组分组 + group_arry(arry, sub_group_length) { + let index = 0; + let new_arry = []; + if (arry.length > sub_group_length) { + while (index < arry.length) { + new_arry.push(arry.slice(index, (index += sub_group_length))); + } + } else { + new_arry = [arry]; + } + return new_arry; + }, + // 数组分组 group_arry(arry, sub_group_length) { let index = 0; diff --git a/components/cart/cart.vue b/components/cart/cart.vue index 8d7632b4..56012f80 100644 --- a/components/cart/cart.vue +++ b/components/cart/cart.vue @@ -1296,10 +1296,17 @@ }, // 页面样式处理 - page_style_handle() { - var value = (this.propCartNavBottomValue > 0) ? (parseInt(this.propCartNavBottomValue*2)+20) : 20; + page_style_handle() { + var value = 0; + if(app.globalData.data.is_use_native_tabbar == 1) { + // #ifdef H5 + value += (uni.getWindowInfo().windowBottom || 50)+40; + // #endif + } else { + value += ((this.propCartNavBottomValue-8)*2)+20; + } this.setData({ - bottom_fixed_style: 'bottom:'+(((this.propCartNavBottomValue-8)*2)+20)+'rpx' + bottom_fixed_style: 'bottom:'+value+'rpx' }); } }, @@ -1530,7 +1537,7 @@ z-index: 1002 !important; } .discount_detail-popup { - margin-bottom: 122rpx; + margin-bottom: 140rpx; height: calc(70vh - 122rpx); overflow-y: auto; } diff --git a/components/common/common.vue b/components/common/common.vue index 35e41da0..67942a63 100644 --- a/components/common/common.vue +++ b/components/common/common.vue @@ -94,7 +94,9 @@ // 显示响应方法 on_show() { //隐藏系统tabbar - app.globalData.system_hide_tabbar(); + if(app.globalData.data.is_use_native_tabbar != 1) { + app.globalData.system_hide_tabbar(); + } // 初始化配置 this.init_config(); @@ -145,7 +147,7 @@ // 底部菜单初始化 footer_init() { var upd_data = { - is_tabbar: app.globalData.is_tabbar_pages() + is_tabbar: (app.globalData.data.is_use_native_tabbar == 1) ? false : app.globalData.is_tabbar_pages() }; if(upd_data['is_tabbar']) { upd_data['key'] = Math.random(); diff --git a/components/popup/popup.vue b/components/popup/popup.vue index 43fdb6e0..8a4f0eeb 100644 --- a/components/popup/popup.vue +++ b/components/popup/popup.vue @@ -101,7 +101,7 @@ // 初初始化处理 init_handle() { // 弹窗从底部弹出,获取底部菜单高度、如果当前为底部菜单页面则增加底部间距 - var tabbar_height = (this.propPosition == 'bottom' && app.globalData.is_tabbar_pages()) ? ((app.globalData.app_tabbar_height_value()*2)+20) : 0; + var tabbar_height = (app.globalData.data.is_use_native_tabbar != 1 && this.propPosition == 'bottom' && app.globalData.is_tabbar_pages()) ? ((app.globalData.app_tabbar_height_value()*2)+20) : 0; // 左边距位置处理 var left = 0; diff --git a/pages/goods-category/goods-category.vue b/pages/goods-category/goods-category.vue index 3d1a1496..f8f2c3ab 100644 --- a/pages/goods-category/goods-category.vue +++ b/pages/goods-category/goods-category.vue @@ -22,7 +22,7 @@ - + @@ -91,7 +91,7 @@ - + @@ -444,6 +444,11 @@ popup_status: false, // 获取搜索框高度 search_height: 0, + // 底部tab高度 - 只有H5下有值 + window_bottom_height: 0, + // #ifdef H5 + window_bottom_height: (app.globalData.data.is_use_native_tabbar == 1) ? (uni.getWindowInfo().windowBottom || 50) : 0, + // #endif // 样式 left_content_actual_style: '', right_content_actual_style: '', @@ -679,21 +684,28 @@ // 内容实际大小处理 content_actual_size_handle() { + // 是否使用原生菜单 + var left_style_value = 0; + var botton_style_value = 0; + if(app.globalData.data.is_use_native_tabbar != 1) { + left_style_value = this.footer_height_value+20; + botton_style_value = this.footer_height_value; + } // 左侧 var left_style = ''; if(this.category_goods_is_show_cart_nav == 1) { - left_style = 'height: calc(100% - 120rpx - '+(this.footer_height_value+20)+'rpx);'; + left_style = 'height: calc(100% - 120rpx - '+left_style_value+'rpx);'; } // 右侧 var right_style = ''; if(this.category_goods_is_show_cart_nav == 1 && this.common_site_type != 1) { - right_style = 'padding-bottom: calc(120rpx + '+(this.footer_height_value+20)+'rpx);'; + right_style = 'padding-bottom: calc(120rpx + '+left_style_value+'rpx);'; } this.setData({ left_content_actual_style: left_style, right_content_actual_style: right_style, - botton_nav_style: 'bottom: calc(20rpx + '+this.footer_height_value+'rpx);', - cart_content_style: 'bottom: calc(150rpx + '+this.footer_height_value+'rpx);', + botton_nav_style: 'bottom: calc(20rpx + '+botton_style_value+'rpx);', + cart_content_style: 'bottom: calc(150rpx + '+botton_style_value+'rpx);', }); },