格式完成以后就是也看看到的那个样子了
<!--pages/main-video/main-video.wxml-->
<view>
<view class="videoList">
<block wx:for="{{videoList}}" wx:key="{{item.srtisId}}">
<video-item class="item" itemData="{{item}}" />
</block>
</view>
</view>
// pages/main-video/main-video.js
import { getTopMv } from "../../services/request/myvideorequest"
Page({
/**
* 页面的初始数据
*/
data: {
videoList:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getvideo()
},
async getvideo(){
const videolist = await getTopMv()
this.setData({videoList:videolist.data})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
/* pages/main-video/main-video.wxss */
.videoList{
display: flex;
flex-wrap: wrap;
justify-content: space-around;
padding:0 10rpx;
}
.item{
width: 48%;
}
{
"usingComponents": {
"video-item":"/components/video-items/video-item"
}
}
<!--components/video-item/video-item.wxml-->
<wxs src="/utils/format.wxs" module="format"></wxs>
<view class="item">
<view class="album">
<image class="image" mode="widthFix" src="{{itemData.cover}}"></image>
<view class="info">
<view class="count">{{format.formatCount(itemData.playCount)}}</view>
<view class="duration">{{format.formatTime(itemData.mv.videos[0].duration)}}</view>
</view>
</view>
<view class="content">{{itemData.name}}-{{itemData.artistName}}</view>
</view>
// components/video-item/video-item.js
Component({
/**
* 组件的属性列表
*/
properties: {
itemData:{
type:Object,
value:{}
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
/* components/video-item/video-item.wxss */
.item {
margin-bottom: 30rpx;
}
.album {
position: relative;
border-radius: 24rpx;
overflow: hidden;
display: flex;
}
.album .image{
width: 100%;
}
.info {
position: absolute;
padding: 0 10rpx;
box-sizing: border-box;
width: 100%;
bottom: 8rpx;
display: flex;
justify-content: space-between;
color: #fff;
font-size: 24rpx;
}
.info .count{
padding-left: 36rpx;
position: relative;
}
.info .count::before{
content: "";
position: absolute;
left: -2rpx;
top: 4rpx;
width: 30rpx;
height: 24rpx;
background-size: cover;
background-image :url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAGNFJREFUeF7tXXucHFWV/k71JCTT1ZOQTHeHICoKyXT1EHntym+FFUTxBXmRzIIBUZSH4oIi6yoqRBDRnwKCLwRUSEJCgk9Y2WVFZFd3FVcWTKZrEgTxtyEh3Z3EZLp7QmC6zqYmEwIJqXurpqenqvr0v33uud/5zv2qbt17bhVBfsKAMHBABki4EQaEgQMzIAKR0SEMeDAgApHhIQyIQGQMCAPBGJA7SDDepFWLMCACaZFES5jBGBCBBONNWrUIAyKQFkm0hBmMARFIMN6kVYswIAJpkURLmMEYEIEE401atQgDIpAWSbSEGYwBEUgw3qRVizAgAmmRREuYwRgQgQTjTVq1CAMikBZJtIQZjAERSDDepFWLMCACaZFES5jBGBCBBONNWrUIAyKQFkm0hBmMARFIMN6kVYswIAJpkURLmMEYEIEE401atQgDDRNIdWv3LB7kkwzgGAYfC+CYFuFQwgwFA7yBgEcBPA4DvcnOvp82AlZDBFIt5s5lom8RkGoEKPEhDIyYAcLDbUwXTcgUnhqJrxELpFq0HgLh1JGAkLbCwGgxYACXtmfsbwT1PyKBVIu5P4JoVtDOpZ0w0AwG2kBHBr2TBBZItWhdAcJXmxGg9CEMjIwBfsTM9J0SxEcggVSL3VkYzqNgvC5Ip9JGGGg2A0GnWgEFkjsXREuaHaT0JwyMgIFeM2Mf5bd9MIGUra+CcYXfzsReGBhLBoh4ejLd95wfDIEEUitZv2HgLX46ElthYKwZIDLOSKZ7/8UPjkACqZYs9tOJ2AoDYWCAGV9IZe3FfrCIQPywJbaRZkAEEun0Cfj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DEgAgldSgRQmBgQgYQpG4IldAyIQEKXEgEUJgZEIGHKhmAJHQMikNClRACFiQERSJiyIVhCx4AIJHQpEUBhYuD/AdBe85sTKI9gAAAAAElFTkSuQmCC");
}
.content{
margin-top:10rpx;
font-size:28rpx;
overflow: hidden;
text-overflow:ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient:vertical;
}
{
"component": true,
"usingComponents": {}
}
function formatCount(count){
if(count>=100000000){
return (count/100000000).toFixed(1)+"亿"
}else if(count>=10000){
return (count/10000).toFixed(1)+"万"
}else{
return count
}
}
function formatTime(time){
if(time>=1000){
time = time/1000
}
var minute = Math.floor(time/60)
var second = Math.floor(time)%60
return minute+":"+second
}
module.exports={
formatCount:formatCount,
formatTime:formatTime
}