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

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