coupon.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar title="我的优惠券" fixed border> </Navbar>
  5. <view class="content">
  6. <view class="cont_tab">
  7. <Tab
  8. :active="tabActive"
  9. :tabList="tabList"
  10. @confirm="tabConfirm"
  11. keyName="text"
  12. size="28rpx"
  13. />
  14. </view>
  15. <view class="cont">
  16. <view class="item" v-for="(item, index) in detials" :key="index">
  17. <view class="item-left">
  18. <view class="item-left-top">
  19. <view class="type">
  20. <trans _t="运费券" v-if="item.typetype == 1"></trans>
  21. <trans _t="购物券" v-if="item.typetype == 2"></trans>
  22. </view>
  23. <view class="name">{{ item.title }}</view>
  24. </view>
  25. <view class="time"
  26. >{{ item.starttime }} - {{ item.endtime }}
  27. </view>
  28. </view>
  29. <view class="item-right">
  30. <view class="price">
  31. <text>{{ symbol.symbol }}</text>
  32. {{ Moneyhtml(item.money) }}
  33. </view>
  34. <view class="status">
  35. <trans _t="满" />
  36. {{ symbol.symbol + Moneyhtml(item.amount) }}
  37. <trans _t="可用" />
  38. </view>
  39. <view class="use-btn" @click="toShop">
  40. <trans _t="立即使用"></trans>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="null_warp" v-if="!detials.length">
  45. <view class="null_text">{{ t("无数据") }}</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </Theme>
  51. </template>
  52. <script setup>
  53. import Navbar from "@/components/navbar";
  54. import { computed, ref, nextTick } from "vue";
  55. import { t } from "@/locale";
  56. import Tab from "@/components/tabs.vue";
  57. import { useSystemStore, useTabbarStore } from "@/store";
  58. import { Moneyhtml, useGlobal, Toast } from "@/utils";
  59. import { onShow } from "@dcloudio/uni-app";
  60. import { SHOP_COUPON_LIST } from "@/api";
  61. const useTabbar = useTabbarStore();
  62. const useSystem = useSystemStore();
  63. const symbol = computed(() => useSystem.getSymbol);
  64. const tabActive = ref(0);
  65. const tabList = [
  66. { text: "可使用", status: 0 },
  67. { text: "已使用", status: 2 },
  68. { text: "已过期", status: 3 },
  69. ];
  70. const detials = ref([]);
  71. const tabConfirm = (item, index) => {
  72. if (!item) return;
  73. tabActive.value = index;
  74. nextTick(() => {
  75. getData();
  76. });
  77. };
  78. const getData = async () => {
  79. try {
  80. const res = await SHOP_COUPON_LIST(tabActive.value);
  81. detials.value = res.data || [];
  82. } catch (error) {
  83. Toast(error.msg);
  84. }
  85. };
  86. const toShop = () => {
  87. uni.navigateTo({ url: "/pages/index/products?channel=1" });
  88. };
  89. onShow(() => {
  90. nextTick(() => {
  91. getData();
  92. });
  93. });
  94. </script>
  95. <style lang="less" scoped>
  96. @import url("@/style.less");
  97. .wrap {
  98. background: var(--bg);
  99. min-height: 100vh;
  100. .content {
  101. flex-grow: 1;
  102. height: calc(100vh - 44px);
  103. flex-direction: column;
  104. .flex();
  105. .cont_tab {
  106. background-color: var(--light);
  107. padding: 0 48rpx;
  108. }
  109. .cont {
  110. flex-grow: 1;
  111. overflow: hidden scroll;
  112. padding: 24rpx;
  113. .item {
  114. .hor(space-between);
  115. margin-top: 16rpx;
  116. border-radius: 20rpx;
  117. box-shadow: 0px 8rpx 20rpx 0px var(--bor-color1);
  118. .item-left {
  119. .hor(space-between);
  120. flex-direction: column;
  121. padding: 24rpx 0 24rpx 24rpx;
  122. .item-left-top {
  123. .type {
  124. width: max-content;
  125. padding: 6rpx 16rpx;
  126. background: #eb3a68;
  127. color: var(--light);
  128. border-radius: 10rpx;
  129. .size(20rpx);
  130. text-align: center;
  131. }
  132. .name {
  133. color: var(--text);
  134. .size(28rpx);
  135. margin-top: 10rpx;
  136. }
  137. }
  138. .time {
  139. color: var(--text-02);
  140. .size(20rpx);
  141. }
  142. }
  143. .item-right {
  144. min-width: 240rpx;
  145. position: relative;
  146. text-align: center;
  147. background: linear-gradient(180deg, #e6704d 0%, #eb3e67 100%);
  148. border-radius: 0 20rpx 20rpx 0;
  149. padding: 24rpx;
  150. box-sizing: border-box;
  151. .price {
  152. color: var(--light);
  153. .size(44rpx);
  154. font-weight: 700;
  155. line-height: 44rpx;
  156. text {
  157. .size(28rpx);
  158. }
  159. }
  160. .status {
  161. color: var(--light);
  162. .size(24rpx);
  163. margin: 14rpx auto;
  164. }
  165. .use-btn {
  166. width: max-content;
  167. padding: 6rpx 10rpx;
  168. margin: 0 auto;
  169. background-color: var(--bg);
  170. color: #eb3a68;
  171. border-radius: 10rpx;
  172. .size(28rpx);
  173. }
  174. }
  175. }
  176. .null_warp {
  177. .null_text {
  178. min-height: 100rpx;
  179. .flex_center();
  180. .size(28rpx);
  181. color: #333;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. </style>