task_ima_tab.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="task-tab">
  3. <scroll-view class="scroll-Y row" scroll-x="true">
  4. <view class="z-tabs-scroll-view row-justify-sb center" style="position: relative;">
  5. <view class="column-c p-lr30 p-t30 p-b20" v-for="(item,index) in navList" :key="index"
  6. @click="setType(index)">
  7. <image class="wh-60 r-circle" :class="index===current?'double-border':''" :src="item.product_icon"
  8. mode="aspectFill">
  9. </image>
  10. <view class="m-t16 sys-size-24 sys-weight-600" :class="{'default-text':index===current}">
  11. {{item.briefness_name}}
  12. </view>
  13. </view>
  14. <view class="half-circle m-t20"></view>
  15. </view>
  16. </scroll-view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. getTaskType
  22. } from "@/api/task";
  23. export default {
  24. data() {
  25. return {
  26. current: 0,
  27. navList: [{
  28. id: 0,
  29. briefness_name: '全部',
  30. product_icon: '/static/img/task/task-all.png'
  31. }]
  32. }
  33. },
  34. mounted() {
  35. this.getTaskType()
  36. },
  37. methods: {
  38. getTaskType() {
  39. getTaskType().then(res => {
  40. if (res.code === 1) {
  41. this.navList.push(...res.data)
  42. }
  43. })
  44. },
  45. setType(current) {
  46. // this.$nextTick(() => {
  47. // uni.createSelectorQuery().in(this).select(".z-tabs-scroll-view").fields({
  48. // scrollOffset: true
  49. // }, data => {
  50. // if (data) {
  51. // this.currentScrollLeft = data.scrollLeft;
  52. // console.log(data);
  53. // } else {}
  54. // }).exec();
  55. // })
  56. if (current !== this.current) {
  57. this.current = current
  58. this.$emit('setProductId', this.navList[current].id)
  59. }
  60. },
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .task-tab {
  66. margin: 0 20rpx;
  67. border-radius: 30rpx;
  68. background: #fff;
  69. width: calc(100% - 40rpx);
  70. }
  71. .default-text {
  72. color: #10B261;
  73. }
  74. .half-circle {
  75. width: 20rpx;
  76. height: 10rpx;
  77. background-color: #3eaf7c;
  78. border-top-left-radius: 10rpx;
  79. border-top-right-radius: 10rpx;
  80. position: absolute;
  81. bottom: 0;
  82. left: calc(25%/2 - 10rpx);
  83. }
  84. .half-transition {
  85. transition: all .5s ease;
  86. }
  87. .tab-item {
  88. // width: 25%;
  89. }
  90. .double-border {
  91. box-shadow: 0 0 0 6rpx #fff, 0 0 0 12rpx #10B261;
  92. }
  93. </style>