task_ima_tab.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. name: 'task-ima-tab',
  25. props:{
  26. listType:{
  27. default:0
  28. }
  29. },
  30. data() {
  31. return {
  32. current: 0,
  33. navList: [{
  34. id: 0,
  35. briefness_name: '全部',
  36. product_icon: '/static/img/task/task-all.png'
  37. }],
  38. typeList:[
  39. {
  40. id: 2,
  41. briefness_name: '垫资还款',
  42. product_icon: '/static/img/task/task-refund.png'
  43. },
  44. {
  45. id: 1,
  46. briefness_name: '房抵业务',
  47. product_icon: '/static/img/task/task-loan.png'
  48. },
  49. {
  50. id: 3,
  51. briefness_name: '消费金融',
  52. product_icon: '/static/img/task/task-financial.png'
  53. },
  54. {
  55. id: 4,
  56. briefness_name: '其他服务',
  57. product_icon: '/static/img/task/task-else.png'
  58. }
  59. ]
  60. }
  61. },
  62. watch:{
  63. },
  64. mounted() {
  65. console.log(this.listType+'----------------------------dsadsadas')
  66. if(this.listType===1){
  67. this.navList=this.typeList
  68. console.log('--------------------------------')
  69. }else {
  70. this.getTaskType()
  71. }
  72. },
  73. methods: {
  74. getTaskType() {
  75. getTaskType().then(res => {
  76. if (res.code === 1) {
  77. this.navList.push(...res.data)
  78. }
  79. })
  80. },
  81. setType(current) {
  82. // this.$nextTick(() => {
  83. // uni.createSelectorQuery().in(this).select(".z-tabs-scroll-view").fields({
  84. // scrollOffset: true
  85. // }, data => {
  86. // if (data) {
  87. // this.currentScrollLeft = data.scrollLeft;
  88. // console.log(data);
  89. // } else {}
  90. // }).exec();
  91. // })
  92. if (current !== this.current) {
  93. this.current = current
  94. this.$emit('setProductId', this.navList[current].id)
  95. }
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .task-tab {
  102. margin: 0 20rpx;
  103. border-radius: 30rpx;
  104. background: #fff;
  105. width: calc(100% - 40rpx);
  106. }
  107. .default-text {
  108. color: #10B261;
  109. }
  110. .half-circle {
  111. width: 20rpx;
  112. height: 10rpx;
  113. background-color: #3eaf7c;
  114. border-top-left-radius: 10rpx;
  115. border-top-right-radius: 10rpx;
  116. position: absolute;
  117. bottom: 0;
  118. left: calc(25%/2 - 10rpx);
  119. }
  120. .half-transition {
  121. transition: all .5s ease;
  122. }
  123. .tab-item {
  124. // width: 25%;
  125. }
  126. .double-border {
  127. box-shadow: 0 0 0 6rpx #fff, 0 0 0 12rpx #10B261;
  128. }
  129. </style>