微信小程序点击右上角胶囊分享动态获取title
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
微信⼩程序点击右上⾓胶囊分享动态获取title
刚⼜试了下,这种有点试⽅法有点复杂了
⽅法⼀:
wxml:(⽗级页⾯)
<view class="pageLi flex" catchtap="toInstitute" data-name="{{item.shop_name}}" data-id="{{item.id}}">
<image src='{{item.headimg}}' mode='aspectFill'></image>
<view class="pagePre sub">
<text class="tit f32">{{item.shop_name}}</text>
<view class="page_text flex">
<text wx:for="{{item.sports}}" wx:if="{{idx<4}}" wx:for-index="idx" wx:for-item="item2">{{item2.sport_name}}</text>
</view>
<text class="phone">联系电话:{{item.phone}}</text>
<text class="add">浏览:{{item.sort}}</text>
<text class="add">{{item.address}}</text>
</view>
</view>
wxjs:(⽗级页⾯)
toInstitute: function(e) {
let share_title=
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/newPage/institute/index?share_title=' + share_title + '&id=' + id
})
},
wxjs:(⼦页⾯)
data: {
id: 0,
shareTitle:''
},
onLoad: function (options) {
this.data.id = options.id
this.data.shareTitle=options.share_title
console.log(this.data.shareTitle)
console.log(options.share_title)
}
/**
* ⽤户点击右上⾓分享
*/
onShareAppMessage: function (options) {
console.log(options.share_title)
// ⽤户点击了“转发”按钮
return {
title: this.data.shareTitle
}
},
⽅法⼆:(简化法)当前页⾯的分享
wxml:
<view class="pageList f24">
<view class="pageLi flex" data-id="{{item.id}}" data-name="{{traininfo.shop_name}}">
<image src='{{traininfo.headimg}}' mode='aspectFill'></image>
<view class="pagePre sub">
<text class="tit f32">{{traininfo.shop_name}}</text>
<view class="page_text flex">
<text wx:for="{{sports}}" wx:if="{{idx<4}}" wx:for-index="idx" wx:for-item="item2">{{item2.sport_name}}</text>
</view>
<text class="phone" data-phone="{{traininfo.phone}}" catchtap="tophone" style="color:#04B59A;text-decoration: underline;">联系电话:{{traininfo.phone}}</text> <text class="add" catchtap="openMap" style="color:#04B59A;text-decoration: underline;">{{traininfo.address}}</text>
</view>
</view>
</view>
wxjs:
data: {
shareTitleSub:''
},
onLoad: function () {
app.mylocation().then(function (res) {
app.HTTP.post(app.URL.train_url, param, (res) => {
that.data.shareTitleSub=res.traininfo.shop_name
})
}
onShareAppMessage: function (options) {
console.log(options.share_title)
// ⽤户点击了“转发”按钮
return {
title: this.data.shareTitleSub }
},。