任务、素材下拉刷新

master
Tuisku 3 years ago
parent e1055fa68e
commit f4076ed153

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -6,7 +6,7 @@ Page({
*/
data: {
data: {},
host: getApp().globalData.host
cdn: getApp().globalData.cdn
},
/**

@ -1,6 +1,6 @@
<!--utils/video/video.wxml-->
<view class="main">
<video style="width: 100%;" src="{{host+data.fileUrl}}"></video>
<video style="width: 100%;" src="{{cdn+data.fileUrl}}"></video>
<view class="bottom">
<view class="title">{{data.title}}</view>
<view class="cards">
@ -16,7 +16,7 @@
<image style="width: 24rpx;height: 24rpx;" src="/images/ic_sc_bs@2x.png"></image>
收藏
</button>
<button class="one" plain="{{true}}" data-url="{{host+data.fileUrl}}" bindtap="downloadfile">
<button class="one" plain="{{true}}" data-url="{{cdn+data.fileUrl}}" bindtap="downloadfile">
<image style="width: 24rpx;height: 24rpx;" src="/images/ic_bc_bs@2x.png"></image>
保存
</button>

@ -6,7 +6,8 @@ Page({
* 页面的初始数据
*/
data: {
data: {},
cdn: getApp().globalData.cdn
},
/**
@ -27,8 +28,55 @@ Page({
wx.setBackgroundColor({
backgroundColor: '#000000',
})
let that = this
wx.getStorage({
key: 'article',
success(res){
console.log('todata')
console.log(res)
that.setData({
data: res.data
})
}
})
},
downloadfile(e){
wx.showLoading({
title: '正在下载',
mask: true
})
var url = e.currentTarget.dataset.url;
//下载文件,生成临时地址
wx.downloadFile({
url: url,
success(res) {
console.log(res)
//保存到本地
wx.saveFile({
tempFilePath: res.tempFilePath,
success: function (res) {
console.log(res)
console.log('保存到本地',res)
wx.saveImageToPhotosAlbum({
filePath: res.savedFilePath,
complete(res){
wx.hideLoading();
console.log('保存到相册',res)
}
})
},
fail: function (err) {
wx.hideLoading();
console.log('保存失败:', err)
},
complete(res){
wx.hideLoading();
console.log(res)
}
});
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

@ -1,26 +1,26 @@
<!--pages/lookup/lookimg/img.wxml-->
<!--utils/video/video.wxml-->
<view class="main">
<image style="width: 750rpx;height: 750rpx;" src="/pages/quest/subpage/detail/image/short/img_xtuone@2x.png"></image>
<image style="width: 100%;" src="{{cdn+data.fileUrl}}"></image>
<view class="bottom">
<view class="title">3月31日上海展厅摄影图片</view>
<view class="title">{{data.title}}</view>
<view class="cards">
<view class="card">星途追风</view>
<view class="card">星途凌云</view>
</view>
<view class="operation">
<view class="one">
<button class="one" plain="{{true}}" open-type="share">
<image style="width: 24rpx;height: 24rpx;" src="/images/ic_fx_bs@2x.png"></image>
分享
</view>
<view class="one">
</button>
<button class="one" plain="{{true}}">
<image style="width: 24rpx;height: 24rpx;" src="/images/ic_sc_bs@2x.png"></image>
收藏
</view>
<view class="one">
</button>
<button class="one" plain="{{true}}" data-url="{{cdn+data.fileUrl}}" bindtap="downloadfile">
<image style="width: 24rpx;height: 24rpx;" src="/images/ic_bc_bs@2x.png"></image>
保存
</view>
</button>
</view>
</view>
</view>

@ -4,18 +4,20 @@
background-color: black;
width: 750rpx;
height: 90vh;
padding-bottom: 10vh;
display: flex;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
padding-bottom: 10vh;
}
.bottom{
.bottom {
width: 750rpx;
position: fixed;
bottom: 80rpx;
}
.title {
font-size: 32rpx;
font-family: PingFangSC-Regular, PingFang SC;
@ -47,17 +49,23 @@
width: 750rpx;
padding: 32rpx;
}
.one{
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
line-height: 20rpx;
display: flex;
flex-direction: column;
align-items: center;
.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{
.operation {
display: flex;
justify-content: space-around;
margin-top: 122rpx;

@ -101,7 +101,7 @@ Page({
questes: [],
maxpage: 1,
page: 1,
host: getApp().globalData.host
cdn: getApp().globalData.cdn
},
/**
* 生命周期函数--监听页面加载
@ -237,7 +237,22 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.onRefresh()
},
onRefresh:function(){
//导航条加载动画
wx.showNavigationBarLoading()
//loading 提示框
wx.showLoading({
title: 'Loading...',
})
console.log("下拉刷新啦");
setTimeout(function () {
wx.hideLoading();
wx.hideNavigationBarLoading();
//停止下拉刷新
wx.stopPullDownRefresh();
}, 2000)
},
/**

@ -1,3 +1,4 @@
{
"usingComponents": {}
"usingComponents": {},
"enablePullDownRefresh": true
}

@ -23,7 +23,7 @@
<view class="mat_card" wx:for="{{questes}}" wx:key="index" data-id="{{item.id}}" data-url="/pages/material/subpage/newest/newest" bindtap="to">
<view class="mat_top">
<!-- <view class="mat_image"></view> -->
<image class="mat_image" src="{{host + item.url}}"></image>
<image class="mat_image" src="{{cdn + item.coverUrl}}"></image>
</view>
<view style="width: 328rpx;height: 1rpx;background: linear-gradient(90deg, rgba(232, 232, 232, 0) 0%, #E8E8E8 49%, rgba(232, 232, 232, 0) 100%);"></view>
<view class="mat_bottom">{{item.name}}</view>

@ -1,4 +1,9 @@
// pages/material/subpage/newest/newest.js
import {
http,
formatTime,
lookup
} from '../../../../utils/util'
Page({
/**
@ -99,27 +104,73 @@ Page({
showOrHide: false,
ac: false,
choose: false,
id: null
id: null,
listdata: [],
count: 0,
flag: 5
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log(options.id)
this.setData({
id: options.id
})
this.getdata()
wx.setNavigationBarTitle({
title: '最新素材',
success: function (res) {}
})
},
getdata() {
let that = this
http("/reference/listByDay", "post", {
date: formatTime(new Date(new Date().getTime() - 86400000 * that.data.count)),
groupId: Number(this.data.id),
}).then(res => {
if (res.data.length === 0) {
this.setData({
count: this.data.count + 1,
})
this.getdata()
} else {
// 单日数据
let arr = {}
// 是否全选
arr.all = false
arr.time = formatTime(new Date(new Date().getTime() - 86400000 * that.data.count)).split(' ')[0]
arr.refrence = []
res.data.forEach(el=>{
// 单卡数据
let ele = el
// 单选
ele.choose = false
// 当前位置
ele.index = that.data.count
// 卡片数据
arr.refrence = arr.refrence.concat(ele)
})
this.setData({
listdata: this.data.listdata.concat(arr),
flag: this.data.flag - 1,
})
this.setData({
count: this.data.count + 1,
})
}
// if (this.data.flag > 1) {
// this.getdata()
// }
})
},
to(e) {
if (this.data.choose) {} else {
wx.navigateTo({
url: e.currentTarget.dataset.url,
})
}
// if (this.data.choose) {} else {
// wx.navigateTo({
// url: e.currentTarget.dataset.url,
// })
// }
// console.log(e.currentTarget.dataset.item)
lookup(e.currentTarget.dataset.item)
},
// 点击菜单栏触发的事件函数
handleClick: function (e) {
@ -155,7 +206,6 @@ Page({
}
// 令当前点击的菜单栏高亮
navItem.forEach((v, i) => i === index ? v.is = true : v.is = false)
// console.log(selectItem[index].rank)
this.setData({
showOrHide: true,
selectedItem: selectItem[index].rank,
@ -188,7 +238,6 @@ Page({
v.is = false
})) : (navItem.forEach((v) => v.is = false))
// 调取借口触发筛选
// console.log(navItem)
this.setData({
listNum: -1,
showOrHide: false,
@ -196,19 +245,52 @@ Page({
selectedItem
})
},
tochoose () {
tochoose() {
this.setData({
choose:!this.data.choose
choose: !this.data.choose
})
},
choose (e) {
console.log(e)
choose(e) {
let a = e.currentTarget.dataset.data.index
let b = e.currentTarget.dataset.index
let c = 'listdata[' + a + '].refrence[' + b + '].choose'
this.setData({
ac:!this.data.ac
[c] : !this.data.listdata[a].refrence[b].choose
})
let flag = true
for (let i = 0; i < this.data.listdata[a].refrence.length; i++) {
if (this.data.listdata[a].refrence[i].choose) {
} else {
flag = false
}
}
if (flag) {
// this.data.listdata[a].all = true
let d = 'listdata[' + a + '].all'
this.setData({
[d]: true
})
} else {
// this.data.listdata[a].all = false
let d = 'listdata[' + a + '].all'
this.setData({
[d]: false
})
}
},
chooseall (e) {
let a = 'listdata[' + e.currentTarget.dataset.index + '].all'
let b = e.currentTarget.dataset.index
for (let i = 0; i < this.data.listdata[b].refrence.length; i++) {
let c = 'listdata['+b+'].refrence['+i+'].choose'
this.setData({
[c]: !this.data.listdata[b].all
})
}
this.setData({
[a]: !this.data.listdata[b].all
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
@ -248,7 +330,7 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
this.getdata()
},
/**

@ -20,24 +20,28 @@
<view class="{{showOrHide?'shadow':''}}" bind:tap="closeMask" />
<!-- 素材展示 -->
<view class="mat">
<view class="mat_card">
<view class="card_top">今天
<view></view>
<view class="mat_card" wx:for="{{listdata}}" wx:key="index" data-day="{{index}}">
<view class="card_top">
{{item.time}}
<button class="allin" wx:if="{{choose}}" data-index="{{index}}" bindtap="chooseall">{{item.all?'全不选':'全选'}}</button>
</view>
<view class="cards">
<view class="card" data-url="/pages/lookup/loockvideo/video" bindtap="to" capture-bind:longtap="tochoose">
<!-- <view class="card" wx:for="{{item.refrence}}" wx:key="index" data-item="{{item}}" data-in="{{index}}" data-url="/pages/lookup/loockvideo/video" bindtap="to" capture-bind:longtap="tochoose"> -->
<view class="card" wx:for="{{item.refrence}}" wx:key="index" data-item="{{item}}" data-in="{{index}}" bindtap="to">
<!-- 封面图片 -->
<image style="width: 144rpx;height: 144rpx;border-radius: 8rpx;" src="../../../quest/subpage/detail/image/short/img_xtuone@2x.png"></image>
<!-- 左下角播放时长 -->
<view class="time">
<!-- <view class="time">
<image style="width: 16rpx;height: 18rpx;margin-right: 5rpx;" src="/images/img_bofang@2x.png"></image>03:32
</view>
</view> -->
<!-- 收藏标志 -->
<image class="shouca" src="/images/ic_shouc@2x.png"></image>
<!-- <image class="shouca" src="/images/ic_shouc@2x.png"></image> -->
<!-- 多选 -->
<view wx:if="{{choose}}" class="choose {{ac?'active':'non'}}" catchtap="choose"></view>
<view wx:if="{{choose}}" wx:key="index" class="choose {{item.choose?'active':'non'}}" data-data="{{item}}" data-index="{{index}}" catchtap="choose"></view>
</view>
</view>
</view>
<!-- 加载更多 -->
<button style="color: #D0D0D0;" bindtap="getdata">加载更多</button>
</view>
</view>

@ -138,6 +138,9 @@
line-height: 32rpx;
margin-top: 8rpx;
margin-bottom: 32rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.card {
@ -169,27 +172,46 @@
width: 32rpx;
height: 32rpx;
position: relative;
bottom: 165rpx;
bottom: 145rpx;
left: 105rpx;
}
.choose.non{
.choose.non {
width: 32rpx;
height: 32rpx;
background: rgba(0, 0, 0, 0.3);
border: 2rpx solid #FFFFFF;
position: relative;
bottom: 113rpx;
bottom: 93rpx;
left: 100rpx;
border-radius: 32rpx;
}
.choose.active{
.choose.active {
width: 32rpx;
height: 32rpx;
background: #006BFF;
border: 2rpx solid #FFFFFF;
position: relative;
bottom: 113rpx;
bottom: 93rpx;
left: 100rpx;
border-radius: 32rpx;
}
.allin {
width: 120rpx !important;
height: 48rpx !important;
background: #F9F9F9;
border-radius: 24rpx !important;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
line-height: 24rpx;
padding: 0rpx !important;
margin: 0rpx !important;
display: flex;
justify-content: center;
align-items: center;
right: 32rpx;
}

@ -251,9 +251,23 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.onRefresh()
},
onRefresh:function(){
//导航条加载动画
wx.showNavigationBarLoading()
//loading 提示框
wx.showLoading({
title: 'Loading...',
})
console.log("下拉刷新啦");
setTimeout(function () {
wx.hideLoading();
wx.hideNavigationBarLoading();
//停止下拉刷新
wx.stopPullDownRefresh();
}, 2000)
},
/**
* 页面上拉触底事件的处理函数
*/

@ -1,3 +1,4 @@
{
"usingComponents": {}
"usingComponents": {},
"enablePullDownRefresh": true
}

@ -10,7 +10,7 @@ const formatTime = date => {
const minute = date.getMinutes()
const second = date.getSeconds()
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
return `${[year, month, day].map(formatNumber).join('-')} ${[hour, minute, second].map(formatNumber).join(':')}`
}
const formatNumber = n => {
@ -63,7 +63,7 @@ const http = (url, method, data, isLoading = true) => {
}
const lookup = (e) => {
// console.log(e)
console.log(e.type)
if (e.type === 1) {
wx.navigateTo({
url: '/pages/lookup/loockvideo/video',
@ -73,7 +73,13 @@ const lookup = (e) => {
data: e
})
} else {
wx.navigateTo({
url: '/pages/lookup/lookimg/img',
})
wx.setStorage({
key: 'article',
data: e
})
}
}

Loading…
Cancel
Save