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.

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