product.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // myComponents/product/product.js
  2. const app = getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. tableData:{
  9. type:Array,
  10. value:[],
  11. observers:function(val){
  12. // console.log(val)
  13. }
  14. },
  15. total:{
  16. type:Number,
  17. value:null
  18. }
  19. },
  20. /**
  21. * 组件的初始数据
  22. */
  23. data: {
  24. imgHttp:app.globalData.imgHttp
  25. },
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. //查看图片
  31. previewImage(e) {
  32. const { current,imglist } = e.currentTarget.dataset
  33. var imgs = []
  34. for(var i =0;i<imglist.length;i++){
  35. imgs.push(this.data.imgHttp + imglist[i].guid)
  36. }
  37. current = this.data.imgHttp + current
  38. wx.previewImage({
  39. current,
  40. urls:imgs,
  41. })
  42. },
  43. //打开关注类型
  44. open(e){
  45. var index = e.currentTarget.dataset.index
  46. this.setData({
  47. ['tableData['+ index + '].show'] : true
  48. })
  49. },
  50. //关闭关注类型
  51. cancel(e){
  52. var index = e.currentTarget.dataset.index
  53. this.setData({
  54. ['tableData['+ index + '].show'] : false
  55. })
  56. },
  57. //关注
  58. attention(e){
  59. var {type,index} = e.currentTarget.dataset
  60. },
  61. //监控
  62. control(e){
  63. var index = e.currentTarget.dataset.index
  64. },
  65. //加载更多
  66. loadMore(){
  67. this.triggerEvent('loadMore')
  68. }
  69. },
  70. /**
  71. * 组件的生命周期函数列表
  72. */
  73. lifetimes: {
  74. // 在组件实例进入页面节点树时执行
  75. attached: function () {
  76. // 初始化操作
  77. console.log(this.properties.tableData);
  78. // ...
  79. },
  80. // 在组件实例被移除出页面节点树时执行
  81. detached: function () {
  82. // 清理工作
  83. console.log('组件销毁');
  84. // ...
  85. },
  86. // ...
  87. },
  88. })