浏览代码

时间与大小

release
HolyKnightIX 2 年前
父节点
当前提交
e129f41b20
共有 2 个文件被更改,包括 63 次插入30 次删除
  1. +39
    -0
      src/utils/index.js
  2. +24
    -30
      src/views/myPage/myPage.vue

+ 39
- 0
src/utils/index.js 查看文件

@@ -113,3 +113,42 @@ export function timestampToTime(timestamp, format) {
export function getDeviceType() {
return navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
}




/**
* @description:根据经纬度计算距离
* @param {*} locationInfo (lat1, lng1, lat2, lng2)
* @return: distanceObj: { distance , distance_str }
*/
export function getDistances(lat1, lng1, lat2, lng2) {

function rad(d) {
return d * Math.PI / 180.0;
}
var radLat1 = rad(lat1);
var radLat2 = rad(lat2);
var a = radLat1 - radLat2;
var b = rad(lng1) - rad(lng2);
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * 6378.137;
s = Math.round(s * 10000) / 10000;

var distance = s;
var distance_str = "";

if (parseInt(distance) >= 1) {
distance_str = distance.toFixed(2) + "km";
} else {
distance_str = (distance * 1000).toFixed(2) + "m";
}

let objData = {
distance: distance,
distance_str: distance_str
}
return objData
}


+ 24
- 30
src/views/myPage/myPage.vue 查看文件

@@ -24,8 +24,12 @@
<div class="videoName">
{{ item.title || "暂无" }}
</div>
<div class="createTime">视频时长:{{ item.videoTime }}</div>
<div class="createTime">视频容量:{{ item.videoSize }}</div>
<div class="createTime">
视频时长:{{ formatSeconds(item.videoTime) }}
</div>
<div class="createTime">
视频容量:{{ bytesToSize(item.videoSize) }}
</div>
<div class="createTime">
创建时间:{{
changeTime(item.createDate, "YYYY-MM-DD hh:mm:ss")
@@ -140,6 +144,24 @@ export default {
}
},

// 秒转化时分秒
formatSeconds(seconds) {
if (seconds) {
return formatSeconds(seconds);
} else {
return "无";
}
},

// 将bytes转化
bytesToSize(bytes) {
if (bytes) {
return bytesToSize(bytes);
} else {
return "无";
}
},

// 查看详情
goDetail(item) {
const status = item.videoStatus;
@@ -186,33 +208,6 @@ export default {
});
},

// 将获取到的视频详情(视频时长、视频容量)加入视频列表
getDetailJoinList(list) {
const that = this;
console.log(list, "list");
let i = 0;
list.forEach(async (val) => {
if (val.videoStatus == 2 && val.videoId) {
const videoData = await that.getVideoDetialById(val.videoId);
that.$set(
that.videoList[i],
"videoTime",
formatSeconds(videoData.duration)
);
that.$set(
that.videoList[i],
"videoSize",
bytesToSize(videoData.size)
);
that.$set(that.videoList[i], "coverUrl", videoData.coverURL);
} else {
that.$set(that.videoList[i], "videoTime", "无");
that.$set(that.videoList[i], "videoSize", "无");
}
i++;
});
},

/**
* @description:获取作品列表
*/
@@ -221,7 +216,6 @@ export default {
const res = await getVideoList(pageNum, pageSize);
console.log(res, "获取作品列表");
this.videoList = res.data.list;
this.getDetailJoinList(this.videoList);
this.total = res.data.total;
} catch (error) {
console.log(error, "error");


正在加载...
取消
保存