template.uvue 7.9 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2
  <!-- #ifdef APP -->
3
  <scroll-view style="flex: 1; background-color: #f8f8f8" enable-back-to-top="true">
W
wanganxp 已提交
4
  <!-- #endif -->
DCloud-WZF's avatar
DCloud-WZF 已提交
5 6 7
    <view class="uni-container">
      <view class="uni-header-logo">
        <image class="uni-header-image" src="/static/templateIndex.png"></image>
DCloud-WZF's avatar
DCloud-WZF 已提交
8
      </view>
Y
yurj26 已提交
9
      <view class="uni-text-box">
DCloud-WZF's avatar
DCloud-WZF 已提交
10
        <text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text>
W
wanganxp 已提交
11
        <u-link href="https://ext.dcloud.net.cn" :text="'https://ext.dcloud.net.cn'" :inWhiteList="true"></u-link>
DCloud-WZF's avatar
DCloud-WZF 已提交
12 13
      </view>
      <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
W
wanganxp 已提交
14 15 16
        <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
          <text class="uni-panel-text" :class="item.enable == false ? 'text-disabled' : ''">{{ item.name }}</text>
          <image :src="
DCloud-WZF's avatar
DCloud-WZF 已提交
17 18 19 20 21
              item.pages.length > 0
                ? item.open
                  ? arrowUpIcon
                  : arrowDownIcon
                : arrowRightIcon
22
            " class="uni-icon-size">
DCloud-WZF's avatar
DCloud-WZF 已提交
23 24
          </image>
        </view>
A
Anne_LXM 已提交
25
        <view v-if="item.open">
26
          <view class="uni-navigate-item" :hover-class="page.enable == false ? '' : 'is--active'"
W
wanganxp 已提交
27 28
            v-for="(page, key) in item.pages" :key="key" @click="goDetailPage(page)">
            <text class="uni-navigate-text" :class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
29
            <image :src="arrowRightIcon" class="uni-icon-size"></image>
DCloud-WZF's avatar
DCloud-WZF 已提交
30
          </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
31 32 33
        </view>
      </view>
    </view>
W
wanganxp 已提交
34
  <!-- #ifdef APP -->
DCloud-WZF's avatar
DCloud-WZF 已提交
35
  </scroll-view>
DCloud-WZF's avatar
DCloud-WZF 已提交
36
  <!-- #endif -->
DCloud_JSON's avatar
DCloud_JSON 已提交
37 38
</template>

Y
yurj26 已提交
39
<script lang="uts">
W
wanganxp 已提交
40 41 42 43 44
  type Page = {
    name : string
    enable ?: boolean
    url : string
  }
DCloud_JSON's avatar
DCloud_JSON 已提交
45

