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

174 行
3.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. 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. if(res.data){
  43. that.setData({
  44. kData:res.data,
  45. couponId: res.data.couponId
  46. });
  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. let param1 = {
  62. targetAd: 7,
  63. }
  64. Http.get({
  65. url: config.api.change,
  66. data: param1,
  67. }).then(res => {
  68. if(res.data){
  69. this.setData({
  70. pData:res.data,
  71. couponId1: res.data.couponId
  72. });
  73. }
  74. })
  75. .catch(err => {
  76. wx.showToast({
  77. title: err.errMsg,
  78. icon: 'none',
  79. duration: 2000,
  80. mask: false
  81. });
  82. })
  83. },
  84. // 换一换
  85. getChange(){
  86. if(this.data.couponId){
  87. let that = this;
  88. let param = {
  89. targetAd: 6,
  90. couponid:this.data.couponId
  91. }
  92. Http.get({
  93. url: config.api.change,
  94. data:param,
  95. }).then(res => {
  96. that.setData({
  97. kData:res.data,
  98. couponId: res.data.couponId
  99. });
  100. })
  101. .catch(err => {
  102. console.log(err)
  103. wx.showToast({
  104. title: err.errMsg,
  105. icon: 'none',
  106. duration: 2000,
  107. mask: false
  108. });
  109. })
  110. }
  111. if(this.data.couponId1){
  112. let param1 = {
  113. targetAd: 7,
  114. couponid1:this.data.couponId1
  115. }
  116. Http.get({
  117. url: config.api.change,
  118. data: param1,
  119. }).then(res => {
  120. this.setData({
  121. pData:res.data,
  122. couponId1: res.data.couponId
  123. });
  124. })
  125. .catch(err => {
  126. wx.showToast({
  127. title: err.errMsg,
  128. icon: 'none',
  129. duration: 2000,
  130. mask: false
  131. });
  132. })
  133. }
  134. },
  135. //跳转砍价详情
  136. gotokjdetail: function (e) {
  137. wx.navigateTo({
  138. url: `/pages/coupon/detail/index?couponChannelId=${
  139. e.currentTarget.dataset.couponchannelid
  140. }&couponId=${
  141. e.currentTarget.dataset.couponid
  142. }&targetAd=${
  143. e.currentTarget.dataset.targetad
  144. }`
  145. });
  146. },
  147. //跳转拼团详情
  148. gotoptdetail: function (e) {
  149. wx.navigateTo({
  150. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${
  151. e.currentTarget.dataset.couponchannelid
  152. }&couponId=${
  153. e.currentTarget.dataset.couponid
  154. }&targetAd=${
  155. e.currentTarget.dataset.targetad
  156. }`
  157. });
  158. },
  159. },
  160. ready() {
  161. app.couponChannelListCallback = token => {
  162. Http.setToken(token);
  163. this.getList();
  164. this.getptList();
  165. // this.getChange();
  166. };
  167. if (app.globalData.token && app.globalData.token != null) {
  168. app.couponChannelListCallback(app.globalData.token);
  169. }
  170. }
  171. });