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

add文本分享示例

上级 8659bafa
......@@ -1022,58 +1022,58 @@
}
},
{
"path" : "pages/API/element-takesnapshot/element-takesnapshot",
"style" :
{
"navigationBarTitleText" : "takeSnapshot",
"enablePullDownRefresh" : false
"path": "pages/API/element-takesnapshot/element-takesnapshot",
"style": {
"navigationBarTitleText": "takeSnapshot",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/API/element-draw/element-draw",
"style" :
{
"navigationBarTitleText" : "getDrawableContext",
"enablePullDownRefresh" : false
"path": "pages/API/element-draw/element-draw",
"style": {
"navigationBarTitleText": "getDrawableContext",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/component/general-event/transition-event",
"style" :
{
"navigationBarTitleText" : "transitionend事件",
"enablePullDownRefresh" : false
"path": "pages/component/general-event/transition-event",
"style": {
"navigationBarTitleText": "transitionend事件",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/API/install-apk/install-apk",
"style" :
{
"navigationBarTitleText" : "install-apk",
"enablePullDownRefresh" : false
"path": "pages/API/install-apk/install-apk",
"style": {
"navigationBarTitleText": "install-apk",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/template/schema/schema",
"style" :
{
"navigationBarTitleText" : "打开schema示例"
"path": "pages/template/schema/schema",
"style": {
"navigationBarTitleText": "打开schema示例"
}
},
{
"path" : "pages/component/sticky-section/sticky-section",
"style" :
{
"navigationBarTitleText" : "sticky-section",
"enablePullDownRefresh" : false
"path": "pages/component/sticky-section/sticky-section",
"style": {
"navigationBarTitleText": "sticky-section",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/component/list-view/list-view-multiplex",
"style" :
"path": "pages/component/list-view/list-view-multiplex",
"style": {
"navigationBarTitleText": "list-view-multiplex",
"enablePullDownRefresh": false
}
},
{
"navigationBarTitleText" : "list-view-multiplex",
"enablePullDownRefresh" : false
"path": "pages/template/share/share",
"style": {
"navigationBarTitleText": "分享",
"enablePullDownRefresh": false
}
}
......
......@@ -8,48 +8,24 @@
</view>
<view class="uni-text-box">
<text class="hello-text">以下是部分模板示例,更多模板见插件市场:</text>
<u-link
href="https://ext.dcloud.net.cn"
:text="'https://ext.dcloud.net.cn'"
:inWhiteList="true"
></u-link>
<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">
<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="
<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"
>
" class="uni-icon">
</image>
</view>
<view class="uni-panel-c" v-if="item.open">
<view
class="uni-navigate-item"
:hover-class="page.enable == false?'':'is--active'"
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
>
<view class="uni-navigate-item" :hover-class="page.enable == false?'':'is--active'"
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>
......@@ -61,21 +37,21 @@
</template>
<script lang="uts">
type Page = {
name: string
enable?: boolean
url: string
}
type Page = {
name : string
enable ?: boolean
url : string
}
type ListItem = {
id: string
name: string
open: boolean
pages: Page[]
url?: string
enable?: boolean
}
export default {
type ListItem = {
id : string
name : string
open : boolean
pages : Page[]
url ?: string
enable ?: boolean
}
export default {
data() {
return {
list: [
......@@ -88,11 +64,11 @@ export default {
pages: [
{
name: '顶部搜索框随时下移长列表',
url:'long-list'
url: 'long-list'
},
{
name: '顶部banner长列表',
url:'long-list2'
url: 'long-list2'
},
] as Page[],
},
......@@ -118,11 +94,11 @@ export default {
pages: [
{
name: '下划线样式',
url:'swiper-list'
url: 'swiper-list'
},
{
name: '字体放大样式',
url:'swiper-list2'
url: 'swiper-list2'
},
] as Page[],
},
......@@ -190,7 +166,19 @@ export default {
name: '日历',
open: false,
pages: [] as Page[],
},
}, {
id: 'schema',
url: 'schema',
name: '打开外部链接',
open: false,
pages: [] as Page[],
}, {
id: 'share',
url: 'share',
name: '分享示例',
open: false,
pages: [] as Page[],
}
] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
......@@ -198,9 +186,9 @@ export default {
}
},
methods: {
triggerCollapse(index: number, item: ListItem) {
triggerCollapse(index : number, item : ListItem) {
if (item.pages.length == 0) {
const page: Page = {
const page : Page = {
name: item.name,
enable: item.enable,
url: item.url!,
......@@ -216,7 +204,7 @@ export default {
}
}
},
goDetailPage(e: Page) {
goDetailPage(e : Page) {
if (e.enable == false) {
uni.showToast({
icon: 'none',
......@@ -233,9 +221,9 @@ export default {
})
},
},
}
}
</script>
<style>
@import '../../common/uni-uvue.css';
@import '../../common/uni-uvue.css';
</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.
先完成此消息的编辑!
想要评论请 注册