C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.6 KiB

  1. // pages/index/sw/index.js
  2. let config = require("../../../config/config.js");
  3. let Http = require("../../../utils/HttpBasics");
  4. // let Http = require("../../../utils/HttpBasics");
  5. const app = getApp();
  6. Component({
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {},
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. list: [],
  16. total:''
  17. },
  18. /**
  19. * 组件的方法列表
  20. */
  21. methods: {
  22. gotomore: function() {
  23. wx.navigateTo({
  24. url: "/pages/rushToBuy/index"
  25. });
  26. },
  27. gotodetail: function(e) {
  28. console.log(e);
  29. wx.navigateTo({
  30. url: `/pages/coupon/detail/index?couponChannelId=${
  31. e.currentTarget.dataset.couponchannelid
  32. }&couponId=${
  33. e.currentTarget.dataset.couponid
  34. }&targetAd=${
  35. e.currentTarget.dataset.targetad
  36. }`
  37. });
  38. }
  39. },
  40. ready() {
  41. app.couponChannelListCallback = token => {
  42. Http.setToken(token);
  43. Http.get({
  44. url: config.api.couponChannelList,
  45. data: {
  46. pageNum: 1,
  47. pageSize: 5,
  48. targetAd: 2
  49. }
  50. }).then(res => {
  51. console.log(res);
  52. this.setData({
  53. list: res.data.list,
  54. total:res.data.total
  55. });
  56. })
  57. .catch(err => {
  58. wx.showToast({
  59. title: err.errMsg,
  60. icon: 'none',
  61. duration: 2000,
  62. mask: false
  63. });
  64. })
  65. };
  66. if (app.globalData.token && app.globalData.token != null) {
  67. console.log("couponChannelList init 1");
  68. app.couponChannelListCallback(app.globalData.token);
  69. }
  70. }
  71. });