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.

79 line
1.7 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. barginicon: imgurl.barginicon.url,
  18. list: [],
  19. total:''
  20. },
  21. /**
  22. * 组件的方法列表
  23. */
  24. methods: {
  25. getList() {
  26. let that = this;
  27. Http.get({
  28. url: config.api.couponChannelList,
  29. data: {
  30. pageNum: 1,
  31. pageSize: 5,
  32. targetAd: 6
  33. }
  34. }).then(res => {
  35. that.setData({
  36. list: res.data.list,
  37. total: res.data.total
  38. });
  39. })
  40. .catch(err => {
  41. console.log(err)
  42. wx.showToast({
  43. title: err.errMsg,
  44. icon: 'none',
  45. duration: 2000,
  46. mask: false
  47. });
  48. })
  49. },
  50. gotomore: function() {
  51. wx.navigateTo({
  52. url: "/pages/bargain/bargain"
  53. });
  54. },
  55. gotodetail: function(e) {
  56. wx.navigateTo({
  57. url: `/pages/coupon/detail/index?couponChannelId=${
  58. e.currentTarget.dataset.couponchannelid
  59. }&couponId=${
  60. e.currentTarget.dataset.couponid
  61. }&targetAd=${
  62. e.currentTarget.dataset.targetad
  63. }`
  64. });
  65. }
  66. },
  67. ready() {
  68. app.couponChannelListCallback = token => {
  69. Http.setToken(token);
  70. this.getList();
  71. };
  72. if (app.globalData.token && app.globalData.token != null) {
  73. app.couponChannelListCallback(app.globalData.token);
  74. }
  75. }
  76. });