C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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