提交 1b2d5cf7 编写于 作者: zhaofengliang920817's avatar zhaofengliang920817

修改share示例

上级 0ab86727
...@@ -3,12 +3,15 @@ ...@@ -3,12 +3,15 @@
<button class="button" @click="shareText()">分享文本</button> <button class="button" @click="shareText()">分享文本</button>
<button class="button" @click="shareLink()">分享链接</button> <button class="button" @click="shareLink()">分享链接</button>
<button class="button" @click="sharePrivateImg()">分享单个本地图片</button> <button class="button" @click="sharePrivateImg()">分享单个本地图片</button>
<button class="button" @click="sharePrivateErrorImg()">分享单个本地图片(错误路径)</button>
<button class="button" @click="sharePrivateImgs()">分享多个本地图片</button> <button class="button" @click="sharePrivateImgs()">分享多个本地图片</button>
<button class="button" @click="sharePrivateErrorImgs()">分享多个本地图片(含有错误路径)</button> <button class="button" @click="shareAll()">分享链接、文本、一张图片</button>
<button class="button" @click="shareAll()">分享链接、文本、多张图片</button>
<button class="button" @click="sharePubImg()">选择图片并分享</button> <button class="button" type="primary" @click="shareErrorLink()">分享链接(格式错误)</button>
<button class="button" @click="shareSnapShot()">指定view截图并分享</button> <button class="button" type="primary" @click="sharePrivateErrorImg()">分享单个本地图片(错误路径)</button>
<button class="button" type="primary" @click="sharePrivateErrorImgs()">分享多个本地图片(含有错误路径)</button>
<button class="button" type="warn" @click="sharePubImg()">选择图片并分享</button>
<button class="button" type="warn" @click="shareSnapShot()">指定view截图并分享</button>
</view> </view>
</template> </template>
...@@ -64,6 +67,25 @@ ...@@ -64,6 +67,25 @@
} }
}) })
}, },
shareErrorLink() {
uni.hideToast()
uni.shareWithSystem({
href: 'htp:11',
success(res) {
console.log('Shared----------------------------success')
},
fail(res) {
console.log('Share failed, ' + "res.errCode =" + res.errCode + '---res.errMsg= ' + res.errMsg)
uni.showToast({
icon: "error",
title: "errorCode=" + res.errCode
})
},
complete(res) {
}
})
},
sharePrivateImg() { sharePrivateImg() {
uni.hideToast() uni.hideToast()
const imageSrc : string = "/static/test-image/logo.gif"; const imageSrc : string = "/static/test-image/logo.gif";
...@@ -164,13 +186,9 @@ ...@@ -164,13 +186,9 @@
}, },
shareAll() { shareAll() {
uni.hideToast() uni.hideToast()
const errorImageSrc1 : string = "/static/test-image/logo.jpg1"; const imageSrc : string = "/static/test-video/fast-forward.png";
const errorImageSrc2 : string = "/static/test-image/logo.jpg1";
const imageSrc : string = "/static/test-image/logo.jpg";
let imageUrlList : string[] = Array() let imageUrlList : string[] = Array()
imageUrlList.push(imageSrc) imageUrlList.push(imageSrc)
imageUrlList.push(errorImageSrc1)
imageUrlList.push(errorImageSrc2)
uni.shareWithSystem({ uni.shareWithSystem({
summary: this.summary, summary: this.summary,
href: 'https://uniapp.dcloud.io', href: 'https://uniapp.dcloud.io',
...@@ -227,7 +245,7 @@ ...@@ -227,7 +245,7 @@
uni.getElementById("viewshot")?.takeSnapshot( uni.getElementById("viewshot")?.takeSnapshot(
{ {
success: function (res) { success: function (res) {
// #ifdef APP-ANDROIDn // #ifdef APP-ANDROID
// 打印截图文件临时路径 // 打印截图文件临时路径
console.log(res.tempFilePath) console.log(res.tempFilePath)
const context = UTSAndroid.getUniActivity()!; const context = UTSAndroid.getUniActivity()!;
...@@ -280,6 +298,7 @@ ...@@ -280,6 +298,7 @@
<style> <style>
.button { .button {
margin: 15px; margin: 20px;
margin-bottom: 0px;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册