89 lines
1.5 KiB
JavaScript
89 lines
1.5 KiB
JavaScript
// pages/article/detail.js
|
|
const api = require("../../utils/request.js");
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
elink_f:'',
|
|
domain:getApp().globalData.mediahost
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getDetail(options.id)
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
|
|
getDetail: function (id) {
|
|
var that = this
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
mask:true
|
|
})
|
|
api.request(`/cms/article/${id}/`,'GET').then(res => {
|
|
// res.data.content = res.data.content.replace(/"media/g, '"'+getApp().globalData.mediahost + '/media').replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
|
|
|
|
that.setData(res.data)
|
|
wx.hideLoading({
|
|
complete: (res) => {},
|
|
})
|
|
}).catch(res=>{
|
|
wx.hideLoading({
|
|
complete: (res) => {},
|
|
})
|
|
})
|
|
},
|
|
|
|
}) |