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

6
components/ProductSection.vue

@ -25,8 +25,8 @@
<!-- 图片蒙层 --> <!-- 图片蒙层 -->
<view class="image-overlay" v-if="!isFeel"></view> <view class="image-overlay" v-if="!isFeel"></view>
<!-- 智能体标签 --> <!-- 智能体标签 -->
<view class="content-box-info" v-if="!isFeel"> <view class="content-box-info" v-if="!isFeel&&item.agent">
<view class="ai-tag" v-if="item.agent"> <view class="ai-tag">
<view <view
class="ai-label" class="ai-label"
:style="{ :style="{
@ -180,7 +180,7 @@ export default {
if (img.indexOf("https://") != -1 || img.indexOf("http://") != -1) { if (img.indexOf("https://") != -1 || img.indexOf("http://") != -1) {
return img; return img;
} else { } 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> <template>
<view class="bg"> <view class="bg">
<view class="content"> <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)"> <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> <image class="top-banner" :src="showImg(item.head_img)" mode="aspectFill" lazy-load="true"></image>
</swiper-item> </swiper-item>
</swiper> </swiper> -->
<image class="top-banner" :src="showImg('/uploads/20250821/ebc938df8942dee581971d0584980fba.gif')" mode="aspectFill" lazy-load="true"></image>
</view> </view>
<CustomTabBar :currentTab="3" /> <CustomTabBar :currentTab="3" />
<MusicControl /> <MusicControl />

2
static/js/CommonFunction.js

@ -91,7 +91,7 @@ Vue.prototype.showImg = img => {
if (img.indexOf('https://') != -1 || img.indexOf('http://') != -1) { if (img.indexOf('https://') != -1 || img.indexOf('http://') != -1) {
return img; return img;
} else { } 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 原型上
Vue.prototype.NEWAPIURL = NEWAPIURL; Vue.prototype.NEWAPIURL = NEWAPIURL;
Vue.prototype.NEWAPIURLIMG = 'https://epic.js-dyyj.com';
Vue.prototype.NEWAPIURL = NEWAPIURL;
Vue.prototype.NEWAPIURL_DES = NEWAPIURL_DES; Vue.prototype.NEWAPIURL_DES = NEWAPIURL_DES;
// #ifdef H5 // #ifdef H5

Loading…
Cancel
Save