Commit 8cbf4ab9 by yixinjj

添加无网络逻辑

1 parent 243df4d9
import { getOssToken } from "@/utils/ossUploadFile/uploadFile.js";
import Queue from "@/utils/Queue.js";
const interval = 6
export default {
onLoad() {},
data() {
......@@ -216,24 +217,29 @@ export default {
*/
polling() {
if (this.snapshot === null) return;
if (this.snapshot.size == 0) {
this.enQueue();
setTimeout(() => {
this.polling();
}, 1000 * 60);
} else {
console.log(this.snapshot, "this.snapshot");
const record = this.snapshot.dequeue();
console.log(record);
this.uploadRecord(record);
}
uni.$isNetWork().then(() => {
if (this.snapshot.size == 0) {
this.enQueue();
this.pollingLater(interval);
} else {
const record = this.snapshot.dequeue();
this.uploadRecord(record);
}
}).catch(() => {
this.pollingLater(interval);
});
},
stopPolling() {
this.snapshot.clear();
this.snapshot = null
this.snapshot = null;
},
pollingLater(interval = 60 * 10) {
setTimeout(() => {
this.polling();
}, interval * 1000);
},
onUnload() {
this.stopPolling();
}
},
},
};
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!