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.

127 lines
2.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. const bgColor = require("../../utils/bgColor.js")
  7. Component({
  8. /**
  9. * 组件的属性列表
  10. */
  11. properties: {},
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. sql: bgColor.colorFirst.main.sql,
  17. txt: bgColor.colorFirst.main.txt,
  18. change: imgurl.change.url,
  19. None: imgurl.None.url,
  20. jianUrl: imgurl.jian.url,
  21. barginicon: imgurl.barginicon.url,
  22. wangmeimeibargin: imgurl.wangmeimeibargin.url,
  23. list: [],
  24. pintuanList:[],
  25. total: '',
  26. flag:false,
  27. page:1,
  28. },
  29. /**
  30. * 组件的方法列表
  31. */
  32. methods: {
  33. //获取砍价列表
  34. getList() {
  35. let that = this;
  36. Http.get({
  37. url: config.api.couponChannelList,
  38. data: {
  39. pageNum: this.data.page++,
  40. pageSize: 1,
  41. targetAd: 6
  42. }
  43. }).then(res => {
  44. that.setData({
  45. list: res.data.list,
  46. total: res.data.total
  47. });
  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. //获取拼团列表
  60. getptList() {
  61. Http.get({
  62. url: config.api.couponChannelList,
  63. data: {
  64. pageNum: this.data.page++,
  65. pageSize: 1,
  66. targetAd: 7
  67. },
  68. }).then(res => {
  69. this.setData({
  70. pintuanList: res.data.list,
  71. total: res.data.total,
  72. flag: true
  73. });
  74. console.log(this.data.pintuanList)
  75. })
  76. .catch(err => {
  77. wx.showToast({
  78. title: err.errMsg,
  79. icon: 'none',
  80. duration: 2000,
  81. mask: false
  82. });
  83. })
  84. },
  85. // //换一换
  86. getChange(){
  87. },
  88. //跳转砍价详情
  89. gotokjdetail: function (e) {
  90. wx.navigateTo({
  91. url: `/pages/coupon/detail/index?couponChannelId=${
  92. e.currentTarget.dataset.couponchannelid
  93. }&couponId=${
  94. e.currentTarget.dataset.couponid
  95. }&targetAd=${
  96. e.currentTarget.dataset.targetad
  97. }`
  98. });
  99. },
  100. //跳转拼团详情
  101. gotoptdetail: function (e) {
  102. wx.navigateTo({
  103. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${
  104. e.currentTarget.dataset.couponchannelid
  105. }&couponId=${
  106. e.currentTarget.dataset.couponid
  107. }&targetAd=${
  108. e.currentTarget.dataset.targetad
  109. }`
  110. });
  111. },
  112. },
  113. ready() {
  114. app.couponChannelListCallback = token => {
  115. Http.setToken(token);
  116. this.getList();
  117. this.getptList();
  118. };
  119. if (app.globalData.token && app.globalData.token != null) {
  120. app.couponChannelListCallback(app.globalData.token);
  121. }
  122. }
  123. });