C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

103 lignes
2.3 KiB

  1. let config = require("../../../config/config.js");
  2. let Http = require("../../../utils/HttpBasics");
  3. // let Http = require("../../../utils/HttpBasics");
  4. const app = getApp();
  5. const imgurl = require("../../../utils/imgurl");
  6. Component({
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {},
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. list: [],
  16. cardlist:[],//消费卡列表
  17. total:''
  18. },
  19. /**
  20. * 组件的方法列表
  21. */
  22. methods: {
  23. rushtobuy: function (e) {
  24. wx.navigateTo({
  25. url: `/pages/coupon/detail/index?couponChannelId=${
  26. e.currentTarget.dataset.couponchannelid
  27. }&couponId=${e.currentTarget.dataset.couponid}`
  28. })
  29. },
  30. gotodiscountCardList: function (e) {
  31. wx.navigateTo({
  32. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.quancode}&couponId=${e.currentTarget.dataset.couponid}&cardType=${e.currentTarget.dataset.type}`
  33. });
  34. },
  35. //获取限时抢购列表
  36. getList(){
  37. Http.get({
  38. url: config.api.couponChannelList,
  39. data: {
  40. pageNum: 1,
  41. pageSize: 3,
  42. targetAd: 2
  43. }
  44. }).then(res => {
  45. this.setData({
  46. list: res.data.list,
  47. total: res.data.total,
  48. });
  49. })
  50. .catch(err => {
  51. console.log(err)
  52. wx.showToast({
  53. title: err.errMsg,
  54. icon: 'none',
  55. duration: 2000,
  56. mask: false
  57. });
  58. })
  59. },
  60. //获取消费卡列表
  61. getcardList() {
  62. Http.get({
  63. url: config.api.couponChannelList,
  64. data: {
  65. pageNum: 1,
  66. pageSize: 3,
  67. targetAd: 5
  68. }
  69. }).then(res => {
  70. this.setData({
  71. cardlist: res.data.list,
  72. total: res.data.total
  73. });
  74. })
  75. .catch(err => {
  76. console.log(err)
  77. wx.showToast({
  78. title: err.errMsg,
  79. icon: 'none',
  80. duration: 2000,
  81. mask: false
  82. });
  83. })
  84. }
  85. },
  86. ready() {
  87. app.couponChannelListCallback = token => {
  88. Http.setToken(token);
  89. this.getList();
  90. this.getcardList();
  91. };
  92. if (app.globalData.token && app.globalData.token != null) {
  93. app.couponChannelListCallback(app.globalData.token);
  94. }
  95. }
  96. });