@@ -72,7 +72,10 @@ var config = { | |||||
// 升级公告更新阅读 | // 升级公告更新阅读 | ||||
updateRead: `${host}/zkMessage/updateFlag`, | updateRead: `${host}/zkMessage/updateFlag`, | ||||
// 隐私协议 | // 隐私协议 | ||||
privacyAgr: `${host}/zkPrivate/findById` | |||||
privacyAgr: `${host}/zkPrivate/findById`, | |||||
//首页更新弹框 | |||||
updatePopup: `${host}/zkMessage/showMessage`, | |||||
} | } | ||||
}; | }; | ||||
module.exports = config; | module.exports = config; |
@@ -551,28 +551,28 @@ | |||||
"selectedColor": "#1296db", | "selectedColor": "#1296db", | ||||
"borderStyle": "white", | "borderStyle": "white", | ||||
"list": [{ | "list": [{ | ||||
"pagePath": "pages/index/index", | |||||
"iconPath": "/static/images/tabBar/home.png", | |||||
"selectedIconPath": "/static/images/tabBar/homeActive.png", | |||||
"text": "首页" | |||||
"pagePath": "pages/index/index" | |||||
// "iconPath": "/static/images/tabBar/home.png", | |||||
// "selectedIconPath": "/static/images/tabBar/homeActive.png", | |||||
// "text": "首页" | |||||
}, | }, | ||||
{ | { | ||||
"pagePath": "pages/index/customer", | |||||
"iconPath": "/static/images/tabBar/customer.png", | |||||
"selectedIconPath": "/static/images/tabBar/customerActive.png", | |||||
"text": "接待" | |||||
"pagePath": "pages/index/customer" | |||||
// "iconPath": "/static/images/tabBar/customer.png", | |||||
// "selectedIconPath": "/static/images/tabBar/customerActive.png", | |||||
// "text": "接待" | |||||
}, | }, | ||||
{ | { | ||||
"pagePath": "pages/index/learning", | |||||
"iconPath": "/static/images/tabBar/voice.png", | |||||
"selectedIconPath": "/static/images/tabBar/voiceActive.png", | |||||
"text": "学习" | |||||
"pagePath": "pages/index/learning" | |||||
// "iconPath": "/static/images/tabBar/voice.png", | |||||
// "selectedIconPath": "/static/images/tabBar/voiceActive.png", | |||||
// "text": "学习" | |||||
}, | }, | ||||
{ | { | ||||
"pagePath": "pages/index/personal", | |||||
"iconPath": "/static/images/tabBar/user.png", | |||||
"selectedIconPath": "/static/images/tabBar/userActive.png", | |||||
"text": "个人" | |||||
"pagePath": "pages/index/personal" | |||||
// "iconPath": "/static/images/tabBar/user.png", | |||||
// "selectedIconPath": "/static/images/tabBar/userActive.png", | |||||
// "text": "个人" | |||||
} | } | ||||
] | ] | ||||
}, | }, | ||||
@@ -61,13 +61,19 @@ | |||||
src="/static/images/add.png" mode=""></image> | src="/static/images/add.png" mode=""></image> | ||||
<image class="add2" @click="reshCustom()" src="https://static.quhouse.com/zhikong_xcx_img/refresh.png" mode=""> | <image class="add2" @click="reshCustom()" src="https://static.quhouse.com/zhikong_xcx_img/refresh.png" mode=""> | ||||
</image> | </image> | ||||
<u-tabbar activeColor="#1296db" inactiveColor="#999999" v-model="current" :list="tabbarList"></u-tabbar> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
var util = require("../../utils/util.js"); | |||||
var config = require("../../config"); | |||||
import tabbarList from '@/utils/tabbar.js' | |||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
tabbarList:tabbarList, | |||||
current: 0, | |||||
buildingID: '', | buildingID: '', | ||||
waitCustomList: [], | waitCustomList: [], | ||||
isAdd: '', | isAdd: '', | ||||
@@ -87,8 +93,26 @@ | |||||
this.dataCode = dataCode; | this.dataCode = dataCode; | ||||
this.init() | this.init() | ||||
this.queryHaveDept() | this.queryHaveDept() | ||||
this.updateInit() | |||||
}, | }, | ||||
methods: { | methods: { | ||||
updateInit() { | |||||
uni.request({ | |||||
url: config.service.updateList, | |||||
method: "GET", | |||||
data: { | |||||
id: uni.getStorageSync('weapp_session_userInfo_data').accountId | |||||
}, | |||||
header: { | |||||
'content-type': 'application/json', | |||||
'Access-Token': uni.getStorageSync('weapp_session_login_data').token | |||||
}, | |||||
success: (res) => { | |||||
this.count = res.data.data.count | |||||
this.tabbarList[3].count = res.data.data.count | |||||
} | |||||
}) | |||||
}, | |||||
reshCustom() { | reshCustom() { | ||||
this.init() | this.init() | ||||
}, | }, | ||||
@@ -396,7 +420,7 @@ | |||||
width: 90upx; | width: 90upx; | ||||
height: 90upx; | height: 90upx; | ||||
position: fixed; | position: fixed; | ||||
bottom: 180upx; | |||||
bottom:275upx; | |||||
right: 44upx; | right: 44upx; | ||||
} | } | ||||
@@ -404,7 +428,7 @@ | |||||
width: 90upx; | width: 90upx; | ||||
height: 90upx; | height: 90upx; | ||||
position: fixed; | position: fixed; | ||||
bottom: 60upx; | |||||
bottom: 160upx; | |||||
right: 44upx; | right: 44upx; | ||||
} | } | ||||
</style> | </style> |
@@ -216,14 +216,40 @@ | |||||
@cancel="cancel" @confirm="confirm"></u-select> | @cancel="cancel" @confirm="confirm"></u-select> | ||||
</view> | </view> | ||||
<u-calendar v-model="totalTimeShow" mode="range" @change="totalTimeChange"></u-calendar> | <u-calendar v-model="totalTimeShow" mode="range" @change="totalTimeChange"></u-calendar> | ||||
<u-tabbar activeColor="#1296db" inactiveColor="#999999" v-model="current" :list="tabbarList"></u-tabbar> | |||||
<view class="update" v-if="isShowUpdate"> | |||||
<view class="updateBox"> | |||||
<view class="top"> | |||||
<image src="../../static/images/updateIcon.png"></image> | |||||
</view> | |||||
<view class="content"> | |||||
<view class="tit">{{tit}}</view> | |||||
<u-parse class="ql-editor" :content="content" @preview="preview" @navigate="navigate"/> | |||||
<!-- <rich-text :nodes="content"></rich-text> --> | |||||
</view> | |||||
<view class="btn" @click="lookDetail">查看详情</view> | |||||
<view class="close" @click="close"> | |||||
<u-icon name="close-circle" size="80" color="#FFFFFF"></u-icon> | |||||
</view> | |||||
</view> | |||||
</view> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
var config = require("../../config"); | var config = require("../../config"); | ||||
var util = require("../../utils/util.js"); | |||||
import tabbarList from '@/utils/tabbar.js' | |||||
import uParse from '../../components/gaoyia-parse/parse.vue' | |||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
id:"", | |||||
isShowUpdate:false, | |||||
tit:"", | |||||
content:"", | |||||
tabbarList:tabbarList, | |||||
current: 0, | |||||
userInfo: {}, | userInfo: {}, | ||||
Showhiddenunits: false, | Showhiddenunits: false, | ||||
lpanlist: [], //项目列表 | lpanlist: [], //项目列表 | ||||
@@ -269,7 +295,9 @@ | |||||
statDateEnd:'', | statDateEnd:'', | ||||
}; | }; | ||||
}, | }, | ||||
components: {}, | |||||
components: { | |||||
uParse | |||||
}, | |||||
onShow() { | onShow() { | ||||
this.getMenu() | this.getMenu() | ||||
@@ -305,6 +333,7 @@ | |||||
} | } | ||||
this.initworkThisWeek() | this.initworkThisWeek() | ||||
this.initrealTimeStatistics() | this.initrealTimeStatistics() | ||||
this.updateInit() | |||||
}, | }, | ||||
onPullDownRefresh() { | onPullDownRefresh() { | ||||
this.getMenu() | this.getMenu() | ||||
@@ -345,7 +374,71 @@ | |||||
uni.stopPullDownRefresh() | uni.stopPullDownRefresh() | ||||
}, 3000) | }, 3000) | ||||
}, | }, | ||||
onLoad() { | |||||
this.initPopup() | |||||
}, | |||||
methods: { | methods: { | ||||
close(){ | |||||
this.isShowUpdate = false; | |||||
}, | |||||
lookDetail(){ | |||||
let link = encodeURIComponent(JSON.stringify(this.content)) | |||||
uni.navigateTo({ | |||||
url: "../mine/messageDetail?content=" + link + "&id=" + this.id | |||||
}) | |||||
let data = { | |||||
id:this.id, | |||||
accountId:uni.getStorageSync('weapp_session_userInfo_data').accountId | |||||
} | |||||
uni.request({ | |||||
url: config.service.updateRead, | |||||
method: "GET", | |||||
header: { | |||||
'content-type': 'application/json', | |||||
'Access-Token': uni.getStorageSync('weapp_session_login_data').token | |||||
}, | |||||
data, | |||||
success: (res) => { | |||||
return; | |||||
} | |||||
}) | |||||
this.isShowUpdate = false; | |||||
}, | |||||
initPopup(){ | |||||
uni.request({ | |||||
url: config.service.updatePopup, | |||||
method: "GET", | |||||
header: { | |||||
'content-type': 'application/json', | |||||
'Access-Token': uni.getStorageSync('weapp_session_login_data').token | |||||
}, | |||||
success: (res) => { | |||||
this.content = res.data.data.content | |||||
this.tit = res.data.data.title | |||||
this.aid = res.data.data.accountId | |||||
this.id = res.data.data.id | |||||
this.isShowUpdate = res.data.data.readFlag==0?true:false | |||||
} | |||||
}) | |||||
}, | |||||
updateInit() { | |||||
uni.request({ | |||||
url: config.service.updateList, | |||||
method: "GET", | |||||
data: { | |||||
id: uni.getStorageSync('weapp_session_userInfo_data').accountId | |||||
}, | |||||
header: { | |||||
'content-type': 'application/json', | |||||
'Access-Token': uni.getStorageSync('weapp_session_login_data').token | |||||
}, | |||||
success: (res) => { | |||||
this.count = res.data.data.count | |||||
this.tabbarList[3].count = res.data.data.count | |||||
} | |||||
}) | |||||
}, | |||||
//获取权限 | //获取权限 | ||||
getMenu(){ | getMenu(){ | ||||
console.log("11111") | console.log("11111") | ||||
@@ -648,6 +741,64 @@ | |||||
</script> | </script> | ||||
<style lang="scss" scoped> | <style lang="scss" scoped> | ||||
.update{ | |||||
width: 100%; | |||||
height: 100%; | |||||
background: rgba(0, 0, 0, 0.5); | |||||
position: fixed; | |||||
top: 0; | |||||
left: 0; | |||||
bottom: 0; | |||||
right: 0; | |||||
z-index: 9999; | |||||
.updateBox{ | |||||
width: 80%; | |||||
background: #FFFFFF; | |||||
position: relative; | |||||
left: 50%; | |||||
margin-left: -40%; | |||||
padding: 20rpx; | |||||
border-radius: 10rpx; | |||||
top: 140rpx; | |||||
.top{ | |||||
width: 350rpx; | |||||
height: 220rpx; | |||||
margin: 0 auto; | |||||
image{ | |||||
width: 100%; | |||||
height: 100%; | |||||
} | |||||
} | |||||
.btn{ | |||||
width: 510rpx; | |||||
height: 88rpx; | |||||
background: #2671E2; | |||||
margin: 0 auto; | |||||
display: flex; | |||||
justify-content: center; | |||||
align-items: center; | |||||
font-size: 36rpx; | |||||
border-radius: 8rpx; | |||||
color: #FFFFFF; | |||||
} | |||||
.content{ | |||||
height: 268rpx; | |||||
overflow-y: auto; | |||||
margin: 46rpx 0; | |||||
} | |||||
.tit{ | |||||
font-size: 40rpx; | |||||
text-align: center; | |||||
font-weight: bold; | |||||
} | |||||
.close{ | |||||
position: absolute; | |||||
bottom: -100rpx; | |||||
left: 50%; | |||||
margin-left: -50rpx; | |||||
} | |||||
} | |||||
} | |||||
.activecllasscet{ | .activecllasscet{ | ||||
font-size: 28rpx; | font-size: 28rpx; | ||||
font-weight: 400; | font-weight: 400; | ||||
@@ -51,15 +51,19 @@ | |||||
</view> | </view> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
<u-tabbar activeColor="#1296db" inactiveColor="#999999" v-model="current" :list="tabbarList"></u-tabbar> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
var config = require("../../config"); | var config = require("../../config"); | ||||
var util = require("@/utils/util.js"); | var util = require("@/utils/util.js"); | ||||
import tabbarList from '@/utils/tabbar.js' | |||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
tabbarList:tabbarList, | |||||
current: 0, | |||||
tablist:[ | tablist:[ | ||||
{name:"全文"}, | {name:"全文"}, | ||||
{name:"分点"} | {name:"分点"} | ||||
@@ -75,6 +79,8 @@ | |||||
var i=uni.getStorageSync('fendianindex') | var i=uni.getStorageSync('fendianindex') | ||||
this.buildingID=uni.getStorageSync('buildingID').id; | this.buildingID=uni.getStorageSync('buildingID').id; | ||||
this.clocktab(i) | this.clocktab(i) | ||||
this.updateInit() | |||||
}, | }, | ||||
onPullDownRefresh() { | onPullDownRefresh() { | ||||
var i=uni.getStorageSync('fendianindex') | var i=uni.getStorageSync('fendianindex') | ||||
@@ -84,6 +90,24 @@ | |||||
}, 1000); | }, 1000); | ||||
}, | }, | ||||
methods: { | methods: { | ||||
updateInit() { | |||||
uni.request({ | |||||
url: config.service.updateList, | |||||
method: "GET", | |||||
data: { | |||||
id: uni.getStorageSync('weapp_session_userInfo_data').accountId | |||||
}, | |||||
header: { | |||||
'content-type': 'application/json', | |||||
'Access-Token': uni.getStorageSync('weapp_session_login_data').token | |||||
}, | |||||
success: (res) => { | |||||
this.count = res.data.data.count | |||||
this.tabbarList[3].count = res.data.data.count | |||||
} | |||||
}) | |||||
}, | |||||
//全部学习跳转 | //全部学习跳转 | ||||
quclick(item){ | quclick(item){ | ||||
uni.showLoading({ | uni.showLoading({ | ||||
@@ -19,13 +19,14 @@ | |||||
<image src="/static/images/studyhot.png" style="width: 36rpx;height: 36rpx;" mode=""></image> | <image src="/static/images/studyhot.png" style="width: 36rpx;height: 36rpx;" mode=""></image> | ||||
消息 | 消息 | ||||
</view> | </view> | ||||
<view class="right"> | |||||
<view class="right" style="display: flex;align-items: center;"> | |||||
<view class="count" v-if="count!=0">{{count}}</view> | |||||
<image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image> | <image src="/static/images/arrow.png" style="width: 18rpx;height: 32rpx;" mode=""></image> | ||||
</view> | </view> | ||||
</navigator> | </navigator> | ||||
<navigator class="line" url="/pages/mine/subscribe"> | <navigator class="line" url="/pages/mine/subscribe"> | ||||
<view class="title"> | <view class="title"> | ||||
<image src="/static/images/studyhot.png" style="width: 36rpx;height: 36rpx;" mode=""></image> | |||||
<image src="/static/images/studyhot.png" style="width: 36rpx;height: 36rpx;" mode=""></image> | |||||
订阅消息 | 订阅消息 | ||||
</view> | </view> | ||||
<view class="right"> | <view class="right"> | ||||
@@ -79,6 +80,7 @@ | |||||
</view> | </view> | ||||
</view> | </view> | ||||
<u-tabbar activeColor="#1296db" inactiveColor="#999999" v-model="current" :list="tabbarList"></u-tabbar> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
@@ -86,10 +88,13 @@ | |||||
var app = getApp(); | var app = getApp(); | ||||
var util = require("../../utils/util.js"); | var util = require("../../utils/util.js"); | ||||
var config = require("../../config"); | var config = require("../../config"); | ||||
import tabbarList from '@/utils/tabbar.js' | |||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
tabbarList:tabbarList, | |||||
current: 0, | |||||
tabList: [ | tabList: [ | ||||
{ | { | ||||
name: '系统消息' | name: '系统消息' | ||||
@@ -101,6 +106,7 @@ | |||||
name: "", | name: "", | ||||
photo: "", | photo: "", | ||||
mobile: "", | mobile: "", | ||||
count:0, | |||||
}; | }; | ||||
}, | }, | ||||
onShow: function() { | onShow: function() { | ||||
@@ -108,8 +114,27 @@ | |||||
this.name = userInfos.name, | this.name = userInfos.name, | ||||
this.photo = userInfos.picUrl, | this.photo = userInfos.picUrl, | ||||
this.mobile = userInfos.loginName | this.mobile = userInfos.loginName | ||||
this.updateInit() | |||||
}, | }, | ||||
methods: { | methods: { | ||||
updateInit() { | |||||
uni.request({ | |||||
url: config.service.updateList, | |||||
method: "GET", | |||||
data: { | |||||
id: uni.getStorageSync('weapp_session_userInfo_data').accountId | |||||
}, | |||||
header: { | |||||
'content-type': 'application/json', | |||||
'Access-Token': uni.getStorageSync('weapp_session_login_data').token | |||||
}, | |||||
success: (res) => { | |||||
this.count = res.data.data.count | |||||
this.tabbarList[3].count = res.data.data.count | |||||
} | |||||
}) | |||||
}, | |||||
scan(){ | scan(){ | ||||
uni.navigateTo({ | uni.navigateTo({ | ||||
url:"../mine/registerCode" | url:"../mine/registerCode" | ||||
@@ -184,6 +209,18 @@ | |||||
}; | }; | ||||
</script> | </script> | ||||
<style lang="scss" scoped> | <style lang="scss" scoped> | ||||
.count{ | |||||
background: red; | |||||
width: 50rpx; | |||||
height: 50rpx; | |||||
border-radius: 40rpx; | |||||
color: #FFFFFF; | |||||
display: flex; | |||||
justify-content: center; | |||||
align-items: center; | |||||
font-size: 24rpx; | |||||
margin-right: 20rpx; | |||||
} | |||||
.main { | .main { | ||||
padding: 0 30rpx; | padding: 0 30rpx; | ||||
background: #F8F8F8; | background: #F8F8F8; | ||||
@@ -1,11 +1,9 @@ | |||||
<template> | <template> | ||||
<view class="main"> | <view class="main"> | ||||
<!-- <u-parse class="ql-editor" :content="content" @preview="preview" @navigate="navigate"/> --> | |||||
<u-parse class="ql-editor" :content="content" @preview="preview" @navigate="navigate"/> | |||||
<web-view v-if="webviewShow" :webview-styles="webviewStyles" :src="webviewUrl"></web-view> | <web-view v-if="webviewShow" :webview-styles="webviewStyles" :src="webviewUrl"></web-view> | ||||
<!-- <view v-html="content"></view> --> | <!-- <view v-html="content"></view> --> | ||||
<rich-text :nodes="content"></rich-text> | |||||
<!-- <rich-text :nodes="content"></rich-text> --> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
@@ -0,0 +1,27 @@ | |||||
export default [ | |||||
{ | |||||
pagePath: "/pages/index/index", | |||||
iconPath: "/static/images/tabBar/home.png", | |||||
selectedIconPath: "/static/images/tabBar/homeActive.png", | |||||
text: "首页" | |||||
}, | |||||
{ | |||||
pagePath: "/pages/index/customer", | |||||
iconPath: "/static/images/tabBar/customer.png", | |||||
selectedIconPath: "/static/images/tabBar/customerActive.png", | |||||
text: "接待" | |||||
}, | |||||
{ | |||||
pagePath: "/pages/index/learning", | |||||
iconPath: "/static/images/tabBar/voice.png", | |||||
selectedIconPath: "/static/images/tabBar/voiceActive.png", | |||||
text: "学习" | |||||
}, | |||||
{ | |||||
pagePath: "/pages/index/personal", | |||||
iconPath: "/static/images/tabBar/user.png", | |||||
selectedIconPath: "/static/images/tabBar/userActive.png", | |||||
text: "个人", | |||||
count: 0 | |||||
} | |||||
]; |
@@ -1,5 +1,5 @@ | |||||
<template> | <template> | ||||
<view v-if="show" class="u-tabbar" @touchmove.stop.prevent> | |||||
<view v-if="show" class="u-tabbar" @touchmove.stop.prevent="() => {}"> | |||||
<view class="u-tabbar__content safe-area-inset-bottom" :style="{ | <view class="u-tabbar__content safe-area-inset-bottom" :style="{ | ||||
height: $u.addUnit(height), | height: $u.addUnit(height), | ||||
backgroundColor: bgColor, | backgroundColor: bgColor, | ||||
@@ -14,19 +14,20 @@ | |||||
<view :class="[ | <view :class="[ | ||||
midButton && item.midButton ? 'u-tabbar__content__circle__button' : 'u-tabbar__content__item__button' | midButton && item.midButton ? 'u-tabbar__content__circle__button' : 'u-tabbar__content__item__button' | ||||
]"> | ]"> | ||||
<u-icon | |||||
:size="midButton && item.midButton ? midButtonSize : iconSize" | |||||
:name="index == value ? item.selectedIconPath : item.iconPath" | |||||
:color="index == value ? activeColor : inactiveColor" | |||||
<u-icon | |||||
:size="midButton && item.midButton ? midButtonSize : iconSize" | |||||
:name="elIconPath(index)" | |||||
img-mode="scaleToFill" | |||||
:color="elColor(index)" | |||||
:custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'" | :custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'" | ||||
></u-icon> | ></u-icon> | ||||
<u-badge :count="item.count" :is-dot="item.isDot" | |||||
v-if="item.count > 0" | |||||
<u-badge :count="item.count" :is-dot="item.isDot" | |||||
v-if="item.count || item.isDot" | |||||
:offset="[-2, getOffsetRight(item.count, item.isDot)]" | :offset="[-2, getOffsetRight(item.count, item.isDot)]" | ||||
></u-badge> | ></u-badge> | ||||
</view> | </view> | ||||
<view class="u-tabbar__content__item__text" :style="{ | <view class="u-tabbar__content__item__text" :style="{ | ||||
color: index == value ? activeColor : inactiveColor | |||||
color: elColor(index) | |||||
}"> | }"> | ||||
<text class="u-line-1">{{item.text}}</text> | <text class="u-line-1">{{item.text}}</text> | ||||
</view> | </view> | ||||
@@ -34,13 +35,14 @@ | |||||
<view v-if="midButton" class="u-tabbar__content__circle__border" :class="{ | <view v-if="midButton" class="u-tabbar__content__circle__border" :class="{ | ||||
'u-border': borderTop, | 'u-border': borderTop, | ||||
}" :style="{ | }" :style="{ | ||||
backgroundColor: bgColor | |||||
backgroundColor: bgColor, | |||||
left: midButtonLeft | |||||
}"> | }"> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
<!-- 这里加上一个48rpx的高度,是为了增高有凸起按钮时的防塌陷高度(也即按钮凸出来部分的高度) --> | <!-- 这里加上一个48rpx的高度,是为了增高有凸起按钮时的防塌陷高度(也即按钮凸出来部分的高度) --> | ||||
<view class="u-fixed-placeholder safe-area-inset-bottom" :style="{ | |||||
height: `calc(${$u.addUnit(height)} + ${midButton ? 48 : 0}rpx)`, | |||||
<view class="u-fixed-placeholder safe-area-inset-bottom" :style="{ | |||||
height: `calc(${$u.addUnit(height)} + ${midButton && isBtnTop ? 48 : 0}rpx)`, | |||||
}"></view> | }"></view> | ||||
</view> | </view> | ||||
</template> | </template> | ||||
@@ -110,24 +112,83 @@ | |||||
type: Boolean, | type: Boolean, | ||||
default: true | default: true | ||||
}, | }, | ||||
// 是否隐藏原生tabbar | |||||
hideTabBar: { | |||||
type: Boolean, | |||||
default: true | |||||
}, | |||||
// 是否计算凸起位置的高度 | |||||
isBtnTop: { | |||||
type: Boolean, | |||||
default: true | |||||
} | |||||
}, | }, | ||||
data() { | data() { | ||||
return { | return { | ||||
// 由于安卓太菜了,通过css居中凸起按钮的外层元素有误差,故通过js计算将其居中 | |||||
midButtonLeft: '50%', | |||||
pageUrl: '', // 当前页面URL | |||||
} | } | ||||
}, | }, | ||||
created() { | |||||
// 是否隐藏原生tabbar | |||||
if(this.hideTabBar) uni.hideTabBar(); | |||||
// 获取引入了u-tabbar页面的路由地址,该地址没有路径前面的"/" | |||||
let pages = getCurrentPages(); | |||||
// 页面栈中的最后一个即为项为当前页面,route属性为页面路径 | |||||
this.pageUrl = pages[pages.length - 1].route; | |||||
}, | |||||
computed: { | |||||
elIconPath() { | |||||
return (index) => { | |||||
// 历遍u-tabbar的每一项item时,判断是否传入了pagePath参数,如果传入了 | |||||
// 和data中的pageUrl参数对比,如果相等,即可判断当前的item对应当前的tabbar页面,设置高亮图标 | |||||
// 采用这个方法,可以无需使用v-model绑定的value值 | |||||
let pagePath = this.list[index].pagePath; | |||||
// 如果定义了pagePath属性,意味着使用系统自带tabbar方案,否则使用一个页面用几个组件模拟tabbar页面的方案 | |||||
// 这两个方案对处理tabbar item的激活与否方式不一样 | |||||
if(pagePath) { | |||||
if(pagePath == this.pageUrl || pagePath == '/' + this.pageUrl) { | |||||
return this.list[index].selectedIconPath; | |||||
} else { | |||||
return this.list[index].iconPath; | |||||
} | |||||
} else { | |||||
// 普通方案中,索引等于v-model值时,即为激活项 | |||||
return index == this.value ? this.list[index].selectedIconPath : this.list[index].iconPath | |||||
} | |||||
} | |||||
}, | |||||
elColor() { | |||||
return (index) => { | |||||
// 判断方法同理于elIconPath | |||||
let pagePath = this.list[index].pagePath; | |||||
if(pagePath) { | |||||
if(pagePath == this.pageUrl || pagePath == '/' + this.pageUrl) return this.activeColor; | |||||
else return this.inactiveColor; | |||||
} else { | |||||
return index == this.value ? this.activeColor : this.inactiveColor; | |||||
} | |||||
} | |||||
} | |||||
}, | |||||
mounted() { | |||||
this.midButton && this.getMidButtonLeft(); | |||||
}, | |||||
methods: { | methods: { | ||||
async clickHandler(index) { | async clickHandler(index) { | ||||
if(this.beforeSwitch && typeof(this.beforeSwitch) === 'function') { | if(this.beforeSwitch && typeof(this.beforeSwitch) === 'function') { | ||||
// 执行回调,同时传入索引当作参数 | // 执行回调,同时传入索引当作参数 | ||||
let beforeSwitch = this.beforeSwitch(index); | |||||
// 在微信,支付宝等环境(H5正常),会导致父组件定义的customBack()函数体中的this变成子组件的this | |||||
// 通过bind()方法,绑定父组件的this,让this.customBack()的this为父组件的上下文 | |||||
let beforeSwitch = this.beforeSwitch.bind(this.$u.$parent.call(this))(index); | |||||
// 判断是否返回了promise | // 判断是否返回了promise | ||||
if (!!beforeSwitch && typeof beforeSwitch.then === 'function') { | if (!!beforeSwitch && typeof beforeSwitch.then === 'function') { | ||||
await beforeSwitch.then(res => { | await beforeSwitch.then(res => { | ||||
// promise返回成功, | // promise返回成功, | ||||
this.switchTab(index); | this.switchTab(index); | ||||
}).catch(err => { | }).catch(err => { | ||||
}) | }) | ||||
} else if(beforeSwitch === true) { | } else if(beforeSwitch === true) { | ||||
// 如果返回true | // 如果返回true | ||||
@@ -141,7 +202,16 @@ | |||||
switchTab(index) { | switchTab(index) { | ||||
// 发出事件和修改v-model绑定的值 | // 发出事件和修改v-model绑定的值 | ||||
this.$emit('change', index); | this.$emit('change', index); | ||||
this.$emit('input', index); | |||||
// 如果有配置pagePath属性,使用uni.switchTab进行跳转 | |||||
if(this.list[index].pagePath) { | |||||
uni.switchTab({ | |||||
url: this.list[index].pagePath | |||||
}) | |||||
} else { | |||||
// 如果配置了papgePath属性,将不会双向绑定v-model传入的value值 | |||||
// 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配 | |||||
this.$emit('input', index); | |||||
} | |||||
}, | }, | ||||
// 计算角标的right值 | // 计算角标的right值 | ||||
getOffsetRight(count, isDot) { | getOffsetRight(count, isDot) { | ||||
@@ -153,20 +223,29 @@ | |||||
} else { | } else { | ||||
return -30; | return -30; | ||||
} | } | ||||
}, | |||||
// 获取凸起按钮外层元素的left值,让其水平居中 | |||||
getMidButtonLeft() { | |||||
let windowWidth = this.$u.sys().windowWidth; | |||||
// 由于安卓中css计算left: 50%的结果不准确,故用js计算 | |||||
this.midButtonLeft = (windowWidth / 2) + 'px'; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> | ||||
<style scoped lang="scss"> | <style scoped lang="scss"> | ||||
@import "../../libs/css/style.components.scss"; | |||||
.u-fixed-placeholder { | .u-fixed-placeholder { | ||||
/* #ifndef APP-NVUE */ | |||||
box-sizing: content-box; | box-sizing: content-box; | ||||
/* #endif */ | |||||
} | } | ||||
.u-tabbar { | .u-tabbar { | ||||
&__content { | &__content { | ||||
display: flex; | |||||
@include vue-flex; | |||||
align-items: center; | align-items: center; | ||||
position: relative; | position: relative; | ||||
position: fixed; | position: fixed; | ||||
@@ -174,18 +253,22 @@ | |||||
left: 0; | left: 0; | ||||
width: 100%; | width: 100%; | ||||
z-index: 998; | z-index: 998; | ||||
/* #ifndef APP-NVUE */ | |||||
box-sizing: content-box; | box-sizing: content-box; | ||||
/* #endif */ | |||||
&__circle__border { | &__circle__border { | ||||
border-radius: 100%; | border-radius: 100%; | ||||
width: 110rpx; | width: 110rpx; | ||||
height: 110rpx; | height: 110rpx; | ||||
top: -48rpx; | top: -48rpx; | ||||
left: 50%; | |||||
transform: translateX(-50%); | |||||
position: absolute; | position: absolute; | ||||
z-index: 4; | z-index: 4; | ||||
background-color: #ffffff; | background-color: #ffffff; | ||||
// 由于安卓的无能,导致只有3个tabbar item时,此css计算方式有误差 | |||||
// 故使用js计算的形式来定位,此处不注释,是因为js计算有延后,避免出现位置闪动 | |||||
left: 50%; | |||||
transform: translateX(-50%); | |||||
&:after { | &:after { | ||||
border-radius: 100px; | border-radius: 100px; | ||||
@@ -197,14 +280,16 @@ | |||||
justify-content: center; | justify-content: center; | ||||
height: 100%; | height: 100%; | ||||
padding: 12rpx 0; | padding: 12rpx 0; | ||||
display: flex; | |||||
@include vue-flex; | |||||
flex-direction: column; | flex-direction: column; | ||||
align-items: center; | align-items: center; | ||||
position: relative; | position: relative; | ||||
&__button { | &__button { | ||||
position: absolute; | position: absolute; | ||||
top: 10rpx; | |||||
top: 14rpx; | |||||
left: 50%; | |||||
transform: translateX(-50%); | |||||
} | } | ||||
&__text { | &__text { | ||||
@@ -212,25 +297,29 @@ | |||||
font-size: 26rpx; | font-size: 26rpx; | ||||
line-height: 28rpx; | line-height: 28rpx; | ||||
position: absolute; | position: absolute; | ||||
bottom: 12rpx; | |||||
bottom: 14rpx; | |||||
left: 50%; | left: 50%; | ||||
transform: translateX(-50%); | transform: translateX(-50%); | ||||
width: 100%; | |||||
text-align: center; | |||||
} | } | ||||
} | } | ||||
&__circle { | &__circle { | ||||
position: relative; | position: relative; | ||||
display: flex; | |||||
@include vue-flex; | |||||
flex-direction: column; | flex-direction: column; | ||||
justify-content: space-between; | justify-content: space-between; | ||||
z-index: 10; | z-index: 10; | ||||
/* #ifndef APP-NVUE */ | |||||
height: calc(100% - 1px); | height: calc(100% - 1px); | ||||
/* #endif */ | |||||
&__button { | &__button { | ||||
width: 90rpx; | width: 90rpx; | ||||
height: 90rpx; | height: 90rpx; | ||||
border-radius: 100%; | border-radius: 100%; | ||||
display: flex; | |||||
@include vue-flex; | |||||
justify-content: center; | justify-content: center; | ||||
align-items: center; | align-items: center; | ||||
position: absolute; | position: absolute; | ||||
@@ -1,3 +1,6 @@ | |||||
.demo { | |||||
@mixin vue-flex($direction: row) { | |||||
/* #ifndef APP-NVUE */ | |||||
display: flex; | |||||
flex-direction: $direction; | |||||
/* #endif */ | |||||
} | } |