template.nvue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="uni-container">
  3. <view class="uni-header-logo">
  4. <image class="uni-header-image" src="/static/templateIndex.png"></image>
  5. </view>
  6. <view class="uni-hello-text">
  7. <text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text>
  8. <u-link class="hello-link" href="https://ext.dcloud.net.cn" :text="'https://ext.dcloud.net.cn'" :inWhiteList="true"></u-link>
  9. </view>
  10. <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
  11. <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
  12. <text class="uni-panel-text">{{item.name}}</text>
  13. <text class="uni-panel-icon uni-icon" :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '&#xe581;' : '&#xe470;'}}</text>
  14. </view>
  15. <view class="uni-panel-c" v-if="item.open">
  16. <view class="uni-navigate-item" v-for="(item2,key) in item.pages" :key="key" @click="goDetailPage(item2)">
  17. <text class="uni-navigate-text">{{item2.name ? item2.name : item2}}</text>
  18. <text class="uni-navigate-icon uni-icon">&#xe470;</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. list: [
  29. // #ifdef APP-PLUS || H5 || MP-ALIPAY
  30. {
  31. id: 'navbar',
  32. name: '顶部原生导航标题栏',
  33. open: false,
  34. pages: [
  35. // #ifdef APP-PLUS || H5
  36. {
  37. name: '导航栏带自定义按钮',
  38. url: 'nav-button'
  39. },
  40. {
  41. name: '导航栏带红点和角标',
  42. url: 'nav-dot'
  43. },
  44. {
  45. name: '导航栏带城市选择',
  46. url: 'nav-city-dropdown'
  47. },
  48. {
  49. name: '导航栏带搜索框',
  50. url: 'nav-search-input'
  51. },
  52. // #endif
  53. // #ifdef APP-PLUS || H5 || MP-ALIPAY
  54. {
  55. name: '透明渐变样式',
  56. url: 'nav-transparent'
  57. },
  58. {
  59. name: '导航栏带图片',
  60. url: 'nav-image'
  61. }
  62. // #endif
  63. ]
  64. },
  65. // #endif
  66. // #ifndef QUICKAPP-WEBVIEW
  67. {
  68. name: '顶部选项卡',
  69. url: 'tabbar'
  70. },
  71. // #endif
  72. {
  73. name: '组件通讯',
  74. url: 'component-communication'
  75. },
  76. // #ifndef MP-QQ || QUICKAPP-WEBVIEW
  77. {
  78. name: 'uCharts 图表',
  79. url: 'ucharts'
  80. },
  81. // #endif
  82. // #ifndef QUICKAPP-WEBVIEW
  83. {
  84. name: '列表到详情示例',
  85. url: 'list2detail-list'
  86. },
  87. // #endif
  88. // #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
  89. {
  90. name: '上下滑动切换视频',
  91. url: 'swiper-vertical'
  92. },
  93. // #endif
  94. // #ifdef APP-NVUE
  95. {
  96. name: 'swiper-list',
  97. url: 'swiper-list-nvue'
  98. },
  99. // #endif
  100. {
  101. name: 'GlobalData和vuex',
  102. url: 'global'
  103. },
  104. // #ifdef APP-PLUS
  105. {
  106. name: '问题反馈',
  107. url: '/platforms/app-plus/feedback/feedback'
  108. },
  109. {
  110. name: '打开外部应用',
  111. url: 'scheme'
  112. },
  113. // #endif
  114. // #ifdef APP-PLUS || MP-WEIXIN || MP-QQ || H5
  115. {
  116. name: '微信自定义组件示例(vant ui)',
  117. url: 'vant-button'
  118. }
  119. // #endif
  120. ]
  121. }
  122. },
  123. onShareAppMessage() {
  124. return {
  125. title: '欢迎体验uni-app',
  126. path: '/pages/tabBar/template/template'
  127. }
  128. },
  129. onNavigationBarButtonTap(e) {
  130. uni.navigateTo({
  131. url: '/pages/about/about'
  132. });
  133. },
  134. methods: {
  135. triggerCollapse(e) {
  136. if (!this.list[e].pages) {
  137. this.goDetailPage(this.list[e].url);
  138. return;
  139. }
  140. for (var i = 0; i < this.list.length; ++i) {
  141. if (e === i) {
  142. this.list[i].open = !this.list[e].open;
  143. } else {
  144. this.list[i].open = false;
  145. }
  146. }
  147. },
  148. goDetailPage(e) {
  149. let path = e.url ? e.url : e;
  150. let url = ~path.indexOf('platform') ? path : '/pages/template/' + path + '/' + path;
  151. uni.navigateTo({
  152. url: url
  153. });
  154. return false;
  155. }
  156. }
  157. }
  158. </script>
  159. <style>
  160. @import '../../../common/uni-nvue.css';
  161. </style>