C端小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

111 righe
2.5 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. gotoRushList:function(){
  31. wx.navigateTo({
  32. url: '/pages/rushToBuy/index',
  33. })
  34. },
  35. gotoCardList:function(){
  36. wx.navigateTo({
  37. url: '/pages/discountCardList/discountCardList',
  38. })
  39. },
  40. gotodiscountCardList: function (e) {
  41. wx.navigateTo({
  42. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.quancode}&couponId=${e.currentTarget.dataset.couponid}&cardType=${e.currentTarget.dataset.type}`
  43. });
  44. },
  45. //获取限时抢购列表
  46. getList(){
  47. Http.get({
  48. url: config.api.couponChannelList,
  49. data: {
  50. pageNum: 1,
  51. pageSize: 3,
  52. targetAd: 2
  53. }
  54. }).then(res => {
  55. this.setData({
  56. list: res.data.list,
  57. total: res.data.total,
  58. });
  59. })
  60. .catch(err => {
  61. console.log(err)
  62. wx.showToast({
  63. title: err.errMsg,
  64. icon: 'none',
  65. duration: 2000,
  66. mask: false
  67. });
  68. })
  69. },
  70. //获取消费卡列表
  71. getcardList() {
  72. Http.get({
  73. url: config.api.couponChannelList,
  74. data: {
  75. pageNum: 1,
  76. pageSize: 3,
  77. targetAd: 5
  78. }
  79. }).then(res => {
  80. this.setData({
  81. cardlist: res.data.list,
  82. total: res.data.total
  83. });
  84. })
  85. .catch(err => {
  86. console.log(err)
  87. wx.showToast({
  88. title: err.errMsg,
  89. icon: 'none',
  90. duration: 2000,
  91. mask: false
  92. });
  93. })
  94. }
  95. },
  96. ready() {
  97. app.couponChannelListCallback = token => {
  98. Http.setToken(token);
  99. this.getList();
  100. this.getcardList();
  101. };
  102. if (app.globalData.token && app.globalData.token != null) {
  103. app.couponChannelListCallback(app.globalData.token);
  104. }
  105. }
  106. });