C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

100 wiersze
1.7 KiB

  1. // pages/index/sw/index.js
  2. let config = require('../../../config/config.js')
  3. let Http = require('../../../utils/HttpBasics')
  4. const app = getApp()
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. },
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. tabs: [{
  16. key: 1,
  17. name: "全部"
  18. },
  19. {
  20. key: 2,
  21. name: "餐饮"
  22. },
  23. {
  24. key: 3,
  25. name: "娱乐"
  26. }, {
  27. key: 4,
  28. name: "服饰"
  29. }, {
  30. key: 5,
  31. name: "超市"
  32. },
  33. {
  34. key: 6,
  35. name: "亲子"
  36. }, {
  37. key: 7,
  38. name: "其他"
  39. },
  40. ],
  41. list: [],
  42. current: '1',
  43. current_scroll: '1',
  44. },
  45. /**
  46. * 组件的方法列表
  47. */
  48. methods: {
  49. handleChange({
  50. detail
  51. }) {
  52. this.setData({
  53. current: detail.key
  54. });
  55. },
  56. handleChangeScroll({
  57. detail
  58. }) {
  59. this.setData({
  60. current_scroll: detail.key
  61. });
  62. },
  63. },
  64. ready() {
  65. // TODO business获取
  66. if (app.globalData.token && app.globalData.token != null) {
  67. Http.get({
  68. url: config.api.couponList,
  69. data: {
  70. pageNum: 1,
  71. pageSize: 10
  72. }
  73. }).then(res => {
  74. console.log(res);
  75. this.setData({
  76. list: res.data.list
  77. })
  78. })
  79. } else {
  80. app.couponListCallback = token => {
  81. Http.get({
  82. url: config.api.couponList,
  83. data: {
  84. pageNum: 1,
  85. pageSize: 10
  86. }
  87. }).then(res => {
  88. console.log(res);
  89. this.setData({
  90. list: res.data.list
  91. })
  92. })
  93. }
  94. }
  95. }
  96. })