接口对接

This commit is contained in:
仲么了
2023-03-30 09:04:07 +08:00
parent 3f966d4024
commit 0325347e06
15 changed files with 226 additions and 61 deletions

View File

@@ -1,7 +1,7 @@
const debug = true // true 是连地服务端本地false 是连接线上
const development = {
domain: 'http://pqmcc.com:8040',
domain: 'http://192.168.1.114:10210',
devCode: "2aaecd0b124df819eda75e639a1f91fd",
key: "f81804778c89c779"
}

View File

@@ -23,17 +23,18 @@ export default {
status: "more",
empty: false,
total: 0,
header: {},
header: {
"Content-Type": "application/json;charset=UTF-8",
},
params: {
pages: 1,
step: 20,
entity: {},
currentPage: 1,
pageSize: 20,
},
reload () {
this.data = [];
this.status = "loading";
this.empty = false;
this.params.pages = 1;
this.params.currentPage = 1;
this.next();
},
callBack: null,
@@ -42,47 +43,33 @@ export default {
next () {
me.$request({
url: url,
data: Object.assign(
{
// page: {
// current: this.params.pages,
// orders: [],
// size: this.params.step,
// total: 0,
// },
offset: this.params.pages,
limit: this.params.step,
current: this.params.pages,
pageSize: this.params.step,
},
this.params
),
data: this.params,
header: this.header,
method: "POST",
}).then((res) => {
console.warn(res);
let resultData = res.rows || res.data?.list || res.data?.result?.records || [];
if (this.params.pages == 1) {
let resultData = res.rows || res.data?.list || res.data?.records || [];
if (this.params.currentPage == 1) {
this.data = resultData;
if (resultData.length == 0 || resultData == 0) {
this.empty = true;
} else if (resultData.length < this.params.step) {
} else if (resultData.length < this.params.pageSize) {
this.status = "noMore";
} else if (res.total == resultData.length) {
this.status = "noMore";
}
} else {
this.data.push(...resultData);
if (resultData.length < this.params.step) {
if (resultData.length < this.params.pageSize) {
this.status = "noMore";
}
}
if (this.params.pages == 1) {
if (this.params.currentPage == 1) {
this.firstCallBack && this.firstCallBack();
}
this.loadedCallback && this.loadedCallback();
this.params.pages++;
this.params.currentPage++;
this.total = res.total;
this.loading = false;
});

11
common/js/mqtt.js Normal file
View File

@@ -0,0 +1,11 @@
export const MQTT_IP = '60.204.148.71:9001'//mqtt地址端口, 使用emqx时一定要加mqtt
const MQTT_USERNAME = 'test'//mqtt用户名
const MQTT_PASSWORD = 'test'//密码
export const MQTT_OPTIONS = {
connectTimeout: 5000,
clientId: '',
username: MQTT_USERNAME,
password: MQTT_PASSWORD,
clean: false
}

View File

@@ -24,14 +24,16 @@ export default (options = {}) => {
},
header: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Authorization":"12",
...options.header
},
method: options.method || 'GET',
success: async (res) => {
console.log(res);
if (arr.indexOf(options.url) > -1) {
arr.splice(arr.indexOf(options.url), 1)
}
if (res.data.resultCode !== 10000) {
if (res.data.resultCode !== 10000 && res.data.code !== 'A0000' ) {
errHandler(res.data)
reject(res.data)
} else {