C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

88 lignes
1.9 KiB

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