coupon.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <!--
  2. * @Author: wangwei
  3. * @Date: 2020-12-29 16:05:36
  4. * @LastEditTime: 2021-01-09 20:57:53
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 我的优惠卷
  7. * @FilePath: /java-pc/src/views/member/Header.vue
  8. -->
  9. <template>
  10. <div class="sld_my_coupon">
  11. <MemberTitle :memberTitle="L['我的优惠卷']"></MemberTitle>
  12. <div class="my_coupon_con">
  13. <div class="nav_list">
  14. <!-- <p>{{L['我的优惠卷']}}</p> -->
  15. <div class="con flex">
  16. <div
  17. class="nav_item"
  18. :class="{ active: use_state == 1, pointer: true }"
  19. @click="changeState(1)"
  20. >
  21. {{ L["未使用"] }}
  22. </div>
  23. <div
  24. class="nav_item"
  25. :class="{ active: use_state == 2, pointer: true }"
  26. @click="changeState(2)"
  27. >
  28. {{ L["已使用"] }}
  29. </div>
  30. <div
  31. class="nav_item"
  32. :class="{ active: use_state == 3, pointer: true }"
  33. @click="changeState(3)"
  34. >
  35. {{ L["已过期"] }}
  36. </div>
  37. </div>
  38. </div>
  39. <div class="coupon_container flex_row_start_center">
  40. <div
  41. class="coupon_item"
  42. v-for="(couponItem, index) in coupon_list.data"
  43. :key="index"
  44. :style="{
  45. backgroundImage:
  46. 'url(' +
  47. (couponItem.useState == 1 ? coupon_bg : have_used_bg) +
  48. ')',
  49. }"
  50. >
  51. <img
  52. v-if="couponItem.useState == 2"
  53. class="out_logo"
  54. :src="have_used_logo"
  55. alt=""
  56. />
  57. <img
  58. v-if="couponItem.useState == 3"
  59. class="out_logo"
  60. :src="have_out_time"
  61. alt=""
  62. />
  63. <div v-if="couponItem.couponType == 1" class="price">
  64. <span>¥ </span>
  65. <span>{{ couponItem.publishValue }}</span>
  66. </div>
  67. <div v-if="couponItem.couponType == 2" class="count price">
  68. <span></span>
  69. <span>{{ couponItem.publishValue }}</span>
  70. <span>折</span>
  71. </div>
  72. <div v-if="couponItem.couponType == 3" class="price random">
  73. <span>¥ </span>
  74. <span>{{ couponItem.publishValue }}</span>
  75. </div>
  76. <div class="content">{{ couponItem.couponContent }}</div>
  77. <div class="time">
  78. {{ couponItem.effectiveStart }}-{{ couponItem.effectiveEnd }}
  79. </div>
  80. <div :class="{ type: true, used: couponItem.useState != 1 }">
  81. {{ couponItem.couponTypeValue }}
  82. </div>
  83. <div class="rules overflow_ellipsis_two">
  84. <span class="title">{{ L["使用规则"] }}:</span>
  85. <span>{{ couponItem.description }}</span>
  86. </div>
  87. <div class="btn">
  88. <span
  89. class="normal pointer"
  90. @click="goGoodsList(couponItem)"
  91. v-if="couponItem.useState == 1"
  92. >{{ L["立即使用"] }} ></span
  93. >
  94. <span v-if="couponItem.useState == 2">{{ L["已使用"] }}</span>
  95. <span v-if="couponItem.useState == 3">{{ L["已过期"] }}</span>
  96. </div>
  97. </div>
  98. <SldCommonEmpty
  99. v-show="!coupon_list.data.length"
  100. totalWidth="900"
  101. ></SldCommonEmpty>
  102. </div>
  103. <el-pagination
  104. @current-change="handleCurrentChange"
  105. :currentPage="pageData.current"
  106. :page-size="pageData.pageSize"
  107. layout="prev, pager, next, jumper"
  108. :total="pageData.total"
  109. :hide-on-single-page="true"
  110. class="flex_row_end_center"
  111. ></el-pagination>
  112. </div>
  113. </div>
  114. </template>
  115. <script setup>
  116. import { ElMessage } from "element-plus";
  117. import { getCurrentInstance, ref, onMounted, reactive } from "vue";
  118. // import { lang_zn } from "@/assets/language/zh";
  119. import { getCurLanguage } from '@/composables/common.js';
  120. // const L = lang_zn;
  121. const L = getCurLanguage();
  122. definePageMeta({
  123. layout: "member",
  124. middleware: ["auth"],
  125. });
  126. const { proxy } = getCurrentInstance();
  127. const use_state = ref(1);
  128. const router = useRouter();
  129. const coupon_list = reactive({ data: [] });
  130. const coupon_bg = ref("/coupon/coupon_bg.png");
  131. const have_used_bg = ref("/coupon/have_used_bg.png");
  132. const have_used_logo = ref("/coupon/have_used_logo.png");
  133. const have_out_time = ref("/coupon/have_out_time.png");
  134. const pageData = reactive({
  135. current: 1,
  136. pageSize: 8,
  137. total: 0,
  138. });
  139. const getCouponList = () => {
  140. var param = {};
  141. param.useState = use_state.value;
  142. param.current = pageData.current;
  143. param.pageSize = pageData.pageSize;
  144. get("v3/promotion/front/coupon/list", param)
  145. .then((res) => {
  146. if (res.state == 200) {
  147. coupon_list.data = res.data.list;
  148. pageData.total = res.data.pagination.total;
  149. } else {
  150. ElMessage(res.msg);
  151. }
  152. })
  153. .catch(() => {
  154. //异常处理
  155. });
  156. };
  157. //去优惠券对应的商品列表
  158. const goGoodsList = (item) => {
  159. if (item.useState == "1") {
  160. let params = {};
  161. if (item.storeId > 0) {
  162. params.storeId = item.storeId;
  163. }
  164. if (item.useType == 2 && item.goodsIds) {
  165. params.goodsIds = item.goodsIds;
  166. } else if (item.useType == 3 && item.cateIds) {
  167. params.categoryId = item.cateIds;
  168. }
  169. let newWin = router.resolve({
  170. path: "/goods/list",
  171. query: params,
  172. });
  173. window.open(newWin.href, "_blank");
  174. }
  175. };
  176. //切换
  177. const changeState = (state) => {
  178. pageData.current = 1;
  179. use_state.value = state;
  180. getCouponList();
  181. };
  182. //向前翻页
  183. const handlePrevCilickChange = () => {
  184. pageData.current--;
  185. getCouponList();
  186. };
  187. //向后翻页
  188. const handleNextCilickChange = () => {
  189. pageData.current++;
  190. getCouponList();
  191. };
  192. //页数改变
  193. const handleCurrentChange = (current) => {
  194. pageData.current = current;
  195. getCouponList();
  196. };
  197. onMounted(() => {
  198. getCouponList();
  199. });
  200. </script>
  201. <style lang="scss" scoped>
  202. @use "@/assets/style/coupon.scss" as *;
  203. </style>