wike-tabbar2.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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-level",
  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-chemistry",
  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": "AI绘画"
  93. },
  94. {
  95. pagePath: "/pages/signin/signin",
  96. navigateType: "switchTab",
  97. showBig: false,
  98. fontClass: "tn-icon-constellation",
  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-emoji-good",
  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. if(this.tabBar.list.length>4&&this.is_aipainting == '2'){
  130. this.tabBar.list.splice(2, 1)
  131. }
  132. try {
  133. uni.hideTabBar({
  134. animation: false
  135. })
  136. } catch (e) {
  137. //TODO handle the exception
  138. }
  139. },
  140. methods: {
  141. clickTab(item) {
  142. if (item.showBig == true) {
  143. this.showBig = true
  144. } else {
  145. uni[item.navigateType]({
  146. url: item.pagePath
  147. });
  148. this.showBig = false
  149. }
  150. },
  151. toggleDialog() {
  152. this.showBig = !this.showBig
  153. },
  154. toPost(e) {
  155. this.toggleDialog();
  156. uni.navigateTo({
  157. url: '/pages/' + e
  158. })
  159. },
  160. // 路由跳转
  161. jump(path, parmas) {
  162. if (Boolean(uni.getStorageSync('userInfo').telnum)) {
  163. this.$Router.push({
  164. path: path,
  165. query: parmas
  166. });
  167. } else {
  168. this.$store.commit('LOGIN_TIP', true);
  169. }
  170. }
  171. },
  172. computed: {
  173. ...mapState({
  174. showLoginTip: state => state.user.showLoginTip,
  175. }),
  176. nowPath() {
  177. return getCurrentPages()[0] && getCurrentPages()[0].route;
  178. },
  179. }
  180. };
  181. </script>
  182. <style lang="scss">
  183. .tabbar {
  184. display: flex;
  185. justify-content: space-around;
  186. /* height: 8vh; */
  187. position: fixed;
  188. bottom: 0;
  189. left: 0;
  190. right: 0;
  191. z-index: 9999;
  192. height: 98rpx;
  193. background-color: #ffffff;
  194. // border-top: 1px solid rgba(193, 192, 201, 0.5);
  195. padding-bottom: constant(safe-area-inset-bottom);
  196. padding-bottom: env(safe-area-inset-bottom);
  197. box-shadow: 0 -10rpx 20rpx 0 rgba(137, 148, 143, .1);
  198. min-height: 128rpx;
  199. padding: 0;
  200. height: calc(100rpx + env(safe-area-inset-bottom) / 2);
  201. padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  202. }
  203. .tabbar::before {
  204. content: "";
  205. width: 100%;
  206. height: 152rpx;
  207. // background: url(https://ls11.cn/attachment/images/9/2019/09/TW284XJ028xWXH1mCh7pw7WhZjK4Jj.png) no-repeat;
  208. background-position: center;
  209. background-size: cover;
  210. position: absolute;
  211. left: 0;
  212. bottom: 0;
  213. z-index: -1;
  214. padding-bottom: 0;
  215. padding-bottom: calc(constant(safe-area-inset-bottom) - 12rpx);
  216. padding-bottom: calc(env(safe-area-inset-bottom) - 12rpx);
  217. }
  218. .flex-between {
  219. display: -webkit-box;
  220. display: -webkit-flex;
  221. display: -ms-flexbox;
  222. display: flex;
  223. flex-direction: row;
  224. align-items: center;
  225. justify-content: space-between;
  226. }
  227. .tabbar-item {
  228. width: 33%;
  229. display: -webkit-inline-box;
  230. display: -webkit-inline-flex;
  231. display: -ms-inline-flexbox;
  232. display: inline-flex;
  233. flex-basis: 33%;
  234. flex-direction: column;
  235. align-items: center;
  236. justify-content: space-around;
  237. }
  238. .tabbar-item.active {
  239. color: #fe8b1e;
  240. }
  241. .tabbar-item.big {
  242. position: relative;
  243. top: -23rpx;
  244. // font-size: 130%;
  245. .tabbar-icon {
  246. width: 92rpx;
  247. height: 92rpx;
  248. }
  249. }
  250. .tabbar-icon {
  251. width: 46rpx;
  252. height: 46rpx;
  253. display: block;
  254. margin: 0 auto;
  255. margin-bottom: 4rpx;
  256. // font-size: 46rpx;
  257. // line-height: 10rpx;
  258. }
  259. .tabbar-text {
  260. font-size: 12px;
  261. letter-spacing: 0;
  262. text-align: center;
  263. line-height: 14px;
  264. display: block;
  265. font-weight: 600;
  266. // color: #333;
  267. }
  268. .tabbar-item-num {
  269. position: absolute;
  270. top: 1vw;
  271. font-size: 20rpx;
  272. padding: 4rpx;
  273. border-radius: 50%;
  274. background-color: #ff4a39;
  275. color: #ffffff;
  276. width: 28rpx;
  277. height: 28rpx;
  278. text-align: center;
  279. line-height: 28rpx;
  280. left: 45rpx;
  281. margin: auto;
  282. right: 0;
  283. }
  284. .bg {
  285. position: fixed;
  286. z-index: 1007;
  287. top: 0;
  288. left: 0;
  289. width: 100%;
  290. height: 100%;
  291. background-color: #000;
  292. opacity: .8;
  293. }
  294. .fixed-fabu {
  295. position: fixed;
  296. left: 0;
  297. bottom: 0;
  298. z-index: 1008;
  299. background-color: #fff;
  300. width: 100%;
  301. padding: 30rpx;
  302. border-top-left-radius: 12rpx;
  303. border-top-right-radius: 12rpx;
  304. h2 {
  305. font-size: 18px;
  306. color: #333;
  307. font-weight: 400;
  308. text-align: center;
  309. margin: 20rpx 0;
  310. }
  311. .ul {
  312. padding: 0 50rpx;
  313. }
  314. }
  315. .close {
  316. width: 44px;
  317. height: 44px;
  318. display: block;
  319. margin: 35px auto;
  320. }
  321. @keyframes fabu_animate_in {
  322. 0% {
  323. transform: scale(1);
  324. }
  325. 50% {
  326. transform: scale(1.2);
  327. }
  328. 100% {
  329. transform: scale(1);
  330. }
  331. }
  332. .ani_fabu_in {
  333. animation: fabu_animate_in .5s 0s ease-in-out;
  334. animation-fill-mode: both;
  335. animation-iteration-count: 1
  336. }
  337. @keyframes close_rotate {
  338. 0% {
  339. transform: rotate(0deg)
  340. }
  341. 100% {
  342. transform: rotate(360deg)
  343. }
  344. }
  345. .close_rotate {
  346. animation: close_rotate .5s .1s ease-in-out;
  347. animation-fill-mode: both;
  348. animation-iteration-count: 1
  349. }
  350. .btn-personal-rec {
  351. border-radius: 10rpx;
  352. line-height: 150rpx;
  353. height: 150rpx;
  354. font-size: 50rpx;
  355. color: #fff;
  356. font-weight: bold;
  357. margin: 40rpx auto;
  358. display: flex;
  359. align-items: center;
  360. justify-content: center;
  361. box-shadow: 0rpx 14rpx 34rpx rgba(41, 57, 88, 0.4);
  362. }
  363. .btn-personal-rec .btn-img {
  364. margin-right: 20rpx;
  365. width: 70rpx;
  366. height: 70rpx;
  367. }
  368. .recruit {
  369. background: linear-gradient(to right, #03a9f48c, #03A9F4);
  370. }
  371. .partjob {
  372. background: linear-gradient(to right, #FF98008c, #FF9800);
  373. // line-height: 100rpx;
  374. }
  375. .resume {
  376. background: linear-gradient(to right, #FF57228c, #FF5722);
  377. }
  378. @keyframes fadeInUp {
  379. from {
  380. opacity: 0;
  381. -webkit-transform: translate3d(0, 100%, 0);
  382. transform: translate3d(0, 100%, 0);
  383. }
  384. to {
  385. opacity: 1;
  386. -webkit-transform: translate3d(0, 0, 0);
  387. transform: translate3d(0, 0, 0);
  388. }
  389. }
  390. .fadeInUp {
  391. animation-name: fadeInUp;
  392. animation-duration: .5s;
  393. animation-delay: 0s;
  394. }
  395. </style>