接口对接修改

This commit is contained in:
仲么了
2023-07-24 08:47:20 +08:00
parent 2104bc0c4c
commit 689436759f
31 changed files with 1070 additions and 448 deletions

View File

@@ -1,13 +1,13 @@
const debug = true // true 是连地服务端本地false 是连接线上
const development = {
domain: 'http://192.168.1.114:10210',
domain: 'http://192.168.1.139:10215',
devCode: "2aaecd0b124df819eda75e639a1f91fd",
key: "f81804778c89c779"
}
const production = {
domain: 'http://192.168.1.60:8094',
domain: 'http://192.168.1.13:10215',
}
const config = debug ? development : production

71
common/js/drawMixin.js Normal file
View File

@@ -0,0 +1,71 @@
// 屏幕适配 mixin 函数
// * 默认缩放值
const scale = {
width: '1',
height: '1',
};
// * 设计稿尺寸px
const baseWidth = 375;
const baseHeight = 667;
// * 需保持的比例默认1.77778
const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5));
export default {
data() {
return {
// * 定时函数
drawTiming: null,
};
},
mounted() {
this.calcRate();
window.addEventListener('resize', this.resize);
},
beforeDestroy() {
window.removeEventListener('resize', this.resize);
},
methods: {
calcRate() {
const appRef = this.$refs['appRef'];
const fatherRef = this.$refs['fatherRef'];
if (!appRef) return;
// 当前宽高比
const currentRate = parseFloat(
(fatherRef.offsetWidth / fatherRef.offsetHeight).toFixed(5)
);
if (appRef) {
if (currentRate > baseProportion) {
// 表示更宽
scale.width = (
(fatherRef.offsetHeight * baseProportion) /
baseWidth
).toFixed(5);
scale.height = (
fatherRef.offsetHeight / baseHeight
).toFixed(5);
appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`;
} else {
// 表示更高
scale.height = (
fatherRef.offsetWidth /
baseProportion /
baseHeight
).toFixed(5);
scale.width = (fatherRef.offsetWidth / baseWidth).toFixed(
5
);
appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`;
}
}
},
resize() {
clearTimeout(this.drawTiming);
this.drawTiming = setTimeout(() => {
this.calcRate();
}, 200);
},
},
};

View File

@@ -1,6 +1,6 @@
export const MQTT_IP = '60.204.148.71:9001'//mqtt地址端口, 使用emqx时一定要加mqtt
const MQTT_USERNAME = 'test'//mqtt用户名
const MQTT_PASSWORD = 'test'//密码
export const MQTT_IP = '192.168.1.18:8083/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
const MQTT_USERNAME = 't_user'//mqtt用户名
const MQTT_PASSWORD = 'njcnpqs'//密码
export const MQTT_OPTIONS = {
connectTimeout: 5000,

View File

@@ -1,4 +1,10 @@
import CryptoJS from 'crypto-js'
if(typeof navigator === 'undefined') {
var navigator = {
appName: 'Netscape',
};
var window = {};
}
function SM2Cipher(a) {
this.ct = 1;
this.sm3c3 = this.sm3keybase = this.p2 = null;

View File

@@ -1,5 +1,7 @@
import request from './request'
import cache from './cacheKey.js'
import { queryDictDataCache } from '../api/dictionary.js'
import cacheKey from './cacheKey.js'
const toast = (title, duration = 1500, call, mask = false, icon = 'none') => {
if (Boolean(title) === false) {
return
@@ -198,14 +200,23 @@ const prePage = () => {
}
const loginSuccess = (data) => {
console.log(data);
uni.setStorageSync('access_token', data.token_type + ' ' + data.access_token)
uni.setStorageSync('refresh_token', data.refresh_token)
let strings = data.access_token.split('.') //截取token获取载体
var userInfo = JSON.parse(decodeURIComponent(escape(window.atob(strings[1].replace(/-/g, '+').replace(/_/g, '/')))))
console.log(escape,atob);
var userInfo = JSON.parse(decodeURIComponent(escape(atob(strings[1].replace(/-/g, '+').replace(/_/g, '/')))))
userInfo.authorities = userInfo.authorities[0]
uni.setStorageSync('userInfo', userInfo)
uni.reLaunch({
url: '/pages/index/index',
console.log('reLaunch');
queryDictDataCache().then((res) => {
uni.setStorageSync(cacheKey.dictData, res.data)
uni.reLaunch({
url: '/pages/index/index',
fail: (err) => {
console.log(err);
}
})
})
}