template.uvue 4.6 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1
<template>
W
wanganxp 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
	<view class="uni-container">
		<view class="uni-header-logo">
			<image class="uni-header-image" src="/static/templateIndex.png"></image>
		</view>
		<view class="uni-hello-text">
			<text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text>
			<u-link class="hello-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">
			<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="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
					class="uni-icon">
				</image>
			</view>
			<view class="uni-panel-c" v-if="item.open">
				<view class="uni-navigate-item" 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>
					<image :src="arrowRightIcon" class="uni-icon"></image>
				</view>
			</view>
		</view>
	</view>
DCloud_JSON's avatar
DCloud_JSON 已提交
27 28 29
</template>

<script lang="ts">
W
wanganxp 已提交
30 31 32 33 34
	type Page = {
		name : string,
		enable ?: boolean,
		url : string
	}
DCloud_JSON's avatar
DCloud_JSON 已提交
35

W
wanganxp 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48
	type ListItem = {
		id : string,
		name : string,
		open : boolean,
		pages : Page[],
		url ?: string,
		enable ?: boolean
	}
	export default {
		data() {
			return {
				list: [
					{
W
wanganxp 已提交
49 50 51 52 53 54
						id: "long-list",
						url: "long-list",
						name: "复杂长列表",
						open: false,
						enable: false,
						pages: [] as Page[]
55 56 57 58 59 60
					},{
						id: "scroll-fold-nav",
						url: "scroll-fold-nav",
						name: "随滚动折叠的导航栏",
						open: false,
						pages: [] as Page[]
W
wanganxp 已提交
61
					},{
62 63
						id: "scroll-fold-nav2",
						url: "scroll-fold-nav2",
64
						name: "随滚动折叠的导航栏2",
65 66
						open: false,
						pages: [] as Page[]
W
wanganxp 已提交
67 68 69 70 71 72
					}, {
						id: "swiper-list",
						url: "swiper-list",
						name: "swiper-list",
						open: false,
						enable: false,
DCloud-WZF's avatar
DCloud-WZF 已提交
73 74
						pages: [] as Page[]

W
wanganxp 已提交
75
					}, {
76
						id: "custom-refresher",
W
wanganxp 已提交
77
						url: "custom-pull-page",
78 79 80 81 82 83 84
						name: "自定义上拉下拉效果(前端实现)",
						open: false,
						pages: [] as Page[]
					},{
						id: "custom-refresher",
						url: "custom-refresher",
						name: "自定义下拉刷新(原生实现)",
W
wanganxp 已提交
85 86
						open: false,
						pages: [] as Page[]
87
					},
W
wanganxp 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
					{
						id: "pull-zoom-image",
						url: "pull-zoom-image",
						name: "下拉缩放顶部封面图",
						open: false,
						enable: false,
						pages: [] as Page[]
					},
					{
						id: "show-search-with-scroll",
						url: "show-search-with-scroll",
						name: "滚动后自动显隐的搜索框",
						open: false,
						enable: false,
						pages: [] as Page[]
					},
					{
						id: "swiper-vertical-video",
						url: "swiper-vertical-video",
						name: "竖滑视频",
						open: false,
						pages: [] as Page[]
					},
					{
112 113
						id: "scroll-sticky",
						url: "scroll-sticky",
W
wanganxp 已提交
114 115
						name: "吸顶",
						open: false,
116 117
						pages: [] as Page[]
					},
W
wanganxp 已提交
118 119 120 121 122 123
					{
						id: "drop-card",
						url: "drop-card",
						name: "划走式卡片",
						open: false,
						pages: [] as Page[]
Y
yurj26 已提交
124 125 126 127 128 129 130 131
					},
                    {
                        id: "calendar",
                        url: "calendar",
                        name: "日历",
                        open: false,
                        pages: [] as Page[]
                    }
W
wanganxp 已提交
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
				] as ListItem[],
				arrowUpIcon: '/static/icons/arrow-up.png',
				arrowDownIcon: '/static/icons/arrow-down.png',
				arrowRightIcon: '/static/icons/arrow-right.png',
			}
		},
		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_JSON's avatar
DCloud_JSON 已提交
172 173 174
</script>

<style>
W
wanganxp 已提交
175
	@import '../../common/uni-uvue.css';
DCloud_JSON's avatar
DCloud_JSON 已提交
176
</style>