template.nvue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="uni-container">
  3. <view v-if="!hasLeftWin" class="uni-header-logo">
  4. <image class="uni-header-image" src="/static/templateIndex.png"></image>
  5. </view>
  6. <view v-if="!hasLeftWin" 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'"
  9. :inWhiteList="true"></u-link>
  10. </view>
  11. <view :class="{'pc-hide': hideList.indexOf(item.url) !== -1 && hasLeftWin}" class="uni-panel"
  12. v-for="(item, index) in list" :key="item.id">
  13. <view
  14. :class="{'left-win-active': leftWinActive === item.url && hasLeftWin, 'uni-panel-h-on': item.open}"
  15. class="uni-panel-h" @click="triggerCollapse(index, item.id)">
  16. <text class="uni-panel-text">{{item.name}}</text>
  17. <text class="uni-panel-icon uni-icon"
  18. :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '&#xe581;' : '&#xe470;'}}</text>
  19. </view>
  20. <view class="uni-panel-c" v-if="item.open ">
  21. <view
  22. :class="{'left-win-active': leftWinActive === item2.url && hasLeftWin, 'pc-hide': hideList.indexOf(item2.url) !== -1 && hasLeftWin}"
  23. class="uni-navigate-item" v-for="(item2,key) in item.pages" :key="key" @click="goDetailPage(item2)">
  24. <text class="uni-navigate-text">{{item2.name ? item2.name : item2}}</text>
  25. <text class="uni-navigate-icon uni-icon">&#xe470;</text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. hasLeftWin: {
  35. type: Boolean
  36. },
  37. leftWinActive: {
  38. type: String
  39. }
  40. },
  41. data() {
  42. return {
  43. hideList: [
  44. 'ucharts',
  45. 'nav-city-dropdown'
  46. ],
  47. list: [
  48. // #ifdef APP-PLUS || H5 || MP-ALIPAY
  49. {
  50. id: 'navbar',
  51. name: '顶部原生导航标题栏',
  52. open: false,
  53. pages: [
  54. // #ifdef APP-PLUS || H5
  55. {
  56. name: '导航栏带自定义按钮',
  57. url: 'nav-button'
  58. },
  59. {
  60. name: '导航栏带红点和角标',
  61. url: 'nav-dot'
  62. },
  63. {
  64. name: '导航栏带城市选择',
  65. url: 'nav-city-dropdown'
  66. },
  67. {
  68. name: '导航栏带搜索框',
  69. url: 'nav-search-input'
  70. },
  71. // #endif
  72. // #ifdef APP-PLUS || H5 || MP-ALIPAY
  73. {
  74. name: '透明渐变样式',
  75. url: 'nav-transparent'
  76. },
  77. {
  78. name: '导航栏带图片',
  79. url: 'nav-image'
  80. }
  81. // #endif
  82. ]
  83. },
  84. // #endif
  85. // #ifndef QUICKAPP-WEBVIEW || MP-KUAISHOU
  86. {
  87. name: '顶部选项卡',
  88. url: 'tabbar'
  89. },
  90. // #endif
  91. {
  92. name: '组件通讯',
  93. url: 'component-communication'
  94. },
  95. // #ifndef MP-QQ || QUICKAPP-WEBVIEW
  96. // {
  97. // name: 'uCharts 图表',
  98. // url: 'ucharts'
  99. // },
  100. // #endif
  101. // #ifndef QUICKAPP-WEBVIEW
  102. {
  103. name: '列表到详情示例',
  104. url: 'list2detail-list'
  105. },
  106. // #endif
  107. // #ifndef VUE3
  108. // #ifdef APP-PLUS
  109. // {
  110. // name: '上下滑动切换视频',
  111. // url: 'swiper-vertical'
  112. // },
  113. // #endif
  114. // #endif
  115. // #ifdef APP-NVUE
  116. {
  117. name: 'swiper-list',
  118. url: 'swiper-list-nvue'
  119. },
  120. // #endif
  121. {
  122. name: 'GlobalData和vuex',
  123. url: 'global'
  124. },
  125. // #ifdef APP-PLUS
  126. {
  127. name: '问题反馈',
  128. url: '/platforms/app-plus/feedback/feedback'
  129. },
  130. {
  131. name: '打开外部应用',
  132. url: 'scheme'
  133. },
  134. // #endif
  135. // #ifdef APP-PLUS || MP-WEIXIN || MP-QQ || H5
  136. // {
  137. // name: '微信自定义组件示例(vant ui)',
  138. // url: 'vant-button'
  139. // }
  140. // #endif
  141. ]
  142. }
  143. },
  144. onShareAppMessage() {
  145. return {
  146. title: '欢迎体验uni-app',
  147. path: '/pages/tabBar/template/template'
  148. }
  149. },
  150. onNavigationBarButtonTap(e) {
  151. uni.navigateTo({
  152. url: '/pages/about/about'
  153. });
  154. },
  155. // #ifdef H5
  156. watch: {
  157. $route: {
  158. immediate: true,
  159. handler(newRoute) {
  160. if (newRoute.matched.length) {
  161. let path = newRoute.path.split('/')[3]
  162. for (const item of this.list) {
  163. if (Array.isArray(item.pages)) {
  164. for (const page of item.pages) {
  165. if (page === path || page.url && page.url === path) {
  166. item.open = true
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. },
  175. // #endif
  176. methods: {
  177. triggerCollapse(e, id) {
  178. if (!this.list[e].pages) {
  179. this.goDetailPage(this.list[e].url);
  180. return;
  181. }
  182. for (var i = 0; i < this.list.length; ++i) {
  183. if (e === i) {
  184. this.list[i].open = !this.list[i].open;
  185. } else {
  186. this.list[i].open = false;
  187. }
  188. }
  189. },
  190. goDetailPage(e) {
  191. let path = e.url ? e.url : e;
  192. let url = ~path.indexOf('platform') ? path : '/pages/template/' + path + '/' + path;
  193. if (this.hasLeftWin) {
  194. uni.reLaunch({
  195. url: url
  196. })
  197. } else {
  198. uni.navigateTo({
  199. url: url
  200. })
  201. }
  202. return false;
  203. }
  204. }
  205. }
  206. </script>
  207. <style>
  208. @import '../../../common/uni-nvue.css';
  209. </style>