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

164 行
3.7 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. pData:[],
  25. couponId:'',
  26. couponId1: '',
  27. },
  28. /**
  29. * 组件的方法列表
  30. */
  31. methods: {
  32. //获取砍价列表
  33. getList() {
  34. let that = this;
  35. let param ={
  36. targetAd: 6,
  37. }
  38. Http.get({
  39. url: config.api.change,
  40. data:param,
  41. }).then(res => {
  42. that.setData({
  43. kData:res.data
  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. //获取拼团列表
  57. getptList() {
  58. let param1 = {
  59. targetAd: 7,
  60. }
  61. Http.get({
  62. url: config.api.change,
  63. data: param1,
  64. }).then(res => {
  65. this.setData({
  66. pData:res.data,
  67. couponId: res.data.couponId
  68. });
  69. console.log( this.data.couponId)
  70. })
  71. .catch(err => {
  72. wx.showToast({
  73. title: err.errMsg,
  74. icon: 'none',
  75. duration: 2000,
  76. mask: false
  77. });
  78. })
  79. },
  80. // 换一换
  81. getChange(){
  82. let param1 = {
  83. targetAd: 7,
  84. couponId: this.data.couponId1
  85. }
  86. Http.get({
  87. url: config.api.change,
  88. data: param1,
  89. }).then(res => {
  90. this.setData({
  91. pData: res.data,
  92. couponId1: res.data.couponId
  93. });
  94. })
  95. .catch(err => {
  96. wx.showToast({
  97. title: err.errMsg,
  98. icon: 'none',
  99. duration: 2000,
  100. mask: false
  101. });
  102. })
  103. let param = {
  104. targetAd: 6,
  105. couponId: this.data.couponId
  106. }
  107. Http.get({
  108. url: config.api.change,
  109. data: param,
  110. }).then(res => {
  111. this.setData({
  112. kData: res.data,
  113. couponId: res.data.couponId
  114. });
  115. })
  116. .catch(err => {
  117. console.log(err)
  118. wx.showToast({
  119. title: err.errMsg,
  120. icon: 'none',
  121. duration: 2000,
  122. mask: false
  123. });
  124. })
  125. },
  126. //跳转砍价详情
  127. gotokjdetail: function (e) {
  128. wx.navigateTo({
  129. url: `/pages/coupon/detail/index?couponChannelId=${
  130. e.currentTarget.dataset.couponchannelid
  131. }&couponId=${
  132. e.currentTarget.dataset.couponid
  133. }&targetAd=${
  134. e.currentTarget.dataset.targetad
  135. }`
  136. });
  137. },
  138. //跳转拼团详情
  139. gotoptdetail: function (e) {
  140. wx.navigateTo({
  141. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${
  142. e.currentTarget.dataset.couponchannelid
  143. }&couponId=${
  144. e.currentTarget.dataset.couponid
  145. }&targetAd=${
  146. e.currentTarget.dataset.targetad
  147. }`
  148. });
  149. },
  150. },
  151. ready() {
  152. app.couponChannelListCallback = token => {
  153. Http.setToken(token);
  154. this.getList();
  155. this.getptList();
  156. };
  157. if (app.globalData.token && app.globalData.token != null) {
  158. app.couponChannelListCallback(app.globalData.token);
  159. }
  160. }
  161. });