blockItem.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // pages/components/blockItem/blockItem.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. item_data: {
  8. type:Object
  9. }
  10. },
  11. ready(){
  12. // console.log(this.properties.item_data);
  13. },
  14. /**
  15. * 组件的初始数据
  16. */
  17. data: {
  18. imgShow:false
  19. },
  20. /**
  21. * 组件的方法列表
  22. */
  23. methods: {
  24. navigator(e){
  25. const type = e.target.dataset.type;
  26. const target_data = e.target.dataset.target;
  27. const title = e.target.dataset.title;
  28. if(!type)return;
  29. switch(type){
  30. case "url":{
  31. let attr = encodeURIComponent(`${target_data}`);
  32. wx.navigateTo({
  33. url: '/pages/webView/webView?url='+attr
  34. })
  35. break;
  36. }
  37. case "special":{
  38. wx.navigateTo({
  39. url: `/pages/special/special?special_id=${target_data}&title=${title}`
  40. })
  41. break;
  42. }
  43. case "goods":{
  44. wx.navigateTo({
  45. url: `/pages/details/details?goods_id=${target_data}&title=商品详情`
  46. })
  47. break;
  48. }
  49. case "brand":{
  50. wx.navigateTo({
  51. url: `/pages/brand/brand?brand_id=${target_data}&title=${title}`
  52. })
  53. break;
  54. }
  55. default: {
  56. console.log(type+'类型找不到');
  57. }
  58. }
  59. },
  60. load(e){
  61. this.setData({
  62. imgShow:true
  63. });
  64. }
  65. }
  66. })