index.ux 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <import name="home-page" src="../Home/index.ux"></import>
  2. <import name="category-page" src="../Category/index.ux"></import>
  3. <import name="shelf-page" src="../Shelf/index.ux"></import>
  4. <import name="my-page" src="../My/index.ux"></import>
  5. <template>
  6. <stack class="stack-wrap">
  7. <div class="index-wrap">
  8. <tabs class="tab-content" onchange="tabbarChange" index="{{current}}">
  9. <tab-content>
  10. <home-page @change="pageSwitch"></home-page>
  11. <category-page></category-page>
  12. <shelf-page @change="pageSwitch"></shelf-page>
  13. <my-page @customer="openCustomer"></my-page>
  14. </tab-content>
  15. </tabs>
  16. <div class="fixed-tabbar">
  17. <image src="../../assets/imgs/shadow.png" class="shadow"></image>
  18. <div class="tabbar-item__wrap">
  19. <block for="tab in tabbar">
  20. <div class="tabbar-item " @click="tabbarChange(tab)">
  21. <image src="{{tab.index === current ? tab.active_icon : tab.icon}}"></image>
  22. <text class="{{tab.index === current ? 'tabbar-name__cur' : ''}}">{{tab.name}}</text>
  23. </div>
  24. </block>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="stack-popup" @click="closeWrap" if="showPopup">
  29. <div class="customer-popup" @click="copyWechat">
  30. <text class="title">联系客服</text>
  31. <image src="{{$app.$def.data.cutomerQrcode}}"></image>
  32. </div>
  33. </div>
  34. </stack>
  35. </template>
  36. <script>
  37. export default {
  38. private: {
  39. tabbar: [
  40. {
  41. name: "首页",
  42. title: "追书云",
  43. icon: "../../assets/imgs/home.png",
  44. active_icon: "../../assets/imgs/home_choose.png",
  45. index: 0
  46. },
  47. {
  48. name: "分类",
  49. title: "书城",
  50. icon: "../../assets/imgs/category.png",
  51. active_icon: "../../assets/imgs/category_choose.png",
  52. index: 1
  53. },
  54. {
  55. name: "书架",
  56. title: "我的书架",
  57. icon: "../../assets/imgs/shelf.png",
  58. active_icon: "../../assets/imgs/shelf_choose.png",
  59. index: 2
  60. },
  61. {
  62. name: "我的",
  63. title: "个人中心",
  64. icon: "../../assets/imgs/my.png",
  65. active_icon: "../../assets/imgs/my_choose.png",
  66. index: 3
  67. }
  68. ],
  69. current: 1,
  70. showPopup: false
  71. },
  72. onBackPress() {
  73. // 退出逻辑
  74. if (this.$app.$def.data.backClickCount === 0) {
  75. this.$app.$def.data.backClickCount++;
  76. this.$app.$def.createShortcut()
  77. return true;
  78. }
  79. },
  80. /**
  81. * 当用户点击菜单按钮时触发,调用app中定义的方法showMenu
  82. * 注意:使用加载器测试`创建桌面快捷方式`功能时,请先在`系统设置`中打开`应用加载器`的`桌面快捷方式`权限
  83. */
  84. onMenuPress() {
  85. this.$app.$def.showMenu();
  86. },
  87. tabbarChange(tab) {
  88. this.current = tab.index;
  89. this.$page.setTitleBar({ text: this.tabbar[tab.index].title });
  90. },
  91. pageSwitch() {
  92. this.current = 1;
  93. },
  94. closeWrap() {
  95. this.showPopup = false;
  96. },
  97. copyWechat(e) {
  98. e.stopPropagation();
  99. },
  100. openCustomer() {
  101. this.showPopup = true;
  102. }
  103. }
  104. </script>
  105. <style lang="less">
  106. @import "../../assets/less/index.less";
  107. </style>