提交 469322d8 编写于 作者: W wanganxp

add文本分享示例

上级 8659bafa
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
"style": { "style": {
"navigationBarTitleText": "progress" "navigationBarTitleText": "progress"
} }
}, },
{ {
"path": "pages/component/form/form", "path": "pages/component/form/form",
"style": { "style": {
"navigationBarTitleText": "form" "navigationBarTitleText": "form"
} }
}, },
{ {
"path": "pages/component/button/button", "path": "pages/component/button/button",
...@@ -199,31 +199,31 @@ ...@@ -199,31 +199,31 @@
"style": { "style": {
"navigationBarTitleText": "general-event" "navigationBarTitleText": "general-event"
} }
}, },
{ {
"path": "pages/component/unicloud-db-contacts/list", "path": "pages/component/unicloud-db-contacts/list",
"style": { "style": {
"navigationBarTitleText": "联系人", "navigationBarTitleText": "联系人",
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{ {
"path": "pages/component/unicloud-db-contacts/add", "path": "pages/component/unicloud-db-contacts/add",
"style": { "style": {
"navigationBarTitleText": "新增联系人" "navigationBarTitleText": "新增联系人"
} }
}, },
{ {
"path": "pages/component/unicloud-db-contacts/edit", "path": "pages/component/unicloud-db-contacts/edit",
"style": { "style": {
"navigationBarTitleText": "编辑联系人" "navigationBarTitleText": "编辑联系人"
} }
}, },
{ {
"path": "pages/component/unicloud-db-contacts/detail", "path": "pages/component/unicloud-db-contacts/detail",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
}, },
{ {
"path": "pages/tabBar/API", "path": "pages/tabBar/API",
...@@ -262,17 +262,17 @@ ...@@ -262,17 +262,17 @@
"navigationBarTitleText": "页面跳转" "navigationBarTitleText": "页面跳转"
} }
}, },
{ {
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color", "path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
"style": { "style": {
"navigationBarTitleText": "设置导航条颜色" "navigationBarTitleText": "设置导航条颜色"
} }
}, },
{ {
"path": "pages/API/set-navigation-bar-title/set-navigation-bar-title", "path": "pages/API/set-navigation-bar-title/set-navigation-bar-title",
"style": { "style": {
"navigationBarTitleText": "设置导航条标题" "navigationBarTitleText": "设置导航条标题"
} }
}, },
{ {
"path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color", "path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color",
...@@ -287,11 +287,11 @@ ...@@ -287,11 +287,11 @@
"navigationBarTitleText": "新页面-1" "navigationBarTitleText": "新页面-1"
} }
}, },
{ {
"path": "pages/API/navigator/new-page/new-page-3", "path": "pages/API/navigator/new-page/new-page-3",
"style": { "style": {
"navigationBarTitleText": "新页面-3" "navigationBarTitleText": "新页面-3"
} }
}, },
{ {
"path": "pages/API/navigator/new-page/onLoad", "path": "pages/API/navigator/new-page/onLoad",
...@@ -311,7 +311,7 @@ ...@@ -311,7 +311,7 @@
"style": { "style": {
"navigationBarTitleText": "获取节点" "navigationBarTitleText": "获取节点"
} }
}, },
{ {
"path": "pages/API/get-element-by-id/get-element-by-id-multiple-root-node", "path": "pages/API/get-element-by-id/get-element-by-id-multiple-root-node",
"style": { "style": {
...@@ -371,24 +371,24 @@ ...@@ -371,24 +371,24 @@
"style": { "style": {
"navigationBarTitleText": "获取定位" "navigationBarTitleText": "获取定位"
} }
}, },
{ {
"path": "pages/API/interceptor/interceptor", "path": "pages/API/interceptor/interceptor",
"style": { "style": {
"navigationBarTitleText": "拦截器" "navigationBarTitleText": "拦截器"
} }
}, },
{ {
"path": "pages/API/interceptor/page1", "path": "pages/API/interceptor/page1",
"style": { "style": {
"navigationBarTitleText": "拦截器测试页面 1" "navigationBarTitleText": "拦截器测试页面 1"
} }
}, },
{ {
"path": "pages/API/interceptor/page2", "path": "pages/API/interceptor/page2",
"style": { "style": {
"navigationBarTitleText": "拦截器测试页面 2" "navigationBarTitleText": "拦截器测试页面 2"
} }
}, },
{ {
"path": "pages/tabBar/CSS", "path": "pages/tabBar/CSS",
...@@ -944,13 +944,13 @@ ...@@ -944,13 +944,13 @@
"navigationBarTitleText": "顶部搜索框随时下移长列表", "navigationBarTitleText": "顶部搜索框随时下移长列表",
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{ {
"path": "pages/template/long-list2/long-list2", "path": "pages/template/long-list2/long-list2",
"style": { "style": {
"navigationBarTitleText": "顶部banner长列表", "navigationBarTitleText": "顶部banner长列表",
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{ {
"path": "pages/component/list-view/list-view", "path": "pages/component/list-view/list-view",
...@@ -1013,69 +1013,69 @@ ...@@ -1013,69 +1013,69 @@
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/component/sticky-header/sticky-header", "path": "pages/component/sticky-header/sticky-header",
"style": { "style": {
"navigationBarTitleText": "sticky-header", "navigationBarTitleText": "sticky-header",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path" : "pages/API/element-takesnapshot/element-takesnapshot", "path": "pages/API/element-takesnapshot/element-takesnapshot",
"style" : "style": {
{ "navigationBarTitleText": "takeSnapshot",
"navigationBarTitleText" : "takeSnapshot", "enablePullDownRefresh": false
"enablePullDownRefresh" : false }
} },
}, {
{ "path": "pages/API/element-draw/element-draw",
"path" : "pages/API/element-draw/element-draw", "style": {
"style" : "navigationBarTitleText": "getDrawableContext",
{ "enablePullDownRefresh": false
"navigationBarTitleText" : "getDrawableContext", }
"enablePullDownRefresh" : false },
} {
}, "path": "pages/component/general-event/transition-event",
{ "style": {
"path" : "pages/component/general-event/transition-event", "navigationBarTitleText": "transitionend事件",
"style" : "enablePullDownRefresh": false
{ }
"navigationBarTitleText" : "transitionend事件", },
"enablePullDownRefresh" : false {
} "path": "pages/API/install-apk/install-apk",
}, "style": {
{ "navigationBarTitleText": "install-apk",
"path" : "pages/API/install-apk/install-apk", "enablePullDownRefresh": false
"style" : }
{ },
"navigationBarTitleText" : "install-apk", {
"enablePullDownRefresh" : false "path": "pages/template/schema/schema",
} "style": {
}, "navigationBarTitleText": "打开schema示例"
{ }
"path" : "pages/template/schema/schema", },
"style" : {
{ "path": "pages/component/sticky-section/sticky-section",
"navigationBarTitleText" : "打开schema示例" "style": {
} "navigationBarTitleText": "sticky-section",
}, "enablePullDownRefresh": false
{ }
"path" : "pages/component/sticky-section/sticky-section", },
"style" : {
{ "path": "pages/component/list-view/list-view-multiplex",
"navigationBarTitleText" : "sticky-section", "style": {
"enablePullDownRefresh" : false "navigationBarTitleText": "list-view-multiplex",
} "enablePullDownRefresh": false
}, }
{ },
"path" : "pages/component/list-view/list-view-multiplex", {
"style" : "path": "pages/template/share/share",
{ "style": {
"navigationBarTitleText" : "list-view-multiplex", "navigationBarTitleText": "分享",
"enablePullDownRefresh" : false "enablePullDownRefresh": false
} }
} }
], ],
"globalStyle": { "globalStyle": {
...@@ -1127,4 +1127,4 @@ ...@@ -1127,4 +1127,4 @@
"query": "" //启动参数,在页面的onLoad函数里面得到 "query": "" //启动参数,在页面的onLoad函数里面得到
}] }]
} }
} }
\ No newline at end of file
<template> <template>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view style="flex: 1"> <scroll-view style="flex: 1">
<!-- #endif --> <!-- #endif -->
<view class="uni-container"> <view class="uni-container">
<view class="uni-header-logo"> <view class="uni-header-logo">
<image class="uni-header-image" src="/static/templateIndex.png"></image> <image class="uni-header-image" src="/static/templateIndex.png"></image>
</view> </view>
<view class="uni-text-box"> <view class="uni-text-box">
<text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text> <text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text>
<u-link <u-link href="https://ext.dcloud.net.cn" :text="'https://ext.dcloud.net.cn'" :inWhiteList="true"></u-link>
href="https://ext.dcloud.net.cn"
:text="'https://ext.dcloud.net.cn'"
:inWhiteList="true"
></u-link>
</view> </view>
<view class="uni-panel" v-for="(item, index) in list" :key="item.id"> <view class="uni-panel" v-for="(item, index) in list" :key="item.id">
<view <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
class="uni-panel-h" <text class="uni-panel-text" :class="item.enable == false ? 'text-disabled' : ''">{{ item.name }}</text>
:class="item.open ? 'uni-panel-h-on' : ''" <image :src="
@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.pages.length > 0
? item.open ? item.open
? arrowUpIcon ? arrowUpIcon
: arrowDownIcon : arrowDownIcon
: arrowRightIcon : arrowRightIcon
" " class="uni-icon">
class="uni-icon"
>
</image> </image>
</view> </view>
<view class="uni-panel-c" v-if="item.open"> <view class="uni-panel-c" v-if="item.open">
<view <view class="uni-navigate-item" :hover-class="page.enable == false?'':'is--active'"
class="uni-navigate-item" v-for="(page, key) in item.pages" :key="key" @click="goDetailPage(page)">
:hover-class="page.enable == false?'':'is--active'" <text class="uni-navigate-text" :class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
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> <image :src="arrowRightIcon" class="uni-icon"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
</template> </template>
<script lang="uts"> <script lang="uts">
type Page = { type Page = {
name: string name : string
enable?: boolean enable ?: boolean
url: string url : string
} }
type ListItem = { type ListItem = {
id: string id : string
name: string name : string
open: boolean open : boolean
pages: Page[] pages : Page[]
url?: string url ?: string
enable?: boolean enable ?: boolean
} }
export default { export default {
data() { data() {
return { return {
list: [ list: [
{ {
id: 'long-list', id: 'long-list',
url: 'long-list', url: 'long-list',
name: '左右滑动长列表', name: '左右滑动长列表',
open: false, open: false,
enable: true, enable: true,
pages: [ pages: [
{ {
name: '顶部搜索框随时下移长列表', name: '顶部搜索框随时下移长列表',
url:'long-list' url: 'long-list'
}, },
{ {
name: '顶部banner长列表', name: '顶部banner长列表',
url:'long-list2' url: 'long-list2'
}, },
] as Page[], ] as Page[],
}, },
{ {
id: 'list-news', id: 'list-news',
url: 'list-news', url: 'list-news',
name: '列表到详情', name: '列表到详情',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'scroll-fold-nav', id: 'scroll-fold-nav',
url: 'scroll-fold-nav', url: 'scroll-fold-nav',
name: '随滚动折叠的导航栏', name: '随滚动折叠的导航栏',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'swiper-list', id: 'swiper-list',
url: 'swiper-list', url: 'swiper-list',
name: 'swiper-list', name: 'swiper-list',
open: false, open: false,
pages: [ pages: [
{ {
name: '下划线样式', name: '下划线样式',
url:'swiper-list' url: 'swiper-list'
}, },
{ {
name: '字体放大样式', name: '字体放大样式',
url:'swiper-list2' url: 'swiper-list2'
}, },
] as Page[], ] as Page[],
}, },
{ {
id: 'custom-refresher', id: 'custom-refresher',
url: 'custom-refresher', url: 'custom-refresher',
name: '自定义下拉刷新', name: '自定义下拉刷新',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'pull-zoom-image', id: 'pull-zoom-image',
url: 'pull-zoom-image', url: 'pull-zoom-image',
name: '下拉缩放顶部封面图', name: '下拉缩放顶部封面图',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'swiper-vertical-video', id: 'swiper-vertical-video',
url: 'swiper-vertical-video', url: 'swiper-vertical-video',
name: '竖滑视频', name: '竖滑视频',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'scroll-sticky', id: 'scroll-sticky',
url: 'scroll-sticky', url: 'scroll-sticky',
name: 'scroll-view自定义滚动吸顶', name: 'scroll-view自定义滚动吸顶',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
// { // {
// id: 'half-screen', // id: 'half-screen',
// url: 'half-screen', // url: 'half-screen',
// name: '半屏弹窗', // name: '半屏弹窗',
// open: false, // open: false,
// enable: false, // enable: false,
// pages: [] as Page[], // pages: [] as Page[],
// }, // },
{ {
id: 'drop-card', id: 'drop-card',
url: 'drop-card', url: 'drop-card',
name: '划走式卡片', name: '划走式卡片',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'navbar-lite', id: 'navbar-lite',
url: 'navbar-lite', url: 'navbar-lite',
name: '自定义导航栏', name: '自定义导航栏',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'custom-tab-bar', id: 'custom-tab-bar',
url: 'custom-tab-bar', url: 'custom-tab-bar',
name: '自定义TabBar', name: '自定义TabBar',
open: false, open: false,
enable: true, enable: true,
pages: [] as Page[], pages: [] as Page[],
}, },
{ {
id: 'calendar', id: 'calendar',
url: 'calendar', url: 'calendar',
name: '日历', name: '日历',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, }, {
] as ListItem[], id: 'schema',
arrowUpIcon: '/static/icons/arrow-up.png', url: 'schema',
arrowDownIcon: '/static/icons/arrow-down.png', name: '打开外部链接',
arrowRightIcon: '/static/icons/arrow-right.png', open: false,
} pages: [] as Page[],
}, }, {
methods: { id: 'share',
triggerCollapse(index: number, item: ListItem) { url: 'share',
if (item.pages.length == 0) { name: '分享示例',
const page: Page = { open: false,
name: item.name, pages: [] as Page[],
enable: item.enable, }
url: item.url!, ] as ListItem[],
} arrowUpIcon: '/static/icons/arrow-up.png',
this.goDetailPage(page) arrowDownIcon: '/static/icons/arrow-down.png',
return arrowRightIcon: '/static/icons/arrow-right.png',
}
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) { methods: {
if (e.enable == false) { triggerCollapse(index : number, item : ListItem) {
uni.showToast({ if (item.pages.length == 0) {
icon: 'none', const page : Page = {
title: '暂不支持', 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,
}) })
return },
}
const url =
e.url.indexOf('platform') > -1
? e.url
: `/pages/template/${e.url}/${e.url}`
uni.navigateTo({
url,
})
}, },
}, }
}
</script> </script>
<style> <style>
@import '../../common/uni-uvue.css'; @import '../../common/uni-uvue.css';
</style> </style>
\ No newline at end of file
<template>
<view>
<button class="button" @click="shareText('https://uniapp.dcloud.io/uni-app-x','分享到')">分享</button>
</view>
</template>
<script>
import Intent from 'android.content.Intent';
export default {
data() {
return {
}
},
methods: {
shareText(text:string,title:string){
const context = UTSAndroid.getUniActivity()!;
const intent = new Intent(Intent.ACTION_SEND)
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
context.startActivity(Intent.createChooser(intent, title));
// 这里是简单的文本分享示例,如需分享文件图片,需要使用fileProvider
},
}
}
</script>
<style>
.button {
margin: 30rpx;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册