From c8c3f384040bad0044dcabf72e162e35b5786afa Mon Sep 17 00:00:00 2001 From: tanghaolin <1723298894@qq.com> Date: 星期二, 08 十一月 2022 17:38:10 +0800 Subject: [PATCH] 修改系统tabbar为自定义tabbar --- custom-tab-bar/index.wxss | 38 +++++++++ custom-tab-bar/index.wxml | 8 ++ login/login/index.js | 19 ---- map/index.js | 10 ++ custom-tab-bar/index.js | 47 +++++++++++ utils/constant.js | 4 map/index.wxml | 4 station/list/index.js | 8 ++ app.json | 4 map/index.wxss | 15 +++ mine/index/index.js | 6 + workDesktop/index/index.js | 9 ++ monitor/station/index.js | 6 + custom-tab-bar/index.json | 3 14 files changed, 153 insertions(+), 28 deletions(-) diff --git a/app.json b/app.json index 940f79b..509add4 100644 --- a/app.json +++ b/app.json @@ -52,7 +52,8 @@ "reportForm/index/index", "reportForm/Detail/index", "video/station/index", - "video/single/index" + "video/single/index", + "corpIndex/szjt/index" ], "window": { "backgroundTextStyle": "light", @@ -70,6 +71,7 @@ "location" ], "tabBar": { + "custom": true, "color": "#8E9397", "selectedColor": "#16b5cb", "backgroundColor": "#ffffff", diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js new file mode 100644 index 0000000..3fb4c4a --- /dev/null +++ b/custom-tab-bar/index.js @@ -0,0 +1,47 @@ +Component({ + data: { + selected: 1, + color: "#8E9397", + selectedColor: "#16b5cb", + list: [ + { + pagePath: "/station/list/index", + text: "鍒楄〃", + iconPath: "/images/tabbar/minitorUnActive.png", + selectedIconPath: "/images/tabbar/minitorActive.png" + }, + { + pagePath: "/workDesktop/index/index", + text: "宸ヤ綔", + iconPath: "/images/tabbar/workDesktopUnActive.png", + selectedIconPath: "/images/tabbar/workDesktopActive.png" + }, + { + pagePath: "/map/index", + text: "鍦板浘", + iconPath: "/images/tabbar/mapUnActive.png", + selectedIconPath: "/images/tabbar/mapActive.png" + }, + { + pagePath: "/mine/index/index", + text: "鎴戠殑", + iconPath: "/images/tabbar/mineUnActive.png", + selectedIconPath: "/images/tabbar/mineActive.png" + } + ] + }, + attached() { + }, + methods: { + switchTab(e) { + console.log(e,37) + const data = e.currentTarget.dataset + const url = data.path + this.setData({ + selected: data.index + }) + console.log(this.data.selected,43) + wx.switchTab({url}) + } + } +}) \ No newline at end of file diff --git a/custom-tab-bar/index.json b/custom-tab-bar/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/custom-tab-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/custom-tab-bar/index.wxml b/custom-tab-bar/index.wxml new file mode 100644 index 0000000..29d1b9e --- /dev/null +++ b/custom-tab-bar/index.wxml @@ -0,0 +1,8 @@ +<!--miniprogram/custom-tab-bar/index.wxml--> +<cover-view class="tab-bar"> + <cover-view class="tab-bar-border"></cover-view> + <cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab"> + <cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image> + <cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view> + </cover-view> +</cover-view> diff --git a/custom-tab-bar/index.wxss b/custom-tab-bar/index.wxss new file mode 100644 index 0000000..bb3196d --- /dev/null +++ b/custom-tab-bar/index.wxss @@ -0,0 +1,38 @@ +.tab-bar { + position: fixed; + bottom: 0; + left: 0; + right: 0; + height: 96rpx; + background: white; + display: flex; + padding-bottom: env(safe-area-inset-bottom); +} + +.tab-bar-border { + background-color: rgba(0, 0, 0, 0.33); + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 1px; + transform: scaleY(0.5); +} + +.tab-bar-item { + flex: 1; + text-align: center; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; +} + +.tab-bar-item cover-image { + width: 54rpx; + height: 54rpx; +} + +.tab-bar-item cover-view { + font-size: 20rpx; +} diff --git a/login/login/index.js b/login/login/index.js index 198118a..ce54f87 100644 --- a/login/login/index.js +++ b/login/login/index.js @@ -216,25 +216,6 @@ wx.switchTab({ url: '../../workDesktop/index/index', }) - - // var pages = getCurrentPages(); - // if (pages.length >= 2) { - // //var currPage = pages[pages.length - 1]; //褰撳墠椤甸潰 - // var prevPage = pages[pages.length - 2]; //杩斿洖涓婁竴涓〉闈� - // //console.log(prevPage.route) - // if (prevPage) { - // var fn = prevPage.refreshUserInfo; - // if (typeof fn == "function") - // fn(); - // wx.navigateBack(); - // } else { - // wx.navigateTo({ - // url: "/workDestop/index/index" - // }); - // } - // } else { - // wx.navigateBack(); - // } }, //鐐瑰嚮鐪熷疄鐢ㄦ埛鐧诲綍鎸夐挳 tapBindUserReal: function (e) { diff --git a/map/index.js b/map/index.js index e7d49a5..cf77df7 100644 --- a/map/index.js +++ b/map/index.js @@ -90,8 +90,6 @@ ] }, onLoad: function (options) { - // console.log(wx.getSystemInfoSync()) - // console.log(wx.getSystemInfoSync().windowHeight * 0.2 * -1 - 10) var userInfo = app.globalData.userInfo; // console.log(userInfo) if (userInfo) { @@ -111,6 +109,14 @@ // this.getRepairFormList(); }, onReady: function () {}, + onShow(){ + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 2 + }) + } + }, //灞曠ず鎵�鏈塵arker鏍囩偣鐨勮閲� setIncludePoints() { var MapContext = wx.createMapContext('detailMap'); diff --git a/map/index.wxml b/map/index.wxml index 2c0309d..ecc8f5e 100644 --- a/map/index.wxml +++ b/map/index.wxml @@ -66,7 +66,7 @@ <view wx:else="{{markerTipInfo.markerInfo.Records.length==0}}" class="zanWuShuju"> 鏆傛棤鐩戞帶鏁版嵁 </view> - <view wx:if="{{link_box}}" class="block_list_url"> + <view wx:if="{{link_box}}" class="block_list_url" > <view bindtap="tapOpenStationMonitorPageInList" data-stationid="{{markerTipInfo.markerInfo.ObjectID}}" data-stationname="{{markerTipInfo.markerInfo.ObjectName}}"> <icon class="iconfont icon-jiankong"></icon> <span style="padding-left:10px;padding-right:10px;">鐩戞帶</span> @@ -265,7 +265,7 @@ </movable-view> </movable-area> --> - <view class="drawerBox" style="bottom:{{drawerMenuMoveData.bottom}}rpx" bindtouchstart="drawerTouchStart" + <view wx:if="{{false}}" class="drawerBox" style="bottom:{{drawerMenuMoveData.bottom}}rpx" bindtouchstart="drawerTouchStart" bindtouchend="drawerTouchEnd" bindtouchmove="drawerTouchMove"> <view class="cu-card case no-card shadow drawerBody" style="height:{{drawerMenuMoveData.height}}rpx;"> <view style="width: 100%;display: flex;justify-content: center;align-items: center;"> diff --git a/map/index.wxss b/map/index.wxss index 4e26a33..64c176b 100644 --- a/map/index.wxss +++ b/map/index.wxss @@ -714,5 +714,20 @@ top: 0; width: 100%; opacity: 0.5; +} +.cu-modal.bottom-modal.show { + margin-bottom: 155rpx; +} +.cu-modal.bottom-modal { + margin-bottom: -1000rpx; +} +.cu-modal.show { + opacity: 1; + transition-duration: 0.3s; + -ms-transform: scale(1); + transform: scale(1); + overflow-x: hidden; + overflow-y: auto; + pointer-events: auto; } \ No newline at end of file diff --git a/mine/index/index.js b/mine/index/index.js index 968e7c4..07b7aed 100644 --- a/mine/index/index.js +++ b/mine/index/index.js @@ -29,6 +29,12 @@ userInfo: userInfo }); } + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 3 + }) + } }, openSetting: function () { wx.openSetting({ diff --git a/monitor/station/index.js b/monitor/station/index.js index 2f2a0ec..0474078 100644 --- a/monitor/station/index.js +++ b/monitor/station/index.js @@ -284,6 +284,9 @@ }, //鑾峰彇娉电珯杩愯鏃堕棿 getWorkTime: function () { + wx.showLoading({ + title: '姝e湪鑾峰彇寮�鏈烘椂闂�', + }) var that = this; var machineList = this.data.machineList; var userInfo = app.globalData.userInfo; @@ -299,7 +302,8 @@ 'content-type': 'application/json' }, success(res) { - // console.log(res,306) + wx.hideLoading() + console.log(res,306) var result = res.data if (result.Code != 0) { return; diff --git a/station/list/index.js b/station/list/index.js index 637d72c..ae73f00 100644 --- a/station/list/index.js +++ b/station/list/index.js @@ -46,6 +46,14 @@ this.initialStationTree(); return; }, + onShow(){ + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 0 + }) + } + }, onShareAppMessage: function () { return Constant.Share; }, diff --git a/utils/constant.js b/utils/constant.js index cead408..733a747 100644 --- a/utils/constant.js +++ b/utils/constant.js @@ -28,8 +28,8 @@ Login: { DemoUserID: 11, DemoEmployeeID: 11, - LogoUrl: "http://demo.beng35.com/assets/miniProgram/LoginLogo.png", - BackgroupImageUrl: "http://demo.beng35.com/assets/miniProgram/LoginBackground.png" + LogoUrl: "http://demo.beng35.com/assets/miniProgram/LoginLogo.png?v=11", + BackgroupImageUrl: "http://demo.beng35.com/assets/miniProgram/LoginBackground.png?v=22" } }, } \ No newline at end of file diff --git a/workDesktop/index/index.js b/workDesktop/index/index.js index 8975244..97328c2 100644 --- a/workDesktop/index/index.js +++ b/workDesktop/index/index.js @@ -173,7 +173,14 @@ onShareAppMessage: function () { return Constant.Share; }, - onShow: function () {}, + onShow: function () { + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 1 + }) + } + }, onReady: function () {}, onHide: function () {} }) \ No newline at end of file -- Gitblit v1.9.3