uniapp 小程序 H5 移动端 写 table 表格 组件

4 篇文章 0 订阅
这是一个使用Vue.js编写的移动端用户统计页面模板,包含查询按钮、表格展示以及分页功能。页面使用scroll-view进行横向滚动,表格数据显示本月、本年累计和累计同比增长%,并实现了上一页、下一页的切换。数据加载过程中显示加载中提示。
摘要由CSDN通过智能技术生成

在这里插入图片描述

<template>
  <view class="userStatistics">
    <scroll-view scroll-x class="bg-white nav text-center">
        <view class="botton" @click="getList">查询</view>
        <view class="table">
          <view class="tr bg-w">
            <view class="th">月份</view>
            <view class="th">本月</view>
            <view class="th">本年累计</view>
            <view class="th">累计同比增长%</view>
          </view>
          <block v-for="(item, index) of listData" :key="item.code">
            <view class="tr bg-g" v-if="index % 2 == 0">
              <view class="td">{{ item.code }}</view>
              <view class="td">{{ item.text }}</view>
              <view class="td">{{ item.type }}</view>
            </view>
            <view class="tr" v-else>
              <view class="td">{{ item.code }}</view>
              <view class="td">{{ item.text }}</view>
              <view class="td">{{ item.type }}</view>
            </view></block
          >
        </view>
        <view class="pageList">
          <view :class="current == 1 ? 'disable' : ''" @click="changePage(1)"
            >上一页</view
          >
          <view>当前页:{{ current }}</view>
          <view @click="changePage(2)">下一页</view>
        </view>
      </view>
    </scroll-view>
    <view class="cu-load load-modal" v-if="loadModal">
      <!-- <view class="cuIcon-emojifill text-orange"></view> -->
      <image src="/static/logo.png" mode="aspectFit"></image>
      <view class="gray-text">加载中...</view>
    </view>
  </view>
</template>

<script>
import api from "@/api/api";
import moment from "moment";
export default {
  name: "statistics",

  data() {
    return {
      loadModal: false,
      current: 1,
      pageSize: 10,
      listData: [
        { code: "01", text: "text1", type: "type1" },
        { code: "02", text: "text2", type: "type2" },
        { code: "03", text: "text3", type: "type3" },
        { code: "04", text: "text4", type: "type4" },
        { code: "05", text: "text5", type: "type5" },
        { code: "06", text: "text6", type: "type6" },
        { code: "07", text: "text7", type: "type7" },
      ],
      url: { list: "/mobile/list", 
      },
      loadModal: false,
      month: undefined,
    };
  },
  watch: {
    current: {
      immediate: true,
      handler() {
        // console.log(this.district, "6666nnn");
        this.getList();
      },
    },
  },

  mounted() {
    let _self = this;
    _self.getList();
  },
  methods: {
    changePage(val) {
      if (val === 1) {
        if (this.current !== 1) this.current--;
      }
      if (val === 2) {
        this.current++;
      }
    },
    getList() {
      let _self = this;
      // _self.loadModal = true;
      _self.$http
        .get(this.url.list, { current: this.current, pageSize: this.pageSize })
        .catch((err) => {
          _self.loadModal = true;
          // console.log(err);
        });
    },

  },
};
</script>

<style lang="scss">
.userStatistics {
  .container {
    color: #358deb;
    padding: 10px;
    table {
      border: 0px solid darkgray;
    }

    .tr {
      display: flex;

      width: 100%;

      justify-content: center;

      height: 3rem;

      align-items: center;
    }

    .td {
      width: 40%;

      justify-content: center;

      text-align: center;
    }

    .bg-w {
      background: snow;
    }

    .bg-g {
      background: #e6f3f9;
    }

    .th {
      width: 40%;

      justify-content: center;

      background: #358deb;

      color: #fff;

      display: flex;

      height: 3rem;

      align-items: center;
    }
    .pageList {
      display: flex;
      margin-top: 10px;
      justify-content: space-around;
    }
    .disable {
      color: rgb(214, 174, 174);
    }
  }
}
</style>

参考:https://wenku.baidu.com/view/edf9e9d17f1cfad6195f312b3169a4517723e568.html

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值