This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop-wechat/pages/article/detail/index.js

75 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2020-04-25 22:59:04 +08:00
const App = getApp();
// 富文本插件
import wxParse from '../../../wxParse/wxParse.js';
Page({
/**
* 页面的初始数据
*/
data: {
// 文章详情
detail: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 获取文章详情
this.getArticleDetail(options.article_id);
},
/**
* 获取文章详情
*/
getArticleDetail(article_id) {
let _this = this;
App._get('article/detail', {
article_id
2020-08-28 10:50:12 +08:00
}, function (result) {
2020-04-25 22:59:04 +08:00
let detail = result.data.detail;
// 富文本转码
if (detail.article_content.length > 0) {
wxParse.wxParse('content', 'html', detail.article_content, _this, 0);
}
_this.setData({
detail
});
});
},
/**
* 分享当前页面
*/
onShareAppMessage() {
// 构建页面参数
2020-08-28 10:50:12 +08:00
const params = App.getShareUrlParams({
2020-04-25 22:59:04 +08:00
'article_id': this.data.detail.article_id
});
return {
title: this.data.detail.article_title,
path: "/pages/article/detail/index?" + params
};
},
2020-08-28 10:50:12 +08:00
/**
* 分享到朋友圈
* 本接口为 Beta 版本暂只在 Android 平台支持详见分享到朋友圈 (Beta)
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
*/
onShareTimeline() {
// 构建页面参数
const params = App.getShareUrlParams({
'article_id': this.data.detail.article_id
});
return {
// title: this.data.detail.article_title,
path: "/pages/article/detail/index?" + params
};
}
2020-04-25 22:59:04 +08:00
})