wike-tabbar.vue 10 KB

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