Browse Source

在线时间

dev_des
1054425342@qq.com 2 months ago
parent
commit
a9748db0c6
  1. 334
      App.vue
  2. 6
      components/ProductSection.vue
  3. 5
      pages/index/intelligentAgent.vue
  4. 2
      static/js/CommonFunction.js
  5. 2
      static/js/request.js

334
App.vue

@ -1,4 +1,6 @@
<script>
import store from './store'
export default {
globalData: {
mainSliderIndex: 0,
@ -11,38 +13,46 @@ export default {
networkStartTime: null, //
networkEndTime: null, //
},
onLaunch: function () {
// 使
this.initUserUsageStats();
// 使
this.retryReportLocalStats();
//
// this.initBackgroundMusic();
//
this.Post({ id: 10217 }, "/api/article/getArticleById").then((res) => {
try {
let SHFlag = res.data.title;
// let SHFlag = res.data.subtitle
uni.setStorageSync("SHFlag", SHFlag);
} catch (e) {}
});
},
onShow: function () {
//
this.recordAppShow();
},
onHide: function () {
// 退
this.recordAppHide();
},
onLaunch: function () {
// 使
this.initUserUsageStats();
// 使
this.retryReportLocalStats();
//
// this.initBackgroundMusic();
//
this.Post({ id: 10217 }, "/api/article/getArticleById").then((res) => {
try {
let SHFlag = res.data.title;
// let SHFlag = res.data.subtitle
uni.setStorageSync("SHFlag", SHFlag);
} catch (e) {}
});
},
onShow: function () {
//
this.recordAppShow();
this.getUserInfo()
},
onHide: function () {
// 退
this.recordAppHide();
},
methods: {
// 使
initUserUsageStats() {
// ID
this.globalData.userSessionId = this.generateSessionId();
},
getUserInfo(){
if(!this.getUserId())return
this.Post({}, "/framework/user/getInfo", "DES")
.then((res) => {
uni.setStorageSync('userInfo', JSON.stringify(res.data))
})
},
// 使
initUserUsageStats() {
// ID
this.globalData.userSessionId = this.generateSessionId();
},
// ID
generateSessionId() {
@ -51,31 +61,31 @@ export default {
return `session_${timestamp}_${random}`;
},
// -
recordAppShow() {
//
this.getNetworkTime()
.then((networkTime) => {
this.globalData.networkStartTime = networkTime;
})
.catch((err) => {
//
});
},
// -
recordAppHide() {
//
this.getNetworkTime()
.then((networkTime) => {
this.globalData.networkEndTime = networkTime;
// 使1
this.reportUserUsageStats();
})
.catch((err) => {
//
});
},
// -
recordAppShow() {
//
this.getNetworkTime()
.then((networkTime) => {
this.globalData.networkStartTime = networkTime;
})
.catch((err) => {
//
});
},
// -
recordAppHide() {
//
this.getNetworkTime()
.then((networkTime) => {
this.globalData.networkEndTime = networkTime;
// 使1
this.reportUserUsageStats();
})
.catch((err) => {
//
});
},
getUserId() {
const userInfoFromStorage = uni.getStorageSync("userInfo");
if (userInfoFromStorage) {
@ -87,38 +97,38 @@ export default {
return store.state.user.userInfo.id;
},
// 使
reportUserUsageStats() {
if (
!this.globalData.networkStartTime ||
!this.globalData.networkEndTime
) {
return;
}
let userId = this.getUserId();
const usageData = {
sessionId: this.globalData.userSessionId,
startTime: this.globalData.networkStartTime.toString(),
endTime: this.globalData.networkEndTime.toString(),
userId: userId,
method: "POST",
};
if (!userId) {
this.saveUsageStatsToLocal(usageData);
return;
}
//
this.Post(usageData, "/api/visit/end", "DES")
.then((res) => {
//
this.clearUsageStats();
})
.catch((err) => {
//
this.saveUsageStatsToLocal(usageData);
});
},
// 使
reportUserUsageStats() {
if (
!this.globalData.networkStartTime ||
!this.globalData.networkEndTime
) {
return;
}
let userId = this.getUserId();
const usageData = {
sessionId: this.globalData.userSessionId,
startTime: this.globalData.networkStartTime.toString(),
endTime: this.globalData.networkEndTime.toString(),
userId: userId,
method: "POST",
};
if (!userId) {
this.saveUsageStatsToLocal(usageData);
return;
}
//
this.Post(usageData, "/api/visit/end", "DES")
.then((res) => {
//
this.clearUsageStats();
})
.catch((err) => {
//
this.saveUsageStatsToLocal(usageData);
});
},
//
getPlatform() {
@ -137,40 +147,40 @@ export default {
return "unknown";
},
//
getNetworkTime() {
return new Promise((resolve, reject) => {
//
this.Post({}, "/api/visit/currentTime", "DES")
.then((res) => {
if (res.code == 1 || res.code == 200) {
// serverTime
const networkTime = res.data;
resolve(networkTime);
} else {
reject(new Error(res.msg || "获取网络时间失败"));
}
})
.catch((err) => {
reject(err);
});
});
},
//
getDeviceInfo() {
try {
const systemInfo = uni.getSystemInfoSync();
return {
model: systemInfo.model || "",
system: systemInfo.system || "",
platform: systemInfo.platform || "",
version: systemInfo.version || "",
};
} catch (e) {
return {};
}
},
//
getNetworkTime() {
return new Promise((resolve, reject) => {
//
this.Post({}, "/api/visit/currentTime", "DES")
.then((res) => {
if (res.code == 1 || res.code == 200) {
// serverTime
const networkTime = res.data;
resolve(networkTime);
} else {
reject(new Error(res.msg || "获取网络时间失败"));
}
})
.catch((err) => {
reject(err);
});
});
},
//
getDeviceInfo() {
try {
const systemInfo = uni.getSystemInfoSync();
return {
model: systemInfo.model || "",
system: systemInfo.system || "",
platform: systemInfo.platform || "",
version: systemInfo.version || "",
};
} catch (e) {
return {};
}
},
// 使
clearUsageStats() {
@ -179,46 +189,46 @@ export default {
this.globalData.userSessionId = null;
},
// 使
saveUsageStatsToLocal(usageData) {
try {
const localStats = uni.getStorageSync("pendingUsageStats") || [];
localStats.push(usageData);
uni.setStorageSync("pendingUsageStats", localStats);
} catch (e) {
//
}
},
// 使
retryReportLocalStats() {
try {
const localStats = uni.getStorageSync("pendingUsageStats") || [];
if (localStats.length === 0) {
return;
}
let userId = this.getUserId();
if (!userId) {
return;
}
//
localStats.forEach((stats, index) => {
stats.userId = userId;
this.Post(stats, "/api/visit/end", "DES")
.then((res) => {
//
localStats.splice(index, 1);
uni.setStorageSync("pendingUsageStats", localStats);
})
.catch((err) => {
//
});
});
} catch (e) {
//
}
},
// 使
saveUsageStatsToLocal(usageData) {
try {
const localStats = uni.getStorageSync("pendingUsageStats") || [];
localStats.push(usageData);
uni.setStorageSync("pendingUsageStats", localStats);
} catch (e) {
//
}
},
// 使
retryReportLocalStats() {
try {
const localStats = uni.getStorageSync("pendingUsageStats") || [];
if (localStats.length === 0) {
return;
}
let userId = this.getUserId();
if (!userId) {
return;
}
//
localStats.forEach((stats, index) => {
stats.userId = userId;
this.Post(stats, "/api/visit/end", "DES")
.then((res) => {
//
localStats.splice(index, 1);
uni.setStorageSync("pendingUsageStats", localStats);
})
.catch((err) => {
//
});
});
} catch (e) {
//
}
},
initBackgroundMusic() {
try {

6
components/ProductSection.vue

@ -25,8 +25,8 @@
<!-- 图片蒙层 -->
<view class="image-overlay" v-if="!isFeel"></view>
<!-- 智能体标签 -->
<view class="content-box-info" v-if="!isFeel">
<view class="ai-tag" v-if="item.agent">
<view class="content-box-info" v-if="!isFeel&&item.agent">
<view class="ai-tag">
<view
class="ai-label"
:style="{
@ -180,7 +180,7 @@ export default {
if (img.indexOf("https://") != -1 || img.indexOf("http://") != -1) {
return img;
} else {
return this.$options._base.prototype.NEWAPIURL + img;
return this.$options._base.prototype.NEWAPIURLIMG + img;
}
},
},

5
pages/index/intelligentAgent.vue

@ -1,11 +1,12 @@
<template>
<view class="bg">
<view class="content">
<swiper class="top-banner" :indicator-dots="false" :autoplay="false" v-if="topBanner && topBanner.length > 0">
<!-- <swiper class="top-banner" :indicator-dots="false" :autoplay="false" v-if="topBanner && topBanner.length > 0">
<swiper-item v-for="(item, index) in topBanner" :key="index" @click.stop="gotoUrlNew(item)">
<image class="top-banner" :src="showImg(item.head_img)" mode="aspectFill" lazy-load="true"></image>
</swiper-item>
</swiper>
</swiper> -->
<image class="top-banner" :src="showImg('/uploads/20250821/ebc938df8942dee581971d0584980fba.gif')" mode="aspectFill" lazy-load="true"></image>
</view>
<CustomTabBar :currentTab="3" />
<MusicControl />

2
static/js/CommonFunction.js

@ -91,7 +91,7 @@ Vue.prototype.showImg = img => {
if (img.indexOf('https://') != -1 || img.indexOf('http://') != -1) {
return img;
} else {
return Vue.prototype.NEWAPIURL + img ;
return Vue.prototype.NEWAPIURLIMG + img ;
}
}

2
static/js/request.js

@ -51,6 +51,8 @@ const handleError = (res, reject, noForceLogin) => {
// 挂载到 Vue 原型上
Vue.prototype.NEWAPIURL = NEWAPIURL;
Vue.prototype.NEWAPIURLIMG = 'https://epic.js-dyyj.com';
Vue.prototype.NEWAPIURL = NEWAPIURL;
Vue.prototype.NEWAPIURL_DES = NEWAPIURL_DES;
// #ifdef H5

Loading…
Cancel
Save