推拿小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.0 KiB

  1. <template>
  2. <view class="page">
  3. <navbar title="代金券" leftClick @leftClick="$utils.navigateBack" color="#fff" />
  4. <view class="tabs">
  5. <uv-tabs
  6. :list="tabs"
  7. @click="onTabChange"
  8. :customStyle="{
  9. backgroundColor: '#FFFFFF',
  10. }"
  11. :activeStyle="{
  12. color: '#84A73F',
  13. fontSize: '28rpx',
  14. whiteSpace: 'nowrap',
  15. paddingTop: '29rpx',
  16. paddingBottom: '21rpx',
  17. }"
  18. :inactiveStyle="{
  19. color: '#000000',
  20. fontSize: '28rpx',
  21. whiteSpace: 'nowrap',
  22. paddingTop: '29rpx',
  23. paddingBottom: '21rpx',
  24. }"
  25. lineHeight="5rpx"
  26. lineWidth="92rpx"
  27. lineColor="linear-gradient(to right, #84A73F, #D8FF8F)"
  28. :scrollable="false"
  29. ></uv-tabs>
  30. </view>
  31. <template v-if="current == 0" >
  32. <view class="list voucher">
  33. <!-- todo: check only show status == 0? -->
  34. <view class="list-item" v-for="item in list" :key="item.id">
  35. <voucherCard :data="item" ></voucherCard>
  36. </view>
  37. </view>
  38. </template>
  39. <template v-else-if="current == 1" >
  40. <view class="list store">
  41. <view class="list-item" v-for="item in list" :key="item.id">
  42. <storeCard :data="item" ></storeCard>
  43. </view>
  44. </view>
  45. </template>
  46. </view>
  47. </template>
  48. <script>
  49. import mixinsList from '@/mixins/list.js'
  50. import voucherCard from '../components/voucher/voucherCard.vue'
  51. import storeCard from '../components/voucher/storeCard.vue'
  52. const TAB_AND_API_FIELDS_MAPPING = {
  53. 0: 'queryVouchersList',
  54. 1: 'queryVoucherShopList',
  55. }
  56. export default {
  57. mixins : [mixinsList],
  58. components: {
  59. voucherCard,
  60. storeCard,
  61. },
  62. data() {
  63. return {
  64. tabs: [{
  65. name: "代金券"
  66. }, {
  67. name: "可使用门店"
  68. }],
  69. current: 0,
  70. queryParams: {
  71. pageNo: 1,
  72. pageSize: 10,
  73. type: 1, // type:0-抵扣 1-代金券
  74. }
  75. };
  76. },
  77. computed: {
  78. mixinsListApi() {
  79. return TAB_AND_API_FIELDS_MAPPING[this.current]
  80. }
  81. },
  82. methods: {
  83. onTabChange(e) {
  84. this.current = e.index
  85. if (this.current === 0) { // 代金券
  86. this.queryParams = {
  87. pageNo: 1,
  88. pageSize: 10,
  89. type: 1, // type:0-抵扣 1-代金券
  90. }
  91. } else { // 可使用门店
  92. this.queryParams = {
  93. pageNo: 1,
  94. pageSize: 10,
  95. }
  96. }
  97. this.list = []
  98. this.getData()
  99. },
  100. },
  101. }
  102. </script>
  103. <style scoped lang="scss">
  104. .page {
  105. background-color: $uni-bg-color;
  106. min-height: 100vh;
  107. /deep/ .nav-bar__view {
  108. background-image: linear-gradient(#84A73F, #D8FF8F);
  109. }
  110. }
  111. .tabs {
  112. /deep/ .uv-tabs__wrapper__nav__line {
  113. bottom: 0;
  114. }
  115. }
  116. .list {
  117. &-item {
  118. display: block;
  119. & + & {
  120. margin-top: 20rpx;
  121. }
  122. }
  123. &.voucher {
  124. padding: 30rpx 28rpx;
  125. }
  126. &.store {
  127. padding: 29rpx 13rpx;
  128. }
  129. }
  130. </style>