C端小程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

146 rader
3.4 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. // debugger
  37. let that = this;
  38. let param = ''
  39. if(val=='1'){
  40. param={
  41. targetAd : 6,
  42. couponId: this.data.couponId
  43. }
  44. }else{
  45. param = {
  46. targetAd : 7,
  47. couponId: this.data.couponId1
  48. }
  49. }
  50. Http.get({
  51. url: config.api.change,
  52. data:param,
  53. }).then(res => {
  54. console.log(res)
  55. console.log(123)
  56. if(res.data != undefined && res.data){
  57. if(val=='1'){
  58. that.setData({
  59. kData: res.data.data,
  60. kSize: res.data.size,
  61. couponId: res.data.data.couponId,
  62. });
  63. }else{
  64. that.setData({
  65. pData: res.data.data,
  66. pSize:res.data.size,
  67. couponId1: res.data.data.couponId
  68. });
  69. }
  70. } else {
  71. if(val=='1'){
  72. that.setData({
  73. kData: '',
  74. kSize: '',
  75. couponId: '',
  76. });
  77. }else{
  78. that.setData({
  79. pData: '',
  80. pSize:'',
  81. couponId1: ''
  82. });
  83. }
  84. }
  85. })
  86. .catch(err => {
  87. console.log(err)
  88. wx.showToast({
  89. title: err.errMsg,
  90. icon: 'none',
  91. duration: 2000,
  92. mask: false
  93. });
  94. })
  95. },
  96. // 换一换
  97. getChange(){
  98. let that = this
  99. if (that.kSize != 1 && that.kSize != 0){
  100. that.getList(1)
  101. }
  102. if (that.pSize!=1 && that.pSize !=0) {
  103. that.getList(2)
  104. }
  105. },
  106. //跳转砍价详情
  107. gotokjdetail: function (e) {
  108. wx.navigateTo({
  109. url: `/pages/coupon/detail/index?couponChannelId=${
  110. e.currentTarget.dataset.couponchannelid
  111. }&couponId=${
  112. e.currentTarget.dataset.couponid
  113. }&targetAd=${
  114. e.currentTarget.dataset.targetad
  115. }`
  116. });
  117. },
  118. //跳转拼团详情
  119. gotoptdetail: function (e) {
  120. wx.navigateTo({
  121. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${
  122. e.currentTarget.dataset.couponchannelid
  123. }&couponId=${
  124. e.currentTarget.dataset.couponid
  125. }&targetAd=${
  126. e.currentTarget.dataset.targetad
  127. }`
  128. });
  129. },
  130. },
  131. ready() {
  132. app.couponChannelListCallback = (token,val) => {
  133. Http.setToken(token);
  134. this.getList(1);
  135. this.getList(2);
  136. };
  137. if (app.globalData.token && app.globalData.token != null) {
  138. app.couponChannelListCallback(app.globalData.token);
  139. }
  140. }
  141. });