first commit

This commit is contained in:
Ls
2026-02-12 12:19:20 +08:00
commit 219fd9be5c
529 changed files with 169918 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import { onMounted, ref } from "vue";
import { WebSocket } from '@/Service/Comm/TwWebSocket';
import { Service } from "@/Service/Service"
import { CNRiderOrderService } from '@/Service/CN/CNRiderOrderService'
import { CNRiderLoginService } from "@/Service/CN/CNRiderLoginService";
let isios = ref(false)
const currentLatitude = ref(0);
const currentLongitude = ref(0);
let locationTimer : ReturnType<typeof setInterval> | null = null;
onLaunch(() => {
isios.value = uni.getSystemInfoSync().platform != 'ios'//是否为ios
//#ifdef APP-PLUS//app
if (isios.value) {
getUpData()//更新
}
//#endif
// 在 App 启动时,立即初始化并建立 WebSocket 连接
if (Service.GetUserIsLogin()) {
WebSocket.ConnectSocketInit();
}
// 打开调用
uni.$on("ImCom", () => {
WebSocket.ConnectSocketInit();
})
// 关闭调用
uni.$on("ImComOff", () => {
WebSocket.CloseSocket();
})
});
onShow(() => {
WebSocket.ConnectSocketInit();
});
onHide(() => {
});
const startFetchingLocation = () => {
// 安全检查:如果定时器已存在,先清除,防止重复启动
if (locationTimer) {
clearInterval(locationTimer);
}
console.log("开始定时获取位置间隔1分钟...");
// 1. 立即执行第一次获取
getLocationNow();
// 2. 设置定时器,每 60000 毫秒 (1分钟) 执行一次
locationTimer = setInterval(() => {
getLocationNow();
}, 60000);
};
const getLocationNow = () => {
uni.getLocation({
type: 'wgs84',
isHighAccuracy: true,
success: (res) => {
if (Service.GetUserIsLogin()) {
CNRiderOrderService.UpdateRiderLocation(res.longitude, res.latitude).then(res => { })
}
},
fail: (err) => {
// console.error('获取经纬度失败:', err);
}
});
};
/**
* 停止定时获取位置
*/
const stopFetchingLocation = () => {
if (locationTimer) {
clearInterval(locationTimer);
locationTimer = null; // 清理 ID
}
};
const getUpData = () => {
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
CNRiderLoginService.GetAppVersion(wgtinfo.versionCode, 'Rider').then(res => {
if(res.code==0){
if (res.data.url!=='') {
setTimeout(function() {
Service.GoPage('/pages/index/upApp?url='+res.data.url)
}, 1000)
}
}
})
})
}
</script>
<style lang="scss">
@import "uview-plus/index.scss";
@import "colorui/main.css";
@import "colorui/icon.css";
page {
--nav-mian: #1890FF; //全局颜色
--nav-vice: #52C41A; //副颜色
--nav-diluted: #FF4D4F; //次颜色
}
</style>

View File

@@ -0,0 +1,7 @@
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [uni()],
});