index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. var app = getApp();
  2. Component({
  3. properties: {
  4. parameter:{
  5. type: Object,
  6. value:{
  7. class:'0'
  8. },
  9. },
  10. logoUrl:{
  11. type:String,
  12. value:'',
  13. }
  14. },
  15. data: {
  16. navH: ""
  17. },
  18. ready: function(){
  19. this.setClass();
  20. var pages = getCurrentPages();
  21. if (pages.length <= 1) this.setData({'parameter.return':0});
  22. },
  23. attached: function () {
  24. this.setData({
  25. navH: app.globalData.navHeight
  26. });
  27. },
  28. methods: {
  29. return:function(){
  30. var pages = getCurrentPages();
  31. wx.navigateBack({
  32. delta: pages.length-2
  33. });
  34. },
  35. setGoodsSearch:function(){
  36. wx.navigateTo({
  37. url: '/pages/goods_search/index',
  38. })
  39. },
  40. setClass:function(){
  41. var color = '';
  42. switch (this.data.parameter.class) {
  43. case "0": case 'on':
  44. color = 'on'
  45. break;
  46. case '1': case 'black':
  47. color = 'black'
  48. break;
  49. case '2': case 'gray':
  50. color = 'gray'
  51. break;
  52. case '3': case "red":
  53. color = 'red'
  54. break;
  55. case '4': case "gradual01":
  56. color = 'gradual01'
  57. break;
  58. default:
  59. break;
  60. }
  61. this.setData({
  62. 'parameter.class': color
  63. })
  64. }
  65. }
  66. })