抖音小程序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.

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