wike-tabbar.vue 9.7 KB

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