ok
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
// pages/details/details.js
|
||||
|
||||
|
||||
const request = require('../../utils/request')
|
||||
const ui = require('../../utils/ui')
|
||||
const wxParse = require("../../wxParse/wxParse.js");
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -6,15 +12,127 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
|
||||
navTitle: "详情",
|
||||
date: "",
|
||||
title: "",
|
||||
content: "",
|
||||
aid: 0,
|
||||
isDow: false,
|
||||
ext_download_link: ""
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
let that = this;
|
||||
if (!options.aid) {
|
||||
wx.navigateBack()
|
||||
this.triggerEvent('onBack')
|
||||
}
|
||||
that.setData({
|
||||
aid: options.aid
|
||||
})
|
||||
that.GetDetailsInfo()
|
||||
console.log(options);
|
||||
//
|
||||
},
|
||||
|
||||
initContent() {
|
||||
let that = this;
|
||||
console.log(that.data.content);
|
||||
if (that.data.content.length > 0) {
|
||||
wxParse.wxParse('content', 'html', that.data.content, that, 0);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
GetDetailsInfo() {
|
||||
let that = this;
|
||||
request.request({
|
||||
method: "GET",
|
||||
// https://app.19year.cn/api.php/doc/details?id=51
|
||||
url: "/api.php/doc/details?id=" + that.data.aid
|
||||
}).then(res => {
|
||||
if (res.data.code === 1) {
|
||||
|
||||
that.setData({
|
||||
title: res.data.data.title,
|
||||
date: res.data.data.date,
|
||||
content: res.data.data.content,
|
||||
ext_download_link: res.data.data.ext_download_link,
|
||||
})
|
||||
if (res.data.data.ext_download_link.length > 0) {
|
||||
that.setData({
|
||||
isDow: true
|
||||
})
|
||||
}
|
||||
that.initContent()
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log('ERROR')
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
downloadFileOpen() {
|
||||
let that = this;
|
||||
let link = that.data.ext_download_link
|
||||
wx.setClipboardData({
|
||||
data: link,
|
||||
success: function (res) {
|
||||
wx.getClipboardData({
|
||||
success: function (res) {
|
||||
wx.showToast({
|
||||
title: '复制成功'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
//复制到剪切板
|
||||
// wx.setClipboardData({
|
||||
// data: link,
|
||||
// success(res) {
|
||||
// console.log('copy success');
|
||||
// //获取剪切板的纸
|
||||
// // wx.getClipboardData({
|
||||
// // success(res) {
|
||||
// // console.log(res) // data
|
||||
// // that.copyContent = res.data
|
||||
// // }
|
||||
// // })
|
||||
// }
|
||||
// })
|
||||
|
||||
|
||||
|
||||
// wx.showLoading({
|
||||
// title: '下载中',
|
||||
// })
|
||||
//下载文件
|
||||
// wx.downloadFile({
|
||||
// url: link,
|
||||
// success (res) {
|
||||
// if (res.statusCode === 200) {
|
||||
// const filePath = res.tempFilePath
|
||||
// wx.openDocument({
|
||||
// filePath: filePath,
|
||||
// showMenu:true, //关键点
|
||||
// success: function (res) {
|
||||
// console.log('打开文档成功')
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user