product.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. imgHttp:app.globalData.imgHttp
  21. },
  22. /**
  23. * 组件的方法列表
  24. */
  25. methods: {
  26. //查看图片
  27. previewImage(e) {
  28. const { current,imglist } = e.currentTarget.dataset
  29. var imgs = []
  30. for(var i =0;i<imglist.length;i++){
  31. imgs.push(this.data.imgHttp + imglist[i].guid)
  32. }
  33. current = this.data.imgHttp + current
  34. wx.previewImage({
  35. current,
  36. urls:imgs,
  37. })
  38. },
  39. //打开关注类型
  40. open(e){
  41. var index = e.currentTarget.dataset.index
  42. this.setData({
  43. ['tableData['+ index + '].show'] : true
  44. })
  45. },
  46. //关闭关注类型
  47. cancel(e){
  48. var index = e.currentTarget.dataset.index
  49. this.setData({
  50. ['tableData['+ index + '].show'] : false
  51. })
  52. },
  53. //关注
  54. attention(e){
  55. var {type,index} = e.currentTarget.dataset
  56. },
  57. //监控
  58. control(e){
  59. var index = e.currentTarget.dataset.index
  60. }
  61. },
  62. /**
  63. * 组件的生命周期函数列表
  64. */
  65. lifetimes: {
  66. // 在组件实例进入页面节点树时执行
  67. attached: function () {
  68. // 初始化操作
  69. console.log(this.properties.tableData);
  70. // ...
  71. },
  72. // 在组件实例被移除出页面节点树时执行
  73. detached: function () {
  74. // 清理工作
  75. console.log('组件销毁');
  76. // ...
  77. },
  78. // ...
  79. },
  80. })