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.

73 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. jianUrl: wx.getStorageSync('imgurl').jian.url,
  16. list: [],
  17. total:''
  18. },
  19. /**
  20. * 组件的方法列表
  21. */
  22. methods: {
  23. gotomore: function() {
  24. wx.navigateTo({
  25. url: "/pages/rushToBuy/index"
  26. });
  27. },
  28. gotodetail: function(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. this.setData({
  52. list: res.data.list,
  53. total:res.data.total
  54. });
  55. })
  56. .catch(err => {
  57. console.log(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. app.couponChannelListCallback(app.globalData.token);
  68. }
  69. }
  70. });