task_ima_tab.vue 2.3 KB

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