C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

130 行
3.0 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. kData:[],
  24. kSize:'',
  25. pSize: '',
  26. pData:[],
  27. couponId:'',
  28. couponId1: '',
  29. },
  30. /**
  31. * 组件的方法列表
  32. */
  33. methods: {
  34. //获取砍价拼团数据
  35. getList(val) {
  36. let that = this;
  37. let param = ''
  38. if(val=='1'){
  39. param={
  40. targetAd : 6,
  41. couponId: this.data.couponId
  42. }
  43. }else{
  44. param = {
  45. targetAd : 7,
  46. couponId: this.data.couponId1
  47. }
  48. }
  49. Http.get({
  50. url: config.api.change,
  51. data:param,
  52. }).then(res => {
  53. if(res.data){
  54. if(val=='1'){
  55. that.setData({
  56. kData: res.data.data,
  57. kSize: res.data.size,
  58. couponId: res.data.data.couponId,
  59. });
  60. }else{
  61. that.setData({
  62. pData: res.data.data,
  63. pSize:res.data.size,
  64. couponId1: res.data.data.couponId
  65. });
  66. }
  67. }
  68. })
  69. .catch(err => {
  70. console.log(err)
  71. wx.showToast({
  72. title: err.errMsg,
  73. icon: 'none',
  74. duration: 2000,
  75. mask: false
  76. });
  77. })
  78. },
  79. // 换一换
  80. getChange(){
  81. let that = this
  82. if (that.kSize != 1 && that.kSize != 0){
  83. console.log(111111111111)
  84. that.getList(1)
  85. }
  86. if (that.pSize!=1 && that.pSize !=0) {
  87. console.log(22222222222)
  88. that.getList(2)
  89. }
  90. },
  91. //跳转砍价详情
  92. gotokjdetail: function (e) {
  93. wx.navigateTo({
  94. url: `/pages/coupon/detail/index?couponChannelId=${
  95. e.currentTarget.dataset.couponchannelid
  96. }&couponId=${
  97. e.currentTarget.dataset.couponid
  98. }&targetAd=${
  99. e.currentTarget.dataset.targetad
  100. }`
  101. });
  102. },
  103. //跳转拼团详情
  104. gotoptdetail: function (e) {
  105. wx.navigateTo({
  106. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${
  107. e.currentTarget.dataset.couponchannelid
  108. }&couponId=${
  109. e.currentTarget.dataset.couponid
  110. }&targetAd=${
  111. e.currentTarget.dataset.targetad
  112. }`
  113. });
  114. },
  115. },
  116. ready() {
  117. app.couponChannelListCallback = (token,val) => {
  118. Http.setToken(token);
  119. this.getList(1);
  120. this.getList(2);
  121. };
  122. if (app.globalData.token && app.globalData.token != null) {
  123. app.couponChannelListCallback(app.globalData.token);
  124. }
  125. }
  126. });