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.

127 lines
2.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. 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. that.getList(1)
  84. }
  85. if (that.pSize != 1 && that.pSize != 0) {
  86. that.getList(2)
  87. }
  88. },
  89. //跳转砍价详情
  90. gotokjdetail: function (e) {
  91. wx.navigateTo({
  92. url: `/pages/coupon/detail/index?couponChannelId=${
  93. e.currentTarget.dataset.couponchannelid
  94. }&couponId=${
  95. e.currentTarget.dataset.couponid
  96. }&targetAd=${
  97. e.currentTarget.dataset.targetad
  98. }`
  99. });
  100. },
  101. //跳转拼团详情
  102. gotoptdetail: function (e) {
  103. wx.navigateTo({
  104. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${
  105. e.currentTarget.dataset.couponchannelid
  106. }&couponId=${
  107. e.currentTarget.dataset.couponid
  108. }&targetAd=${
  109. e.currentTarget.dataset.targetad
  110. }`
  111. });
  112. },
  113. },
  114. ready() {
  115. app.couponChannelListCallback = (token,val) => {
  116. Http.setToken(token);
  117. this.getList(1);
  118. this.getList(2);
  119. };
  120. if (app.globalData.token && app.globalData.token != null) {
  121. app.couponChannelListCallback(app.globalData.token);
  122. }
  123. }
  124. });