couponCenter.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div class="coupon-center">
  3. <BaseHeader></BaseHeader>
  4. <div class="content">
  5. <div>
  6. <div class="coupon-title">
  7. <router-link to="/">
  8. <img src="../assets/images/logo.png" width="120" alt="">
  9. </router-link>
  10. <p>领券中心</p>
  11. <Input search style="width:400px" @on-search='search' enter-button="搜索" placeholder="搜索优惠券" />
  12. </div>
  13. <div class="fontsize_18 recommend">推荐好券</div>
  14. <empty v-if="list.length===0" />
  15. <ul class="coupon-list" v-else>
  16. <li v-for="(item, index) in list" class="coupon-item" :key="index">
  17. <div class="c-left">
  18. <div>
  19. <span v-if="item.couponType === 'PRICE'" class="fontsize_12 global_color">¥<span class="price">{{item.price | unitPrice}}</span></span>
  20. <span v-if="item.couponType === 'DISCOUNT'" class="fontsize_12 global_color"><span class="price">{{item.couponDiscount}}</span>折</span>
  21. <span class="describe">满{{item.consumeThreshold}}元可用</span>
  22. </div>
  23. <p>使用范围:{{useScope(item.scopeType, item.storeName)}}</p>
  24. <p>有效期:{{item.endTime}}</p>
  25. </div>
  26. <b></b>
  27. <a class="c-right" @click="receive(item)">立即领取</a>
  28. <i class="circle-top"></i>
  29. <i class="circle-bottom"></i>
  30. </li>
  31. </ul>
  32. <Page :total="total" @on-change="changePageNum"
  33. v-if="list.length && total > params.pageNumber"
  34. class="pageration"
  35. @on-page-size-change="changePageSize"
  36. :page-size="params.pageSize"
  37. show-sizer>
  38. </Page>
  39. </div>
  40. </div>
  41. <BaseFooter></BaseFooter>
  42. </div>
  43. </template>
  44. <script>
  45. import {couponList, receiveCoupon} from '@/api/member.js'
  46. export default {
  47. data () {
  48. return {
  49. list: [], // 优惠券列表
  50. total: 0, // 优惠券总数
  51. params: { // 请求参数
  52. pageNumber: 1,
  53. pageSize: 20
  54. }
  55. }
  56. },
  57. methods: {
  58. search (item) {
  59. this.params.couponName = item
  60. this.params.pageNumber = 1
  61. this.getList()
  62. },
  63. getList () {
  64. this.$Spin.show()
  65. couponList(this.params).then(res => {
  66. this.$Spin.hide()
  67. this.loading = false
  68. if (res.success) {
  69. this.list = res.result.records
  70. this.total = res.result.total
  71. }
  72. }).catch(() => { this.$Spin.hide() })
  73. },
  74. changePageNum (val) {
  75. this.params.pageNumber = val;
  76. this.getList()
  77. },
  78. changePageSize (val) {
  79. this.pageNumber = 1;
  80. this.params.pageSize = val;
  81. this.getList()
  82. },
  83. receive (item) {
  84. receiveCoupon(item.id).then(res => {
  85. if (res.success) {
  86. this.$Modal.confirm({
  87. title: '领取优惠券',
  88. content: '<p>优惠券领取成功,可到我的优惠券页面查看</p>',
  89. okText: '我的优惠券',
  90. cancelText: '立即使用',
  91. onOk: () => {
  92. this.$router.push('/home/Coupons')
  93. },
  94. onCancel: () => {
  95. if (item.storeId !== 'platform') {
  96. this.$router.push({path: '/merchant', query: {id: item.storeId}})
  97. } else {
  98. if (item.scopeType === 'PORTION_GOODS_CATEGORY') {
  99. this.$router.push({path: '/goodsList', query: {categoryId: item.scopeId}})
  100. } else {
  101. this.$router.push({path: '/goodsList'})
  102. }
  103. }
  104. }
  105. });
  106. }
  107. })
  108. },
  109. useScope (type, storeName) {
  110. let shop = '平台';
  111. let goods = '全部商品'
  112. if (storeName !== 'platform') shop = storeName
  113. switch (type) {
  114. case 'ALL':
  115. goods = '全部商品'
  116. break;
  117. case 'PORTION_GOODS':
  118. goods = '部分商品'
  119. break;
  120. case 'PORTION_GOODS_CATEGORY':
  121. goods = '部分分类商品'
  122. break;
  123. }
  124. return `${shop}${goods}可用`
  125. }
  126. },
  127. mounted () {
  128. this.getList()
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. @import '../assets/styles/coupon.scss';
  134. .content{
  135. width: 100%;
  136. background-color: #fff;
  137. > div {
  138. margin: 10px auto;
  139. width: 1200px;
  140. }
  141. }
  142. .coupon-title {
  143. display: flex;
  144. align-items: center;
  145. p{
  146. font-size: 18px;
  147. margin-right: 500px;
  148. }
  149. border-bottom: 2px solid $theme_color;
  150. }
  151. .recommend {
  152. margin: 20px auto;
  153. font-weight: bold;
  154. width: 200px;
  155. text-align: center;
  156. }
  157. .coupon-item {
  158. b{
  159. background: url('../assets/images/small-circle.png') top left repeat-y;
  160. }
  161. }
  162. .pageration {
  163. text-align: right;
  164. padding-bottom: 10px;
  165. }
  166. </style>