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.

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