<template>
<view class="content">
<form @submit="formSubmit" @reset="formReset">
<input class="uni-input" name="title" placeholder="文章标题"/>
<input class="uni-input" name="miaoshu" placeholder="文章描述"/>
<input class="uni-input" name="imgurl" placeholder="图片地址"/>
<input class="uni-input" name="url" placeholder="跳转链接"/>
<button formType="submit">分享到微信群或好友</button>
<button type="default" formType="reset">清空以上信息</button>
<view class="banquan">里客云科技开发</view>
</form>
</view>
</template>
<script>
export default {
data() {
return {}
},
// 执行事件
methods:{
formSubmit:function(e){
var title = e.detail.value.title;
var miaoshu = e.detail.value.miaoshu;
var imgurl = e.detail.value.imgurl;
var url = e.detail.value.url;
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 0,
href: url,
title: title,
summary: miaoshu,
imageUrl: imgurl,
success: function (res) {
console.log(JSON.stringify(res));
uni.showToast({
title: '已分享',
duration: 2000
});
},
fail: function (err) {
var errrr = JSON.stringify(err);
if(errrr){
uni.showModal({
title: '表单不能留空',
content: '请完善所有信息再发起分享',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
}
});
},
},
}
</script>
<style>
*{margin: 0;padding: 0;}
.content{
width: 100%;
margin: 20px auto;
}
.content .uni-input{
width: 80%;
height: 45px;
margin: 8px auto;
border: 1px solid #ccc;
margin-bottom: 8px;
padding-left: 8px;
border-radius: 10px;
font-size: 16px;
color: #333;
}
.content button{
width: 80%;
height: 45px;
line-height: 45px;
margin: 8px auto;
border: 1px solid #ccc;
margin-bottom: 8px;
padding-left: 8px;
border-radius: 10px;
font-size: 16px;
color: #fff;
background: #56b273;
border: none;
}
button::after{ border: none;}
.content .banquan{
text-align: center;
margin-top: 50px;
font-size: 15px;
color: #666;
}
</style>
uni-app实现Android分享到微信朋友圈和微信好友
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...