index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const dateServ = require('../../../utils/date')
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. comments:{
  8. type:Array,
  9. default: []
  10. },
  11. title: {
  12. type:String,
  13. default: '评价列表'
  14. },
  15. showMore: {
  16. type:Boolean,
  17. default: false
  18. }
  19. },
  20. /**
  21. * 组件的初始数据
  22. */
  23. data: {
  24. },
  25. /**
  26. * 组件的方法列表
  27. */
  28. methods: {
  29. more(){
  30. this.triggerEvent('more')
  31. },
  32. preview(event){
  33. console.log(event);
  34. let image = event.currentTarget.dataset.image
  35. let comment = event.currentTarget.dataset.item
  36. wx.previewImage({
  37. current: image,
  38. urls: comment.images,
  39. success: function(res) {
  40. console.log(res)
  41. }
  42. })
  43. }
  44. },
  45. lifetimes: {
  46. async created() {},
  47. async attached() {// 在组件实例进入页面节点树时执行
  48. // console.log(this.comments);
  49. // let isarr = Array.isArray(this.comments)
  50. // if(!isarr){
  51. // this.comments = [this.comments]
  52. // }
  53. // console.log(this.comments);
  54. },
  55. moved() {},
  56. detached() {
  57. },
  58. ready: function () {// 在组件在视图层布局完成后执行
  59. // console.log(this.data);
  60. // this.data.comments.forEach(comment =>{
  61. // console.log(typeof comment.updatedAt);
  62. // if(typeof comment.updatedAt == 'date'){
  63. // return comment.updatedAt = dateServ.formatTime(comment.updatedAt,'YY-mm-dd hh:mm:ss')
  64. // }
  65. // return comment.updatedAt
  66. // })
  67. // this.setData({
  68. // comments:this.data.comments
  69. // })
  70. },
  71. },
  72. })