| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- // pages/maritime/maritime.js
- import { postApi } from "../../apis/api";
- Page({
- data: {
- list: [],
- total: "",
- currentPage: 1,
- size: 10,
- },
- async getList(isScroll) {
- let { list, currentPage, size } = this.data;
- let { data } = await postApi("/maritime/notice/getFileList", {
- currentPage,
- size,
- shipId: wx.getStorageSync("shipId"),
- userId: wx.getStorageSync("userId"),
- });
- let { total, status } = data;
- if (status == 0) {
- if (isScroll) {
- list = [...list, ...data.result];
- } else {
- list = data.result;
- }
- } else {
- if (!isScroll) {
- list = [];
- }
- }
- this.setData({
- list,
- total,
- });
- },
- async openFile(e) {
- try {
- wx.showLoading({
- title: "正在加载...",
- });
- let { downloadUrl: url, suffixName } = e.currentTarget.dataset.item;
- wx.downloadFile({
- url,
- success: ({ tempFilePath: filePath }) => {
- wx.hideLoading();
- wx.openDocument({
- filePath,
- fileType: suffixName.toLowerCase(),
- });
- },
- });
- } catch (error) {
- wx.showToast({
- title: "系统繁忙",
- icon: "error",
- });
- wx.hideLoading();
- }
- },
- onPullDownRefresh() {
- this.setData({
- list: [],
- currentPage: 1,
- total: 0,
- });
- this.getList();
- },
- scrollList() {
- if (
- this.data.total == 0 ||
- this.data.total <= this.data.size * this.data.currentPage
- )
- return;
- this.data.currentPage += 1;
- this.getList(true);
- },
- scrollDownList() {
- this.setData({
- total: 0,
- currentPage: 1,
- list: [],
- });
- this.getList();
- },
- onLoad(options) {},
- onShow() {
- console.log("show");
- this.setData({
- list: [],
- currentPage: 1,
- size: 10,
- });
- this.getList();
- },
- });
|