weal_center.vue 6.2 KB

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