index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // components/diy-group/index.js
  2. var Nova = getApp().Nova;
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. options: null,
  9. buybutton: {
  10. type: Number,
  11. value: 3,
  12. },
  13. },
  14. /**
  15. * 组件的初始数据
  16. */
  17. data: {
  18. timeData: {},
  19. },
  20. ready: function() { // 在组件布局完成后执行,确保options参数中有data信息
  21. this.loadData()
  22. },
  23. /**
  24. * 组件的方法列表
  25. */
  26. methods: {
  27. async loadData() {
  28. await Nova.checkComponentsDataProperties(this);
  29. console.log(this.data.options.data)
  30. let list = await Nova.getBlockData(this.data.options.data)
  31. let {
  32. options
  33. } = this.data
  34. console.log('拼团', options);
  35. list.forEach((li, index) => {
  36. let now = new Date()
  37. let endTime = new Date(li.endTime.iso).getTime()
  38. let time = (endTime - now.getTime()) > 0 ? (endTime - now.getTime()) : 0
  39. list[index].time = time
  40. list[index].timeDate = {}
  41. });
  42. let {
  43. column,
  44. data,
  45. style,
  46. } = options
  47. let {
  48. className,
  49. filter
  50. } = data
  51. this.setData({
  52. column,
  53. list,
  54. data,
  55. style,
  56. className,
  57. filter
  58. })
  59. console.log(this.data.list)
  60. },
  61. onChange(e) {
  62. let index = e.currentTarget.dataset.index
  63. let timeData = `list[${index}].timeDate`
  64. this.setData({
  65. [timeData]: e.detail,
  66. });
  67. },
  68. toUrl(e) {
  69. console.log(e)
  70. let id = e.currentTarget.dataset.id
  71. wx.navigateTo({
  72. url: '/nova-shop/pages/goods/groupBuy/discount/index?id=' + id
  73. });
  74. }
  75. }
  76. })