From 50f01140c403a4e2f9c879eb6cd98ff4a32faabc Mon Sep 17 00:00:00 2001 From: whitechiina <1293616053@qq.com> Date: Tue, 2 Jun 2026 16:18:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/style_scss.scss | 56 +++- common/tools.js | 41 ++- custom-tab-bar/index.js | 250 ++++++++++++++ custom-tab-bar/index.json | 3 + custom-tab-bar/index.wxml | 15 + custom-tab-bar/index.wxss | 47 +++ pageOne/mes/setUp.vue | 4 +- pages.json | 34 +- pages/h5/bridge.vue | 56 ++++ pages/login/login.vue | 1 + pages/tabbar/index.vue | 270 ++++++++------- pages/tabbar/me.vue | 24 +- pages/tabbar/shop.vue | 316 ++++++++++-------- pages/tabbar/sort.vue | 160 +++++---- .../.sourcemap/mp-weixin/common/vendor.js.map | 2 +- .../mp-weixin/pageOne/mes/setUp.js.map | 2 +- .../mp-weixin/pages/h5/bridge.js.map | 1 + .../mp-weixin/pages/login/login.js.map | 2 +- .../mp-weixin/pages/tabbar/index.js.map | 2 +- .../mp-weixin/pages/tabbar/me.js.map | 2 +- .../mp-weixin/pages/tabbar/shop.js.map | 2 +- .../mp-weixin/pages/tabbar/sort.js.map | 2 +- unpackage/dist/dev/mp-weixin/app.json | 4 +- unpackage/dist/dev/mp-weixin/common/main.wxss | 24 ++ unpackage/dist/dev/mp-weixin/common/vendor.js | 6 +- .../address-picker/address-picker.js | 4 +- .../lxc-count-style/lxc-count-style.js | 4 +- .../dev/mp-weixin/custom-tab-bar/index.js | 250 ++++++++++++++ .../dev/mp-weixin/custom-tab-bar/index.json | 3 + .../dev/mp-weixin/custom-tab-bar/index.wxml | 15 + .../dev/mp-weixin/custom-tab-bar/index.wxss | 47 +++ .../mp-weixin/pageOne/indexs/allEvaluate.js | 2 +- .../dev/mp-weixin/pageOne/indexs/confirm.js | 2 +- .../dev/mp-weixin/pageOne/indexs/detail.js | 2 +- .../dev/mp-weixin/pageOne/indexs/notDetail.js | 2 +- .../dev/mp-weixin/pageOne/indexs/notList.js | 2 +- .../dev/mp-weixin/pageOne/indexs/search.js | 2 +- .../dev/mp-weixin/pageOne/indexs/shopList.js | 2 +- .../dist/dev/mp-weixin/pageOne/mes/aaa.js | 2 +- .../dist/dev/mp-weixin/pageOne/mes/addEdit.js | 2 +- .../dist/dev/mp-weixin/pageOne/mes/addNew.js | 2 +- .../dist/dev/mp-weixin/pageOne/mes/address.js | 2 +- .../dev/mp-weixin/pageOne/mes/agreement.js | 2 +- .../dev/mp-weixin/pageOne/mes/collection.js | 2 +- .../dev/mp-weixin/pageOne/mes/evaluate.js | 2 +- .../dev/mp-weixin/pageOne/mes/information.js | 2 +- .../dev/mp-weixin/pageOne/mes/invitation.js | 2 +- .../dev/mp-weixin/pageOne/mes/myPoints.js | 2 +- .../dev/mp-weixin/pageOne/mes/orderDetail.js | 2 +- .../dev/mp-weixin/pageOne/mes/orderList.js | 2 +- .../dist/dev/mp-weixin/pageOne/mes/proRank.js | 2 +- .../mp-weixin/pageOne/mes/proStatistics.js | 2 +- .../dev/mp-weixin/pageOne/mes/promotion.js | 2 +- .../dev/mp-weixin/pageOne/mes/saleRank.js | 2 +- .../dist/dev/mp-weixin/pageOne/mes/service.js | 2 +- .../dist/dev/mp-weixin/pageOne/mes/setUp.js | 2 +- .../dev/mp-weixin/pageOne/mes/subsidyCom.js | 2 +- .../dev/mp-weixin/pageOne/mes/subsidyDay.js | 2 +- .../dev/mp-weixin/pageOne/mes/subsidyLoop.js | 2 +- .../dev/mp-weixin/pageOne/mes/subsidyShare.js | 2 +- .../dev/mp-weixin/pageOne/mes/withdraw.js | 2 +- .../dist/dev/mp-weixin/pageOne/shopConfirm.js | 2 +- .../dist/dev/mp-weixin/pages/h5/bridge.js | 2 + .../dist/dev/mp-weixin/pages/h5/bridge.json | 5 + .../dist/dev/mp-weixin/pages/h5/bridge.wxml | 1 + .../dist/dev/mp-weixin/pages/h5/bridge.wxss | 6 + .../dist/dev/mp-weixin/pages/login/login.js | 2 +- .../dist/dev/mp-weixin/pages/tabbar/index.js | 2 +- .../dev/mp-weixin/pages/tabbar/index.wxml | 2 +- .../dev/mp-weixin/pages/tabbar/index.wxss | 2 +- .../dist/dev/mp-weixin/pages/tabbar/me.js | 2 +- .../dist/dev/mp-weixin/pages/tabbar/me.wxml | 2 +- .../dist/dev/mp-weixin/pages/tabbar/me.wxss | 2 +- .../dist/dev/mp-weixin/pages/tabbar/shop.js | 2 +- .../dist/dev/mp-weixin/pages/tabbar/shop.wxml | 2 +- .../dist/dev/mp-weixin/pages/tabbar/sort.js | 2 +- .../dist/dev/mp-weixin/pages/tabbar/sort.wxml | 2 +- .../components/uni-icons/uni-icons.js | 4 +- .../components/uni-nav-bar/uni-nav-bar.js | 4 +- .../components/uni-nav-bar/uni-status-bar.js | 4 +- .../components/uni-popup/uni-popup.js | 4 +- .../uni-rate/components/uni-rate/uni-rate.js | 4 +- .../uni-transition/uni-transition.js | 4 +- .../uview-ui/components/u-parse/libs/trees.js | 4 +- .../uview-ui/components/u-parse/u-parse.js | 4 +- 85 files changed, 1358 insertions(+), 421 deletions(-) create mode 100644 custom-tab-bar/index.js create mode 100644 custom-tab-bar/index.json create mode 100644 custom-tab-bar/index.wxml create mode 100644 custom-tab-bar/index.wxss create mode 100644 pages/h5/bridge.vue create mode 100644 unpackage/dist/dev/.sourcemap/mp-weixin/pages/h5/bridge.js.map create mode 100644 unpackage/dist/dev/mp-weixin/custom-tab-bar/index.js create mode 100644 unpackage/dist/dev/mp-weixin/custom-tab-bar/index.json create mode 100644 unpackage/dist/dev/mp-weixin/custom-tab-bar/index.wxml create mode 100644 unpackage/dist/dev/mp-weixin/custom-tab-bar/index.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/h5/bridge.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/h5/bridge.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/h5/bridge.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/h5/bridge.wxss diff --git a/common/style_scss.scss b/common/style_scss.scss index e1572d5..b5b8c31 100644 --- a/common/style_scss.scss +++ b/common/style_scss.scss @@ -309,17 +309,51 @@ image { letter-spacing: $i + rpx; } } -/*苹果底部选项栏适配*/ -.nav_bottom { - box-sizing: content-box; - padding-bottom: constant(safe-area-inset-bottom);//兼容 IOS<11.2 - padding-bottom: env(safe-area-inset-bottom);//兼容 IOS>11.2 -} - -/* 特殊处理 */ -.tline { - text-decoration: line-through; - /* 加删除线 */ +/*苹果底部选项栏适配*/ +.nav_bottom { + box-sizing: content-box; + padding-bottom: constant(safe-area-inset-bottom);//兼容 IOS<11.2 + padding-bottom: env(safe-area-inset-bottom);//兼容 IOS>11.2 +} + +$custom-tabbar-height: 100rpx; +$custom-tabbar-page-gap: 120rpx; +$custom-tabbar-action-gap: 240rpx; +$custom-tabbar-scroll-offset: 320rpx; + +.tabbar-page { + min-height: 100vh; + box-sizing: border-box; +} + +.tabbar-page-padding { + padding-bottom: $custom-tabbar-page-gap; + padding-bottom: calc(#{$custom-tabbar-page-gap} + constant(safe-area-inset-bottom)); + padding-bottom: calc(#{$custom-tabbar-page-gap} + env(safe-area-inset-bottom)); +} + +.tabbar-page-padding-action { + padding-bottom: $custom-tabbar-action-gap; + padding-bottom: calc(#{$custom-tabbar-action-gap} + constant(safe-area-inset-bottom)); + padding-bottom: calc(#{$custom-tabbar-action-gap} + env(safe-area-inset-bottom)); +} + +.tabbar-fixed-above-tabbar { + bottom: $custom-tabbar-height; + bottom: calc(#{$custom-tabbar-height} + constant(safe-area-inset-bottom)); + bottom: calc(#{$custom-tabbar-height} + env(safe-area-inset-bottom)); +} + +.tabbar-scroll-area { + height: calc(100vh - #{$custom-tabbar-scroll-offset}); + height: calc(100vh - #{$custom-tabbar-scroll-offset} - constant(safe-area-inset-bottom)); + height: calc(100vh - #{$custom-tabbar-scroll-offset} - env(safe-area-inset-bottom)); +} + +/* 特殊处理 */ +.tline { + text-decoration: line-through; + /* 加删除线 */ } /* 多少行(3~15) */ .one_overflow{ diff --git a/common/tools.js b/common/tools.js index 0a769a0..d5989ea 100644 --- a/common/tools.js +++ b/common/tools.js @@ -19,11 +19,48 @@ var tools = { }) } }, + isPromotionUnlockedValue: function(value) { + return value === true || value === 'true' || value === 1 || value === '1' + }, + getPromotionUnlocked: function() { + return this.isPromotionUnlockedValue(uni.getStorageSync('promotionUnlocked')) + }, + setPromotionUnlocked: function(value = true) { + if (this.isPromotionUnlockedValue(value)) { + uni.setStorageSync('promotionUnlocked', true) + return true + } + uni.removeStorageSync('promotionUnlocked') + return false + }, + setPromotionBridgeSkip: function(path) { + if (!path) { + return + } + uni.setStorageSync('promotionBridgeSkipPath', path) + }, + setTabbarSelectedPath: function(path) { + if (!path) { + return + } + uni.setStorageSync('tabbarSelectedPath', path) + }, + getTabbarSelectedPath: function() { + return uni.getStorageSync('tabbarSelectedPath') || '' + }, + consumePromotionBridgeSkip: function(path) { + const skipPath = uni.getStorageSync('promotionBridgeSkipPath') + if (skipPath && skipPath === path) { + uni.removeStorageSync('promotionBridgeSkipPath') + return true + } + return false + }, clearLoginStorage: function() { - const promotionUnlocked = uni.getStorageSync('promotionUnlocked') + const promotionUnlocked = this.getPromotionUnlocked() uni.clearStorageSync() if (promotionUnlocked) { - uni.setStorageSync('promotionUnlocked', promotionUnlocked) + this.setPromotionUnlocked(true) } }, //图片地址拼接 diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js new file mode 100644 index 0000000..53df352 --- /dev/null +++ b/custom-tab-bar/index.js @@ -0,0 +1,250 @@ +const defaultList = [ + { + pagePath: '/pages/tabbar/index', + iconPath: '/static/images/icon_sy.png', + selectedIconPath: '/static/images/icon_syf.png', + text: '首页' + }, + { + pagePath: '/pages/tabbar/sort', + iconPath: '/static/images/icon_fl.png', + selectedIconPath: '/static/images/icon_flf.png', + text: '分类' + }, + { + pagePath: '/pages/tabbar/shop', + iconPath: '/static/images/icon_gwc.png', + selectedIconPath: '/static/images/icon_gwcf.png', + text: '购物车' + }, + { + pagePath: '/pages/tabbar/me', + iconPath: '/static/images/icon_wd.png', + selectedIconPath: '/static/images/icon_wdf.png', + text: '我的' + } +] + +const promotionList = [ + { + pagePath: '/pages/tabbar/index', + iconPath: '/static/images/icon_sy.png', + selectedIconPath: '/static/images/icon_syf.png', + text: '首页', + h5Url: 'https://point.agrimedia.cn/affiliate-activity/pages/index/index' + }, + { + pagePath: '/pages/tabbar/shop', + iconPath: '/static/images/icon_gwc.png', + selectedIconPath: '/static/images/icon_gwcf.png', + text: '榜单', + h5Url: 'https://point.agrimedia.cn/affiliate-activity/pages/rank/rank' + }, + { + pagePath: '/pages/tabbar/sort', + iconPath: '/static/images/icon_fl.png', + selectedIconPath: '/static/images/icon_flf.png', + text: '分类', + h5Url: 'https://point.agrimedia.cn/affiliate-activity/pages/classify/classify' + }, + { + pagePath: '/pages/tabbar/me', + iconPath: '/static/images/icon_wd.png', + selectedIconPath: '/static/images/icon_wdf.png', + text: '我的' + } +] + +function isPromotionUnlockedValue(value) { + return value === true || value === 'true' || value === 1 || value === '1' +} + +function normalizePagePath(path) { + if (!path) { + return '' + } + return path.charAt(0) === '/' ? path : `/${path}` +} + +function isTabbarUnlocked() { + return isPromotionUnlockedValue(wx.getStorageSync('promotionUnlocked')) +} + +function getTabList(isPromotionUnlocked) { + return isPromotionUnlocked ? defaultList : promotionList +} + +function isKnownTabPath(path) { + if (!path) { + return false + } + return defaultList.some(item => item.pagePath === path) || promotionList.some(item => item.pagePath === path) +} + +function setTabbarSelectedPath(path) { + if (!path) { + return + } + wx.setStorageSync('tabbarSelectedPath', path) +} + +function getStoredTabbarSelectedPath() { + return wx.getStorageSync('tabbarSelectedPath') || '' +} + +function getCurrentStackPagePath() { + const pages = getCurrentPages() + const currentPage = pages[pages.length - 1] + if (currentPage && currentPage.route) { + return normalizePagePath(currentPage.route) + } + return '' +} + +function getCurrentTabBarInstance() { + const pages = getCurrentPages() + const currentPage = pages[pages.length - 1] + if (!currentPage || typeof currentPage.getTabBar !== 'function') { + return null + } + return currentPage.getTabBar() +} + +function syncCurrentTabBar(selectedPath = '') { + const tabBar = getCurrentTabBarInstance() + if (tabBar && typeof tabBar.syncPromotionStatus === 'function') { + tabBar.syncPromotionStatus(selectedPath || getCurrentStackPagePath()) + } +} + +let routeListenerRegistered = false + +Component({ + data: { + selected: '/pages/tabbar/index', + list: defaultList, + isPromotionUnlocked: false, + isIphoneX: false + }, + lifetimes: { + attached() { + this.registerRouteListener() + this.syncPromotionStatus(this.getCurrentPagePath()) + this.syncSafeArea() + } + }, + pageLifetimes: { + show() { + this.syncPromotionStatus(this.getCurrentPagePath()) + } + }, + methods: { + registerRouteListener() { + if (routeListenerRegistered || typeof wx.onAppRoute !== 'function') { + return + } + routeListenerRegistered = true + wx.onAppRoute((res) => { + const path = normalizePagePath(res && res.path ? res.path : '') + if (!isKnownTabPath(path)) { + return + } + setTabbarSelectedPath(path) + syncCurrentTabBar(path) + }) + }, + getCurrentPagePath() { + const currentPath = getCurrentStackPagePath() + if (isKnownTabPath(currentPath)) { + return currentPath + } + const storedPath = getStoredTabbarSelectedPath() + if (isKnownTabPath(storedPath)) { + return storedPath + } + return '' + }, + syncSafeArea() { + const systemInfo = wx.getSystemInfoSync() + const safeArea = systemInfo.safeArea || {} + const isIphoneX = !!safeArea.bottom && safeArea.bottom < systemInfo.screenHeight + this.setData({ isIphoneX }) + }, + syncPromotionStatus(selectedPath = '') { + const isPromotionUnlocked = isTabbarUnlocked() + const list = getTabList(isPromotionUnlocked) + const currentPath = this.getCurrentPagePath() + let nextSelected = selectedPath || currentPath || this.data.selected + const selectedExists = list.some(item => item.pagePath === nextSelected) + if (!selectedExists) { + const currentSelectedExists = list.some(item => item.pagePath === currentPath) + if (currentSelectedExists) { + nextSelected = currentPath + } else { + const storedPath = getStoredTabbarSelectedPath() + const storedSelectedExists = list.some(item => item.pagePath === storedPath) + nextSelected = storedSelectedExists ? storedPath : (list[0] ? list[0].pagePath : '') + } + } + const nextData = { + isPromotionUnlocked, + list, + selected: nextSelected + } + if ( + this.data.isPromotionUnlocked !== isPromotionUnlocked || + this.data.list !== list || + this.data.selected !== nextSelected + ) { + this.setData({ + ...nextData + }) + } + return nextData + }, + setSelectedByPath(path) { + const currentPath = path || '' + const exists = this.data.list.some(item => item.pagePath === currentPath) + if (exists && this.data.selected !== currentPath) { + this.setData({ selected: currentPath }) + } + }, + switchTab(e) { + const isPromotionUnlocked = isTabbarUnlocked() + const { index, pagePath } = e.currentTarget.dataset + const currentList = getTabList(isPromotionUnlocked) + let item = null + let selectedPath = '' + if (pagePath) { + selectedPath = pagePath + item = currentList.find(tab => tab.pagePath === pagePath) || null + } + if (!item && typeof index !== 'undefined') { + const currentIndex = Number(index) + item = currentList[currentIndex] + selectedPath = item ? item.pagePath : '' + } + if (!item) { + return + } + if (!isPromotionUnlocked && item.h5Url) { + const pages = getCurrentPages() + const currentPage = pages[pages.length - 1] + const from = currentPage && currentPage.route ? `/${currentPage.route}` : '' + wx.navigateTo({ + url: `/pages/h5/bridge?url=${encodeURIComponent(item.h5Url)}&from=${encodeURIComponent(from)}` + }) + return + } + setTabbarSelectedPath(item.pagePath) + this.setData({ + selected: selectedPath, + isPromotionUnlocked, + list: currentList + }) + wx.switchTab({ + url: item.pagePath + }) + } + } +}) diff --git a/custom-tab-bar/index.json b/custom-tab-bar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/custom-tab-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/custom-tab-bar/index.wxml b/custom-tab-bar/index.wxml new file mode 100644 index 0000000..e0e0e79 --- /dev/null +++ b/custom-tab-bar/index.wxml @@ -0,0 +1,15 @@ + + + + + {{item.text}} + + + diff --git a/custom-tab-bar/index.wxss b/custom-tab-bar/index.wxss new file mode 100644 index 0000000..7029e61 --- /dev/null +++ b/custom-tab-bar/index.wxss @@ -0,0 +1,47 @@ +.tabbar { + position: fixed; + left: 0; + right: 0; + bottom: 0; + z-index: 999; + background: #ffffff; + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.04); +} + +.tabbar-safe { + padding-bottom: env(safe-area-inset-bottom); +} + +.tabbar__inner { + display: flex; + align-items: center; + justify-content: space-around; + min-height: 100rpx; + border-top: 1rpx solid #f2f2f2; +} + +.tabbar__item { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 10rpx 0 8rpx; +} + +.tabbar__icon { + width: 46rpx; + height: 46rpx; + margin-bottom: 6rpx; +} + +.tabbar__text { + font-size: 22rpx; + line-height: 1.2; + color: #666666; +} + +.tabbar__text--active { + color: #ee4237; + font-weight: 600; +} diff --git a/pageOne/mes/setUp.vue b/pageOne/mes/setUp.vue index 1d74a1f..e433754 100644 --- a/pageOne/mes/setUp.vue +++ b/pageOne/mes/setUp.vue @@ -44,7 +44,7 @@ }, methods: { syncPromotionStatus() { - this.promotionUnlocked = !!uni.getStorageSync('promotionUnlocked') + this.promotionUnlocked = this.$tools.getPromotionUnlocked() }, handlePromotion() { if (this.promotionUnlocked) { @@ -56,7 +56,7 @@ if (remainCount > 0) { return } - uni.setStorageSync('promotionUnlocked', true) + this.$tools.setPromotionUnlocked(true) this.promotionUnlocked = true this.promotionTapCount = 0 uni.$emit('promotionUnlocked') diff --git a/pages.json b/pages.json index 68c0169..0d53483 100644 --- a/pages.json +++ b/pages.json @@ -27,14 +27,21 @@ "navigationStyle": "custom" } }, - { - "path": "pages/tabbar/shop", - "style": { - "navigationBarTitleText": "", - "navigationStyle": "custom" - } - } - ], + { + "path": "pages/tabbar/shop", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "pages/h5/bridge", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "default" + } + } + ], "subPackages": [{ "root": "pageOne", "pages": [ @@ -264,10 +271,11 @@ "navigationBarBackgroundColor": "#F8F8F8", "backgroundColor": "#FFFFFF" }, - "tabBar": { - "color": "#666", - "selectedColor": "#ee4237", - "backgroundColor": "#FFFFFF", + "tabBar": { + "custom": true, + "color": "#666", + "selectedColor": "#ee4237", + "backgroundColor": "#FFFFFF", "list": [{ "pagePath": "pages/tabbar/index", "iconPath": "/static/images/icon_sy.png", @@ -290,4 +298,4 @@ "text": "我的" }] } -} \ No newline at end of file +} diff --git a/pages/h5/bridge.vue b/pages/h5/bridge.vue new file mode 100644 index 0000000..68b0353 --- /dev/null +++ b/pages/h5/bridge.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/pages/login/login.vue b/pages/login/login.vue index 47eefc8..363a09c 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -56,6 +56,7 @@ this.$tools.showtt(res.msg) if(res.code!=1) return uni.setStorageSync('token',res.data.userinfo.token) + uni.setStorageSync('uid',res.data.userinfo.id) setTimeout(() => { this.$tools.goSwitchTab('/pages/tabbar/index') },1000) diff --git a/pages/tabbar/index.vue b/pages/tabbar/index.vue index 46dce8d..8fef50a 100644 --- a/pages/tabbar/index.vue +++ b/pages/tabbar/index.vue @@ -1,113 +1,157 @@ - - - - - + + + + + diff --git a/pages/tabbar/me.vue b/pages/tabbar/me.vue index 1336942..ffa2323 100644 --- a/pages/tabbar/me.vue +++ b/pages/tabbar/me.vue @@ -1,6 +1,6 @@