cu-custom.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const app = getApp();
  2. Component({
  3. /**
  4. * 组件的一些选项
  5. */
  6. options: {
  7. addGlobalClass: true,
  8. multipleSlots: true
  9. },
  10. /**
  11. * 组件的对外属性
  12. */
  13. properties: {
  14. bgColor: {
  15. type: String,
  16. default: ''
  17. },
  18. isCustom: {
  19. type: [Boolean, String],
  20. default: false
  21. },
  22. isBack: {
  23. type: [Boolean, String],
  24. default: false
  25. },
  26. isShare:{
  27. type: [Boolean, String],
  28. default: false
  29. },
  30. bgImage: {
  31. type: String,
  32. default: ''
  33. },
  34. },
  35. /**
  36. * 组件的初始数据
  37. */
  38. data: {
  39. StatusBar: app.globalData.StatusBar,
  40. CustomBar: app.globalData.CustomBar,
  41. Custom: app.globalData.Custom
  42. },
  43. /**
  44. * 组件的方法列表
  45. */
  46. methods: {
  47. BackPage() {
  48. if( this.data.isShare ){
  49. console.log( "share to home" );
  50. wx.reLaunch({
  51. url: '/pages/index/index',
  52. });
  53. }else{
  54. console.log("back");
  55. wx.navigateBack({
  56. delta: 1
  57. });
  58. }
  59. },
  60. toHome(){
  61. console.log("tohome")
  62. let curPage = getCurrentPages()
  63. let index = -1;
  64. for( let i in curPage){
  65. let route = curPage[i].route.split("?")[0];
  66. if (route == 'pages/index/index'){
  67. index = i;
  68. break;
  69. }
  70. }
  71. if( index == -1){
  72. wx.reLaunch({
  73. url: '/pages/index/index',
  74. })
  75. }else{
  76. wx.navigateBack({
  77. delta: curPage.length - index-1
  78. })
  79. }
  80. }
  81. }
  82. })