template.uvue 6.1 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5 6 7
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1">
    <!-- #endif -->
    <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 11 12 13 14 15 16 17
        <text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text>
        <u-link
          href="https://ext.dcloud.net.cn"
          :text="'https://ext.dcloud.net.cn'"
          :inWhiteList="true"
        ></u-link>
      </view>
      <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
DCloud-WZF's avatar
DCloud-WZF 已提交
18
        <view
DCloud-WZF's avatar
DCloud-WZF 已提交
19 20 21
          class="uni-panel-h"
          :class="item.open ? 'uni-panel-h-on' : ''"
          @click="triggerCollapse(index, item)"
DCloud-WZF's avatar
DCloud-WZF 已提交
22 23
        >
          <text
DCloud-WZF's avatar
DCloud-WZF 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
            class="uni-panel-text"
            :class="item.enable == false ? 'text-disabled' : ''"
            >{{ item.name }}</text
          >
          <image
            :src="
              item.pages.length > 0
                ? item.open
                  ? arrowUpIcon
                  : arrowDownIcon
                : arrowRightIcon
            "
            class="uni-icon"
          >
          </image>
        </view>
        <view class="uni-panel-c" v-if="item.open">
          <view
M
mehaotian 已提交
42 43
            class="uni-navigate-item"
						:hover-class="page.enable == false?'':'is--active'"
DCloud-WZF's avatar
DCloud-WZF 已提交
44 45 46
            v-for="(page, key) in item.pages"
            :key="key"
            @click="goDetailPage(page)"
DCloud-WZF's avatar
DCloud-WZF 已提交
47
          >
DCloud-WZF's avatar
DCloud-WZF 已提交
48 49 50 51 52 53 54
            <text
              class="uni-navigate-text"
              :class="page.enable == false ? 'text-disabled' : ''"
              >{{ page.name }}</text
            >
            <image :src="arrowRightIcon" class="uni-icon"></image>
          </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
55 56 57
        </view>
      </view>
    </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
58
    <!-- #ifdef APP -->
DCloud-WZF's avatar
DCloud-WZF 已提交
59
  </scroll-view>
DCloud-WZF's avatar
DCloud-WZF 已提交
60
  <!-- #endif -->
DCloud_JSON's avatar
DCloud_JSON 已提交
61 62
</template>

Y
yurj26 已提交
63
<script lang="uts">
DCloud-WZF's avatar
DCloud-WZF 已提交
64 65 66 67 68
type Page = {
  name: string
  enable?: boolean
  url: string
}
DCloud_JSON's avatar
DCloud_JSON 已提交
69

DCloud-WZF's avatar
DCloud-WZF 已提交
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
type ListItem = {
  id: string
  name: string
  open: boolean
  pages: Page[]
  url?: string
  enable?: boolean
}
export default {
  data() {
    return {
      list: [
        {
          id: 'long-list',
          url: 'long-list',
shutao-dc's avatar
shutao-dc 已提交
85
          name: '左右滑动长列表',
DCloud-WZF's avatar
DCloud-WZF 已提交
86
          open: false,
H
hdx 已提交
87
          enable: true,
shutao-dc's avatar
shutao-dc 已提交
88 89 90 91 92 93 94 95 96 97
          pages: [
            {
              name: '顶部搜索框随时下移长列表',
              url:'long-list'
            },
            {
              name: '顶部banner长列表',
              url:'long-list2'
            },
          ] as Page[],
W
微调  
wanganxp 已提交
98 99 100 101 102 103 104
        },
        {
          id: 'list-news',
          url: 'list-news',
          name: '列表到详情',
          open: false,
          pages: [] as Page[],
DCloud-WZF's avatar
DCloud-WZF 已提交
105 106
        },
        {
107 108
          id: 'scroll-fold-nav',
          url: 'scroll-fold-nav',
W
wanganxp 已提交
109
          name: '随滚动折叠的导航栏',
DCloud-WZF's avatar
DCloud-WZF 已提交
110 111 112 113 114 115 116 117
          open: false,
          pages: [] as Page[],
        },
        {
          id: 'swiper-list',
          url: 'swiper-list',
          name: 'swiper-list',
          open: false,
W
微调  
wanganxp 已提交
118 119 120 121 122 123 124 125 126 127
          pages: [
            {
              name: '下划线样式',
              url:'swiper-list'
            },
            {
              name: '字体放大样式',
              url:'swiper-list2'
            },
          ] as Page[],
128
        },
DCloud-WZF's avatar
DCloud-WZF 已提交
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
        {
          id: 'custom-refresher',
          url: 'custom-refresher',
          name: '自定义下拉刷新',
          open: false,
          pages: [] as Page[],
        },
        {
          id: 'pull-zoom-image',
          url: 'pull-zoom-image',
          name: '下拉缩放顶部封面图',
          open: false,
          pages: [] as Page[],
        },
        {
          id: 'swiper-vertical-video',
          url: 'swiper-vertical-video',
          name: '竖滑视频',
          open: false,
          pages: [] as Page[],
        },
        {
          id: 'scroll-sticky',
          url: 'scroll-sticky',
153
          name: 'scroll-view自定义滚动吸顶',
DCloud-WZF's avatar
DCloud-WZF 已提交
154 155 156
          open: false,
          pages: [] as Page[],
        },
157 158 159 160 161 162 163 164
        // {
        //   id: 'half-screen',
        //   url: 'half-screen',
        //   name: '半屏弹窗',
        //   open: false,
        //   enable: false,
        //   pages: [] as Page[],
        // },
DCloud-WZF's avatar
DCloud-WZF 已提交
165 166 167 168 169 170
        {
          id: 'drop-card',
          url: 'drop-card',
          name: '划走式卡片',
          open: false,
          pages: [] as Page[],
M
mehaotian 已提交
171 172
        },
        {
173 174
          id: 'navbar-lite',
          url: 'navbar-lite',
M
mehaotian 已提交
175 176 177
          name: '自定义导航栏',
          open: false,
          pages: [] as Page[],
H
hdx 已提交
178 179 180 181 182 183
        },
        {
          id: 'custom-tab-bar',
          url: 'custom-tab-bar',
          name: '自定义TabBar',
          open: false,
184 185
          enable: true,
          pages: [] as Page[],
DCloud-WZF's avatar
DCloud-WZF 已提交
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
        },
        {
          id: 'calendar',
          url: 'calendar',
          name: '日历',
          open: false,
          pages: [] as Page[],
        },
      ] as ListItem[],
      arrowUpIcon: '/static/icons/arrow-up.png',
      arrowDownIcon: '/static/icons/arrow-down.png',
      arrowRightIcon: '/static/icons/arrow-right.png',
    }
  },
  methods: {
Y
yurj26 已提交
201
    triggerCollapse(index: number, item: ListItem) {
DCloud-WZF's avatar
DCloud-WZF 已提交
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
      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_JSON's avatar
DCloud_JSON 已提交
237 238 239
</script>

<style>
DCloud-WZF's avatar
DCloud-WZF 已提交
240 241
@import '../../common/uni-uvue.css';
</style>