blockItem.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. },
  19. /**
  20. * 组件的方法列表
  21. */
  22. methods: {
  23. navigator(e){
  24. const type = e.target.dataset.type;
  25. const target_data = e.target.dataset.target;
  26. const title = e.target.dataset.title;
  27. if(!type)return;
  28. switch(type){
  29. case "url":{
  30. let attr = encodeURIComponent(`${target_data}&title=${title}`);
  31. console.log(attr);
  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. }
  61. })