index.js
2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
import { enterPageTrack } from "../../api/api"
Component({
properties: {
listItem: Object,
noResult: Boolean,
isMaxScreen:Boolean
},
data: {
templateInfo: {
IMG_URL,
}
},
methods: {
toDetail(e) {
console.log(e);
const { item, type } = e.currentTarget.dataset;
let url = '', tempArr = []
if (item.materialDetailInfoList && item.materialDetailInfoList.length) {
item.materialDetailInfoList.forEach(el => {
tempArr.push(el.image)
})
}
if (type == 'PDF') {
this.openPDF(tempArr[0],item)
return
}
url = JSON.stringify(tempArr)
wx.setStorageSync('pageQueryOfcontent', url);
let pageUrl = `/packageEquity/pages/trainingMaterials/pages/playVideo/index`
let target = pageUrl + `?type=${type}&title=${item.title}&id=${item.id}`
wx.navigateTo({
url: target
});
},
// 打开PDF
openPDF(url,item) {
wx.showLoading()
this.openPdf = false
let _this = this
wx.downloadFile({
url: url,
success: function (res) {
const manage = wx.getFileSystemManager()
let fileName = item.title
manage.saveFile({
tempFilePath: res.tempFilePath,
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
success: function (res) {
wx.openDocument({
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
fileType: 'pdf',
showMenu: false,
success: function (res) {
wx.hideLoading();
_this.openPdf = true
_this.toAddTrack(item.id)
}
})
}
})
},
fail() {
wx.hideLoading();
}
})
},
toAddTrack(id) {
const userInfo = wx.$util.getUserInfo()
const params = {
goodsId: id,
goodsType: 0,
merchantId: userInfo.default4SStoreInfo.merchantId,
merchantName: userInfo.default4SStoreInfo.merchantName
}
enterPageTrack(params).then(res => {
// this.trackId = res.data
wx.setStorageSync('pageQueryOfcontent_trackId', res.data);
})
},
}
})