parent
5bd3a35176
commit
e088ca415d
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 5.8 KiB |
@ -0,0 +1,235 @@
|
||||
// pages/lookup/lookimg/img.js
|
||||
import {
|
||||
http,
|
||||
matchType
|
||||
} from '../../../utils/util'
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
data: {},
|
||||
cdn: getApp().globalData.cdn,
|
||||
shou: true
|
||||
},
|
||||
//用户点击右上角分享朋友圈
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.data.data.title,
|
||||
query: 'value=' + JSON.stringify(this.data.data),
|
||||
imageUrl: this.data.data.fileUrl ? this.data.cdn + this.data.data.fileUrl : this.data.cdn + this.data.data.teachRefeFileUrl
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
wx.setNavigationBarTitle({
|
||||
title: '文件查看',
|
||||
})
|
||||
wx.setNavigationBarColor({
|
||||
// frontColor: '#ffffff',
|
||||
// backgroundColor: '#000000',
|
||||
animation: {
|
||||
duration: 400,
|
||||
timingFunc: 'easeIn'
|
||||
}
|
||||
})
|
||||
// wx.setBackgroundColor({
|
||||
// backgroundColor: '#000000',
|
||||
// })
|
||||
wx.showShareMenu({
|
||||
withShareTicket: true,
|
||||
menus: ['shareAppMessage', 'shareTimeline']
|
||||
})
|
||||
// 获取当前场景值 以适应单页面模式
|
||||
// 1154 为单页面模式的场景值
|
||||
var pathData = wx.getLaunchOptionsSync()
|
||||
if (pathData.scene == 1154) {
|
||||
console.log(options)
|
||||
var value = JSON.parse(options.value)
|
||||
this.setData({
|
||||
data: JSON.parse(options.value),
|
||||
shou: false
|
||||
})
|
||||
} else {
|
||||
let that = this
|
||||
wx.getStorage({
|
||||
key: 'file',
|
||||
success(res) {
|
||||
let a = matchType(res.data.fileUrl)
|
||||
that.setData({
|
||||
data: res.data,
|
||||
'data.filetype': a
|
||||
})
|
||||
},
|
||||
fail: {}
|
||||
})
|
||||
}
|
||||
},
|
||||
downloadfile(e) {
|
||||
wx.showLoading({
|
||||
title: '正在下载',
|
||||
mask: true
|
||||
})
|
||||
console.log(e)
|
||||
var url = this.data.data.fileUrl;
|
||||
//下载文件,生成临时地址
|
||||
wx.downloadFile({
|
||||
url: this.data.cdn + url,
|
||||
success(res) {
|
||||
console.log(res)
|
||||
//保存到本地
|
||||
wx.getFileSystemManager().saveFile({
|
||||
tempFilePath: res.tempFilePath,
|
||||
success: function (res) {
|
||||
console.log(res)
|
||||
console.log('保存到本地', res)
|
||||
},
|
||||
fail: function (err) {
|
||||
wx.showToast({
|
||||
title: '保存失败',
|
||||
duration: 2000,
|
||||
mask: true,
|
||||
});
|
||||
console.log('保存失败:', err)
|
||||
},
|
||||
complete(res) {
|
||||
wx.hideLoading();
|
||||
console.log(res)
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
seefile(e) {
|
||||
wx.showLoading({
|
||||
title: '正在加载',
|
||||
mask: true
|
||||
})
|
||||
var url = this.data.data.fileUrl;
|
||||
//下载文件,生成临时地址
|
||||
wx.downloadFile({
|
||||
url: this.data.cdn + url,
|
||||
success(res) {
|
||||
console.log(res)
|
||||
wx.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
showMenu: true,
|
||||
success(re) {
|
||||
wx.showToast({
|
||||
title: '加载成功',
|
||||
duration: 2000,
|
||||
mask: true,
|
||||
});
|
||||
},
|
||||
fail(re) {
|
||||
wx.showToast({
|
||||
title: '加载失败',
|
||||
duration: 2000,
|
||||
mask: true,
|
||||
});
|
||||
},
|
||||
complete(re) {
|
||||
wx.hideLoading();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
add() {
|
||||
http("/userReference/add", "post", {
|
||||
referenceId: this.data.data.id
|
||||
}).then(re => {
|
||||
wx.showToast({
|
||||
title: re.data,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
}).then(res => {
|
||||
if (re.code === 200) {
|
||||
this.setData({
|
||||
'data.isCollected': 1
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
del() {
|
||||
http("/userReference/del", "post", {
|
||||
referenceId: this.data.data.id
|
||||
}).then(re => {
|
||||
wx.showToast({
|
||||
title: re.data,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
}).then(res => {
|
||||
if (re.code === 200) {
|
||||
this.setData({
|
||||
'data.isCollected': 0
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
to(e) {
|
||||
console.log(e)
|
||||
if (e.currentTarget.dataset.type === '1') {
|
||||
wx.navigateTo({
|
||||
url: '/pages/lookup/labelsearch/brand/brandsearch?id=' + e.currentTarget.dataset.mes.id + '&name=' + e.currentTarget.dataset.mes.name,
|
||||
})
|
||||
} else if (e.currentTarget.dataset.type === '2') {
|
||||
wx.navigateTo({
|
||||
url: '/pages/lookup/labelsearch/tag/tagsearch?id=' + e.currentTarget.dataset.mes.id + '&name=' + e.currentTarget.dataset.mes.title,
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<!--pages/lookup/lookfile/lookfile.wxml-->
|
||||
<!--pages/lookup/lookimg/img.wxml-->
|
||||
<!--utils/video/video.wxml-->
|
||||
<view class="main">
|
||||
<image bindtap="seefile" wx:if="{{data.filetype==='word'}}" mode="widthFix" style="width: 750rpx;" src="../../../images/img_word@2x.png"></image>
|
||||
<image bindtap="seefile" wx:if="{{data.filetype==='excel'}}" mode="widthFix" style="width: 750rpx;" src="../../../images/img_excel@2x.png"></image>
|
||||
<image bindtap="seefile" wx:if="{{data.filetype==='pdf'}}" mode="widthFix" style="width: 750rpx;" src="../../../images/img_pdf@2x.png"></image>
|
||||
<image bindtap="seefile" wx:if="{{data.filetype==='ppt'}}" mode="widthFix" style="width: 750rpx;" src="../../../images/img_ppt@2x.png"></image>
|
||||
<view class="bottom">
|
||||
<view class="title">{{data.title}}</view>
|
||||
<view class="cards">
|
||||
<view class="card" wx:for="{{data.brandList}}" wx:key="index" data-type="1" data-mes="{{item}}" bindtap="to">{{item.name}}</view>
|
||||
<view class="card" wx:for="{{data.tagList}}" wx:key="index" data-type="2" data-mes="{{item}}" bindtap="to">{{item.title}}</view>
|
||||
</view>
|
||||
<view class="operation" wx:if="{{shou}}">
|
||||
<button class="one" plain="{{true}}" open-type="share">
|
||||
<image style="width: 48rpx;height: 48rpx;" src="/images/ic_fx_bs@2x.png"></image>
|
||||
分享
|
||||
</button>
|
||||
<button class="one" wx:if="{{data.isCollected===0}}" plain="{{true}}" bindtap="add">
|
||||
<image style="width: 48rpx;height: 48rpx;" src="/images/ic_sc_bs@2x.png"></image>
|
||||
收藏
|
||||
</button>
|
||||
<button class="one" wx:if="{{data.isCollected}}" plain="{{true}}" bindtap="del">
|
||||
<image style="width: 48rpx;height: 48rpx;" src="/images/ic_shouc@2x.png"></image>
|
||||
取消收藏
|
||||
</button>
|
||||
<button class="one" plain="{{true}}" data-url="{{data.fileUrl?cdn+data.fileUrl:cdn+data.teachRefeFileUrl}}" bindtap="downloadfile">
|
||||
<image style="width: 48rpx;height: 48rpx;" src="/images/ic_bc_bs@2x.png"></image>
|
||||
保存
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -0,0 +1,75 @@
|
||||
/* pages/lookup/lookimg/img.wxss */
|
||||
/* utils/video/video.wxss */
|
||||
.main {
|
||||
background-color: black;
|
||||
width: 750rpx;
|
||||
min-height: 90vh;
|
||||
padding-bottom: 10vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
width: 750rpx;
|
||||
position: fixed;
|
||||
bottom: 70rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 32rpx;
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
font-weight: 400;
|
||||
color: #FFFFFF;
|
||||
line-height: 32rpx;
|
||||
padding: 32rpx;
|
||||
padding-bottom: 0rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
/* width: 144rpx; */
|
||||
height: 56rpx;
|
||||
padding: 0rpx 10rpx;
|
||||
border-radius: 4rpx;
|
||||
border: 1px solid #FFB17C;
|
||||
font-size: 24rpx;
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
font-weight: 400;
|
||||
color: #FF8B3C;
|
||||
line-height: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: flex;
|
||||
width: 750rpx;
|
||||
padding: 32rpx;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.one {
|
||||
font-size: 20rpx!important;
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
font-weight: 400;
|
||||
color: #FFFFFF!important;
|
||||
line-height: 20rpx!important;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: auto!important;
|
||||
border: none!important;
|
||||
margin: 0rpx!important;
|
||||
/* padding: 0rpx!important; */
|
||||
}
|
||||
|
||||
.operation {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-top: 50rpx;
|
||||
}
|
Loading…
Reference in new issue