微信

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class="mainPage">
  3. <div class="box">
  4. <discounts @toUse='toUse' :data='item' @toDetail="toDetail" v-for="(item,index) in list" :key="index"></discounts>
  5. <noMore v-if="hasPic"></noMore>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. import line from '../../../common/icon/cicyle.png'
  11. import logo from '../../../common/icon/logo-t.png'
  12. import Line3 from '../../../common/icon/Line3.png'
  13. import used from '../../../common/icon/already.png'
  14. import failure from '../../../common/icon/inv.png'
  15. // 上拉加载组件
  16. import scroll from '../../../components/scroll/scroll'
  17. import noMore from '../../../components/noMore/noMore'
  18. import discounts from '../../../components/discounts/discounts'
  19. import { mapState, createNamespacedHelpers } from 'vuex'
  20. const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
  21. export default {
  22. data () {
  23. return {
  24. logo,
  25. Line3,
  26. used,
  27. failure,
  28. pullUpLoad: true,
  29. pullUpLoadThreshold: 40,
  30. startY: 0,
  31. isloading: true,
  32. hasPic: false,
  33. hasMore: true,
  34. list: [],
  35. line
  36. }
  37. },
  38. components: {
  39. scroll,
  40. noMore,
  41. discounts
  42. },
  43. created () {
  44. this.getCouponList().then((res) => {
  45. // console.log(JSON.stringify(res))
  46. // console.log(JSON.stringify(this.couponList))
  47. for (var n = 0; n < res.length; n++) {
  48. this.list.push({
  49. title: res[n].Coupon.CouponName,
  50. desc: res[n].Coupon.Share.UseInstruction,
  51. time: this.toolClass.dateFormat(res[n].EndDate),
  52. useType: res[n].Status === 1 ? '未使用' : '已使用',
  53. tag: res[n].Coupon.CouponType === 'coupon' ? '课程' : '商品',
  54. customercouponid: res[n].CustomerCouponId,
  55. couponid: res[n].Coupon.CouponId,
  56. Coupon: res[n].Coupon
  57. })
  58. }
  59. })
  60. },
  61. methods: {
  62. ...caseTableActions([
  63. 'getCouponList',
  64. ]),
  65. change (item, index) {
  66. this.active = index
  67. },
  68. toUse (item) {
  69. console.log(item)
  70. if (item.Coupon.Targets.length > 1) {
  71. this.$router.push({ name: 'indexPage' })
  72. } else {
  73. if (item.tag === '商品') {
  74. this.$router.push({ name: 'coffeeIndex' })
  75. } else {
  76. this.$router.push({ name: 'majorProjectsDetail', query: { id: item.Coupon.Targets[0].TargetId } })
  77. }
  78. }
  79. },
  80. toDetail (item) {
  81. this.$router.push({ name: 'couponsDetail', query: { id: item.customercouponid } })
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. @import 'page.scss';
  88. </style>