推拿小程序前端代码仓库
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.

151 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. <voucherCard class="list-item"
  35. v-for="item in list"
  36. :key="item.id"
  37. :data="item"
  38. ></voucherCard>
  39. </view>
  40. </template>
  41. <template v-else-if="current == 1" >
  42. <view class="list store">
  43. <storeCard class="list-item"
  44. v-for="item in list"
  45. :key="item.id"
  46. :data="item"
  47. ></storeCard>
  48. </view>
  49. </template>
  50. </view>
  51. </template>
  52. <script>
  53. import mixinsList from '@/mixins/list.js'
  54. import voucherCard from '../components/voucher/voucherCard.vue'
  55. import storeCard from '../components/voucher/storeCard.vue'
  56. const TAB_AND_API_FIELDS_MAPPING = {
  57. 0: 'queryVouchersList',
  58. 1: 'queryVoucherShopList',
  59. }
  60. export default {
  61. mixins : [mixinsList],
  62. components: {
  63. voucherCard,
  64. storeCard,
  65. },
  66. data() {
  67. return {
  68. tabs: [{
  69. name: "代金券"
  70. }, {
  71. name: "可使用门店"
  72. }],
  73. current: 0,
  74. queryParams: {
  75. pageNo: 1,
  76. pageSize: 10,
  77. type: 1, // type:0-抵扣 1-代金券
  78. }
  79. };
  80. },
  81. computed: {
  82. mixinsListApi() {
  83. return TAB_AND_API_FIELDS_MAPPING[this.current]
  84. }
  85. },
  86. methods: {
  87. onTabChange(e) {
  88. this.current = e.index
  89. if (this.current === 0) { // 代金券
  90. this.queryParams = {
  91. pageNo: 1,
  92. pageSize: 10,
  93. type: 1, // type:0-抵扣 1-代金券
  94. }
  95. } else { // 可使用门店
  96. this.queryParams = {
  97. pageNo: 1,
  98. pageSize: 10,
  99. }
  100. }
  101. this.list = []
  102. this.getData()
  103. }
  104. },
  105. }
  106. </script>
  107. <style scoped lang="scss">
  108. .page {
  109. background-color: $uni-bg-color;
  110. min-height: 100vh;
  111. /deep/ .nav-bar__view {
  112. background-image: linear-gradient(#84A73F, #D8FF8F);
  113. }
  114. }
  115. .tabs {
  116. /deep/ .uv-tabs__wrapper__nav__line {
  117. bottom: 0;
  118. }
  119. }
  120. .list {
  121. &-item {
  122. display: block;
  123. & + & {
  124. margin-top: 20rpx;
  125. }
  126. }
  127. &.voucher {
  128. padding: 30rpx 28rpx;
  129. }
  130. &.store {
  131. padding: 29rpx 13rpx;
  132. }
  133. }
  134. </style>