W
wanganxp 已提交
46 47 48 49 50 51 52 53 54 55 56
  type ListItem = {
    id : string
    name : string
    open : boolean
    pages : Page[]
    url ?: string
    enable ?: boolean
  }
  export default {
    data() {
      return {
57
        list: [
W
wanganxp 已提交
58 59 60 61 62 63 64 65
          {
            id: 'long-list',
            url: 'long-list',
            name: '左右滑动长列表',
            open: false,
            enable: true,
            pages: [
              {
66
                name: 'Android顶部搜索框随时下移长列表',
W
wanganxp 已提交
67
                url: 'long-list'
68
              },
69
              // #ifdef WEB
W
wanganxp 已提交
70
              {
71
                name: '顶部banner长列表(嵌套滚动)',
W
wanganxp 已提交
72
                url: 'long-list2'
73 74
              },
              // #endif
75
              // #ifdef APP-IOS || APP-ANDROID
76
              {
77
                name: '顶部banner长列表(嵌套滚动)',
78 79
                url: 'long-list-nested'
              },
DCloud_iOS_XHY's avatar
DCloud_iOS_XHY 已提交
80
              // #endif
W
wanganxp 已提交
81
            ] as Page[],
82
          },
W
wanganxp 已提交
83 84 85
          {
            id: 'list-news',
            url: 'list-news',
86
            name: '列表到详情(吸顶)',
W
wanganxp 已提交
87 88
            open: false,
            pages: [] as Page[],
雪洛's avatar
雪洛 已提交
89
          },
W
wanganxp 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
          {
            id: 'swiper-list',
            url: 'swiper-list',
            name: 'swiper-list',
            open: false,
            pages: [
              {
                name: '下划线样式',
                url: 'swiper-list'
              },
              {
                name: '字体放大样式',
                url: 'swiper-list2'
              },
            ] as Page[],
          },
106 107 108 109 110 111 112
          {
            id: 'slider-100',
            url: 'slider-100',
            name: 'slider-100',
            open: false,
            pages: [] as Page[],
          },
113 114 115
          {
            id: 'custom-long-list',
            url: 'custom-long-list',
W
wanganxp 已提交
116
            name: '自定义虚拟长列表uni-recycle-view',
117 118
            open: false,
            pages: [] as Page[],
119 120 121 122 123 124 125
          },
          {
            id: 'scroll-fold-nav',
            url: 'scroll-fold-nav',
            name: '随滚动折叠的导航栏',
            open: false,
            pages: [] as Page[],
126 127
          },
          // #ifdef APP
W
wanganxp 已提交
128 129 130 131 132 133
          {
            id: 'custom-refresher',
            url: 'custom-refresher',
            name: '自定义下拉刷新',
            open: false,
            pages: [] as Page[],
134 135 136 137 138 139 140
          },
          {
            id: 'pull-zoom-image',
            url: 'pull-zoom-image',
            name: '下拉缩放顶部封面图',
            open: false,
            pages: [] as Page[],
141 142 143 144 145 146 147
          },
          {
            id: 'scroll-sticky',
            url: 'scroll-sticky',
            name: 'scroll-view自定义滚动吸顶',
            open: false,
            pages: [] as Page[],
148
          },
W
wanganxp 已提交
149
          // #endif
W
wanganxp 已提交
150 151 152 153 154 155
          {
            id: 'swiper-vertical-video',
            url: 'swiper-vertical-video',
            name: '竖滑视频',
            open: false,
            pages: [] as Page[],
156
          },
DCloud-yyl's avatar
DCloud-yyl 已提交
157 158 159 160 161 162 163
          {
            id: 'half-screen',
            url: 'half-screen',
            name: '半屏弹窗',
            open: false,
            pages: [] as Page[],
          },
W
wanganxp 已提交
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
          {
            id: 'drop-card',
            url: 'drop-card',
            name: '划走式卡片',
            open: false,
            pages: [] as Page[],
          },
          {
            id: 'navbar-lite',
            url: 'navbar-lite',
            name: '自定义导航栏',
            open: false,
            pages: [] as Page[],
          },
          {
            id: 'custom-tab-bar',
            url: 'custom-tab-bar',
            name: '自定义TabBar',
            open: false,
            enable: true,
            pages: [] as Page[],
185
          },
W
wanganxp 已提交
186
          // #ifdef APP
W
wanganxp 已提交
187 188 189 190 191 192
          {
            id: 'calendar',
            url: 'calendar',
            name: '日历',
            open: false,
            pages: [] as Page[],
193 194
          },
          // #endif
195
          {
W
wanganxp 已提交
196 197 198 199 200
            id: 'schema',
            url: 'schema',
            name: '打开外部链接',
            open: false,
            pages: [] as Page[],
201 202
          },
          // #ifdef APP-ANDROID
203
          {
W
wanganxp 已提交
204 205 206 207 208
            id: 'share',
            url: 'share',
            name: '分享示例',
            open: false,
            pages: [] as Page[],
209
          },
210 211 212 213 214 215 216 217 218
          // #endif
          // #ifdef APP-ANDROID
          {
            id: 'lottie-anim',
            url: 'lottie-anim',
            name: 'lottie动画-需要自定义基座',
            open: false,
            pages: [] as Page[],
          },
219 220 221
          // #endif
          // #ifdef WEB
          {
222 223 224
            id: 'browser-element',
            url: 'browser-element',
            name: '如何使用浏览器 element',
225 226 227
            open: false,
            pages: [] as Page[],
          },
W
wanganxp 已提交
228
          // #endif
W
wanganxp 已提交
229 230 231 232
        ] as ListItem[],
        arrowUpIcon: '/static/icons/arrow-up.png',
        arrowDownIcon: '/static/icons/arrow-down.png',
        arrowRightIcon: '/static/icons/arrow-right.png',
DCloud-WZF's avatar
DCloud-WZF 已提交
233 234
      }
    },
W
wanganxp 已提交
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
    methods: {
      triggerCollapse(index : number, item : ListItem) {
        if (item.pages.length == 0) {
          const page : Page = {
            name: item.name,
            enable: item.enable,
            url: item.url!,
          }
          this.goDetailPage(page)
          return
        }
        for (var i = 0; i < this.list.length; ++i) {
          if (index == i) {
            this.list[i].open = !this.list[i].open
          } else {
            this.list[i].open = false
          }
        }
      },
      goDetailPage(e : Page) {
        if (e.enable == false) {
          uni.showToast({
            icon: 'none',
            title: '暂不支持',
          })
          return
        }
        const url =
          e.url.indexOf('platform') > -1
            ? e.url
            : `/pages/template/${e.url}/${e.url}`
        uni.navigateTo({
          url,
DCloud-WZF's avatar
DCloud-WZF 已提交
268
        })
W
wanganxp 已提交
269
      },
DCloud-WZF's avatar
DCloud-WZF 已提交
270
    },
W
wanganxp 已提交
271
  }
272
</script>