C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

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