C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.5 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. wx.navigateTo({
  29. url: `/pages/coupon/detail/index?couponChannelId=${
  30. e.currentTarget.dataset.couponchannelid
  31. }&couponId=${
  32. e.currentTarget.dataset.couponid
  33. }&targetAd=${
  34. e.currentTarget.dataset.targetad
  35. }`
  36. });
  37. }
  38. },
  39. ready() {
  40. app.couponChannelListCallback = token => {
  41. Http.setToken(token);
  42. Http.get({
  43. url: config.api.couponChannelList,
  44. data: {
  45. pageNum: 1,
  46. pageSize: 5,
  47. targetAd: 2
  48. }
  49. }).then(res => {
  50. this.setData({
  51. list: res.data.list,
  52. total:res.data.total
  53. });
  54. })
  55. .catch(err => {
  56. console.log(err)
  57. wx.showToast({
  58. title: err.errMsg,
  59. icon: 'none',
  60. duration: 2000,
  61. mask: false
  62. });
  63. })
  64. };
  65. if (app.globalData.token && app.globalData.token != null) {
  66. app.couponChannelListCallback(app.globalData.token);
  67. }
  68. }
  69. });