wike-tabbar.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view>
  3. <view class="tabbar cu-bar flex-between bg-white" :class="isShowAnimate ? 'fadeInUp' : ''" :style="{'background-color':tabBar.bgColor,'border-top-color':tabBar.borderColor}"
  4. v-show="onTabbar">
  5. <block v-for="(item, index) in tabBar.list" :key="index">
  6. <view class="action tabbar-item" :class="[item.showBig?'add-action':'']" :style="{color:item.pagePath==('/'+nowPath)?themecolor:tabBar.color}"
  7. @click="clickTab(item)">
  8. <block v-if="tabBar.showType=='img'">
  9. <image class="tabbar-icon" :src="item.pagePath==('/'+nowPath)? item.selectedIconPath : item.iconPath"></image>
  10. </block>
  11. <block v-if="tabBar.showType=='iconfont'">
  12. <view :class="['tabbar-icon',item.fontClass]" :style="{'font-size':'22px','background-color':item.showBig?themecolor:''}"></view>
  13. </block>
  14. <text class="tabbar-text">{{ item.text }}</text>
  15. <text class="tabbar-item-num" v-if="item.num">{{item.num}}</text>
  16. </view>
  17. </block>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. mapMutations,
  24. mapActions,
  25. mapState,
  26. mapGetters
  27. } from 'vuex';
  28. export default {
  29. props: {
  30. onTabbar: {
  31. type: Boolean,
  32. default: true
  33. },
  34. infonum: {
  35. type: String,
  36. default: ''
  37. },
  38. isShowAnimate: {
  39. type: Boolean,
  40. default: false
  41. },
  42. isglobalpartjob: {
  43. type: String,
  44. default: '1'
  45. },
  46. themecolor: {
  47. type: String,
  48. default: '#26B3A0'
  49. },
  50. is_aipainting:{
  51. type: String,
  52. default: ''
  53. }
  54. },
  55. computed: {
  56. ...mapGetters(['appInfo'])
  57. },
  58. data() {
  59. return {
  60. showBig: false,
  61. tabBar: {
  62. color: '#333333',
  63. selectedColor: '#26B3A0',
  64. showType: "iconfont", //img/图片模式,iconfont/字体图标模式
  65. borderColor: "#d3d3d3",
  66. bgColor: "#ffffff",
  67. list: [{
  68. pagePath: "/pages/index/index",
  69. navigateType: "switchTab",
  70. showBig: false,
  71. fontClass: "tn-icon-home-capsule",
  72. "iconPath": "/static/images/tabs/index.png",
  73. "selectedIconPath": "/static/images/tabs/indexs.png",
  74. "text": "首页"
  75. },
  76. {
  77. pagePath: "/pages/template/template",
  78. navigateType: "switchTab",
  79. showBig: false,
  80. fontClass: "tn-icon-cube",
  81. "iconPath": "/static/images/tabs/joblist.png",
  82. "selectedIconPath": "/static/images/tabs/joblists.png",
  83. "text": "应用"
  84. },
  85. {
  86. pagePath: "/pages/painting/painting",
  87. navigateType: "switchTab",
  88. showBig: false,
  89. fontClass: "tn-icon-image",
  90. "iconPath": "/static/images/tabs/joblist.png",
  91. "selectedIconPath": "/static/images/tabs/joblists.png",
  92. "text": "绘画"
  93. },
  94. {
  95. pagePath: "/pages/signin/signin",
  96. navigateType: "switchTab",
  97. showBig: false,
  98. fontClass: "tn-icon-funds",
  99. "iconPath": "/static/images/tabs/joblist.png",
  100. "selectedIconPath": "/static/images/tabs/joblists.png",
  101. "text": "任务"
  102. },
  103. {
  104. pagePath: "/pages/user/user",
  105. navigateType: "switchTab",
  106. showBig: false,
  107. fontClass: "tn-icon-my",
  108. "iconPath": "/static/images/tabs/mine.png",
  109. "selectedIconPath": "/static/images/tabs/mines.png",
  110. "text": "我的"
  111. }
  112. ]
  113. },
  114. };
  115. },
  116. onReady() {
  117. try {
  118. uni.hideTabBar({
  119. animation: false
  120. })
  121. } catch (e) {
  122. //TODO handle the exception
  123. }
  124. // setTimeout(function(){
  125. // uni.showTabBar({});
  126. // },600);
  127. },
  128. mounted() {
  129. // console.log(this.is_aipainting);
  130. if(this.tabBar.list.length>4&&this.is_aipainting == '2'){
  131. this.tabBar.list.splice(2, 1)
  132. }
  133. try {
  134. uni.hideTabBar({
  135. animation: false
  136. })
  137. } catch (e) {
  138. //TODO handle the exception
  139. }
  140. },
  141. methods: {
  142. clickTab(item) {
  143. if (item.showBig == true) {
  144. this.showBig = true
  145. } else {
  146. uni[item.navigateType]({
  147. url: item.pagePath
  148. });
  149. this.showBig = false
  150. }
  151. },
  152. toggleDialog() {
  153. this.showBig = !this.showBig
  154. },
  155. toPost(e) {
  156. this.toggleDialog();
  157. uni.navigateTo({
  158. url: '/pages/' + e
  159. })
  160. },
  161. // 路由跳转
  162. jump(path, parmas) {
  163. if (Boolean(uni.getStorageSync('userInfo').telnum)) {
  164. this.$Router.push({
  165. path: path,
  166. query: parmas
  167. });
  168. } else {
  169. this.$store.commit('LOGIN_TIP', true);
  170. }
  171. }
  172. },
  173. computed: {
  174. ...mapState({
  175. showLoginTip: state => state.user.showLoginTip,
  176. }),
  177. nowPath() {
  178. return getCurrentPages()[0] && getCurrentPages()[0].route;
  179. },
  180. }
  181. };
  182. </script>
  183. <style lang="scss">
  184. .tabbar {
  185. display: flex;
  186. justify-content: space-around;
  187. /* height: 8vh; */
  188. position: fixed;
  189. bottom: 0;
  190. left: 0;
  191. right: 0;
  192. z-index: 9999;
  193. height: 98rpx;
  194. background-color: #ffffff;
  195. // border-top: 1px solid rgba(193, 192, 201, 0.5);
  196. padding-bottom: constant(safe-area-inset-bottom);
  197. padding-bottom: env(safe-area-inset-bottom);
  198. box-shadow: 0 -10rpx 20rpx 0 rgba(137, 148, 143, .1);
  199. min-height: 128rpx;
  200. padding: 0;
  201. height: calc(100rpx + env(safe-area-inset-bottom) / 2);
  202. padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  203. }
  204. .tabbar::before {
  205. content: "";
  206. width: 100%;
  207. height: 152rpx;
  208. // background: url(https://ls11.cn/attachment/images/9/2019/09/TW284XJ028xWXH1mCh7pw7WhZjK4Jj.png) no-repeat;
  209. background-position: center;
  210. background-size: cover;
  211. position: absolute;
  212. left: 0;
  213. bottom: 0;
  214. z-index: -1;
  215. padding-bottom: 0;
  216. padding-bottom: calc(constant(safe-area-inset-bottom) - 12rpx);
  217. padding-bottom: calc(env(safe-area-inset-bottom) - 12rpx);
  218. }
  219. .flex-between {
  220. display: -webkit-box;
  221. display: -webkit-flex;
  222. display: -ms-flexbox;
  223. display: flex;
  224. flex-direction: row;
  225. align-items: center;
  226. justify-content: space-between;
  227. }
  228. .tabbar-item {
  229. width: 33%;
  230. display: -webkit-inline-box;
  231. display: -webkit-inline-flex;
  232. display: -ms-inline-flexbox;
  233. display: inline-flex;
  234. flex-basis: 33%;
  235. flex-direction: column;
  236. align-items: center;
  237. justify-content: space-around;
  238. }
  239. .tabbar-item.active {
  240. color: #fe8b1e;
  241. }
  242. .tabbar-item.big {
  243. position: relative;
  244. top: -23rpx;
  245. // font-size: 130%;
  246. .tabbar-icon {
  247. width: 92rpx;
  248. height: 92rpx;
  249. }
  250. }
  251. .tabbar-icon {
  252. width: 46rpx;
  253. height: 46rpx;
  254. display: block;
  255. margin: 0 auto;
  256. margin-bottom: 4rpx;
  257. // font-size: 46rpx;
  258. // line-height: 10rpx;
  259. }
  260. .tabbar-text {
  261. font-size: 12px;
  262. letter-spacing: 0;
  263. text-align: center;
  264. line-height: 14px;
  265. display: block;
  266. font-weight: 600;
  267. // color: #333;
  268. }
  269. .tabbar-item-num {
  270. position: absolute;
  271. top: 1vw;
  272. font-size: 20rpx;
  273. padding: 4rpx;
  274. border-radius: 50%;
  275. background-color: #ff4a39;
  276. color: #ffffff;
  277. width: 28rpx;
  278. height: 28rpx;
  279. text-align: center;
  280. line-height: 28rpx;
  281. left: 45rpx;
  282. margin: auto;
  283. right: 0;
  284. }
  285. .bg {
  286. position: fixed;
  287. z-index: 1007;
  288. top: 0;
  289. left: 0;
  290. width: 100%;
  291. height: 100%;
  292. background-color: #000;
  293. opacity: .8;
  294. }
  295. .fixed-fabu {
  296. position: fixed;
  297. left: 0;
  298. bottom: 0;
  299. z-index: 1008;
  300. background-color: #fff;
  301. width: 100%;
  302. padding: 30rpx;
  303. border-top-left-radius: 12rpx;
  304. border-top-right-radius: 12rpx;
  305. h2 {
  306. font-size: 18px;
  307. color: #333;
  308. font-weight: 400;
  309. text-align: center;
  310. margin: 20rpx 0;
  311. }
  312. .ul {
  313. padding: 0 50rpx;
  314. }
  315. }
  316. .close {
  317. width: 44px;
  318. height: 44px;
  319. display: block;
  320. margin: 35px auto;
  321. }
  322. @keyframes fabu_animate_in {
  323. 0% {
  324. transform: scale(1);
  325. }
  326. 50% {
  327. transform: scale(1.2);
  328. }
  329. 100% {
  330. transform: scale(1);
  331. }
  332. }
  333. .ani_fabu_in {
  334. animation: fabu_animate_in .5s 0s ease-in-out;
  335. animation-fill-mode: both;
  336. animation-iteration-count: 1
  337. }
  338. @keyframes close_rotate {
  339. 0% {
  340. transform: rotate(0deg)
  341. }
  342. 100% {
  343. transform: rotate(360deg)
  344. }
  345. }
  346. .close_rotate {
  347. animation: close_rotate .5s .1s ease-in-out;
  348. animation-fill-mode: both;
  349. animation-iteration-count: 1
  350. }
  351. .btn-personal-rec {
  352. border-radius: 10rpx;
  353. line-height: 150rpx;
  354. height: 150rpx;
  355. font-size: 50rpx;
  356. color: #fff;
  357. font-weight: bold;
  358. margin: 40rpx auto;
  359. display: flex;
  360. align-items: center;
  361. justify-content: center;
  362. box-shadow: 0rpx 14rpx 34rpx rgba(41, 57, 88, 0.4);
  363. }
  364. .btn-personal-rec .btn-img {
  365. margin-right: 20rpx;
  366. width: 70rpx;
  367. height: 70rpx;
  368. }
  369. .recruit {
  370. background: linear-gradient(to right, #03a9f48c, #03A9F4);
  371. }
  372. .partjob {
  373. background: linear-gradient(to right, #FF98008c, #FF9800);
  374. // line-height: 100rpx;
  375. }
  376. .resume {
  377. background: linear-gradient(to right, #FF57228c, #FF5722);
  378. }
  379. @keyframes fadeInUp {
  380. from {
  381. opacity: 0;
  382. -webkit-transform: translate3d(0, 100%, 0);
  383. transform: translate3d(0, 100%, 0);
  384. }
  385. to {
  386. opacity: 1;
  387. -webkit-transform: translate3d(0, 0, 0);
  388. transform: translate3d(0, 0, 0);
  389. }
  390. }
  391. .fadeInUp {
  392. animation-name: fadeInUp;
  393. animation-duration: .5s;
  394. animation-delay: 0s;
  395. }
  396. </style>