template.nvue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. import uLink from '@/components/uLink.vue'
  26. export default {
  27. components: {
  28. uLink
  29. },
  30. data() {
  31. return {
  32. list: [
  33. // #ifdef APP-PLUS || H5 || MP-ALIPAY
  34. {
  35. id: 'navbar',
  36. name: '顶部原生导航标题栏',
  37. open: false,
  38. pages: [
  39. // #ifdef APP-PLUS || H5
  40. {
  41. name: '导航栏带自定义按钮',
  42. url: 'nav-button'
  43. },
  44. {
  45. name: '导航栏带红点和角标',
  46. url: 'nav-dot'
  47. },
  48. {
  49. name: '导航栏带城市选择',
  50. url: 'nav-city-dropdown'
  51. },
  52. {
  53. name: '导航栏带搜索框',
  54. url: 'nav-search-input'
  55. },
  56. // #endif
  57. // #ifdef APP-PLUS || H5 || MP-ALIPAY
  58. {
  59. name: '透明渐变样式',
  60. url: 'nav-transparent'
  61. },
  62. {
  63. name: '导航栏带图片',
  64. url: 'nav-image'
  65. }
  66. // #endif
  67. ]
  68. },
  69. // #endif
  70. // #ifndef QUICKAPP-WEBVIEW
  71. {
  72. name: '顶部选项卡',
  73. url: 'tabbar'
  74. },
  75. // #endif
  76. {
  77. name: '组件通讯',
  78. url: 'component-communication'
  79. },
  80. // #ifndef MP-QQ || QUICKAPP-WEBVIEW
  81. {
  82. name: 'uCharts 图表',
  83. url: 'ucharts'
  84. },
  85. // #endif
  86. // #ifndef QUICKAPP-WEBVIEW
  87. {
  88. name: '列表到详情示例',
  89. url: 'list2detail-list'
  90. },
  91. // #endif
  92. // #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
  93. {
  94. name: '上下滑动切换视频',
  95. url: 'swiper-vertical'
  96. },
  97. // #endif
  98. // #ifdef APP-NVUE
  99. {
  100. name: 'swiper-list',
  101. url: 'swiper-list-nvue'
  102. },
  103. // #endif
  104. {
  105. name: 'GlobalData和vuex',
  106. url: 'global'
  107. },
  108. // #ifdef APP-PLUS
  109. {
  110. name: '问题反馈',
  111. url: '/platforms/app-plus/feedback/feedback'
  112. },
  113. {
  114. name: '打开外部应用',
  115. url: 'scheme'
  116. },
  117. // #endif
  118. // #ifdef APP-PLUS || MP-WEIXIN || MP-QQ || H5
  119. {
  120. name: '微信自定义组件示例(vant ui)',
  121. url: 'vant-button'
  122. }
  123. // #endif
  124. ],
  125. navigateFlag: false
  126. }
  127. },
  128. onLoad() {},
  129. onReady() {},
  130. onShareAppMessage() {
  131. return {
  132. title: '欢迎体验uni-app',
  133. path: '/pages/tabBar/template/template'
  134. }
  135. },
  136. onNavigationBarButtonTap(e) {
  137. uni.navigateTo({
  138. url: '/pages/about/about'
  139. });
  140. },
  141. methods: {
  142. triggerCollapse(e) {
  143. if (!this.list[e].pages) {
  144. this.goDetailPage(this.list[e].url);
  145. return;
  146. }
  147. for (var i = 0; i < this.list.length; ++i) {
  148. if (e === i) {
  149. this.list[i].open = !this.list[e].open;
  150. } else {
  151. this.list[i].open = false;
  152. }
  153. }
  154. },
  155. goDetailPage(e) {
  156. if (this.navigateFlag) {
  157. return;
  158. }
  159. this.navigateFlag = true;
  160. let path = e.url ? e.url : e;
  161. let url = ~path.indexOf('platform') ? path : '/pages/template/' + path + '/' + path;
  162. uni.navigateTo({
  163. url: url
  164. });
  165. setTimeout(() => {
  166. this.navigateFlag = false;
  167. }, 200)
  168. return false;
  169. }
  170. }
  171. }
  172. </script>
  173. <style>
  174. @import '../../../common/uni-nvue.css';
  175. </style>