js
// pages/downloadFile/downloadFile.js Page({ /** * 页面的初始数据 */ data: { a:'0' }, onClicksource:function(e){ console.log("复制来源信息",e.currentTarget.dataset); let source = e.currentTarget.dataset.source wx.setClipboardData({ data: source }) }, /** * 生命周期函数--监听页面加载 */ onl oad(options) { let that=this let id = options.id console.log(options); wx.request({ url: 'https://api.uom.cn/?mod=seek&act=downloadfile', method:"POST", data:{ id:id }, header:{ 'content-type': 'application/x-www-form-urlencoded' }, success(res){ console.log(res); let fileInfo=res.data[0] let k = fileInfo.id+fileInfo.code let nowtime = Math.round(new Date() / 1000) let fileSize = fileInfo.fileSize/1024/1024 let source ='' var Y,M,D; var Shijianchuo=Number(fileInfo.newstime); Shijianchuo=Shijianchuo*1000; var time = new Date(Shijianchuo); Y = time.getFullYear() + '-'; M = time.getMonth()+1 +"-"; D = time.getDate(); console.log("时间",Y+M+D); fileInfo.newstime=Y+M+D; if(fileInfo.laiyuan!=''){ source = "https://mp.weixin.qq.com/s/"+fileInfo.laiyuan }; fileSize = fileSize.toFixed(2) console.log(k); if( fileInfo.ewmtime == 0 || nowtime > fileInfo.ewmtime){ wx.request({ url: 'https://api.uom.cn/?mod=gzh&act=sendticket', data: { k: k, }, header: { 'content-type': 'application/json' // 默认值 }, success (e) { //console.log("获取ticket的返回结果",e.data) fileInfo.fwhticket = e.data.ticket fileInfo.ewmtime = e.data.ewmtime console.log("获取ticket的返回结果",e) that.setData({ fileInfo:fileInfo, }) } }) }; that.setData({ fileInfo:fileInfo, fileSize:fileSize, source:source, a:'1' }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })
wxml
<!--pages/downloadFile/downloadFile.wxml--> <view class="box"> <view class="title"> 文 件 名 : <text style="color: #2E5A81;">{{fileInfo.title}}</text> </view> <view class="fileTime"> {{"上传时间:"+fileInfo.newstime}} </view> <view class="FileOnClicks"> {{"点 击 量 :"+fileInfo.onclick}} </view> <view class="fileSize"> {{"文件大小:"+fileSize+" MB"}} </view> <view class="source"> 文件来源地址<text style="color: #aaa; font-size: 25rpx;">(点击链接复制)</text>: <text class="source1" bindtap="onClicksource" data-source="{{source}}">{{source}}</text> </view> <view class="fileQR"> <!-- {{fileInfo.}} --> <image wx:if="{{a==0}}" show-menu-by-longpress src="/images/meteorite.gif" style="width: 70rpx;height:70rpx; border-radius: 20%;" mode='scaleToFill'></image> <image wx:if="{{a!=0}}" show-menu-by-longpress src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={{fileInfo.fwhticket}}" style="width: 300rpx;height:300rpx;" mode='scaleToFill'></image> </view> <view class="hint"> 长按上方二维码下载文件 </view> <view class="hint1"> (有时加载较慢,请稍等) </view> </view> <view class="base"> <image src="/images/dt.png" style="width: 100%; height: 100%;"></image> </view>
wxss
/* pages/downloadFile/downloadFile.wxss */ .box{ padding: 10rpx; height: 100%; } .title{ background-color: #fff; padding: 25rpx 10rpx; } .fileTime{ background-color: #eee; padding: 25rpx 10rpx; } .FileOnClicks{ background-color: #fff; padding: 25rpx 10rpx; } .fileSize{ background-color: #eee; padding: 25rpx 10rpx; } .source{ background-color: #fff; padding: 25rpx 10rpx; } .source1{ color: #366dbe; display: flex; flex-wrap: wrap; font-size: 28rpx; } .fileQR{ display: flex; justify-content: center; text-align: center; padding: 100rpx 10rpx; } .hint{ display: flex; justify-content: center; text-align: center; font-size: 50rpx; font-weight: bolder; color: #71a3b3; } .hint1{ display: flex; justify-content: center; text-align: center; font-size: 30rpx; font-weight: bolder; color: #97a2a5; } .base{ height: 200rpx; width: 100%; position: fixed; bottom: 0rpx; /* background-image: linear-gradient(to bottom,#eee,#2e5a81); */ }
标签:color,source,二维码,let,fileSize,fileInfo,页面 From: https://www.cnblogs.com/meetlilanglang/p/16838675.html