Commit 16ab2579 by yixinjj

轮询逻辑拆分

1 parent 8bb2c25e
import { getOssToken } from "@/utils/ossUploadFile/uploadFile.js";
import Queue from "@/utils/Queue.js";
const interval = 6
const interval = 6;
export default {
onLoad() {},
data() {
......@@ -222,18 +222,24 @@ export default {
polling() {
console.log(this.snapshot.size, "this.snapshot.size");
if (this.snapshot === null) return;
uni.$isNetWork().then(() => {
if (this.snapshot.size == 0) {
this.enQueue();
this.pollingLater(interval);
} else {
const record = this.snapshot.dequeue();
this.uploadRecord(record);
}
}).catch(() => {
uni
.$isNetWork()
.then(() => {
this.upload();
})
.catch(() => {
this.pollingLater(interval);
});
},
upload() {
if (this.snapshot.size == 0) {
this.enQueue();
this.pollingLater(interval);
} else {
const record = this.snapshot.dequeue();
this.uploadRecord(record);
}
},
stopPolling() {
this.snapshot.clear();
this.snapshot = null;
......@@ -247,5 +253,5 @@ export default {
beforeDestroy() {
console.log("stopPolling");
this.stopPolling();
}
},
};
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!