diff --git a/src/utils/index.js b/src/utils/index.js
index efe43a1..6fc1250 100644
--- a/src/utils/index.js
+++ b/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
+}
+
diff --git a/src/views/myPage/myPage.vue b/src/views/myPage/myPage.vue
index 98628a0..41adec8 100644
--- a/src/views/myPage/myPage.vue
+++ b/src/views/myPage/myPage.vue
@@ -24,8 +24,12 @@
{{ item.title || "暂无" }}
- 视频时长:{{ item.videoTime }}
- 视频容量:{{ item.videoSize }}
+
+ 视频时长:{{ formatSeconds(item.videoTime) }}
+
+
+ 视频容量:{{ bytesToSize(item.videoSize) }}
+
创建时间:{{
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");