修改兼容h5调试

This commit is contained in:
2025-12-16 17:32:54 +08:00
parent 08eaa9f438
commit 9be7e49229
8 changed files with 30 additions and 42 deletions

View File

@@ -8,7 +8,7 @@ export default (params) => {
const shopId = uni.cache.get("shopId") * 1;
const userInfo = uni.cache.get("userInfo") || {};
// #ifdef H5
token = "21f0a0b10e1d40ce9c6464037fedb792";
token = "b61c8b0f1c9d47ad924e33c48b496ce6";
// #endif
let header = {
version: uni.conf.version,

View File

@@ -32,13 +32,14 @@ uni.conf = {
baseUrlwws,
};
console.log('uni.conf',uni.conf)
export const changeEnv = (env) => {
if (env === "test") {
let baseUrl = "http://192.168.1.42"
let baseUrlwws="ws://192.168.1.42:2348"
// #ifdef H5
baseUrl = "/api"
baseUrlwws="http://192.168.1.42:2348"
// #endif
uni.conf = {
debug: true,
@@ -47,7 +48,7 @@ export const changeEnv = (env) => {
phpChatWx: 'ws://192.168.1.42:2348',
version: 100,
autoRemoveCache,
baseUrlwws: "ws://192.168.1.42:2348",
baseUrlwws,
};
}
if (env === "prod") {
@@ -59,4 +60,6 @@ export const changeEnv = (env) => {
baseUrlwws: "wss://czgeatws.sxczgkj.com/wss",
};
}
};
};
export default uni.conf

View File

@@ -1,34 +0,0 @@
// const debug = process.env.NODE_ENV == 'development' ? true : false;
const debug = false
// #ifdef H5
const proxyApi = "/api"
// #endif
// #ifdef MP-WEIXIN || APP || MP-ALIPAY
const proxyApi = 'http://192.168.1.42' // 调试地址
const proxyApiwws = 'ws://192.168.1.42:2348' // 调试地址
// #endif
// #ifdef H5
const baseUrl = debug ? proxyApi : "http://192.168.1.42"
const baseUrlwws = 'ws://192.168.1.42:2348'
// #endif
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.com' // 线上
const baseUrlwws = debug ? proxyApiwws : 'wss://czgeatws.sxczgkj.com/wss' // 线上
// #endif
const version = '100'
const autoRemoveCache = {
count: 100000,
size: 100000
}
uni.conf = {
debug,
baseUrl,
version,
autoRemoveCache,
baseUrlwws
}

View File

@@ -11,7 +11,9 @@ function get(key) {
return ''
}
// #ifdef H5
return res.value
// #endif
if (res.expiretime && res.expiretime < Date.now()) {
remove(key)

View File

@@ -1,4 +1,3 @@
import './0-conf'
import './1-utils'
import './2-url'
import './3-pro'

View File

@@ -1,6 +1,8 @@
import App from './App'
import uviewPlus from '@/uni_modules/uview-plus'
import './framework/bootstrap'
import config from '@/common/config.js'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'

View File

@@ -233,6 +233,10 @@ export const useWebSocket = defineStore('socketTask', () => {
// 发送消息
const sendMessage = (data) => {
console.log('data',data)
if(!data){
return
}
if (isConnected.value && data) {
// console.log('发送消息', data);
socketTask.value.send({

View File

@@ -115,6 +115,18 @@ export const productStore = defineStore("product", {
getLocation() {
return new Promise((resolve, reject) => {
console.log("获取经纬度");
// #ifdef H5
resolve({
accuracy: 65,
altitude: 0,
errMsg: "getLocation:ok",
horizontalAccuracy: 65,
latitude: 23.129163,
longitude: 113.264435,
speed: -1,
verticalAccuracy: 65,
});
// #endif
uni.getLocation({
type: "wgs84",
altitude: true,
@@ -298,11 +310,11 @@ export const productStore = defineStore("product", {
]) {
resolve(
true
);
);
} else {
reject(
false
);
);
}
},
});